Skip to content

Commit a06ac0a

Browse files
committed
fix: allow sequences for center
1 parent 580ef67 commit a06ac0a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

sumpy/point_calculus.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
if TYPE_CHECKING:
3636
from collections.abc import Callable, Sequence
3737

38-
from optype.numpy import Array1D, Array2D, ArrayND
38+
from optype.numpy import Array1D, Array2D, ArrayND, ToArray1D
3939

4040

4141
__doc__ = """
@@ -99,28 +99,27 @@ class CalculusPatch:
9999
_pshape: tuple[int, ...]
100100

101101
def __init__(self,
102-
center: Array1D[np.floating[Any]],
102+
center: ToArray1D[np.floating[Any]],
103103
h: float = 1e-1,
104104
order: int = 4,
105105
nodes: NodesKind = "chebyshev") -> None:
106-
self.center = center
107-
dtype = center.dtype
106+
self.center = np.asarray(center)
108107

109108
npoints = order + 1
110109
if nodes == "equispaced":
111-
points_1d = np.linspace(-h/2, h/2, npoints, dtype=dtype)
110+
points_1d = np.linspace(-h/2, h/2, npoints)
112111
weights_1d = None
113112

114113
elif nodes == "chebyshev":
115-
a = np.arange(npoints, dtype=dtype)
114+
a = np.arange(npoints)
116115
points_1d = (h/2)*np.cos((2*(a+1)-1)/(2*npoints)*np.pi)
117116
weights_1d = None
118117

119118
elif nodes == "legendre":
120119
from scipy.special import legendre
121120
points_1d, weights_1d, _ = legendre(npoints).weights.T
122-
points_1d = (points_1d * (h/2)).astype(dtype)
123-
weights_1d = (weights_1d * (h/2)).astype(dtype)
121+
points_1d = points_1d * (h/2)
122+
weights_1d = weights_1d * (h/2)
124123

125124
else:
126125
raise ValueError(f"invalid node set: {nodes}")

0 commit comments

Comments
 (0)