Skip to content

Commit

Permalink
Fix equality for FieldVectors with different type
Browse files Browse the repository at this point in the history
Before this commit, == for FieldVectors with different types was falling
back to the AbstractArray ==, resulting in false positives. Now
FieldVectors with different types are always considered different.
  • Loading branch information
Sbozzolo committed Oct 2, 2024
1 parent e632054 commit ca6b3d3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ main
- Extended `create_dss_buffer` and `weighted_dss!` for `FieldVector`s, rather than
just `Field`s. PR [#2000](https://github.com/CliMA/ClimaCore.jl/pull/2000).

### ![][badge-🐛bugfix] Fix equality for `FieldVector`s with different type

Due to a bug, `==` was not recursively checking `FieldVector`s with different
types, which resulted in false positives. This is now fixed and `FieldVector`s
are always considered different.

PR [#2021](https://github.com/CliMA/ClimaCore.jl/pull/2021).

v0.14.16
-------

Expand Down
5 changes: 5 additions & 0 deletions src/Fields/fieldvector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -494,3 +494,8 @@ rcompare(x::T, y::T) where {T <: Union{FieldVector, NamedTuple}} =
# Define == to call rcompare for two fieldvectors of the same
# exact type.
Base.:(==)(x::T, y::T) where {T <: FieldVector} = rcompare(x, y)

# FieldVectors with different types are always different. We need this
# explicitly because FieldVectors are AbstractArrays, so we have to override
# the default method
Base.:(==)(x::T1, y::T2) where {T1 <: FieldVector, T2 <: FieldVector} = false

0 comments on commit ca6b3d3

Please sign in to comment.