Skip to content

Commit

Permalink
missing np.import_array() added (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramezquitao committed Mar 5, 2024
1 parent 31b181e commit cb135b2
Show file tree
Hide file tree
Showing 25 changed files with 29 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pyoptools/misc/Poly1Drot/Poly1Drot.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#cython: profile=True
import numpy as np
cimport numpy as np
np.import_array()

cimport cython

cdef extern from "math.h":
Expand Down
2 changes: 1 addition & 1 deletion pyoptools/misc/cmisc/cmisc.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cdef extern from "Python.h":

cdef extern from "numpy/arrayobject.h":

cdef void import_array()
#cdef void import_array()

cdef object PyArray_ZEROS(int nd, np.npy_intp *dims, int typenum, int fortran)
cdef object PyArray_SimpleNew(int nd, np.npy_intp *dims, int typenum)
Expand Down
2 changes: 1 addition & 1 deletion pyoptools/misc/cmisc/cmisc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
cimport numpy as np

import_array()
np.import_array()

cimport cython

Expand Down
1 change: 0 additions & 1 deletion pyoptools/misc/definitions/definitions.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Definitions that help to speed up some processces

cimport numpy as np
from numpy import inf, array
# Infinity vector is used in many places to show no intersection, to
# avoid runtime creation of many infiniti vectors, inf_vect should be used
Expand Down
1 change: 1 addition & 0 deletions pyoptools/misc/lsq/lsq.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from pyoptools.misc.Poly2D.Poly2D cimport *
#from pyoptools.misc.Poly2D import *

cimport numpy as np
np.import_array()
import numpy as np
cimport cython

Expand Down
2 changes: 2 additions & 0 deletions pyoptools/misc/plist/plist.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# cython: profile=True
cimport numpy as np
np.import_array()

from numpy import array, float64
import six

Expand Down
1 change: 1 addition & 0 deletions pyoptools/raytrace/component/component.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ from pyoptools.raytrace.ray.ray cimport Ray
from pyoptools.raytrace.surface.surface cimport Surface
from numpy import inf, asarray, pi, alltrue, sometrue, isinf, isnan, array, dot, float64
cimport numpy as np
np.import_array()


#from misc import rot_mat, rot_mat_i
Expand Down
2 changes: 2 additions & 0 deletions pyoptools/raytrace/ray/ray.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

cimport numpy as np
np.import_array()

from cpython cimport bool


Expand Down
1 change: 0 additions & 1 deletion pyoptools/raytrace/ray/ray.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ from sys import exit

import numpy as np
from numpy import dot, array, float_, inf, float64, empty, zeros, sqrt as npsqrt
cimport numpy as np

#from misc import rot_mat, rot_mat_i,mvdot, dot_test
from pyoptools.misc.cmisc.cmisc cimport * # rot_mat, rot_mat_i
Expand Down
1 change: 1 addition & 0 deletions pyoptools/raytrace/surface/aspherical.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ cdef extern from "math.h":


cimport numpy as np
np.import_array()


#from ray_trace.surface.taylor_poly import eval_poly, Poly_DyDx
Expand Down
1 change: 1 addition & 0 deletions pyoptools/raytrace/surface/cylinder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ from pyoptools.raytrace.ray.ray cimport Ray
from pyoptools.raytrace.surface.surface cimport Surface
from numpy import pi, power, array, inf, sqrt, absolute, float64, dot, sin, cos
cimport numpy as np
np.import_array()
#from enthought.traits.api import Float, Tuple
#from enthought.traits.ui.view import Group, Item
#from enthought.tvtk.api import tvtk
Expand Down
1 change: 1 addition & 0 deletions pyoptools/raytrace/surface/cylindrical.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ from pyoptools.raytrace.ray.ray cimport Ray
from pyoptools.raytrace.surface.surface cimport Surface
from numpy import power, array, inf, absolute, float64, dot, sqrt as npsqrt
cimport numpy as np
np.import_array()

#from enthought.traits.api import Float, Tuple
#from enthought.traits.ui.view import Group, Item
Expand Down
1 change: 1 addition & 0 deletions pyoptools/raytrace/surface/idealsurface.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ from pyoptools.misc.definitions import inf_vect
from pyoptools.raytrace.surface.surface cimport Surface
from pyoptools.raytrace.ray.ray cimport Ray
cimport numpy as np
np.import_array()

cdef class IdealSurface(Surface):
"""Clase que representa una superficie ideal. Se utiliza para crear
Expand Down
2 changes: 2 additions & 0 deletions pyoptools/raytrace/surface/plane.pxd
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from pyoptools.raytrace.surface.surface cimport Surface
from pyoptools.raytrace.ray.ray cimport Ray
cimport numpy as np


cdef class Plane(Surface):
cpdef _intersection(self, Ray A)
cpdef np.ndarray normal(self, ri)
1 change: 1 addition & 0 deletions pyoptools/raytrace/surface/plane.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ from pyoptools.raytrace.ray.ray cimport Ray
from pyoptools.misc.definitions import *

cimport numpy as np
np.import_array()


cdef class Plane(Surface):
Expand Down
1 change: 1 addition & 0 deletions pyoptools/raytrace/surface/plane_mask.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ cdef extern from "math.h":


cimport numpy as np
np.import_array()


cdef class RPPMask(Surface):
Expand Down
1 change: 1 addition & 0 deletions pyoptools/raytrace/surface/powell.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ cdef extern from "math.h":


cimport numpy as np
np.import_array()


#from ray_trace.surface.taylor_poly import eval_poly, Poly_DyDx
Expand Down
1 change: 1 addition & 0 deletions pyoptools/raytrace/surface/spherical.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cdef extern from "math.h":
'''

cimport numpy as np
np.import_array()


cdef class Spherical(Surface):
Expand Down
1 change: 1 addition & 0 deletions pyoptools/raytrace/surface/taylor_poly.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ from numpy import array, asarray, arange, polyadd, polymul, polysub, polyval,\
dot, inf, roots, zeros, meshgrid, where, abs, sqrt as npsqrt

cimport numpy as np
np.import_array()

from pyoptools.raytrace.surface.surface cimport Surface
from pyoptools.raytrace.ray.ray cimport Ray
Expand Down
1 change: 1 addition & 0 deletions pyoptools/raytrace/system/idealcomponent.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ from pyoptools.raytrace.surface.plane cimport Plane
from math import isinf
from numpy import asarray
cimport numpy as np
np.import_array()


class IdealThickLens(System):
Expand Down
1 change: 1 addition & 0 deletions pyoptools/raytrace/system/system.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ from pyoptools.raytrace.surface.surface cimport Surface
from pyoptools.raytrace.component.component cimport Component

cimport numpy as np
np.import_array()

cdef extern from "math.h":
bint isnan(double x) nogil
Expand Down
2 changes: 2 additions & 0 deletions pyoptools/wavefront/cpsurfrep/cpsurfrep.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ from pyoptools.misc import *

import numpy as np
cimport numpy as np
np.import_array()

cimport cython

#from numpy.ma import is_masked, MaskedArray
Expand Down
1 change: 1 addition & 0 deletions pyoptools/wavefront/field/field.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ cdef extern from "math.h":
double sqrt(double)

cimport numpy as np
np.import_array()
cimport cython


Expand Down
2 changes: 2 additions & 0 deletions pyoptools/wavefront/psurfrep/psurfrep.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ from pyoptools.misc.Poly2D import ord2i, poly2d
from pyoptools.wavefront.field import Field

cimport numpy as np
np.import_array()

cdef extern from "math.h":
double sqrt(double) nogil
double atan2(double, double) nogil
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pyoptools"
version = "0.2.2"
version = "0.2.3"
description = "Python tools for simulation of optical systems"
authors = [{ name = "Ricardo Amézquita Orozco", email = "ramezquitao@cihologramas.com" }]
license = {file = "LICENSE.txt"}
Expand Down

0 comments on commit cb135b2

Please sign in to comment.