Skip to content

Commit

Permalink
fix: allow for numpy 1.X backwards compatibility (#477)
Browse files Browse the repository at this point in the history
* fix: allow for numpy 1.X backwards compatibility

* fix: missing change in install_requires

* fix: using minimum version 1.16.0

* fix: using minimum version 1.16.0

* fix: add copy None for numpy 2.X
  • Loading branch information
RobPasMue authored Aug 20, 2024
1 parent b603bed commit 260a427
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion ansys/mapdl/reader/cython/_binary_reader.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,11 @@ cdef np.ndarray wrap_array(void* c_ptr, int size, int type_flag, int prec_flag):
array_wrapper.set_data(size, c_ptr, my_dtype)

cdef np.ndarray ndarray
ndarray = np.array(array_wrapper)
# TODO: Remove backwards compatibility in the future
if np.__version__.startswith("1."): # Backwards compatibility with numpy 1.X
ndarray = np.array(array_wrapper, copy=False)
else:
ndarray = np.array(array_wrapper, copy=None)

# Assign our object to the 'base' of the ndarray object
np.PyArray_SetBaseObject(ndarray, array_wrapper)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
build-backend = "setuptools.build_meta"
requires = [
"cython>=3.0.0",
"numpy>=2,<3",
"numpy>=1.16.0,<3",
"setuptools>=45.0",
"wheel>=0.37.0",
]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
install_requires=[
"appdirs>=1.4.0",
"matplotlib>=3.0.0",
"numpy>=2,<3",
"numpy>=1.16.0,<3",
"pyvista>=0.32.0,<0.44",
"tqdm>=4.45.0",
"vtk>=9.0.0",
Expand Down

0 comments on commit 260a427

Please sign in to comment.