Skip to content

Commit

Permalink
use Indexable across all active functions (#97)
Browse files Browse the repository at this point in the history
* use Indexable across all active functions

* patch bump
  • Loading branch information
palday committed May 29, 2024
1 parent e724c7f commit 775a1c2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MixedModelsMakie"
uuid = "b12ae82c-6730-437f-aff9-d2c38332a376"
authors = ["Phillip Alday <me@phillipalday.com>", "Douglas Bates <dmbates@gmail.com>", "contributors"]
version = "0.4.2"
version = "0.4.3"

[deps]
BSplineKit = "093aae92-e908-43d7-9660-e50ee39d5a0a"
Expand Down
16 changes: 8 additions & 8 deletions src/caterpillar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ function ranefinfotable(ri::RanefInfo)
end

"""
caterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, r::RanefInfo;
caterpillar!(f::Indexable, r::RanefInfo;
orderby=1, cols::Union{Nothing,AbstractVector}=nothing,
dotcolor=(:red, 0.2), barcolor=:black,
vline_at_zero::Bool=false)
caterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, m::MixedModel,
caterpillar!(f::Indexable, m::MixedModel,
gf::Symbol=first(fnames(m)); orderby=1,
cols::Union{Nothing,AbstractVector}=nothing,
dotcolor=(:red, 0.2), barcolor=:black,
Expand Down Expand Up @@ -110,7 +110,7 @@ specifying `cols`, either by indices or term names.
!!! note
`orderby` is the ``n``th column of the columns specified by `cols`.
"""
function caterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, r::RanefInfo;
function caterpillar!(f::Indexable, r::RanefInfo;
orderby=1, cols::Union{Nothing,AbstractVector}=nothing,
dotcolor=(:red, 0.2), barcolor=:black,
vline_at_zero::Bool=false)
Expand All @@ -136,7 +136,7 @@ function caterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, r::RanefInfo;
return f
end

function caterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, m::MixedModel,
function caterpillar!(f::Indexable, m::MixedModel,
gf::Symbol=first(fnames(m)); kwargs...)
return caterpillar!(f, ranefinfo(m, gf); kwargs...)
end
Expand All @@ -158,10 +158,10 @@ function caterpillar(m::MixedModel, gf::Symbol=first(fnames(m)); kwargs...)
end

"""
qqcaterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, r::RanefInfo;
qqcaterpillar!(f::Indexable, r::RanefInfo;
cols::Union{Nothing,AbstractVector}=nothing,
dotcolor=(:red, 0.2), barcolor=:black)
qqcaterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, m::MixedModel,
qqcaterpillar!(f::Indexable, m::MixedModel,
gf::Symbol=first(fnames(m));
cols::Union{Nothing,AbstractVector}=nothing,
dotcolor=(:red, 0.2), barcolor=:black,
Expand All @@ -181,7 +181,7 @@ of `r.ranef`, usually the `(Intercept)` random effects.
Setting `orderby=nothing` will disable sorting, i.e. return the levels in the
order they are stored in.
"""
function qqcaterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, r::RanefInfo;
function qqcaterpillar!(f::Indexable, r::RanefInfo;
cols::Union{Nothing,AbstractVector}=nothing,
dotcolor=(:red, 0.2), barcolor=:black,
vline_at_zero::Bool=false)
Expand All @@ -206,7 +206,7 @@ function qqcaterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, r::RanefInf
return f
end

function qqcaterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, m::MixedModel,
function qqcaterpillar!(f::Indexable, m::MixedModel,
gf::Symbol=first(fnames(m)); kwargs...)
return qqcaterpillar!(f, ranefinfo(m, gf); kwargs...)
end
Expand Down
8 changes: 4 additions & 4 deletions src/profile.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
zetaplot!(f::Union{Makie.FigureLike,Makie.GridLayout}, pr::MixedModelProfile;
zetaplot!(f::Indexable, pr::MixedModelProfile;
absv=false,
ptyp='β',
coverage=[.5,.8,.9,.95,.99],
Expand All @@ -13,7 +13,7 @@ Valid `ptyp` values are 'β', 'σ', and 'θ'.
If `absv` is `true` then intervals corresponding to coverage levels in
`coverage` are added to each panel.
"""
function zetaplot!(f::Union{Makie.FigureLike,Makie.GridLayout},
function zetaplot!(f::Indexable,
pr::MixedModelProfile;
absv::Bool=false, # plot abs(zeta) vs parameter value and add intervals
ptyp::Char='β',
Expand Down Expand Up @@ -61,7 +61,7 @@ See [`zetaplot!`](@ref).
zetaplot(args...; kwargs...) = zetaplot!(Figure(), args...; kwargs...)

"""
profiledensity!(f::Union{Makie.FigureLike,Makie.GridLayout}, pr::MixedModelProfile;
profiledensity!(f::Indexable, pr::MixedModelProfile;
ptyp::Char='σ',
zbd=3,
share_y_scale=true).
Expand All @@ -73,7 +73,7 @@ Valid `ptyp` values are 'β', 'σ', and 'θ'.
If `share_y_scale`, the each facet shares a common y-scale.
"""
function profiledensity!(f::Union{Makie.FigureLike,Makie.GridLayout},
function profiledensity!(f::Indexable,
pr::MixedModelProfile;
zbd=3,
ptyp::Char='σ',
Expand Down
4 changes: 2 additions & 2 deletions src/shrinkage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function _shrinkage_panel!(ax::Axis, i::Int, j::Int, reref, reest, λ;
end

"""
shrinkageplot!(f::Union{Makie.FigureLike,Makie.GridLayout}, m::MixedModel,
shrinkageplot!(f::Indexable, m::MixedModel,
gf::Symbol=first(fnames(m)), θref;
ellipse=false, ellipse_scale=1, n_ellipse=5,
cols::Union{Nothing,AbstractVector}=nothing,
Expand All @@ -62,7 +62,7 @@ unable to see the ellipses, try increasing `ellipse_scale`.
For degenerate (singular) models, the correlation ellipse will also be degenerate, i.e.,
collapse to a point or line.
"""
function shrinkageplot!(f::Union{Makie.FigureLike,Makie.GridLayout},
function shrinkageplot!(f::Indexable,
m::MixedModel{T},
gf::Symbol=first(fnames(m)),
θref::AbstractVector{T}=(isa(m, LinearMixedModel) ? 1e4 : 1) .*
Expand Down
12 changes: 6 additions & 6 deletions src/xyplot.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
clevelandaxes!(f::Union{Makie.FigureLike,Makie.GridLayout}, labs, layout)
clevelandaxes!(f::Indexable, labs, layout)
Create a set of axes within `f` with rows, columns determined by `layout` sufficient to hold `labs`
"""
function clevelandaxes!(f::Union{Makie.FigureLike,Makie.GridLayout}, labs, layout)
function clevelandaxes!(f::Indexable, labs, layout)
nrow, ncol = layout
npanel = length(labs)
axs = sizehint!(Axis[], npanel)
Expand Down Expand Up @@ -48,13 +48,13 @@ function simplelinreg(x, y)
end

"""
splom!(f::Union{Makie.FigureLike,Makie.GridLayout}, df::DataFrame)
splom!(f::Indexable, df::DataFrame)
Create a scatter-plot matrix in `f` from the columns of `df`.
Non-numeric columns are ignored.
"""
function splom!(f::Union{Makie.FigureLike,Makie.GridLayout}, df::DataFrame;
function splom!(f::Indexable, df::DataFrame;
addcontours::Bool=false)
n_cols = ncol(df)
df = select(df, findall(col -> eltype(col) <: Number, eachcol(df));
Expand All @@ -72,7 +72,7 @@ function splom!(f::Union{Makie.FigureLike,Makie.GridLayout}, df::DataFrame;
end

"""
splomaxes!(f::Union{Makie.FigureLike,Makie.GridLayout}, labels::AbstractVector{<:AbstractString},
splomaxes!(f::Indexable, labels::AbstractVector{<:AbstractString},
panel!::Function, args...;
extraticks::Bool=false, kwargs...)
Expand All @@ -81,7 +81,7 @@ where `k` is the length of `labels`. The `panel!` function should have the sign
`panel!(ax::Axis, i::Integer, j::Integer, args...; kwargs...)` and should draw the
[i,j] panel in `ax`.
"""
function splomaxes!(f::Union{Makie.FigureLike,Makie.GridLayout},
function splomaxes!(f::Indexable,
labels::AbstractVector{<:AbstractString},
panel!::Function, args...; extraticks::Bool=false, kwargs...)
k = length(labels)
Expand Down

2 comments on commit 775a1c2

@palday
Copy link
Owner Author

@palday palday commented on 775a1c2 May 29, 2024

Choose a reason for hiding this comment

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

@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/107849

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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.4.3 -m "<description of version>" 775a1c2edf5fdcff1fabe914770b0d81e467b47a
git push origin v0.4.3

Please sign in to comment.