Пример #1
0
    def create_dataset(cls, name):
        """
        Create dataset, removing an existing dataset first
        """
        lue_test.remove_file_if_existant(name)

        return lue.create_dataset(name)
Пример #2
0
    def test_pathname(self):

        # Relative path
        file_pathname = "file_pathname.h5"
        lue_test.remove_file_if_existant(file_pathname)
        file = lue.hdf5.create_file(file_pathname)
        self.assertEqual(file.pathname, file_pathname)

        # Relative path
        file_pathname = "./file_pathname.h5"
        lue_test.remove_file_if_existant(file_pathname)
        file = lue.hdf5.create_file(file_pathname)
        self.assertEqual(file.pathname, file_pathname)

        # Absolute path
        file_pathname = os.path.abspath("file_pathname.h5")
        lue_test.remove_file_if_existant(file_pathname)
        file = lue.hdf5.create_file(file_pathname)
        self.assertEqual(file.pathname, file_pathname)

        # Unicode
        file_pathname = u"filæ_¶åthnæmæ.h5"
        lue_test.remove_file_if_existant(file_pathname)
        file = lue.hdf5.create_file(file_pathname)
        self.assertEqual(file.pathname, file_pathname)
Пример #3
0
    def test_create_remove(self):

        file_pathname = "file_create.h5"

        lue_test.remove_file_if_existant(file_pathname)

        self.assertFalse(lue.hdf5.file_exists(file_pathname))

        file = lue.hdf5.create_file(file_pathname)

        self.assertTrue(lue.hdf5.file_exists(file_pathname))
        self.assertTrue(os.path.isfile(file_pathname))
        self.assertTrue(os.access(file_pathname, os.F_OK))
        self.assertTrue(os.access(file_pathname, os.R_OK))
        self.assertTrue(os.access(file_pathname, os.W_OK))
        self.assertFalse(os.access(file_pathname, os.X_OK))

        lue.hdf5.remove_file(file_pathname)
        self.assertFalse(lue.hdf5.file_exists(file_pathname))
Пример #4
0
    def setUp(self):

        dataset_name = "my_dataset.lue"
        lue_test.remove_file_if_existant(dataset_name)
        self.dataset = lue.create_dataset(dataset_name)
        self.phenomenon = self.dataset.add_phenomenon("my_phenomenon")

        self.nr_objects = 5
        self.phenomenon.object_id.expand(self.nr_objects)[:] = \
            np.arange(self.nr_objects)

        self.nr_rows = 3
        self.nr_cols = 2
        self.value_shape = (self.nr_rows, self.nr_cols)
        self.numeric_value_type = np.dtype(np.int32)
        self.string_value_type = np.dtype(np.unicode_)

        self.property_set = \
            self.phenomenon.add_property_set("my_property_set")
        numeric_property = self.property_set.add_property(
            "my_numeric_property", self.numeric_value_type, self.value_shape)
        string_property = self.property_set.add_property(
            "my_string_property", self.string_value_type, self.value_shape)

        self.lue_numeric_values = \
            numeric_property.value.expand(self.nr_objects)
        self.numpy_numeric_values = np.arange(
            self.nr_objects * reduce(lambda x, y: x * y, self.value_shape),
            dtype=self.numeric_value_type).reshape((self.nr_objects, ) +
                                                   self.value_shape)
        self.lue_numeric_values[:] = self.numpy_numeric_values

        self.lue_string_values = \
            string_property.value.expand(self.nr_objects)
        self.numpy_string_values = \
            self.numpy_numeric_values.astype(self.string_value_type)
        # self.lue_string_values[:] = self.numpy_string_values

        lue.assert_is_valid(self.dataset)
Пример #5
0
 def test_open_writable(self):
     file_pathname = "file_open_writable.h5"
     lue_test.remove_file_if_existant(file_pathname)
     file = lue.hdf5.create_file(file_pathname)
     file = lue.hdf5.open_file(file_pathname, "w")
Пример #6
0
 def test_open_readonly(self):
     file_pathname = "file_open_readonly.h5"
     lue_test.remove_file_if_existant(file_pathname)
     file = lue.hdf5.create_file(file_pathname)
     file = lue.hdf5.open_file(file_pathname, "r")