diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2018-09-10 15:36:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-10 15:36:08 -0500 |
commit | dc6a5735519aca9aeedf1b8e83fefa1ae43131b3 (patch) | |
tree | e1755eb5594c059f7a719fe8290af8b5cd8f4dfc | |
parent | c39f46158160ef2ccb9602caa0841c4385a018be (diff) | |
parent | 00e50a3a38d1f86e027dd1d77fd5491ade7d248a (diff) | |
download | numpy-dc6a5735519aca9aeedf1b8e83fefa1ae43131b3.tar.gz |
Merge pull request #11922 from eric-wieser/test-maximum_sctype
TST: Add tests for maximum_sctype
-rw-r--r-- | numpy/core/tests/test_numerictypes.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/numpy/core/tests/test_numerictypes.py b/numpy/core/tests/test_numerictypes.py index af4bdba1e..72da9933c 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 @@ class 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) |