-
Notifications
You must be signed in to change notification settings - Fork 69
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
timearray: Revoke deprecation of ==
and redefine its meaning
#357
Conversation
```julia julia> cl == copy(cl) true ```
Codecov Report
@@ Coverage Diff @@
## master #357 +/- ##
==========================================
+ Coverage 85.98% 86.22% +0.23%
==========================================
Files 10 10
Lines 471 479 +8
==========================================
+ Hits 405 413 +8
Misses 66 66
Continue to review full report at Codecov.
|
It works fine for me! (I have never really played with generated functions, so don't count me in for the code review.) Maybe the docstring could me more informative for users? I am not sure beginners will know what fields a
|
ok, I updated it |
src/timearray.jl
Outdated
x.meta == y.meta | ||
``` | ||
""" | ||
@generated function ==(x::TimeArray{T,N}, y::TimeArray{S,M}) where {T,S,N,M} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't require a generated function.
Base.:(==)(x::TimeArray{T,N}, y::TimeArray{S,N}) where {T,S,N} =
all(f->getfield(x, f) == getfield(y, f), fieldnames(TimeArray))
Base.:(==)(x::TimeArray{T,N}, y::TimeArray{S,M}) where {T,S,N,M} = false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, it's elegant.
TIL, all
will do early stopping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and done in following commits
src/timearray.jl
Outdated
|
||
# support for Dict | ||
hash(x::TimeArray, h::UInt) = | ||
mapreduce(+, fieldnames(TimeArray)) do f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sum
is mapreduce(+, ...)
so this can be written
Base.hash(x::TimeArray, h::UInt) = sum(f->hash(getfield(x, f), h), fieldnames(TimeArray))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
NEWS.md
Outdated
### 0.12.0 | ||
|
||
* Revoking deprecation warning of `==` and redefining its meaning as | ||
'comparing all fields of two TimeArray'. (#356, #357) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also be good to note here that two TimeArray
s compare unequal if they have different dimensions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
good to go? |
@dourouc05 please review this