v2.0.0 Released 🎉 #85
treycole
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
PythTB 2.0.0 Release Notes
PythTB 2.0.0 is a major redesign of the package, focused on long-term maintainability, performance, and a modern API. It introduces:
Lattice,Mesh, andWannierclassesquantum metric, local Chern marker, axion angle, and more
This document summarizes the design philosophy, API changes, and migration guidance.
Why PythTB 2.0.0?
The original package had a single-file (
pythtb.py) design that served early use cases well. However, as the codebase expanded, this structure became unwieldy. Version 2.0.0 reorganizes the project into a modular structure with a more intuitive API and consistent naming, following PEP-8 and scientific Python community best practices.The goals:
Major Changes
Version Support
What Changed:
Rationale:
Modular Package Structure
Before: everything in a single
pythtb.pyfile.Now: split into multiple modules under the
pythtb/package:tbmodel.pyTBModelwfarray.pyWFArraymesh.pyw90.pyW90class for Wannier90 interfacinglattice.pyhoptable.pyutils.pyvisualization/models/io/wannier90.pyio/qe.pyRationale:
New Core Classes
LatticeEncapsulates lattice geometry, orbital positions, and nearest-neighbour shells. Every model and wavefunction array references the same lattice instance to ensure consistent coordinates. A
Latticecan be shared across multiple models and wavefunction arrays. TheLatticeclass also provides methods for visualizing the lattice in real and reciprocal space.To create a
Lattice:MeshDescribes k-space grids, paths, and parameter sweeps. Encodes topology (loops, endpoints, adiabatic cycles) so
WFArraycan apply appropriate gauge conditions downstream.To create a
Mesh:WannierBuild Wannier gauges directly inside PythTB from a
WFArray, perform projections, disentanglement and maximal localization, and analyze spreads and centers.API Cleanup & Naming Consistency
Renaming Classes
Renamed classes using PascalCase per PEP 8 conventions
tb_modelTBModelwf_arrayWFArrayw90W90Dropped redundant
objectbase class (i.e.,class TBModel(object):is nowclass TBModel:). All classes are new-style in Python 3.Rationale:
Initialization Patterns
The
LatticeandMeshclasses were introduced to encapsulate lattice geometry and k-point/parameter mesh construction, respectively. This separates concerns and improves code organization. These classes can also be used as standalone utilities and shared across multiple models.tb_model(dim_r, dim_k, lat, orb, per, nspin)TBModel(Lattice, spinful)Latticeinstance.wf_array(model, mesh_arr, nsta_arr)WFArray(Lattice, Mesh, nstates)Meshencodes k-point and parameter grids.Rationale:
Method Renaming & Unification
Many methods were renamed for clarity and consistency. Some methods were merged to reduce redundancy.
Examples:
tb_model.solve_one&tb_model.solve_allTBModel.solve_hamwf_array.berry_phaseparameterdiraxis_idxto avoid conflict with Python keyworddirw90.w90_bands_consistencyW90.bands_w90Rationale:
Vectorization and Performance
What Changed:
tb_model._gen_hamandtb_model._sol_hamfunctions for generating and diagonalizing the Hamiltonian were a major bottleneck. It has been restructured to utilize NumPy vectorization, eliminating explicitforloops over the k-points.Rationale:
Type Hints and Error Handling
What Changed:
raise Errorwith specific exceptions, e.g.,TypeErrororValueErrorRationale:
Logging vs. Print Statements
What Changed:
loggingmodule.Rationale:
Packaging and Distribution
What Changed:
Transitioned from
setup.pytopyproject.toml, added standard files (LICENSE,CHANGELOG,CONTRIBUTING).LICENSE: GPL-3 license (copied over from the .txt file).CHANGELOG: This file for tracking changes between versions.pyproject.toml: Now the recommended way to package Python projects.CONTRIBUTING: Outlines expectations and guidelines for contributors.Rationale:
pyproject.tomlis the new standard for Python packaging.CONTRIBUTINGandLICENSEare now expected in open source.Testing and Continuous Integration
What Changed:
tests/test_examplesdirectory with pytest-based regression tests for all examplestests/test_examples/make_test_example.pyto automatically generate a skeleton for new tests to be made in the future.tests/report_test_status.pyto print a summary of which tests are passing and the date/time of last pass/fail.tests/test_examples/README.mdfor more information.Rationale:
If you have questions or want to propose a change, please open an issue or start a discussion.
This discussion was created from the release v2.0.0.
Beta Was this translation helpful? Give feedback.
All reactions