You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Might it be possible that this method be exposed as a first class method named apply_op (or more simply apply)? I'd be happy to make a PR including the above as a test if there is interest in making this design adjustment.
Here is an example implementation:
defapply(parent: ml_collections.FieldReference, fn, field_type=None):
child=parent._apply_op(fn) # pylint: disable = protected-accessiffield_typeisnotNone:
child._field_type=field_type# pylint: disable = protected-accessa_child_value=child.get()
ifnotisinstance(
a_child_value, child._field_type# pylint: disable = protected-access
):
raiseTypeError(
f"Expected operation result to be of type {field_type}. "f"Instead however it was {type(a_child_value)}. ""Adjust the `field_type` parameter accordingly."
)
returnchild
Hi,
I have found the private function
_apply_op
to be quite useful for custom lazy computation. For example:Might it be possible that this method be exposed as a first class method named
apply_op
(or more simplyapply
)? I'd be happy to make a PR including the above as a test if there is interest in making this design adjustment.Here is an example implementation:
and a corresponding test:
Cheers,
Simon
The text was updated successfully, but these errors were encountered: