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

feat: replaced mathematical kwargs in scheduler constructors #60

Merged
merged 1 commit into from
Mar 2, 2024
Merged

feat: replaced mathematical kwargs in scheduler constructors #60

merged 1 commit into from
Mar 2, 2024

Conversation

lfenzo
Copy link
Contributor

@lfenzo lfenzo commented Feb 13, 2024

Closes #41.

For cyclic schedulers, I've replaced λ* with l*, but I'm open to suggestions. At this moment I preferred replacing only the symbols instead of making more drastic changes to the API. Tests and docs were also adapted!

cc.: @darsnack

@lfenzo lfenzo marked this pull request as ready for review February 16, 2024 12:11
@lfenzo
Copy link
Contributor Author

lfenzo commented Feb 28, 2024

Good to go?

Copy link
Member

@darsnack darsnack left a comment

Choose a reason for hiding this comment

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

I'm happy with your chosen naming scheme, and most of the changes here are broadly good to go.

I would prefer to release a patch with deprecations first. Can we do something like this:

function depkwargs(fn::Symbol, kwargs, remaps::Pair...)
    remaps = Dict(remaps...)
    kwargs = map(keys(kwargs)) do kw
        if haskey(remaps, kw)
            Base.depwarn("Keyword $kw is deprecated. Replacing with $(remaps[kw]) instead.", fn)
            return remaps[kw] => kwargs[kw]
        else
            return kw => kwargs[kw]
        end
    end

    return (; kwargs...)
end

function Triangle(; kwargs...)
     kwargs = depkwargs(:Triangle, kwargs, :λ0 => :l0, :λ1 => :l1)
     return Triangle(kwargs.l0, kwargs.l1, kwargs.period)
end

docs/make.jl Outdated Show resolved Hide resolved
@lfenzo
Copy link
Contributor Author

lfenzo commented Mar 2, 2024

function depkwargs(fn::Symbol, kwargs, remaps::Pair...) (..) end

Very clever! Added to all constructors modified in this PR. Thanks for the snippet!

Copy link
Member

@darsnack darsnack left a comment

Choose a reason for hiding this comment

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

One more small change and then we are good to go. Can you also bump the patch version?

src/cyclic.jl Outdated Show resolved Hide resolved
@lfenzo lfenzo closed this Mar 2, 2024
@lfenzo lfenzo reopened this Mar 2, 2024
Copy link
Member

@darsnack darsnack left a comment

Choose a reason for hiding this comment

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

Looks good, thank you! The nightly failure is unrelated to the PR.

@lfenzo
Copy link
Contributor Author

lfenzo commented Mar 2, 2024

I'm still trying to figure out what happened here, as it turns out, my force push after a git reset to revert the formatting in docs/make.jl somehow caused this PR to be closed.

The body of _tridecay2 and its variants were transferred to the respective positional constructors; patch number was updated and CI errors with Julia nightly seem unrelated.

@darsnack darsnack merged commit 65b64b1 into FluxML:main Mar 2, 2024
11 of 16 checks passed
@lfenzo lfenzo deleted the feat/schedulers-kwargs branch March 2, 2024 22:15
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.

Add start/decay as Kwargs in Schedulers (apart from the UTF-8 ones)
2 participants