Skip to content

Commit 19cecdd

Browse files
Add support for in-place map (#2248)
1 parent 7999a67 commit 19cecdd

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

NEWS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ ClimaCore.jl Release Notes
44
main
55
-------
66

7+
- Added support for `map!` PR
8+
[2248](https://github.com/CliMA/ClimaCore.jl/pull/2248).
9+
710
- The standard `*` symbol now denotes matrix multiplication, and the alias
8-
`const ⋅ = MultiplyColumnwiseBandMatrixField()` is removed PR [2232](https://github.com/CliMA/ClimaCore.jl/pull/2232)
11+
`const ⋅ = MultiplyColumnwiseBandMatrixField()` is being deprecated PR [2232](https://github.com/CliMA/ClimaCore.jl/pull/2232). Please replace use of `` with `*`.
912

1013
- `Fields.Field(Bool, ::AbstractSpace)` is now supported. PR [2239](https://github.com/CliMA/ClimaCore.jl/pull/2239).
1114

src/Fields/mapreduce.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
Base.map(fn, fields::Field...) = Base.broadcast(fn, fields...)
2+
Base.map!(fn, dest::Field, fields::Field...) =
3+
Base.broadcast!(fn, dest, fields...)
24

35
"""
46
Fields.local_sum(v::Field)

test/Fields/unit_field.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ end
8484

8585

8686
field_sin = map(x -> sin((x.x) / 2), Fields.coordinate_field(space))
87+
88+
# Exercise map!
89+
map!(field_sin, Fields.coordinate_field(space)) do x
90+
sin((x.x) / 2)
91+
end
92+
8793
M = Operators.matrix_interpolate(field_sin, 20)
8894
@test size(M) == (20, 20) # 20 x 20 for a 1 element field
8995

0 commit comments

Comments
 (0)