class documentation

class TestScalarDiscovery:

View In Hierarchy

Undocumented

Method test​_char​_special​_case Undocumented
Method test​_char​_special​_case​_deep Undocumented
Method test​_default​_dtype​_instance Undocumented
Method test​_pyscalar​_subclasses No summary
Method test​_scalar Undocumented
Method test​_scalar​_coercion Undocumented
Method test​_scalar​_coercion​_same​_as​_cast​_and​_assignment No summary
Method test​_scalar​_promotion Undocumented
Method test​_scalar​_to​_int​_coerce​_does​_not​_cast Signed integers are currently different in that they do not cast other NumPy scalar, but instead use scalar.__int__(). The hardcoded exception to this rule is np.array(scalar, dtype=integer).
Method test​_unknown​_object Undocumented
Method test​_void​_special​_case Undocumented
def test_char_special_case(self):

Undocumented

def test_char_special_case_deep(self):

Undocumented

@pytest.mark.parametrize('dtype_char', np.typecodes['All'])
def test_default_dtype_instance(self, dtype_char):

Undocumented

@pytest.mark.parametrize('pyscalar', [10, 10.32, 10.14j, 10**100])
def test_pyscalar_subclasses(self, pyscalar):
NumPy arrays are read/write which means that anything but invariant behaviour is on thin ice. However, we currently are happy to discover subclasses of Python float, int, complex the same as the base classes. This should potentially be deprecated.
@pytest.mark.parametrize('scalar', scalar_instances())
def test_scalar(self, scalar):

Undocumented

@pytest.mark.parametrize('scalar', scalar_instances())
def test_scalar_coercion(self, scalar):

Undocumented

@pytest.mark.xfail(IS_PYPY, reason='`int(np.complex128(3))` fails on PyPy')
@pytest.mark.filterwarnings('ignore::numpy.ComplexWarning')
@pytest.mark.parametrize('cast_to', scalar_instances())
def test_scalar_coercion_same_as_cast_and_assignment(self, cast_to):
Test that in most cases:
  • np.array(scalar, dtype=dtype)
  • np.empty((), dtype=dtype)[()] = scalar
  • np.array(scalar).astype(dtype)

should behave the same. The only exceptions are paramteric dtypes (mainly datetime/timedelta without unit) and void without fields.

@pytest.mark.filterwarnings('ignore:Promotion of numbers:FutureWarning')
def test_scalar_promotion(self):

Undocumented

@pytest.mark.parametrize('dtype', np.typecodes['Integer'])
def test_scalar_to_int_coerce_does_not_cast(self, dtype):
Signed integers are currently different in that they do not cast other NumPy scalar, but instead use scalar.__int__(). The hardcoded exception to this rule is np.array(scalar, dtype=integer).
def test_unknown_object(self):

Undocumented

def test_void_special_case(self):

Undocumented