Skip to content

Commit 73bcd8e

Browse files
authored
Merge pull request #360 from PyAutoLabs/feature/linear-light-profile-intensity-dict-pytree
feat: stable pytree_token on LightProfileLinear for jax.jit round-trip
2 parents 4ced7b5 + 29b16b4 commit 73bcd8e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

autogalaxy/profiles/light/linear/abstract.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
intensities to be penalized by a smoothness prior.
1414
"""
1515
import inspect
16+
import itertools
1617
import numpy as np
1718
from typing import Dict, List, Optional
1819

@@ -45,6 +46,22 @@ class LightProfileLinear(LightProfile):
4546
profiles when performing a fit to data.
4647
"""
4748

49+
_pytree_token_counter = itertools.count()
50+
__exclude_identifier_fields__ = ("pytree_token",)
51+
52+
def __init__(self, *args, **kwargs):
53+
super().__init__(*args, **kwargs)
54+
self.pytree_token = next(LightProfileLinear._pytree_token_counter)
55+
56+
def __hash__(self):
57+
return self.pytree_token
58+
59+
def __eq__(self, other):
60+
return (
61+
isinstance(other, LightProfileLinear)
62+
and self.pytree_token == other.pytree_token
63+
)
64+
4865
@property
4966
def regularization(self):
5067
return None

0 commit comments

Comments
 (0)