fferflo / einx

Universal Tensor Operations in Einstein-Inspired Notation for Python.
https://einx.readthedocs.io/en/stable/
MIT License
328 stars 8 forks source link

VSCode/Pylance Doesn't Recognize Specializations #3

Closed nimashoghi closed 10 months ago

nimashoghi commented 10 months ago

Hi @fferflo, awesome library!

It seems like due to the way that you're generating specializations (by assigning to globals()), VSCode's static analysis has some problems detecting the existence of the specialization functions (e.g., einx.sum).

I have a quick and dirty simple fix for this in #2 which seems to be working quite well. Feel free to use that or provide any feedback and I can update accordingly.

Thank you!

fferflo commented 10 months ago

Hey @nimashoghi, thanks for bringing this up!

I have taken a look at the pull request, but believe it would be best to get rid of the "assign to globals() hack" entirely and just declare the specializations as ordinary functions in the global namespace. If I understand correctly, this would also address your problem?

This required some other changes as well, and is committed in https://github.com/fferflo/einx/commit/cfe2c92e5bb1010120228718c76c40c58ff4ef2d. Does this work for you?

nimashoghi commented 10 months ago

That's even better. Awesome! Thanks.