Skip to content

Commit

Permalink
minor analysis rework (#110)
Browse files Browse the repository at this point in the history
* add extra entry point in analysis

* remove unnecessary mapping

* switch order

* fix docs

* bump CairoMakie for docs

* bump patch number
  • Loading branch information
Pietro Vertechi authored Nov 8, 2020
1 parent bcb0035 commit 31941d9
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AlgebraOfGraphics"
uuid = "cbdf2221-f076-402e-a563-3d30da359d67"
authors = ["Pietro Vertechi <[email protected]>"]
version = "0.2.0"
version = "0.2.1"

[deps]
AbstractPlotting = "537997a7-5e4e-5d89-9595-2241ea00577e"
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[deps]
AbstractPlotting = "537997a7-5e4e-5d89-9595-2241ea00577e"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Expand All @@ -8,6 +7,7 @@ Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b"

[compat]
CairoMakie = "0.3.6"
Documenter = "0.25"
Glob = "1"
Literate = "2"
Expand Down
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Documenter, AlgebraOfGraphics, Literate, Glob
# avoid font caching warning in docs
using AbstractPlotting, CairoMakie
using CairoMakie
CairoMakie.activate!()
scatter(rand(10), rand(10))

Expand Down
2 changes: 1 addition & 1 deletion docs/src/generated/internals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pairs(d)
# All outputs of `mapping`, `data`, and `dims` inherit can be combined using `+`
# (adding a new layer), or `*` (merge information in existing layer).

using AbstractPlotting, CairoMakie
using CairoMakie
mpg1 = copy(mpg)
mpg1.Displ = mpg.Displ .* 0.1
ts = data(mpg) * visual(markersize = 5) + data(mpg1) * visual(markersize=10)
Expand Down
4 changes: 2 additions & 2 deletions docs/src/generated/statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# ## Examples

#src using RDatasets: dataset
#src using AlgebraOfGraphics, AbstractPlotting, CairoMakie
#src using AlgebraOfGraphics, CairoMakie
#src mpg = dataset("ggplot2", "mpg");
#src data(mpg) * mapping(:Displ, :Hwy, layout_x = ) * visual(QQPlot) |> draw
#src AbstractPlotting.save("qqplot.svg", AbstractPlotting.current_scene()); nothing #hide
Expand All @@ -17,7 +17,7 @@
#src Needs https://github.com/JuliaStats/Distributions.jl/issues/1196 to work.

using RDatasets: dataset
using AlgebraOfGraphics, AbstractPlotting, CairoMakie
using AlgebraOfGraphics, CairoMakie
mpg = dataset("ggplot2", "mpg");
mpg.IsAudi = mpg.Manufacturer .== "audi"
geom = visual(BoxPlot, layout_x = 1) + visual(Violin, layout_x = 2)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/generated/tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# ## Working with tables

using RDatasets: dataset
using AlgebraOfGraphics, AbstractPlotting, CairoMakie
using AlgebraOfGraphics, CairoMakie
mpg = dataset("ggplot2", "mpg");
cols = mapping(:Displ, :Hwy);
grp = mapping(color = :Cyl => categorical);
Expand Down
12 changes: 8 additions & 4 deletions src/specs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,19 @@ end

global_options(f, d::AlgebraicList) = NamedTuple()

function compute(f, layer, precomputed_attributes)
args, kwargs = split(layer.mapping.value)
return f(args...; precomputed_attributes..., kwargs...)
end

# default fallback to apply a callable to a vector of key => value pairs
# if customized, it must return a vector of key => value pairs
function apply(f, d::AlgebraicList)
global_kwargs = global_options(f, d)
precomputed_attributes = global_options(f, d)
v = map(parent(d)) do layer
analyses, pkeys, mapping, options = layer.analyses, layer.pkeys, layer.mapping, layer.options
analyses, pkeys, options = layer.analyses, layer.pkeys, layer.options
T = plottype(layer)
args, kwargs = split(mapping.value)
res = f(args...; global_kwargs..., kwargs...) * Spec{T}(analyses=analyses, options=options, pkeys=pkeys)
res = compute(f, layer, precomputed_attributes) * Spec{T}(analyses=analyses, options=options, pkeys=pkeys)
return parent(layers(res))
end
return AlgebraicList(reduce(vcat, v))
Expand Down

2 comments on commit 31941d9

@piever
Copy link
Collaborator

@piever piever commented on 31941d9 Nov 9, 2020

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/24356

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.2.1 -m "<description of version>" 31941d95cb1df8ebbed6234be40fdcbe79c14462
git push origin v0.2.1

Please sign in to comment.