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

Relax period and phase_shift type restrictions #32

Merged
merged 2 commits into from
Feb 24, 2021
Merged

Conversation

bencottier
Copy link
Contributor

Closes #29

A couple of tweaks along the way:

  • Change ArgumentError to DomainError for non-positive period, and test this for TimeType as well as Real
  • Refactor other methods so they don't confuse the parametric type variable P

Must have the same supertype, but not necessarily the same concrete type
@codecov
Copy link

codecov bot commented Feb 24, 2021

Codecov Report

Merging #32 (84ed523) into main (5bbb41b) will decrease coverage by 4.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #32      +/-   ##
==========================================
- Coverage   99.11%   95.09%   -4.02%     
==========================================
  Files           9        9              
  Lines         113      102      -11     
==========================================
- Hits          112       97      -15     
- Misses          1        5       +4     
Impacted Files Coverage Δ
src/power.jl 100.00% <ø> (ø)
src/temporal.jl 100.00% <ø> (ø)
src/utils.jl 0.00% <ø> (-87.50%) ⬇️
src/one_hot_encoding.jl 100.00% <100.00%> (ø)
src/periodic.jl 100.00% <100.00%> (ø)
src/scaling.jl 96.15% <100.00%> (-3.85%) ⬇️
src/transformers.jl 100.00% <100.00%> (ø)

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 9249440...68a7bb7. Read the comment docs.

src/periodic.jl Outdated Show resolved Hide resolved
src/periodic.jl Outdated Show resolved Hide resolved
return new{T}(f, period, phase_shift)
function Periodic(f, period::P, phase_shift::S) where {P, S}
if !((P <: Real && S <: Real) || (P <: Period && S <: Period))
throw(ArgumentError("period and phase_shift must have the same supertype"))
Copy link
Member

Choose a reason for hiding this comment

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

I guess this gives a more informative error message compared to my suggestion which would have just been a MethodError.

Co-authored-by: Glenn Moynihan <[email protected]>
@bencottier bencottier merged commit 6c43de4 into main Feb 24, 2021
@nicoleepp nicoleepp deleted the bc/period-subtypes branch February 24, 2021 19:59
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.

Do not restrict period and phase_shift to the same concrete type
2 participants