Skip to content
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

fix breaking zscore changes (backport to 0.32 branch) #565

Merged
merged 4 commits into from
Mar 4, 2020

Conversation

kleinschmidt
Copy link
Member

fixes #556

#490 introduced breaking changes to the constructor of the ZScoreTransform type, adding a fourth mandatory argument. It also introduced an error in cases where the previous default (without dims=) was used for fit and everything the calls it. This PR fixes those by adding an inner constructor with a depwarn for ZScoreTransform, and re-setting the default dims inside the call to fit when dims=nothing.

@kleinschmidt kleinschmidt requested a review from nalimilan March 1, 2020 21:51
@codecov
Copy link

codecov bot commented Mar 1, 2020

Codecov Report

Merging #565 into v0.32-backport will decrease coverage by 0.12%.
The diff coverage is 20%.

Impacted file tree graph

@@                Coverage Diff                 @@
##           v0.32-backport     #565      +/-   ##
==================================================
- Coverage           90.59%   90.47%   -0.13%     
==================================================
  Files                  21       21              
  Lines                2244     2246       +2     
==================================================
- Hits                 2033     2032       -1     
- Misses                211      214       +3
Impacted Files Coverage Δ
src/transformations.jl 88.73% <20%> (-1.99%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d5e6fbc...5a9c060. Read the comment docs.

src/transformations.jl Outdated Show resolved Hide resolved
Co-Authored-By: Milan Bouchet-Valat <[email protected]>
@@ -131,6 +137,7 @@ function fit(::Type{ZScoreTransform}, X::AbstractVector{<:Real};
dims::Union{Integer,Nothing}=nothing, center::Bool=true, scale::Bool=true)
if dims == nothing
Base.depwarn("fit(t, x) is deprecated: use fit(t, x, dims=2) instead", :fit)
dims = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops, shouldn't it be:

Suggested change
dims = 1
dims = 2

@kleinschmidt
Copy link
Member Author

kleinschmidt commented Mar 2, 2020 via email

@nalimilan
Copy link
Member

If there's a relatively simple way of making the old code work, then better implement it I guess.

@nalimilan
Copy link
Member

Sorry I think I misunderstood your point. Were you replying to my last suggestion? Anyway, AFAICT before #490 we didn't support standardizing vectors, so that probably doesn't matter.

@kleinschmidt
Copy link
Member Author

kleinschmidt commented Mar 3, 2020 via email

@nalimilan
Copy link
Member

Ah, yeah, the situation was weird at the time. Well, any deprecation is better than the current state, so choose the one you think is best.

@kleinschmidt
Copy link
Member Author

yeah now that I'm looking back at the state of things in v0.32 was pretty strange...I think providing a no-dims method that does something reasonable and provides a deprecation warning is a reasonable compromise between being a stickler about not changing the API at all (e.g., used to error on vector, still errors on a vector) and making the merged stuff useful.

@kleinschmidt
Copy link
Member Author

Actually, I changed my mind. Previously (v0.32) fit(ZScoreTransform, rand(100)) was a method error. Currently (v0.32.1) it's a different method error because dims=nothing is just passed onto the constructor. With the current PR, it's a depwarn. Removing the check for dims==nothing and just throwing a domain error saying "use dims=1" seems like a better choice overall, since it's more consistent with teh current behavior, the historical behavior, and still informative about how to fix the problem.

@kleinschmidt kleinschmidt merged commit a7a36b8 into v0.32-backport Mar 4, 2020
@nalimilan nalimilan deleted the dfk/zscore-patch branch March 4, 2020 08:55
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