Skip to content

Commit

Permalink
fix cdense min dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
maurapintor committed Nov 11, 2024
1 parent 6ffed52 commit 376affa
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/secml/array/c_dense.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def __init__(self, data=None, dtype=None, copy=False, shape=None):
else: # Other inputs... just need to initialize the input shape
self._input_shape = None
obj = np.asarray(data, dtype=dtype)
if obj.ndim < 1:
obj = obj.reshape(1, *obj.shape)
# numpy created an object array, maybe input is malformed?!
if obj.dtype.char == "O":
raise TypeError("Array is malformed, check input data.")
Expand Down Expand Up @@ -480,9 +482,8 @@ def _check_index_bool(self, idx):
and elem.size != self.shape[elem_idx]
):
raise IndexError(
"boolean index array for axis {:} must have " "size {:}.".format(
elem_idx, self.shape[elem_idx]
)
"boolean index array for axis {:} must have "
"size {:}.".format(elem_idx, self.shape[elem_idx])
)

def _check_index_slice(self, elem_idx, elem):
Expand Down Expand Up @@ -1506,9 +1507,11 @@ def norm(self, order=None, axis=None, keepdims=False):
return self.__class__([0.0])

out = np.linalg.norm(
self.atleast_2d().tondarray().astype(float)
if axis is not None
else self.tondarray().astype(float),
(
self.atleast_2d().tondarray().astype(float)
if axis is not None
else self.tondarray().astype(float)
),
order,
axis,
)
Expand Down

0 comments on commit 376affa

Please sign in to comment.