Skip to content

Commit

Permalink
add missing methods for termvars (#18)
Browse files Browse the repository at this point in the history
* add missing methods for termvars

needed for `missing_omit` and hence `predict`

* JuliaFormatter gets rid of trailing whitespace

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Co-authored-by: Phillip Alday <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 6, 2021
1 parent 66121f0 commit de5ef95
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "StandardizedPredictors"
uuid = "5064a6a7-f8c2-40e2-8bdc-797ec6f1ae18"
authors = "Beacon Biosignals, inc."
version = "0.1.2"
version = "0.1.3"

[deps]
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Expand Down
1 change: 1 addition & 0 deletions src/centering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,4 @@ StatsModels.width(t::CenteredTerm) = StatsModels.width(t.term)
# don't generate schema entries for terms which are already centered
StatsModels.needs_schema(::CenteredTerm) = false
StatsModels.termsyms(t::CenteredTerm) = StatsModels.termsyms(t.term)
StatsModels.termvars(t::CenteredTerm) = StatsModels.termvars(t.term)
1 change: 1 addition & 0 deletions src/scaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,4 @@ StatsModels.width(t::ScaledTerm) = StatsModels.width(t.term)
# don't generate schema entries for terms which are already scaled
StatsModels.needs_schema(::ScaledTerm) = false
StatsModels.termsyms(t::ScaledTerm) = StatsModels.termsyms(t.term)
StatsModels.termvars(t::ScaledTerm) = StatsModels.termvars(t.term)
1 change: 1 addition & 0 deletions src/zscoring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,4 @@ StatsModels.width(t::ZScoredTerm) = StatsModels.width(t.term)
# don't generate schema entries for terms which are already scaled
StatsModels.needs_schema(::ZScoredTerm) = false
StatsModels.termsyms(t::ZScoredTerm) = StatsModels.termsyms(t.term)
StatsModels.termvars(t::ZScoredTerm) = StatsModels.termvars(t.term)
8 changes: 8 additions & 0 deletions test/centering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@
# round-trip schema is empty since needs_schema is false
sch_2 = schema(ff_c, data)
@test isempty(sch_2.schema)

@testset "missing omit" begin
d = (x=[1, 2, missing, 3], y=[1, missing, 2, 3], z=[missing, 1, 2, 3])
dd, nonmissing = StatsModels.missing_omit(d, ff_c)
@test findall(nonmissing) == [1, 4]
@test dd.x == d.x[nonmissing]
@test dd.y == d.y[nonmissing]
end
end

@testset "printing" begin
Expand Down
10 changes: 10 additions & 0 deletions test/scaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@
# round-trip schema is empty since needs_schema is false
sch_2 = schema(ff_c, data)
@test isempty(sch_2.schema)

@testset "missing omit" begin
d = (x=[1, 2, missing, 3], y=[1, missing, 2, 3], z=[missing, 1, 2, 3])
dd, nonmissing = StatsModels.missing_omit(d, ff_c)
# z is ignored:
@test findall(nonmissing) == [1, 4]
# x and y are handled correclty
@test dd.x == d.x[nonmissing]
@test dd.y == d.y[nonmissing]
end
end

@testset "printing" begin
Expand Down
10 changes: 10 additions & 0 deletions test/zscoring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@
# round-trip schema is empty since needs_schema is false
sch_2 = schema(ff_c, data)
@test isempty(sch_2.schema)

@testset "missing omit" begin
d = (x=[1, 2, missing, 3], y=[1, missing, 2, 3], z=[missing, 1, 2, 3])
dd, nonmissing = StatsModels.missing_omit(d, ff_c)
# z is ignored:
@test findall(nonmissing) == [1, 4]
# x and y are handled correclty
@test dd.x == d.x[nonmissing]
@test dd.y == d.y[nonmissing]
end
end

@testset "printing" begin
Expand Down

4 comments on commit de5ef95

@kleinschmidt
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator release()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Error while trying to register: Action not recognized: release

@kleinschmidt
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/46227

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.3 -m "<description of version>" de5ef95eb5ea1784699a9dd4e551526a329bf1c1
git push origin v0.1.3

Please sign in to comment.