Skip to content

Replace RecursiveApply functions with AutoBroadcaster wrappers#2417

Open
dennisYatunin wants to merge 1 commit intomainfrom
dy/math_wrapper
Open

Replace RecursiveApply functions with AutoBroadcaster wrappers#2417
dennisYatunin wants to merge 1 commit intomainfrom
dy/math_wrapper

Conversation

@dennisYatunin
Copy link
Member

@dennisYatunin dennisYatunin commented Jan 10, 2026

Replaces the RecursiveApply module with a new interface that follows the opposite design pattern: instead of defining functions for Tuples and NamedTuples that need to be called in Fields, Operators, MatrixFields, and sometimes even in ClimaAtmos, we can now use a wrapper for Tuples and NamedTuples that behaves the same way when passed to any standard math function. This should make it easy to decouple iteration over field variables from most of ClimaCore's internals.

The new interface can be extended to any iterator type T by defining the method is_auto_broadcastable(::T) = true, as long as T is compatible with UnrolledUtilities.jl. The @auto_broadcaster_args annotation provides a convenient shorthand for extending the new interface to arbitrary functions of Numbers or AbstractArrays, automatically broadcasting those functions over Tuples, NamedTuples, and AutoBroadcasterss. This annotation can also be used to add methods for any other type T, with the resulting behavior depending on whether is_auto_broadcastable is true for that type.

  • Code follows the style guidelines OR N/A.
  • Unit tests are included OR N/A.
  • Code is exercised in an integration test OR N/A.
  • Documentation has been added/updated OR N/A.

@dennisYatunin dennisYatunin force-pushed the dy/math_wrapper branch 9 times, most recently from cc7a736 to 0b0cbe1 Compare January 16, 2026 03:34
@dennisYatunin dennisYatunin force-pushed the dy/math_wrapper branch 2 times, most recently from e603f47 to 5430722 Compare January 21, 2026 17:33
@dennisYatunin dennisYatunin changed the title Replace RecursiveApply interface with MathWrapper Replace RecursiveApply interface with MathMapper Jan 21, 2026
@dennisYatunin dennisYatunin force-pushed the dy/math_wrapper branch 14 times, most recently from 30377bd to 92cf627 Compare January 24, 2026 02:30
@dennisYatunin dennisYatunin marked this pull request as ready for review February 6, 2026 05:47
@dennisYatunin dennisYatunin force-pushed the dy/math_wrapper branch 15 times, most recently from 800de37 to 630972d Compare February 13, 2026 06:43
@dennisYatunin dennisYatunin force-pushed the dy/math_wrapper branch 11 times, most recently from 5a61dc6 to 4486fee Compare February 13, 2026 15:34
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.

2 participants