class documentation
class TestScalarDiscovery: (source)
Undocumented
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
Undocumented |
Method | test |
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 |
Undocumented |
Method | test |
Undocumented |
Method | test |
np.array(scalar, dtype=dtype) |
Method | test |
Undocumented |
Method | test |
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 |
Undocumented |
Method | test |
Undocumented |
@pytest.mark.parametrize( 'dtype_char', np.typecodes[ 'All'])
def test_default_dtype_instance(self, dtype_char): (source) ¶
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) ¶
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_coercion(self, scalar): (source) ¶
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) ¶
@pytest.mark.filterwarnings(
@pytest.mark.parametrize(
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) ¶
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) ¶
@pytest.mark.parametrize(
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)
.