summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2018-09-09 17:32:50 -0700
committerEric Wieser <wieser.eric@gmail.com>2018-09-09 17:40:37 -0700
commit00e50a3a38d1f86e027dd1d77fd5491ade7d248a (patch)
treed60540b25d5118658f29f2d1579ff2486706b4ff
parent058851c5cfc98f50f11237b1c13d77cfd1f40475 (diff)
downloadnumpy-00e50a3a38d1f86e027dd1d77fd5491ade7d248a.tar.gz
TST: Add tests for maximum_sctype
-rw-r--r--numpy/core/tests/test_numerictypes.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/numpy/core/tests/test_numerictypes.py b/numpy/core/tests/test_numerictypes.py
index 4c3cc6c9e..22abe00fd 100644
--- a/numpy/core/tests/test_numerictypes.py
+++ b/numpy/core/tests/test_numerictypes.py
@@ -3,6 +3,7 @@ from __future__ import division, absolute_import, print_function
import sys
import itertools
+import pytest
import numpy as np
from numpy.testing import assert_, assert_equal, assert_raises
@@ -412,3 +413,29 @@ def TestSctypeDict(object):
def test_longdouble(self):
assert_(np.sctypeDict['f8'] is not np.longdouble)
assert_(np.sctypeDict['c16'] is not np.clongdouble)
+
+
+class TestMaximumSctype(object):
+
+ # note that parametrizing with sctype['int'] and similar would skip types
+ # with the same size (gh-11923)
+
+ @pytest.mark.parametrize('t', [np.byte, np.short, np.intc, np.int_, np.longlong])
+ def test_int(self, t):
+ assert_equal(np.maximum_sctype(t), np.sctypes['int'][-1])
+
+ @pytest.mark.parametrize('t', [np.ubyte, np.ushort, np.uintc, np.uint, np.ulonglong])
+ def test_uint(self, t):
+ assert_equal(np.maximum_sctype(t), np.sctypes['uint'][-1])
+
+ @pytest.mark.parametrize('t', [np.half, np.single, np.double, np.longdouble])
+ def test_float(self, t):
+ assert_equal(np.maximum_sctype(t), np.sctypes['float'][-1])
+
+ @pytest.mark.parametrize('t', [np.csingle, np.cdouble, np.clongdouble])
+ def test_complex(self, t):
+ assert_equal(np.maximum_sctype(t), np.sctypes['complex'][-1])
+
+ @pytest.mark.parametrize('t', [np.bool_, np.object_, np.unicode_, np.bytes_, np.void])
+ def test_other(self, t):
+ assert_equal(np.maximum_sctype(t), t)