diff --git a/snirf/pysnirf2.py b/snirf/pysnirf2.py index 18023b0..811a2e0 100644 --- a/snirf/pysnirf2.py +++ b/snirf/pysnirf2.py @@ -576,6 +576,9 @@ def _read_float_array(dataset: h5py.Dataset) -> np.ndarray: (27, 1, 'The optional indexed group has no elements'), # OK (Severity 0) 'OK': (28, 0, 'No issues detected'), + 'CONFLICTING_FIELDS_PRESENT': ( + 29, 3, 'Multiple conflicting fields are present in the same file' + ) } @@ -6762,21 +6765,25 @@ def measurementLists_to_measurementList(self): def _validate(self, result: ValidationResult): # Override measurementList/measurementLists validation, only one is required - ml = self.measurementList is not None - mls = self.measurementLists is not None + if self.measurementList: + ml = True + else: + ml = False + + mls = self.measurementLists.sourceIndex is not None if (ml and mls): - result._add(self.location + '/measurementList', 'OK') - result._add(self.location + '/measurementLists', 'OK') - elif (ml or mls): result._add(self.location + '/measurementList', - ['OPTIONAL_DATASET_MISSING', 'OK'][int(ml)]) + 'CONFLICTING_FIELDS_PRESENT') result._add(self.location + '/measurementLists', - ['OPTIONAL_DATASET_MISSING', 'OK'][int(mls)]) + 'CONFLICTING_FIELDS_PRESENT') + elif (ml or mls): + result._add(self.location + '/measurementList', 'OK') + result._add(self.location + '/measurementLists', 'OK') else: result._add(self.location + '/measurementList', - ['REQUIRED_DATASET_MISSING', 'OK'][int(ml)]) + 'REQUIRED_DATASET_MISSING') result._add(self.location + '/measurementLists', - ['REQUIRED_DATASET_MISSING', 'OK'][int(mls)]) + 'REQUIRED_DATASET_MISSING') # Check time/dataTimeSeries length agreement if all(attr is not None for attr in [self.time, self.dataTimeSeries]): diff --git a/tests/test.py b/tests/test.py index 7f3c0e8..b509270 100644 --- a/tests/test.py +++ b/tests/test.py @@ -817,6 +817,9 @@ def test_dynamic(self): assert sizes[1] < sizes[0], 'Dynamically-loaded files not smaller in memory' + def test_conflicting_fields(self): + # TODO + pass def setUp(self): if VERBOSE: