Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate to Numpy 2 #281

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion friture/generators/pink.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def pinknoise(n, rvs=standard_normal):

# k = int(min(np.floor(np.log(n)/np.log(2)), PINK_FIDELITY))
k = 13 # dynamic k adds audible "clicks"
pink = np.zeros((n,), np.float)
pink = np.zeros((n,), np.float32)

for m in 2 ** np.arange(k):
p = int(np.ceil(float(n) / m))
Expand Down
4 changes: 2 additions & 2 deletions friture/plotCurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def updatePaintNode(self, paint_node, update_data):
vertices.setsize(2 * np.dtype(np.float32).itemsize * size)

polygon_array = np.frombuffer(vertices, dtype=np.float32)
polygon_array[: (size - 1) * 2 + 1 : 2] = np.array(self.curve.x_array() * self.width(), dtype=np.float32, copy=False)
polygon_array[1 : (size - 1) * 2 + 2 : 2] = np.array(self.curve.y_array() * self.height(), dtype=np.float32, copy=False)
polygon_array[: (size - 1) * 2 + 1 : 2] = np.asarray(self.curve.x_array() * self.width(), dtype=np.float32)
polygon_array[1 : (size - 1) * 2 + 2 : 2] = np.asarray(self.curve.y_array() * self.height(), dtype=np.float32)

paint_node.markDirty(QSGNode.DirtyGeometry)

Expand Down
4 changes: 2 additions & 2 deletions friture_extensions/lfilter.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def pyx_lfilter_float64_1D(

cdef Py_ssize_t len_x = x.shape[0]
cdef Py_ssize_t len_b = b.shape[0]
cdef np.int_t n
cdef np.uint_t k
cdef np.intp_t n
cdef np.uintp_t k

cdef np.ndarray[np.float64_t, ndim=1] y = np.empty(x.shape[0])
cdef np.ndarray[np.float64_t, ndim=1] z = np.array(zi, copy=True)
Expand Down
2 changes: 1 addition & 1 deletion friture_extensions/linear_interp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def pyx_linear_interp_2D(np.ndarray[dtype_t, ndim=2] resampled_buffer not None,
dtype_t resampling_ratio,
int n):
cdef dtype_t a
cdef np.int_t i, j
cdef np.intp_t i, j
cdef Py_ssize_t N = data.shape[0]

for i in range(n):
Expand Down
4 changes: 2 additions & 2 deletions friture_extensions/lookup_table.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cimport cython

def pyx_color_from_float(np.ndarray[np.uint32_t, ndim=1] lut not None,
np.ndarray[np.float64_t, ndim=1] values not None):
cdef np.int_t i, j
cdef np.intp_t i, j
cdef Py_ssize_t N = values.shape[0]
cdef np.ndarray[np.uint32_t, ndim=1] out = np.zeros([N], dtype=np.uint32)

Expand All @@ -24,7 +24,7 @@ def pyx_color_from_float(np.ndarray[np.uint32_t, ndim=1] lut not None,

def pyx_color_from_float_2D(np.ndarray[np.uint32_t, ndim=1] lut not None,
np.ndarray[np.float64_t, ndim=2] values not None):
cdef np.int_t i, j, k
cdef np.intp_t i, j, k
cdef Py_ssize_t M = values.shape[0]
cdef Py_ssize_t N = values.shape[1]
cdef np.ndarray[np.uint32_t, ndim=2] out = np.zeros([M, N], dtype=np.uint32)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = [
"setuptools",

# Cython and numpy are needed when running setup.py, to build extensions
"numpy==1.26.4",
"numpy==2.0.1",
"Cython==3.0.10",
]
build-backend = "setuptools.build_meta"
Expand Down Expand Up @@ -35,7 +35,7 @@ dependencies = [
"sounddevice==0.4.5",
"rtmixer==0.1.4",
"docutils==0.21.2",
"numpy==1.26.4",
"numpy==2.0.1",
"PyQt5==5.15.10",
"appdirs==1.4.4",
"pyrr==0.10.3",
Expand Down
2 changes: 1 addition & 1 deletion sandbox/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

def pinknoise(n, rvs=stats.norm.rvs):
k = min(int(np.floor(np.log(n)/np.log(2))), 12)
pink = np.zeros((n,), np.float)
pink = np.zeros((n,), np.float32)

for m in 2**np.arange(k):
p = int(np.ceil(float(n) / m))
Expand Down
2 changes: 1 addition & 1 deletion sandbox/pink2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

def pink1d(n, rvs=stats.norm.rvs):
k = min(int(np.floor(np.log(n)/np.log(2))), 12)
pink = np.zeros((n,), np.float)
pink = np.zeros((n,), np.float32)
m = 1
for i in range(k):
p = int(np.ceil(float(n) / m))
Expand Down
Loading