class documentation

class TestCasting:

View In Hierarchy

Undocumented

Method get​_data Undocumented
Method get​_data​_variation Returns a copy of arr1 that may be non-contiguous or unaligned, and a matching array for arr2 (although not a copy).
Method string​_with​_modified​_length Undocumented
Method test​_nonstandard​_bool​_to​_other Undocumented
Method test​_numeric​_to​_times Undocumented
Method test​_object​_and​_simple​_resolution Undocumented
Method test_object_casts_​NULL_​None_equivalence Undocumented
Method test​_object​_to​_parametric​_internal​_error Undocumented
Method test​_simple​_cancast Undocumented
Method test​_simple​_direct​_casts No summary
Method test​_simple​_string​_casts​_roundtrip Tests casts from and to string by checking the roundtripping property.
Method test​_simple​_to​_object​_resolution Undocumented
Method test​_string​_cancast Undocumented
Method test​_string​_to​_string​_cancast Undocumented
Method test​_time​_to​_time Undocumented
Method test​_unicode​_byteswapped​_cast Undocumented
Method test​_void​_and​_structured​_with​_subarray Undocumented
Method test​_void​_to​_string​_special​_case Undocumented
Class Variable size Undocumented
def get_data(self, dtype1, dtype2):

Undocumented

def get_data_variation(self, arr1, arr2, aligned=True, contig=True):
Returns a copy of arr1 that may be non-contiguous or unaligned, and a matching array for arr2 (although not a copy).
def string_with_modified_length(self, dtype, change_length):

Undocumented

@pytest.mark.parametrize('dtype', np.typecodes['AllInteger']+np.typecodes['AllFloat'])
def test_nonstandard_bool_to_other(self, dtype):

Undocumented

@pytest.mark.parametrize('from_Dt', simple_dtypes)
def test_numeric_to_times(self, from_Dt):

Undocumented

@pytest.mark.parametrize('dtype', simple_dtype_instances())
def test_object_and_simple_resolution(self, dtype):

Undocumented

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

Undocumented

def test_object_to_parametric_internal_error(self):

Undocumented

@pytest.mark.parametrize('from_Dt', simple_dtypes)
def test_simple_cancast(self, from_Dt):

Undocumented

@pytest.mark.filterwarnings('ignore::numpy.ComplexWarning')
@pytest.mark.parametrize('from_dt', simple_dtype_instances())
def test_simple_direct_casts(self, from_dt):

This test checks numeric direct casts for dtypes supported also by the struct module (plus complex). It tries to be test a wide range of inputs, but skips over possibly undefined behaviour (e.g. int rollover). Longdouble and CLongdouble are tested, but only using double precision.

If this test creates issues, it should possibly just be simplified or even removed (checking whether unaligned/non-contiguous casts give the same results is useful, though).

@pytest.mark.parametrize('string_char', ['S', 'U'])
@pytest.mark.parametrize('other_dt', simple_dtype_instances())
def test_simple_string_casts_roundtrip(self, other_dt, string_char):

Tests casts from and to string by checking the roundtripping property.

The test also covers some string to string casts (but not all).

If this test creates issues, it should possibly just be simplified or even removed (checking whether unaligned/non-contiguous casts give the same results is useful, though).

@pytest.mark.parametrize('dtype', simple_dtype_instances())
def test_simple_to_object_resolution(self, dtype):

Undocumented

@pytest.mark.parametrize('other_DT', simple_dtypes)
@pytest.mark.parametrize('string_char', ['S', 'U'])
def test_string_cancast(self, other_DT, string_char):

Undocumented

@pytest.mark.parametrize('other_dt', ['S8', '<U8', '>U8'])
@pytest.mark.parametrize('string_char', ['S', 'U'])
def test_string_to_string_cancast(self, other_dt, string_char):

Undocumented

@pytest.mark.parametrize(['from_dt', 'to_dt', 'expected_casting', 'nom', 'denom'], [('M8[ns]', None, Casting.no|Casting.cast_is_view, 1, 1), (str(np.dtype('M8[ns]').newbyteorder()), None, Casting.equiv, 1, 1), ('M8', 'M8[ms]', Casting.safe|Casting.cast_is_view, 1, 1), ('M8[ms]', 'M8', Casting.unsafe, 1, 1), ('M8[5ms]', 'M8[5ms]', Casting.no|Casting.cast_is_view, 1, 1), ('M8[ns]', 'M8[ms]', Casting.same_kind, 1, 10**6), ('M8[ms]', 'M8[ns]', Casting.safe, 10**6, 1), ('M8[ms]', 'M8[7ms]', Casting.same_kind, 1, 7), ('M8[4D]', 'M8[1M]', Casting.same_kind, None, [-2**63, 0, -1, 1314, -1315, 564442610]), ('m8[ns]', None, Casting.no|Casting.cast_is_view, 1, 1), (str(np.dtype('m8[ns]').newbyteorder()), None, Casting.equiv, 1, 1), ('m8', 'm8[ms]', Casting.safe|Casting.cast_is_view, 1, 1), ('m8[ms]', 'm8', Casting.unsafe, 1, 1), ('m8[5ms]', 'm8[5ms]', Casting.no|Casting.cast_is_view, 1, 1), ('m8[ns]', 'm8[ms]', Casting.same_kind, 1, 10**6), ('m8[ms]', 'm8[ns]', Casting.safe, 10**6, 1), ('m8[ms]', 'm8[7ms]', Casting.same_kind, 1, 7), ('m8[4D]', 'm8[1M]', Casting.unsafe, None, [-2**63, 0, 0, 1314, -1315, 564442610])])
def test_time_to_time(self, from_dt, to_dt, expected_casting, nom, denom):

Undocumented

@pytest.mark.parametrize('order1', ['>', '<'])
@pytest.mark.parametrize('order2', ['>', '<'])
def test_unicode_byteswapped_cast(self, order1, order2):

Undocumented

@pytest.mark.parametrize('casting', ['no', 'unsafe'])
def test_void_and_structured_with_subarray(self, casting):

Undocumented

def test_void_to_string_special_case(self):

Undocumented

size: int =

Undocumented