aelzenaar / bella

New computational package for small-rank matrix groups
BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Package throws errors on Python 3.4 #14

Closed aelzenaar closed 11 months ago

aelzenaar commented 11 months ago

@ariymarkowitz please copy the error message here thx

ariymarkowitz commented 11 months ago
Traceback (most recent call last):
  File "atom.py", line 8, in <module>
    from bella import cayley
  File "/home/amar630/bella/cayley.py", line 68
    warnings.warn(f"generator {n} does not seem to have non-unit determinant {det}",NonUnitDeterminantWarning)
                                                                                  ^
SyntaxError: invalid syntax
ariymarkowitz commented 11 months ago

Errors when I run pytest:

______________________________________ ERROR collecting tests/test_cayley.py ______________________________________
../.local/lib/python3.4/site-packages/_pytest/python.py:507: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=importmode)
../.local/lib/python3.4/site-packages/py/_path/local.py:704: in pyimport
    __import__(modname)
E     File "/home/amar630/bella-main/tests/test_cayley.py", line 18
E       assert matrix_almosteq_up_to_sign(orthogonal_gens[0] @ orthogonal_gens[0], mp.eye(2))
E                                                            ^
E   SyntaxError: invalid syntax
______________________________________ ERROR collecting tests/test_farey.py _______________________________________
ImportError while importing test module '/home/amar630/bella-main/tests/test_farey.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/test_farey.py:3: in <module>
    from bella import farey, riley, cayley
E   ImportError: No module named 'bella'
______________________________________ ERROR collecting tests/test_riley.py _______________________________________
ImportError while importing test module '/home/amar630/bella-main/tests/test_riley.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/test_riley.py:2: in <module>
    from bella import riley,farey
E   ImportError: No module named 'bella'
aelzenaar commented 11 months ago

Traceback (most recent call last): File "atom.py", line 8, in from bella import cayley File "/home/amar630/bella/cayley.py", line 68 warnings.warn(f"generator {n} does not seem to have non-unit determinant {det}",NonUnitDeterminantWarning) ^ SyntaxError: invalid syntax

This one is an easy fix, I just need to replace f"...{var}..." with "...{}...".format(var)

aelzenaar commented 11 months ago

__ ERROR collecting tests/test_cayley.py __ ../.local/lib/python3.4/site-packages/_pytest/python.py:507: in _importtestmodule mod = self.fspath.pyimport(ensuresyspath=importmode) ../.local/lib/python3.4/site-packages/py/_path/local.py:704: in pyimport import(modname) E File "/home/amar630/bella-main/tests/test_cayley.py", line 18 E assert matrix_almosteq_up_to_sign(orthogonal_gens[0] @ orthogonal_gens[0], mp.eye(2)) E ^ E SyntaxError: invalid syntax

This is PEP 465, the syntax was introduced in 3.5. I will need to take a little bit of time to think about this because in order to do precision work I use mpmath.matrix() for matrices almost everywhere and use numpy.array only when doing p-adic work. These two classes have interchangeable syntax so I can pass np.arrays with padics around and as long as I do nothing weird everything works interchangeably. But without @ I think they have different syntax for multiplication (one uses * and one has an external dot(.,.) function iirc) so I will need to think about it. (It would be an easy fix if I didn't care about p-adic support.)

aelzenaar commented 11 months ago

Closing as WONTFIX. The issue is that 3.4 came out almost 10 years ago and support ended for it 6 years ago, and all the very standard dependencies like pandas use more recent language features (which they are entitled to do, since all supported versions of Python have them).

Thus I will roll back the changes I made to matrix multiplication etc. since they have made the software significantly slower (instead of dropping down directly to the C++ backend I have to do some introspection to determine which kind of matrix I have which means spending a lot of CPU cycles in Python and not C, even with the significant speedups of 3.11 this is still slow as it cannot be optimised away).

aelzenaar commented 11 months ago

(For reference having to fall back on introspection makes the apollonian_circles.py example 11% slower on my machine.)

aelzenaar commented 11 months ago

today in "should have done that on a branch"...