Skip to content

Commit

Permalink
chore: handle deprecation warnings from Numpy (capytaine#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
mancellin authored Sep 16, 2024
1 parent 7a764ac commit 0c2e53b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions capytaine/matrices/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ def full_matrix(self, dtype=None) -> np.ndarray:
self._put_in_full_matrix(full_matrix)
return full_matrix

def __array__(self, dtype=None):
def __array__(self, dtype=None, copy=True):
if not copy:
raise ValueError("Making an ndarray out of a BlockMatrix requires copy")
return self.full_matrix(dtype=dtype)

def no_toeplitz(self):
Expand Down Expand Up @@ -587,4 +589,4 @@ def access_block_by_path(self, path):
this_block = self
for index in path:
this_block = this_block.all_blocks[index, index]
return this_block
return this_block
4 changes: 3 additions & 1 deletion capytaine/matrices/low_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,9 @@ def full_matrix(self, dtype=None):
else:
return self.left_matrix @ self.right_matrix

def __array__(self, dtype=None):
def __array__(self, dtype=None, copy=True):
if not copy:
raise ValueError("Making an ndarray out of a BlockMatrix requires copy")
return self.full_matrix(dtype=dtype)

@property
Expand Down
3 changes: 2 additions & 1 deletion capytaine/meshes/meshes.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,8 @@ def generate_lid(self, z=0.0, faces_max_radius=None):
# edges_of_hull_faces.shape = (nb_full_faces, 4, 2)
lid_points_in_local_coords = candidate_lid_points[:, np.newaxis, np.newaxis, :] - hull_faces[:, :, :]
# lid_points_in_local_coords.shape = (nb_candidate_lid_points, nb_full_faces, 4, 2)
side_of_hull_edges = np.cross(lid_points_in_local_coords, edges_of_hull_faces)
side_of_hull_edges = (lid_points_in_local_coords[..., 0] * edges_of_hull_faces[..., 1]
- lid_points_in_local_coords[..., 1] * edges_of_hull_faces[..., 0])
# side_of_hull_edges.shape = (nb_candidate_lid_points, nb_full_faces, 4)
point_is_above_panel = np.all(side_of_hull_edges <= 0, axis=-1) | np.all(side_of_hull_edges >= 0, axis=-1)
# point_is_above_panel.shape = (nb_candidate_lid_points, nb_full_faces)
Expand Down

0 comments on commit 0c2e53b

Please sign in to comment.