class documentation

class TestCasting: (source)

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 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)...
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_structured_field_offsets Undocumented
Method test_structured_view_offsets_paramteric 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): (source)

Undocumented

def get_data_variation(self, arr1, arr2, aligned=True, contig=True): (source)

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

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

def test_object_to_parametric_internal_error(self): (source)

Undocumented

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

Undocumented

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

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

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

Undocumented

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

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

Undocumented

@pytest.mark.parametrize(['to_dt', 'expected_off'], [(np.dtype({'names': ['a', 'b'], 'formats': ['i4', 'f4'], 'offsets': [0, 4]}), 2), (np.dtype({'names': ['b', 'a'], 'formats': ['i4', 'f4'], 'offsets': [0, 4]}), 2), (np.dtype({'names': ['b', 'a'], 'formats': ['i4', 'f4'], 'offsets': [0, 6]}), None)])
def test_structured_field_offsets(self, to_dt, expected_off): (source)

Undocumented

@pytest.mark.parametrize(('from_dt', 'to_dt', 'expected_off'), [('i', '(1,1)i', 0), ('(1,1)i', 'i', 0), ('(2,1)i', '(2,1)i', 0), ('i', dict(names=['a'], formats=['i'], offsets=[2]), None), (dict(names=['a'], formats=['i'], offsets=[2]), 'i', 2), ('i', dict(names=['a', 'b'], formats=['i', 'i'], offsets=[2, 2]), None), ('i,i', 'i,i,i', None), ('i4', 'V3', 0), ('i4', 'V4', 0), ('i4', 'V10', None), ('O', 'V4', None), ('O', 'V8', None), ('V4', 'V3', 0), ('V4', 'V4', 0), ('V3', 'V4', None), ('V4', 'i4', None), ('i,i', 'i,i,i', None)])
def test_structured_view_offsets_paramteric(self, from_dt, to_dt, expected_off): (source)

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

def test_void_to_string_special_case(self): (source)

Undocumented

Undocumented