matnwb icon indicating copy to clipboard operation
matnwb copied to clipboard

[Bug]: Scalar/singleton dataset not exported as such for inherited datasets

Open ehennestad opened this issue 1 month ago • 0 comments

Branch

764-inherited-scalar-shape-export

What happened?

Given the following type definitions:

groups:
- neurodata_type_def: NonScalarData
  neurodata_type_inc: NWBContainer
  datasets:
  - name: data
    dtype: float64
    shape:
    - null

- neurodata_type_def: ScalarDataInherited
  neurodata_type_inc: NonScalarData
  datasets:
  - name: data
    shape: 
    - 1

- neurodata_type_def: ScalarData
  neurodata_type_inc: NWBContainer
  datasets:
  - name: data
    dtype: float64
    shape:
    - 1

ScalarDataInherited and ScalarData are functionally identical, but when exported from MatNWB, ScalarDataInherited is exported as a simple (H5S_SIMPLE) dataset, and ScalarData is exported as a scalar dataset (H5S_SCALAR).

This is because a subclass export method will delegate export of all datasets defined in superclasses to the superclass export method, and the export method implementation in turn will decide whether a dataset should be exported with scalar or simple dataspace type.

Steps to Reproduce

N/A

Error Message

N/A

Operating System

macOS

Matlab Version

R2023b

Code of Conduct

ehennestad avatar Oct 25 '25 13:10 ehennestad