Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Giving a hand on pyright fixes #2

Closed
wants to merge 1,123 commits into from
Closed

Conversation

DanielYang59
Copy link

Summary

Giving a hand on pyright fixes for materialsproject#3646, it's just too much work for a single person I assume. Hoping I could help.

janosh and others added 30 commits November 7, 2023 15:36
fix doc strings with empty return value section
…k of circular imports (materialsproject#3461)

* simplify imports using convenience exports from pymatgen/core/__init__.py

* revert composition.py and
structure.py

* more
…res` in which `primitive` defaults to `False` (materialsproject#3419)

* breaking: change default primitive=True to False in CifParser.get_structures()

* fix CifParser tests

* add test to ensure CIfParser.get_structures() and Structure.from_file() remain consistent in the future

* Structure.from_file add type hints and fix doc str claiming primitive keyword only passed to CIF

* add UserWarning for change of default primitive=True to False made on 2023-10-24

* deprecate get_structures() and change primitive default to False in new parse_structures() method

* use parse_structures in tests

* fix TestCifTransmuter.test_init

return self.parse_structures(*args, **kwargs)
E       TypeError: CifParser.parse_structures() got multiple values for argument 'primitive'

* add comment suggested by @JaGeo

* remove all internal use of deprecated CifParser.get_structures()
…3452)

* fix vasprun not interpreting float overflow as nan

* add test

* pre-commit auto-fixes

* rename and cleanup test_float_overflow

introduce artificial overflow in <varray name="forces"> in vasprun.xml.sc_overflow
rm tests/files/vasprun.xml.force_overflow

---------

Co-authored-by: Eric Taw <eric.taw@ll.mit.edu>
Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
* Move FHI-aims io from atomate2 into pymatgen

1) parsers and AimsOuput ojbects moved over
2) All ASE Atoms objects removed in favor of pymatgen structures
3) TO DO: Check name schemes
4) Create an AimsInputs object in the future

* Initial aims input files

1) remove aims_outputs naming convention
2) Add AimsGeometryIn and AimsControlIn classes

* Add test for the aims parsers

Adjusted from ASE parser tests

* Add tests for AimsOutputs

1) How to handle stress in properties?

* Add aims output refrence files

For aims outputs checks

* Add tests for AimsGeometryIn inputs

Test for both Si and H2O

* Add tests for AimsCube

Make sure that the AimsCubes are properly formatted

* Add tests for aims_control_in

Add test for aims control.in file generators

* gzip all output files

as requested all output files are gzipped

* Gzip all refrence files

1) Species blocks can now read from gzipped file
2) geometry.in can now read a gzip file

* Remove json dict comparision

Error in the Actions from rounding errors, do more explicit test
for as_dict

* Add full type hinting for inputs.py and convert docstrings

1) Docstrings are googledoc format
2) All type hinting is done

* Convert all AimsOutput docstrings to google doc

Everything is also type hintted now

* Add type hining and google doc strings to parsers

* Fix tests

Forgot pip install in the last commit

* Requested changes to tests

1) Moved lines objects to seperate files
2) inline k_point_weights
3) Remove trailing comma
4) tmpdir -> tmp_path

* Update pymatgen/io/aims/inputs.py

use numpy eye instead of a full list

Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
Signed-off-by: Thomas Purcell <tpurcell90@users.noreply.github.com>

* pre-commit auto-fixes

* Make more changes requested

* Rename io.aims.output to io.aims.outputs

Keep it consistent with inputs naming scheme

* Add example for FHI-aims io

* Make corrections suggested by @janosh

1) Remove copy of species file in examples
2) Typo corrections in docstrings
3) d -> dct for `from_dict` methods
4) error mesages for AimsCube
5) Shortened default checks in Inputs
6) Removal of chdir in tests

* add nbstripout to pre-commit hooks apply to FHI-aims-example.ipynb

* class AimsCube snake_case spin_state

* fix doc str

* refactor AimsCube.from_dict

* fix typo

* fix tests

* mv tests/io/aims/(aims_->'')input_files tests/io/aims/(aims_->'')output_files tests/io/aims/(aims_->'')parser_checks

* Correct refrence json files for aims_outputs

aims.output -> aims.outputs module name

---------

Signed-off-by: Thomas Purcell <tpurcell90@users.noreply.github.com>
Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
…ject#3462)

* move function-scoped imports to module scope

* more

* more

* more
* move imports to module scope

* fix doc str trailing blank lines

* fix circular import "from pymatgen.io.cif import CifWriter" in pymatgen.core.structure.py

* fix circular import: cannot import name 'EnumerateStructureTransformation' from partially initialized module 'pymatgen.transformations.advanced_transformations'
* Add default species dir option for inputs

Restore the use of an environment variable to set the
aims species directory

* Fix errors in parsers

1) Remove the filter for deciding if line is in a header or calc chunk
   Done since some lines appear in both
2) Remove stray call to an atoms object made from the atomate2 parsers

Modify the AimsOutput test for Si to use phonon calc file and not a relaxation
to check part 2

* Fix error to use f-strings

had an fstring but did not specify it was

* Add header information to all source files

Add myself and @ansobolev as authors

* Reduce test of default species dir

No need to retest everything, just the one functionality
…aterialsproject#3468)

* fix pkg missing potcar-summary-stats.json.bz2

since setup.py wasn't bundling .json.bz2 files

* make sure test_egg_sources_txt_is_complete catches catches missing JSON files of any compression type

* readme remove dead pymatgen twitter link
…oject#3471)

* breaking: add Substitutor.charge_balanced_tol: float = 1e-9 used in _is_charge_balanced(), prev had to be strictly 0

* refactor

* Composition add properties charge and charge_balanced

* Add TestComposition.test_is_charge_balanced
… /: 'str' and 'str'

tests/io/test_adf.py:259: TypeError
s = readfile(test_dir / "adf" / "RhB18_adf.inp")
…#3470)

* add pymatgen/io/vasp/PBE64Base.yaml

* update MatPESStaticSet PARENT to PBE64Base

* update MatPES known_hash and add PBE64Base hash in test_sets.py

* fix TestMatPESStaticSet to expect PBE_64 as default POTCARs

* use monty zpath in generate_fake_potcar_libraries

* fix TestWavecar.test_standard ValueError

Invalid rtag=-9223372036854775808, must be one of {45200, 45210, 53300, 53310}

/home/runner/work/pymatgen/pymatgen/pymatgen/io/vasp/outputs.py:4252
fix typos like lower case voigt
* Update substitution_probability.py

Signed-off-by: J. George <JaGeo@users.noreply.github.com>

* Update substitution_probability.py

---------

Signed-off-by: J. George <JaGeo@users.noreply.github.com>
* fix AssertionError assert structure  # for mypy

        if temperature and not structure:
            raise ValueError("If using temperature input, you must also include structure")

* Add alphabetical_formula property to
SiteCollection class

* add TestIStructure.test_alphabetical_formula

* Update PBE64Base.yaml hash in test_sets.py
…oject#3479)

* PhononDosPlotter.get_plot add legend keyword to customize legend

sync axes labels font size to legend font size

* improve UX by preventing common user mistake in PhononDosPlotter passing DOS as 1st arg

* Remove debug logging statements in PhononBSPlotter._make_ticks

* add class Kpoint type annos

* Add label setter for Kpoint class

* add __repr__ for PhononBandStructureSymmLine and tests for it

* pretty print kpoint label "GAMMA" as r"$\Gamma$" in PhononBSPlotter

* fix phonon/test_dos.py test class names

* better variable names

* add PhononDos.__repr__ method and test it
…terialsproject#3476)

* Convert all FHI-aims stresses to be 3x3

Previously used voigt

* Update type hinting for parsers.py

Use np array instead of Sequence

Signed-off-by: Thomas Purcell <tpurcell90@users.noreply.github.com>

* fix typo, snake case var name

* Use Tensor.from_voigt instead of my own function

This should now be more consistent

---------

Signed-off-by: Thomas Purcell <tpurcell90@users.noreply.github.com>
Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
Co-authored-by: Thomas Purcell <purcellt@arizona.edu>
janosh and others added 25 commits March 16, 2024 14:52
normalize counter variable names: nfoo, num_foo, nb_foo -> n_foo
…terialsproject#3697)

* Disable CI for GitHub Pages on forked repository

* install pytorch with pip to avoid uv timeouts

---------

Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
…lsproject#3694)

* add type hint and revise docstring

* add type hint and revise docstring, multiple mypy error

* add type hint, multiple mypy error

* revert del of ununsed ctx

* add type annotations

* add type annotations

* reformat docstring and add type hints

* change return set to list

* fix typo

Signed-off-by: Haoyu (Daniel) <yanghaoyu97@outlook.com>

* add TODO tag

* pre-commit auto-fixes

* fix typo

* fix mypy error in graphs

* reformat docstring

* recovert description

* format docstring

* rename arg: to args:

* ruff fixes

* mypy fixes

* fix mypy errors

* remove type annotation

* remove description indentation

* fix return list ordering

* pre-commit auto-fixes

* replace rst styled :: with :

* replace return: with returns:

* docstring format tweaks

* fixed type error

* lint fix

* ruff format

* fix mypy errors

* get_connected_sites remove debug TODO

* remove TODO tag

* remove blank line above Args: if no summary line

* recover comment

* sort optional dep

* add type-extension

---------

Signed-off-by: Haoyu (Daniel) <yanghaoyu97@outlook.com>
Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
…rialsproject#3693)

* fix GulpIO.get_relaxed_structure possibly unbound lattice params

rename variables for readability

* rename latt -> lattice

* fix typos in test names test_potcar_doenst_match_structure

* refactor test_get_el_sp() and test int, float, signed float string, with spin, ValueError for None

* Fix Composition test_formula parsing with NaN

* standardize test class names, e.g. LatticeTestCase->TestLattice

* update StructureMatcher supercell size parsing error expected msg

* refactor oxi state in symbol check in Species class

* remove needless parens when unpacking returned tuple

* fix expected error messages in Composition tests
uv pip install -U invoke sphinx_markdown_builder sphinx_rtd_theme && invoke make-doc
* add vect for xsf

* add test for vect append

* refactor TestXSF

---------

Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
…ve_species`, `remove_sites` (materialsproject#3706)

* return self from Structure methods replace, substitute, remove_species, remove_sites

* assert returned is self in test_replace_species and test_append_insert_remove_replace_substitute

* add missing test for Structure.replace

* rename TestMolecule.test_replace to test_replace_species

* Update return type to Self in Structure in-place modify methods
* fix typo

* define reusable PbcType = tuple[bool, bool, bool]

* rename to PbcLike and move to typing module

* fix outdated Lattice init doc str

* test Lattice init raises ValueError on bad PBCs

* set return type to Self on Lattice methods

* add test_pbc_like in tests/util/test_typing.py and improve existing tests

fix circular import with lattice.py

* remove pkg name from ase git URL

* clean up Jekyll GitHub Pages workflow comments

* improve PathLike type to Union[str, OsPathLike]

* skip tests for SpeciesLike and CompositionLike below py310
* convert some staticmethod to classmethod

* fixed missing Self imports

* take some coderabbitai suggestions
…y function (materialsproject#3703)

* add needs_u_correction(comp: CompositionLike) -> set[str] utility function

* test needs_u_correction

* expected_u, actual_u ensure float

* make needs_u_correction accept a U-correction config dict, defaults to MP2020

* test_needs_u_correction pass different u_configs (MP and MP2020)
…erialsproject#3700)

* Add invert_axes to PhononDosPlotter

* Add tests for invert_axes in PhononDosPlotter

* Add kwargs to PhononDOSPlotter

* Compare more than two PhononBSPlotters

* Add tests to compare more than two PhononBSPlotters

* Fix docstring

* Use dicts with labels as keys in plot_compare instead of separate labels

* always show legend, default self label to 'self' via self_label keyword, change other_plotter type to PhononBSPlotter | dict[str, PhononBSPlotter]

* Test single Plotter in plot_compare

* Use label from Plotter initialisation if single Plotter is passed to plot_compare

* Fix Test

* Add colors to plot_compare in PhononBSPlotter

* refactor code and tests

* Compare shape of distances array for plot_compare()

* Extend tests

---------

Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
* clean up tests

e.g. remove unnecessary for loops when using pytest.approx()

* Fix typo in op_params
* add atomic_orbitals in eV property to pymatgen.core.periodic_table.Element

* test_periodic_table.py sort keys in test_attributes

* tweak atomic_orbitals_eV doc str

* Add unit conversion tests

* TestElement check atomic_orbitals_eV conversion

---------

Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
* better test variable naming

* mv tests/files/(surface_tests->surfaces)

* rename variable names for clarity
…3718)

* rename QuasiHarmonicDebyeApprox and deprecate old class

* remove unnecessary subclassing of unittest.TestCase
* add some Self type annotations

* add more Self and type annotations

* add more Self and type annotations

* pre-commit auto-fixes

* add more Self and type annotations

* format docstring to google style

* add more Self types

* TEMP FIX for normalized repr

* add more Self types

* remove encoding for binary

* use `Attributes` over `Parameters`

* add Self return type to __new__ and __enter__ methods

* use `Self` for multi-line def

* `mypy` fixes in core

* `mypy` fixes in core

* move `mypy` fixes

* add Note tag

* remove unused arg properties from core.ion

* fix mypy error

* fix unit test for reaction energy calc

* fix unit test for core.units

* remove ERROR = UnitError

* google-style doc string return type format

* replace deprecated utcnow

* fix missing datetime import

* replace `app = lines.append`

* slab type hints

* relocate Slab import

* fix vector in adsorption

* use time for time count

* revert datetime utc

* switch to `time`

* switch to `datetime` for utc time for now

* take some  coderabbitai suggestions

* ignore some mypy override errors

* fix type ufloat

* fix BaseLammpsGenerator missing fields inputfile and data (did this actually work before) plus fix mypy errors

* `mypy` fixes

* `mypy` fixes

* more `mypy` fixes

* mypy fixes

down to 69 errors

* fix unit test

* reapply fix for voronoi

* fix mypy and voronoi unit test

* fix unit test for voronoi

* more `mypy` fixes

* one more `mypy` fix

* pre-commit auto-fixes

* fix number import name

* fix lammps generator

* avoid self type hard-coding

* mypy fix

* `sourcery` fix

* `sourcery` fix

* `sourcery` fix

* `mypy` fix

* suppress `mypy` error

* `mypy` and `sourcery` fix

* `mypy` fixes

* fix unit tests

* `mypy` fixes

* `mypy` fixes

* suppress `mypy` error in xcfunc

* fix `mypy` error

* fix `mypy` error

* refactor date parsing in AirssProvider to use std lib datetime instead of pypi pkg dateutil

* fix TestKpoints check kpts_shift

* fix mypy error in sets.py: cast(Sequence[Sequence[float]], kpoints)

* refactor

* fix mypy confusing keyword and positional args in Lattice.from_parameters

* remove now unused mypy ignore in Cssr.from_str

* fix bad refactor in 8bdb484

---------

Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
Signed-off-by: Matthew Evans <7916000+ml-evs@users.noreply.github.com>
@DanielYang59 DanielYang59 changed the base branch from ml-evs/ci-with-mandatory-deps to master April 13, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.