diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2018-09-17 02:03:19 -0700 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2018-09-17 02:05:48 -0700 |
commit | d26ad30deea8e11d3614f8b72b58e1350a055a30 (patch) | |
tree | bee1a2277aa5390ffd53796b149f45c4ca5994f8 /numpy/lib/tests/test_arraypad.py | |
parent | 324e3045c3e5a4c262e9d231663b7228593c8675 (diff) | |
download | numpy-d26ad30deea8e11d3614f8b72b58e1350a055a30.tar.gz |
TST: Add a (failing) test for using np.pad with Fractions, which currently rounds to `float`
Diffstat (limited to 'numpy/lib/tests/test_arraypad.py')
-rw-r--r-- | numpy/lib/tests/test_arraypad.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_arraypad.py b/numpy/lib/tests/test_arraypad.py index 581ae30e5..8ef9530a8 100644 --- a/numpy/lib/tests/test_arraypad.py +++ b/numpy/lib/tests/test_arraypad.py @@ -559,6 +559,25 @@ class TestLinearRamp(object): [0., 0., 0., 0., 0., 0., 0., 0., 0.]]) assert_allclose(test, expected) + @pytest.mark.xfail(exceptions=(AssertionError,)) + def test_object_array(self): + from fractions import Fraction + arr = np.array([Fraction(1, 2), Fraction(-1, 2)]) + actual = np.pad(arr, (2, 3), mode='linear_ramp', end_values=0) + + # deliberately chosen to have a non-power-of-2 denominator such that + # rounding to floats causes a failure. + expected = np.array([ + Fraction( 0, 12), + Fraction( 3, 12), + Fraction( 6, 12), + Fraction(-6, 12), + Fraction(-4, 12), + Fraction(-2, 12), + Fraction(-0, 12), + ]) + assert_equal(actual, expected) + class TestReflect(object): def test_check_simple(self): |