Esempio n. 1
0
def test_empty():
    """Test that an empty dataframe is valid

    (As long as the required columns exist!)
    """
    empty = empty_signals()
    check_signal_specification(empty)
Esempio n. 2
0
def test_unknown_version(signals):
    """Test only the current specification version

    If a new version of the signals specification is implemented, this unit
    test should be updated to the next version.
    """
    with pytest.raises(ValueError):
        # This should fail because version='2' does not exist yet
        check_signal_specification(signals, version='2')
Esempio n. 3
0
    def postconditions(self, results):
        super().postconditions(results)

        if not isinstance(results, FileAdapter):
            raise PostconditionFailed('Output was not a file')

        # Postcondition: file is empty
        if results.empty:
            return

        # Postcondition: when file is not empty, it follows the signal spec
        key = self.output_hdf5_key
        with pd.HDFStore(str(results.file.resolve()), 'r') as store:
            dataframe = pd.read_hdf(store, key)
            check_signal_specification(dataframe)
Esempio n. 4
0
def _check_and_assert_raises(signal_obj, annotation_obj, code):
    with pytest.raises(SignalSpecificationError) as ex_info:
        check_signal_specification(signal_obj, annotation_obj)
    exception = ex_info.value
    assert exception.code == code
Esempio n. 5
0
def test_sample_number_integer(signals):
    """Test that sample_number with integer does not fail"""
    signals['sample_number'] = np.arange(signals.shape[0])
    check_signal_specification(signals)
Esempio n. 6
0
def test_correct_signal_example_dataframe(example_signals_annotations):
    """Test that the signal example shown in the docs conforms to the specs"""
    signals, annotations = example_signals_annotations
    check_signal_specification(signals, annotations)
Esempio n. 7
0
def test_correct_signal_dataframe(signals):
    """Test a correct event dataframe"""
    # This should not raise anything
    check_signal_specification(signals)