diff --git a/test/hl/test_datatype.py b/test/hl/test_datatype.py index 751d9a5..00c0c50 100644 --- a/test/hl/test_datatype.py +++ b/test/hl/test_datatype.py @@ -12,7 +12,7 @@ import numpy as np import math - +import logging import config if config.get("use_h5py"): @@ -23,39 +23,11 @@ from common import ut, TestCase -def read_dtypes(dataset_dtype, names): - """ Returns a 2-tuple containing: - - 1. Output dataset dtype - 2. Dtype containing HDF5-appropriate description of destination - """ - - if len(names) == 0: # Not compound, or all fields needed - format_dtype = dataset_dtype - - elif dataset_dtype.names is None: - raise ValueError("Field names only allowed for compound types") - - elif any(x not in dataset_dtype.names for x in names): - raise ValueError("Field does not appear in this type.") - - else: - format_dtype = np.dtype([(name, dataset_dtype.fields[name][0]) for name in names]) - - if len(names) == 1: - # We don't preserve the field information if only one explicitly selected. - output_dtype = format_dtype.fields[names[0]][0] - - else: - output_dtype = format_dtype - - return output_dtype, format_dtype - - class TestScalarCompound(TestCase): def setUp(self): filename = self.getFileName("scalar_compound_dset") + print("filename:", filename) self.f = h5py.File(filename, "w") self.data = np.array((42.5, -118, "Hello"), dtype=[('a', 'f'), ('b', 'i'), ('c', '|S10')]) self.dset = self.f.create_dataset('x', data=self.data) @@ -180,4 +152,6 @@ def test_nested_compound_vlen(self): if __name__ == '__main__': + loglevel = logging.ERROR + logging.basicConfig(format='%(asctime)s %(message)s', level=loglevel) ut.main()