Skip to content

Commit 3b5eeea

Browse files
committed
TST: un-xfail TestClip
1 parent 7f83c37 commit 3b5eeea

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

torch_np/_ndarray.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def nonzero(self):
376376
tensor = self._tensor
377377
return tuple(asarray(_) for _ in tensor.nonzero(as_tuple=True))
378378

379-
def clip(self, min, max, out=None):
379+
def clip(self, min=None, max=None, out=None):
380380
tensor, t_min, t_max = _helpers.to_tensors_or_none(self, min, max)
381381
result = _impl.clip(tensor, t_min, t_max)
382382
return _helpers.result_or_out(result, out)

torch_np/_wrapper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,9 @@ def round_(a, decimals=0, out=None):
678678
round = round_
679679

680680

681-
def clip(a, a_min, a_max, out=None):
681+
def clip(a, a_min=None, a_max=None, out=None):
682+
# np.clip requires both a_min and a_max not None, while ndarray.clip
683+
# allows of then be None. Allow both here.
682684
arr = asarray(a)
683685
return arr.clip(a_min, a_max, out=out)
684686

torch_np/tests/numpy_tests/core/test_multiarray.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4037,14 +4037,14 @@ def test_datetime(self):
40374037
assert_equal(np.amin(a), a[3])
40384038
assert_equal(np.amax(a), a[3])
40394039

4040-
@pytest.mark.xfail(reason='TODO')
4040+
40414041
class TestNewaxis:
40424042
def test_basic(self):
40434043
sk = np.array([0, -0.1, 0.1])
40444044
res = 250*sk[:, np.newaxis]
40454045
assert_almost_equal(res.ravel(), 250*sk)
40464046

4047-
@pytest.mark.xfail(reason='TODO')
4047+
40484048
class TestClip:
40494049
def _check_range(self, x, cmin, cmax):
40504050
assert_(np.all(x >= cmin))
@@ -4084,6 +4084,7 @@ def _clip_type(self, type_group, array_max,
40844084
self._check_range(x, expected_min, expected_max)
40854085
return x
40864086

4087+
@pytest.mark.skip(reason="endianness")
40874088
def test_basic(self):
40884089
for inplace in [False, True]:
40894090
self._clip_type(
@@ -4101,12 +4102,6 @@ def test_basic(self):
41014102
self._clip_type(
41024103
'uint', 1024, -120, 100, inplace=inplace, expected_min=0)
41034104

4104-
def test_record_array(self):
4105-
rec = np.array([(-5, 2.0, 3.0), (5.0, 4.0, 3.0)],
4106-
dtype=[('x', '<f8'), ('y', '<f8'), ('z', '<f8')])
4107-
y = rec['x'].clip(-0.3, 0.5)
4108-
self._check_range(y, -0.3, 0.5)
4109-
41104105
def test_max_or_min(self):
41114106
val = np.array([0, 1, 2, 3, 4, 5, 6, 7])
41124107
x = val.clip(3)

0 commit comments

Comments
 (0)