diff --git a/capytaine/matrices/block.py b/capytaine/matrices/block.py index 4fd14cf6..7fb7f91f 100644 --- a/capytaine/matrices/block.py +++ b/capytaine/matrices/block.py @@ -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): @@ -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 \ No newline at end of file + return this_block diff --git a/capytaine/matrices/low_rank.py b/capytaine/matrices/low_rank.py index 82e3c2ae..c2eb302e 100644 --- a/capytaine/matrices/low_rank.py +++ b/capytaine/matrices/low_rank.py @@ -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 diff --git a/capytaine/meshes/meshes.py b/capytaine/meshes/meshes.py index c5fd48dc..7ec88e6f 100644 --- a/capytaine/meshes/meshes.py +++ b/capytaine/meshes/meshes.py @@ -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)