Skip to content

validate_arrays=False (the default) prevents some useful schema patterns #691

@braingram

Description

@braingram

#683 is currently removing the ndim validation for RampModel.pixeldq to allow the model to sometimes have a 2D pixeldq and sometimes a 4D. It would be helpful here to use:

oneOf:
  - ndim: 2
  - ndim: 4

However this will fail on valid 2D and 4D pixeldq because by default validate_arrays=False:

validate_arrays=False,

When validate_arrays is False, the ndim validator is not included in the validation, is therefore unknown to the jsonschema validator, and both subschemas pass causing the oneOf to fail.

If we consider removing validate_arrays it may be helpful to also note that it appears inconsistent. On main the following:

import stdatamodels.jwst.datamodels as dm, numpy as np
m = dm.RampModel()
m.pixeldq = np.zeros((10, 10, 10, 10, 10), dtype='uint32')

produces:

ValueError: Array has wrong number of dimensions.  Expected 2, got 5

with or without validate_arrays enabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions