EMS-TU-Ilmenau / fastmat

A library to build up lazily evaluated expressions of linear transforms for efficient scientific computing.
https://fastmat.readthedocs.io
Apache License 2.0
24 stars 8 forks source link

Importing fastmat fails when compiling cython source files with Cython 0.29.20 #87

Closed ahmadomira closed 3 years ago

ahmadomira commented 4 years ago

Equipment

Windows 10 64-bit Python 3.8.0 fastmat 0.1.2.post1, 0.2a4 or 0.2a5 Cython 0.29.20

Description

After (pip) installing fasmat, simply trying to import it would result the following error:

>>> import fastmat
Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "~\AppData\Roamin\Python\Python38\site-packages\fastmat\__init__.py", line 108, in <module> from .Matrix import Matrix, Hermitian, Conjugate, Transpose, flags
    File "fastmat\Matrix.pyx", line 1, in init fastmat.Matrix
AttributeError: type object 'fastmat.Matrix.Matrix' has no attribute '__div__'

Un- and reinstalling different versions of fastmat, including downloading version 0.2a5 manually from source, would result the same error. A 3.8.3 Python interpreter also couldn't help.

Solution,

After installing fastmat 0.2v5 directly from source, Cython was downgraded to 0.29.15 and all cython source files were recompiled locally using:

python setup.py build_ext --inplace

runned from the root directory of fastmat repository.

ChristophWWagner commented 3 years ago

Thanks for the find!

The Cython project reported the fix of a related known regression from the mentioned version [1]: Fix a regression in 0.29.20 where __div__ failed to be found in extension types. (Github issue #3688)

The error could be reproduced with Cython 0.29.20 and was found resolved with Cython 0.29.21.

Seems to be resolved, closing :)

[1] https://github.com/cython/cython/commit/976f5483c6df8570f34076ef25af7e7512dd9347?short_path=ff3c479#diff-ff3c479edefad986d2fe6fe7ead575a46b086e3bbcf0ccc86d85efc4a4c63c79