Skip to content

Commit

Permalink
cython was using the python sqrt
Browse files Browse the repository at this point in the history
  • Loading branch information
pfebrer committed Oct 19, 2023
1 parent d580f15 commit e6654c8
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/sisl/geom/neighs/_neigh_operations.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
"""File meant to be compiled with Cython so that operations are much faster."""
from __future__ import annotations

try:
import cython

from cython.cimports.libc.math import sqrt as SQRT
# This little trick is because cython does not allow you
# to have an statement that sets an imported variable.
# If we directly import sqrt, then it fails because of the
# statement in the except clause (weird).
sqrt = SQRT
# This enables Cython enhanced compatibilities
import cython.cimports.numpy as cnp
except ImportError:
sqrt = lambda x: x**0.5
import cython

from cython.cimports.libc.math import sqrt
import cython.cimports.numpy as cnp

import numpy as np

Expand Down

0 comments on commit e6654c8

Please sign in to comment.