Skip to content

UnitsDataArray serialization does not account for custom dimensions with datetimes #556

Description

@scranford1

Description
UnitsDataArray _pp_serialize does not account for customs dimensions in bounds which may be datetimes.
Create an Array node with a custom dimension using datetimes. Attempt to evaluate the node and convert to an output format with to_format. The serialization will fail due to the datetimes in the bounds for the custom dimensions.

Steps to Reproduce
See additional notes below with a reproducible unit test.

Expected Behavior
Similar to time dimension, any custom dimensions using datetimes should be converted to strings before serialization.

Observed Behavior
An error is thrown, when the datetime is attempted to be serialized.

Additional Notes
NOTE: Nearest neighbor interpolation checks this, so any interpolated node will not fail.

def test_custom_dimension(self):
        from podpac.core.coordinates.utils import add_valid_dimension
        times = [np.datetime64("2026-06-26 14:27:00")]
        add_valid_dimension("CUSTOM")
        data = np.random.rand(11, 11, 1)
        coordinates = Coordinates(
            [clinspace(-25, 25, 11), clinspace(-25, 25, 11), times], dims=["lat", "lon", "CUSTOM"]
        )
        node = Array(source=data, coordinates=coordinates)
        output = node.eval(coordinates)
        output.to_format("png")

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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