Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap class as PyTree for Tracer #137

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions autoarray/operators/over_sampling/uniform.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
from autoarray import exc
from autoarray.operators.over_sampling import over_sample_util

from autofit.jax_wrapper import register_pytree_node_class


@register_pytree_node_class
class OverSamplingUniform(AbstractOverSampling):
def __init__(self, sub_size: Union[int, Array2D]):
"""
Expand Down Expand Up @@ -319,6 +322,15 @@ def over_sampler_from(self, mask: Mask2D) -> "OverSamplerUniform":
mask=mask,
sub_size=self.sub_size,
)

def tree_flatten(self):
children = (self.sub_size,)
aux_data = None
return (children, aux_data)

@classmethod
def tree_unflatten(cls, aux_data, children):
return cls(*children)


class OverSamplerUniform(AbstractOverSampler):
Expand Down
Loading