Skip to content

Commit cf48608

Browse files
committed
minor: simplify code for Sum
1 parent b19387a commit cf48608

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

pylops/basicoperators/Sum.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,17 @@ class Sum(LinearOperator):
5656
"""
5757

5858
def __init__(self, dims, axis=-1, dir=None, dtype="float64"):
59-
if len(dims) == 1:
60-
dims = (dims[0], 1) # to avoid reducing matvec to a scalar
61-
self.dims = dims
6259
if dir is not None:
6360
warnings.warn(
6461
"dir will be deprecated in version 2.0.0, use axis instead.",
6562
category=DeprecationWarning,
6663
stacklevel=2,
6764
)
68-
self.axis = dir
69-
else:
70-
self.axis = axis
65+
axis = dir
66+
if len(dims) == 1:
67+
dims = (dims[0], 1) # to avoid reducing matvec to a scalar
68+
self.dims = dims
69+
self.axis = axis
7170
# data dimensions
7271
self.dims_d = list(dims).copy()
7372
self.dims_d.pop(self.axis)

0 commit comments

Comments
 (0)