Skip to content

Commit b5563ec

Browse files
mtfishmanclaude
andcommitted
Narrow ITensors serialization public API to just the schema struct types
Drops `serialized_type`, `serialize_convert`, and `deserialize_convert` from the `public` declaration. These remain reachable from the JLD2 extension (and from `Base.convert` via the shims) but are no longer part of the package's stable public surface — no current external consumer calls them directly, so committing to them now is premature. The JLD2 file format docs page is updated to match: the prose describes the internal layering without rendering docstring blocks for the unexported helpers, so the `@docs` API list is limited to the schema struct types themselves. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent cff7ed5 commit b5563ec

2 files changed

Lines changed: 11 additions & 20 deletions

File tree

docs/src/JLD2FileFormat.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,16 @@ Keeping the structs and the conversion logic in the main packages means the type
4747
recorded inside the JLD2 file do not encode an extension module namespace, and other
4848
serialization backends can reuse the same machinery without depending on JLD2.
4949

50-
### Backend-agnostic layer
51-
52-
- [`ITensors.serialized_type`](@ref) and [`NDTensors.serialized_type`](@ref): type-level
53-
map from an in-memory type to its [`SerializedX`](@ref) schema struct.
54-
- `Base.convert` overloads (defined alongside `serialized_type`) do the value-level
55-
transform between the in-memory and `Serialized*` representations in both directions.
56-
57-
JLD2's default `wconvert` / `rconvert` already delegate to `Base.convert`, so the
58-
extension itself only needs to provide the `JLD2.writeas` declarations bridging the
59-
two namespaces:
60-
61-
```julia
62-
JLD2.writeas(::Type{T}) where {T <: NDTensors.TensorStorage} = NDTensors.serialized_type(T)
63-
JLD2.writeas(::Type{T}) where {T <: ITensors.Index} = ITensors.serialized_type(T)
64-
# ...
65-
```
50+
Internally the extension is structured around two unexported helper functions per
51+
package — a type-level `serialized_type` that maps an in-memory type to its
52+
schema struct, and a value-level pair `serialize_convert` / `deserialize_convert`
53+
that owns the field-by-field transform. `Base.convert` overloads delegate to
54+
these helpers so non-JLD2 callers can also reach the schema, and the JLD2
55+
extension itself only needs to register a few `JLD2.writeas` declarations
56+
plus permissive `JLD2.rconvert` overloads to bridge into JLD2's machinery.
57+
These helpers are public-but-internal: they may evolve and are not part of the
58+
stable public API surface — only the [`SerializedX`](@ref) schema structs
59+
themselves are.
6660

6761
### Core ITensors types
6862

src/ITensors.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,9 @@ include("set_operations.jl")
8989
include("indexset.jl")
9090
include("itensor.jl")
9191
include("serialization.jl")
92-
# Mark the on-disk schema types and the serialization conversion entry points as
93-
# public API (per Julia docs recommendation for backwards-compatible `public`
94-
# declarations on pre-1.11 Julia).
9592
VERSION >= v"1.11.0-DEV.469" && eval(
9693
Meta.parse(
97-
"public serialized_type, serialize_convert, deserialize_convert, SerializedQNVal, SerializedQN, SerializedTagSet, SerializedQNSpace, SerializedIndex, SerializedITensor"
94+
"public SerializedQNVal, SerializedQN, SerializedTagSet, SerializedQNSpace, SerializedIndex, SerializedITensor"
9895
)
9996
)
10097
include("qn/flux.jl")

0 commit comments

Comments
 (0)