File tree 2 files changed +10
-6
lines changed
2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change
1
+ from numpy .core .numeric import normalize_axis_tuple
2
+
1
3
from ..julia import jl
2
4
from ..tensor import Tensor
3
5
@@ -11,12 +13,14 @@ def vector_norm(
11
13
ord : int | float = 2 ,
12
14
) -> Tensor :
13
15
if axis is not None :
14
- raise ValueError (
15
- "At the moment only `None` (vector norm of a flattened array) "
16
- "is supported. Got: {axis}."
17
- )
16
+ axis = normalize_axis_tuple (axis , x .ndim )
17
+ if axis != tuple (range (x .ndim )):
18
+ raise ValueError (
19
+ "At the moment only `None` (vector norm of a flattened array) "
20
+ "is supported. Got: {axis}."
21
+ )
18
22
19
23
result = Tensor (jl .Finch .norm (x ._obj , ord ))
20
24
if keepdims :
21
- result = result . __getitem__ ( tuple (None for _ in range (x .ndim )))
25
+ result = result [ tuple (None for _ in range (x .ndim ))]
22
26
return result
Original file line number Diff line number Diff line change @@ -298,7 +298,7 @@ def _order(self) -> tuple[int, ...]:
298
298
@property
299
299
def mT (self ) -> "Tensor" :
300
300
axes = list (range (self .ndim ))
301
- axes [- 2 :] = axes [: - 3 : - 1 ]
301
+ axes [- 2 ], axes [ - 1 ] = axes [- 1 ], axes [ - 2 ]
302
302
axes = tuple (axes )
303
303
return self .permute_dims (axes )
304
304
You can’t perform that action at this time.
0 commit comments