class documentation

class TestScalarDiscovery: (source)

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 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...
Method test_scalar Undocumented
Method test_scalar_coercion Undocumented
Method test_scalar_coercion_same_as_cast_and_assignment np.array(scalar, dtype=dtype)
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): (source)

Undocumented

def test_char_special_case_deep(self): (source)

Undocumented

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

Undocumented

@pytest.mark.parametrize('pyscalar', [10, 10.32, 10.14j, 10**100])
def test_pyscalar_subclasses(self, pyscalar): (source)

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): (source)

Undocumented

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

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): (source)

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): (source)

Undocumented

@pytest.mark.parametrize('dtype', np.typecodes['Integer'])
@pytest.mark.parametrize(['scalar', 'error'], [(np.float64(np.nan), ValueError), (np.array(-1).astype(np.ulonglong)[], OverflowError)])
def test_scalar_to_int_coerce_does_not_cast(self, dtype, scalar, error): (source)

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): (source)

Undocumented

def test_void_special_case(self): (source)

Undocumented