Skip to content

Commit

Permalink
Fixes for numpy 2.0 (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinnala authored Jan 9, 2024
1 parent 68bd6fe commit 58f9a88
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion skfem/assembly/dofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def get_facet_dofs(
nodal_ix,
facet_ix,
edge_ix,
np.empty((0,), dtype=np.uint64),
np.empty((0,), dtype=np.int64),
r1,
r2,
r3,
Expand Down
2 changes: 1 addition & 1 deletion skfem/io/meshio.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def from_meshio(m,

# parse any subdomains from cell_sets
if m.cell_sets:
subdomains = {k: v[meshio_type].astype(np.uint64)
subdomains = {k: v[meshio_type].astype(np.int64)
for k, v in m.cell_sets_dict.items()
if meshio_type in v}

Expand Down
9 changes: 5 additions & 4 deletions skfem/mesh/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def boundary_edges(self) -> ndarray:
A = self.edges[:, edge_candidates].T
B = boundary_edges
dims = A.max(0) + 1
ix = np.where(np.in1d(
ix = np.where(np.isin(
np.ravel_multi_index(A.T, dims), # type: ignore
np.ravel_multi_index(B.T, dims), # type: ignore
))[0]
Expand Down Expand Up @@ -271,7 +271,8 @@ def encode_boundary(boundary: Union[ndarray, OrientedBoundary]
return {
**{
f"skfem:s:{name}": [
np.isin(np.arange(self.t.shape[1]), subdomain).astype(int)
np.isin(np.arange(self.t.shape[1],
dtype=np.int64), subdomain).astype(int)
]
for name, subdomain in subdomains.items()
},
Expand All @@ -295,7 +296,7 @@ def _decode_cell_data(self, cell_data: Dict[str, List[ndarray]]):
elif subnames[1] == "b":
mask = (
(1 << np.arange(self.refdom.nfacets))[:, None]
& data[0].astype(int)
& data[0].astype(np.int64)
).astype(bool)
facets = np.sort(self.t2f[mask])
cells = mask.nonzero()[1]
Expand Down Expand Up @@ -399,7 +400,7 @@ def elements_satisfying(self,
"""
midp = self.p[:, self.t].mean(axis=1)
return np.nonzero(test(midp))[0].astype(np.uint64)
return np.nonzero(test(midp))[0].astype(np.int64)

def _expand_facets(self, ix: ndarray) -> Tuple[ndarray, ndarray]:
"""Return vertices and edges corresponding to given facet indices.
Expand Down
2 changes: 1 addition & 1 deletion skfem/mesh/mesh_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def boundary_edges(self) -> ndarray:
A = self.edges[:, edge_candidates].T
B = boundary_edges
dims = A.max(0) + 1
ix = np.where(np.in1d(
ix = np.where(np.isin(
np.ravel_multi_index(A.T, dims), # type: ignore
np.ravel_multi_index(B.T, dims), # type: ignore
))[0]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def runTest(self):
self.assertEqual(len(all_dofs.drop('u').facet), 1)

all_dofs = basis.dofs.get_facet_dofs(
m.facets_satisfying(lambda x: 1))
m.facets_satisfying(lambda x: 1 + x[0] * 0))

self.assertEqual(len(all_dofs.keep('u_n').facet), 1)
self.assertEqual(len(all_dofs.drop('u').facet), 1)
Expand Down

0 comments on commit 58f9a88

Please sign in to comment.