dgasmith / opt_einsum

⚡️Optimizing einsum functions in NumPy, Tensorflow, Dask, and more with contraction order optimization.
https://dgasmith.github.io/opt_einsum/
MIT License
863 stars 68 forks source link

"Finalize" MyPy #176

Closed dgasmith closed 3 years ago

dgasmith commented 3 years ago

Description

For the upcoming release, I did wish to attempt to finalize a round of MyPy, that is, all functions typed at least in a generic way. There still exist too many Any types, but we're making headway. In particular, typing the paths proved to be instructive and helped to unpack some type thrashing. This also helped improve the readability of the dynamic path slightly; I still wish to do another pass or two to make it more self-evident what is happening as this codebase matures.

The last item I wish to do in this PR is switch from YAPF to the black formatter. Black is raising in popularity over the past few years and generally find it much more stable than YAPF. A test run only shows ~50 lines of reasonable changed beyond mapping ' -> ", but helps tremendously for our length arg-based function calls.

As a note, I'm not adding a py.typed yet- I would like to handle the ArrayType better than we currently do before I declare the types "ready".

Questions

Status

codecov[bot] commented 3 years ago

Codecov Report

Merging #176 (911d9d4) into master (8ba3d50) will decrease coverage by 0.10%. The diff coverage is 97.42%.

dgasmith commented 3 years ago

There are NumPy types that we should use: https://github.com/numpy/numpy/blob/main/numpy/typing/_array_like.py

Our NumPy minimum version is quite old, let me see if we can do anything to improve the situation in another PR.