mdanalysis icon indicating copy to clipboard operation
mdanalysis copied to clipboard

Type hints for lib module

Open umak1106 opened this issue 3 years ago • 10 comments

Fixes #

Changes made in this Pull Request:

PR Checklist

  • [ ] Tests?
  • [ ] Docs?
  • [ ] CHANGELOG updated?
  • [ ] Issue raised/referenced?

umak1106 avatar Jun 23 '22 06:06 umak1106

Hello @umak1106! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 182:80: E501 line too long (81 > 79 characters)

Line 164:80: E501 line too long (80 > 79 characters) Line 249:80: E501 line too long (86 > 79 characters) Line 312:80: E501 line too long (98 > 79 characters)

Line 101:80: E501 line too long (88 > 79 characters)

Comment last updated at 2022-09-12 07:29:38 UTC

pep8speaks avatar Jun 23 '22 06:06 pep8speaks

Regarding the stp() function if i set the arguments as arraylike i get this error Argument 1 to "cross" has incompatible type "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]"; expected "Union[SupportsArray[dtype[bool]], _NestedSequence[SupportsArray[dtype[bool]]], bool, _NestedSequence[bool]]"

And if i set it as NDArray I still get an error Argument 1 to "stp" has incompatible type "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]"; expected "ndarray[Any, dtype[Any]]"

The same error above shows for normal()

umak1106 avatar Jun 23 '22 06:06 umak1106

Codecov Report

Base: 94.31% // Head: 94.30% // Decreases project coverage by -0.00% :warning:

Coverage data is based on head (afbf3ca) compared to base (0788165). Patch coverage: 91.89% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3729      +/-   ##
===========================================
- Coverage    94.31%   94.30%   -0.01%     
===========================================
  Files          192      192              
  Lines        24782    24795      +13     
  Branches      3341     3344       +3     
===========================================
+ Hits         23372    23382      +10     
- Misses        1362     1365       +3     
  Partials        48       48              
Impacted Files Coverage Δ
package/MDAnalysis/lib/pkdtree.py 91.91% <82.35%> (-2.59%) :arrow_down:
package/MDAnalysis/__init__.py 92.30% <100.00%> (ø)
package/MDAnalysis/lib/NeighborSearch.py 96.77% <100.00%> (+0.34%) :arrow_up:
package/MDAnalysis/lib/mdamath.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Jun 23 '22 06:06 codecov[bot]

actually typing module is introduced in numpy from 1.20.0 and the gh-ci.yaml file has numpy = 1.19.0 which is why i think the tests are failing

umak1106 avatar Jun 23 '22 06:06 umak1106

@IAlibay plans on bumping the minimal version of numpy to 1.20.0. It means we'll have to wait for the bump to happen before we merge, but you can proceed and ignore the failing pipeline.

jbarnoud avatar Jun 23 '22 07:06 jbarnoud

@umak1106 just a quick note, I am adding type hints to a lot of distances.py as part of #3730, you can probably leave that one to me for now.

hmacdope avatar Jun 23 '22 22:06 hmacdope

ok

umak1106 avatar Jun 23 '22 22:06 umak1106

Errors am facing : MDAnalysis/lib/pkdtree.py:141: error: Incompatible types in assignment (expression has type "Optional[float]", variable has type "None") MDAnalysis/lib/pkdtree.py:184: error: Unsupported operand types for > ("float" and "None") MDAnalysis/lib/pkdtree.py:234: error: Unsupported operand types for > ("float" and "None") MDAnalysis/lib/pkdtree.py:290: error: Unsupported operand types for > ("float" and "None")

umak1106 avatar Jun 26 '22 21:06 umak1106

It looks like you are still using npt.NDArray in pkdtree.

jbarnoud avatar Jul 18 '22 11:07 jbarnoud

It looks like you are still using npt.NDArray in pkdtree.

Yes actually after i faced mypy errors there i didn't push my code

umak1106 avatar Jul 18 '22 22:07 umak1106

Now that #3787 is merged into develop, the develop branch should be merged in here.

jbarnoud avatar Aug 25 '22 11:08 jbarnoud

Wooo! 🎉 Only one mypy error left! With the last few comment addressed we should be good to go 😁

jbarnoud avatar Aug 29 '22 18:08 jbarnoud

Making those changes in pkdtree raises errors like unresolved reference to self

umak1106 avatar Aug 30 '22 09:08 umak1106

Making those changes in pkdtree raises errors like unresolved reference to self

Can you paste the full error message please? It is difficult to figure out what can go wrong without it.

jbarnoud avatar Aug 30 '22 09:08 jbarnoud

Making those changes in pkdtree raises errors like unresolved reference to self

Can you paste the full error message please? It is difficult to figure out what can go wrong without it.

It got fixed . There are no mypy errors in this module now .

umak1106 avatar Sep 10 '22 04:09 umak1106

Congratulations on that PR being merged!

jbarnoud avatar Sep 12 '22 08:09 jbarnoud

Congratulations on that PR being merged!

Thanks

umak1106 avatar Sep 12 '22 08:09 umak1106