Skip to content

Save ShapedAsNT with JLD2 #62

Description

@Cornelius-G

Currently, it's not possible to save ShapedAsNT objects with JLD2.
Minimal example:

using ValueShapes
using JLD2

x = (a=1, b=2,)
vs = valshape(x)

x_shpd = ShapedAsNT(collect(x),vs)
jldsave("test.jld2", x = x_shpd)

This gives the following stacktrace.txt

@waldie11 and I tried solving that by implementing JLD2.writeas and Base.convert but didn't succeed.

We think the problem is somehow related to NamedTupleShape being deconstructed into its components in "JLD2/src/data/writing_datatypes.jl" finally resulting in the error in the function h5convert. This only happens if NamedTupleShape is ShapedAsNT.
Even though we tried for quite some time, we couldn't find a fix.

We noticed that the problem is the same when trying to store a type with unknown size like this:

T = NTuple{N, Int} where N
jldsave("test.jld2", a = T)

(for which we are not sure if something like that should even be possible)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions