Beispiel #1
0
    def test_append_experiment_log(self, tmpdir):
        project = HidraProjectFile(os.path.join(tmpdir, 'project_file.hdf'),
                                   HidraProjectFileMode.OVERWRITE)
        group = project._project_h5[HidraConstants.RAW_DATA][
            HidraConstants.SAMPLE_LOGS]

        project.append_experiment_log('vx', np.array([0.0, 0.1, 0.2]))
        with pytest.raises(KeyError):
            group['vx'].attrs['units']

        project.append_experiment_log('vy',
                                      np.array([0.3, 0.4, 0.5]),
                                      units='mm')
        assert group['vy'].attrs['units'] == 'mm'
Beispiel #2
0
    def test_read_log_units(self, tmpdir):
        project = HidraProjectFile(os.path.join(tmpdir, 'project_file.hdf'),
                                   HidraProjectFileMode.OVERWRITE)

        with pytest.raises(AssertionError) as exception_info:
            project.read_log_units('vx')
        assert 'Missing sample log: vx' in str(exception_info.value)

        project.append_experiment_log('vx', np.array([0.0, 0.1, 0.2]))
        assert project.read_log_units('vx') == ''

        project.append_experiment_log('vy',
                                      np.array([0.3, 0.4, 0.5]),
                                      units='mm')
        assert project.read_log_units('vy') == 'mm'