Skip to main content

widget-bandsplot: Jupyter Widget to Plot Band Structure and Density of States

PyPI version Binder screenshot comparison

A Jupyter widget to plot band structures and density of states. The widget is using the mc-react-bands Javascript package and is turned into a Jupyter widget with anywidget.

Installation

pip install widget-bandsplot

Usage

Minimal usage example of the widget is the following:

widget = BandsPlotWidget(
    bands = [bands_data],
    dos = dos_data,
    energy_range = [-10.0, 10.0],
    format_settings = {
        "showFermi": True,
        "showLegend": True,
    }
)
display(widget)

where bands_data and dos_data are contain the band structure and density of states data, respectively. The format for these data objects is the following:

  • Band structure data follows the AiiDA CLI export format that can be generated from an AiiDA BandsData node with the following command:
    verdi data band export <PK> --format=json
    
  • The density of states data uses a custom format, with a a valid example being:
    dos_data = {
        "fermi_energy": -7.0,
        "dos": [
            {
                "label": "Total DOS",          # required
                "x": [0.0, 0.1, 0.2],          # required
                "y": [1.2, 3.2, 0.0],          # required
                "lineStyle": "dash",           # optional
                "borderColor": "#41e2b3",      # optional
                "backgroundColor": "#51258b",  # optional
            },
            {
                "label": "Co",
                "x": [0.0, 0.1, 0.2],
                "y": [1.2, 3.2, 0.0],
                "lineStyle": "solid",
                "borderColor": "#43ee8b",
                "backgroundColor": "#59595c",
            },
        ],
    }
    

For more detailed usage, see example/example.ipynb and for more example input files see example/data.

Development

Install the python code:

pip install -e .[dev]

You then need to install the JavaScript dependencies and run the development server.

npm install
npm run dev

Open examples/example.ipynb in Jupyter notebook or lab to start developing. Changes made in js/ will be reflected in the notebook.

Releasing and publishing a new version

In order to make a new release of the library and publish to PYPI, run

bumpver update --major/--minor/--patch

This will

  • update version numbers, make a corresponding git commit and a git tag;
  • push this commit and tag to Github, which triggers the Github Action that makes a new Github Release and publishes the package to PYPI.

Github workflow testing

screenshot comparison

The screenshot comparison test will generate images of the widget using selenium and chrome-driver, and compares them to the reference image in test/widget-sample.png.

To update the reference image: download the generated image from the Github Workflow step called "Upload screenshots" and replace test/widget-sample.png.

Acknowledgements

We acknowledge support from the EPFL Open Science Fund via the OSSCAR project.

Metadata

Release files for widget-bandsplot 0.7.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for widget-bandsplot 0.7.4
File Size Uploaded Provenance
widget_bandsplot-0.7.4.tar.gz 185.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for widget-bandsplot 0.7.4
File Interpreter ABI Platform
widget_bandsplot-0.7.4-py3-none-any.whl Python 3 none any Details

Total release size: 373.6 kB

Release files / widget_bandsplot-0.7.4.tar.gz

Download URL widget_bandsplot-0.7.4.tar.gz
Size 185.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a627f6fa5b85b98b8a29dae1fce5c00c6ceae3422e8a657c7ff192ee3d836594
BLAKE2b-256 checksum
How to use checksums
7b9fae147822b63f02a6a25c1263787c3d0074997e351f2cc6ae365387914d99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.5

Release files / widget_bandsplot-0.7.4-py3-none-any.whl

Download URL widget_bandsplot-0.7.4-py3-none-any.whl
Size 187.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aae3d2838be80d7ce514a1f3a761a77baef86691d761e908acdf49462551d4be
BLAKE2b-256 checksum
How to use checksums
bd0abeaffe8d6e2000d45f2da8e50cc799c12cc86380c1c36cc11ae5935a4295
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.5

Security for widget-bandsplot 0.7.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.7.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page