Commit 70288f5
fix(light/linear): mark pytree_token as ephemeral via __getstate__/__setstate__
pytree_token is a process-local counter increment used as a stable
hash/eq identity for LightProfileLinear instances across jax.jit
flatten/unflatten. It is not meaningful state to persist — copying a
number from one process's counter into another's does not preserve
identity across processes.
PyAutoFit's database serializer routes every numeric attribute through
the Value SQL row (sa.Float column), so persisting pytree_token as an
int and reading it back yields a float. Python >=3.12 strictly requires
__hash__ to return int, so any dict keyed on a LightProfileLinear (e.g.
the linear_light_profile_intensity_dict in autogalaxy/abstract_fit.py)
raised TypeError on the visualization path after a fit was loaded via
FitImagingAgg.
Add __getstate__ that omits pytree_token and __setstate__ that assigns
a fresh value if missing. PyAutoFit's Instance._from_object and
Object.__call__ already check for these methods and honour them, so no
PyAutoFit changes are required. The JAX-jit path uses register_model's
attr_const which reads vars(self) directly and is unaffected.
Fixes the smoke-test failure on autolens_workspace_test/main:
scripts/database/scrape/general.py.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent f641d69 commit 70288f5
2 files changed
Lines changed: 66 additions & 0 deletions
File tree
- autogalaxy/profiles/light/linear
- test_autogalaxy/profiles/light/linear
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
65 | 78 | | |
66 | 79 | | |
67 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
0 commit comments