Skip to content

Commit 102ba69

Browse files
maniteja123juliantaylor
authored andcommitted
BUG: solves complex array clip in issue numpy#5354 and added symmetric regression test
1 parent 43c8313 commit 102ba69

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

numpy/core/src/multiarray/arraytypes.c.src

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3467,8 +3467,6 @@ static void
34673467
npy_intp i;
34683468
@type@ max_val, min_val;
34693469

3470-
min_val = *min;
3471-
max_val = *max;
34723470
if (max != NULL) {
34733471
max_val = *max;
34743472
}

numpy/core/tests/test_numeric.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,18 @@ def test_simple_complex(self):
11761176
act = self.clip(a, m, M)
11771177
assert_array_strict_equal(ac, act)
11781178

1179+
def test_clip_complex(self):
1180+
# Address Issue gh-5354 for clipping complex arrays
1181+
# Test native complex input without explicit min/max
1182+
# ie, either min=None or max=None
1183+
a = np.ones(10, dtype=np.complex)
1184+
m = a.min()
1185+
M = a.max()
1186+
am = self.fastclip(a, m, None)
1187+
aM = self.fastclip(a, None, M)
1188+
assert_array_strict_equal(am, a)
1189+
assert_array_strict_equal(aM, a)
1190+
11791191
def test_clip_non_contig(self):
11801192
#Test clip for non contiguous native input and native scalar min/max.
11811193
a = self._generate_data(self.nr * 2, self.nc * 3)

0 commit comments

Comments
 (0)