Skip to content

Commit

Permalink
src/fpylll/io.pyx: Use try...except for import of numpy module
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Jan 10, 2025
1 parent e1eb86c commit 817b2c1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/fpylll/io.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ from fplll.fplll cimport ZT_MPZ, ZT_LONG

# Note: this uses fpylll's numpy and not the global numpy package.
IF HAVE_NUMPY:
from .numpy import is_numpy_integer
try:
from .numpy import is_numpy_integer
have_numpy = True
except ImportError:
have_numpy = False

IF HAVE_QD:
from fpylll.fplll.fplll cimport FT_DD, FT_QD
Expand Down Expand Up @@ -54,7 +58,7 @@ cdef int assign_mpz(mpz_t& t, value) except -1:
return 0

IF HAVE_NUMPY:
if is_numpy_integer(value):
if have_numpy and is_numpy_integer(value):
value = long(value)
mpz_set_pylong(t, value)
return 0
Expand Down

0 comments on commit 817b2c1

Please sign in to comment.