Skip to content

fix: VectorYX2DIrregular from_dict round-trip (missing values property) - #342

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/weak-dataset-from-json
May 28, 2026
Merged

fix: VectorYX2DIrregular from_dict round-trip (missing values property)#342
Jammy2211 merged 1 commit into
mainfrom
feature/weak-dataset-from-json

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

al.from_json failed to load a serialised WeakDataset / ShearYX2DIrregular because VectorYX2DIrregular did not expose its values constructor argument as an attribute. autoconf.dictable.instance_as_dict consequently emitted a serialized dict containing only grid, and from_dict then raised TypeError: VectorYX2DIrregular.__init__() missing 1 required positional argument: 'values'.

This PR adds a one-line values property mirroring the pattern already used by Grid2DIrregular.values and ArrayIrregular.values. Both VectorYX2DIrregular and its ShearYX2DIrregular subclass (in PyAutoGalaxy) now round-trip through output_to_json / from_json.

Refs PyAutoLens issue #554.

API Changes

Added a new public read-only values property on VectorYX2DIrregular returning the underlying (N, 2) ndarray. Purely additive — no existing call sites read vec.values. See full details below.

Test Plan

  • New unit test test__json_round_trip covers output_to_jsonfrom_json for VectorYX2DIrregular
  • Full test_autoarray/structures/vectors/ and test_autoarray/structures/grids/ suites pass locally (88 tests)
Full API Changes (for automation & release notes)

Added

  • autoarray.structures.vectors.irregular.VectorYX2DIrregular.values — property returning the raw (total_vectors, 2) ndarray of [y, x] components.

Migration

None — additive only. Existing code that constructed VectorYX2DIrregular(values=…, grid=…) is unchanged; the new property simply exposes the stored array under the same values name used at construction time.

🤖 Generated with Claude Code

The dictable serialization in autoconf inspects the constructor signature and
emits getattr(obj, arg) for each arg that satisfies hasattr(obj, arg).
VectorYX2DIrregular.__init__ takes (values, grid), but the class lacked a
`values` property, so only `grid` was serialized and from_dict raised:

    TypeError: VectorYX2DIrregular.__init__() missing 1 required
    positional argument: 'values'

This blocked al.from_json for any WeakDataset / ShearYX2DIrregular. Mirror
the pattern already used by Grid2DIrregular.values and ArrayIrregular.values
so all consumers of to_dict / from_dict work without further changes.

Refs PyAutoLens issue #554.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Workspace PR: PyAutoLabs/autolens_workspace#212

@Jammy2211
Jammy2211 merged commit 71b34f1 into main May 28, 2026
6 checks passed
@Jammy2211
Jammy2211 deleted the feature/weak-dataset-from-json branch May 28, 2026 11:01
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant