From 194db18efa3210cdce5d34c365efbcf030ab9ca4 Mon Sep 17 00:00:00 2001 From: Spencer Lyon Date: Wed, 19 Sep 2018 10:11:45 -0400 Subject: [PATCH] CLN: clean up `@require` files to not call `using` on loaded req'd mod --- src/dataframes_api.jl | 35 +++++++++++++---------------------- src/distributions.jl | 8 +------- 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/src/dataframes_api.jl b/src/dataframes_api.jl index b6a8c05..56e4d1f 100644 --- a/src/dataframes_api.jl +++ b/src/dataframes_api.jl @@ -1,16 +1,13 @@ -import .DataFrames.AbstractDataFrame -using .DataFrames - # utilities -_has_group(df::AbstractDataFrame, group::Any) = false -_has_group(df::AbstractDataFrame, group::Symbol) = haskey(df, group) -function _has_group(df::AbstractDataFrame, group::Vector{Symbol}) +_has_group(df::DataFrames.AbstractDataFrame, group::Any) = false +_has_group(df::DataFrames.AbstractDataFrame, group::Symbol) = haskey(df, group) +function _has_group(df::DataFrames.AbstractDataFrame, group::Vector{Symbol}) all(x -> haskey(df, x), group) end -_group_name(df::AbstractDataFrame, group::Symbol) = df[1, group] -function _group_name(df::AbstractDataFrame, groups::Vector{Symbol}) +_group_name(df::DataFrames.AbstractDataFrame, group::Symbol) = df[1, group] +function _group_name(df::DataFrames.AbstractDataFrame, groups::Vector{Symbol}) string("(", join([df[1, g] for g in groups], ", "), ")") end @@ -38,10 +35,10 @@ useful when using the `group` keyword arugment, as the function will be applied to each SubDataFrame. In the example above, the name attribute would set a different mean for each group. """ -function GenericTrace(df::AbstractDataFrame; group=nothing, kind="scatter", kwargs...) +function GenericTrace(df::DataFrames.AbstractDataFrame; group=nothing, kind="scatter", kwargs...) d = Dict{Symbol,Any}(kwargs) if _has_group(df, group) - _traces = by(df, group) do dfg + _traces = DataFrames.by(df, group) do dfg GenericTrace(dfg; kind=kind, name=_group_name(dfg, group), kwargs...) end return GenericTrace[t for t in _traces[:x1]] @@ -65,7 +62,7 @@ $(SIGNATURES) Pass the provided values of `x` and `y` as keyword arguments for constructing the trace from `df`. See other method for more information """ -function GenericTrace(df::AbstractDataFrame, x::Symbol, y::Symbol; kwargs...) +function GenericTrace(df::DataFrames.AbstractDataFrame, x::Symbol, y::Symbol; kwargs...) GenericTrace(df; x=x, y=y, kwargs...) end @@ -74,7 +71,7 @@ $(SIGNATURES) Pass the provided value `y` as keyword argument for constructing the trace from `df`. See other method for more information """ -function GenericTrace(df::AbstractDataFrame, y::Symbol; kwargs...) +function GenericTrace(df::DataFrames.AbstractDataFrame, y::Symbol; kwargs...) GenericTrace(df; y=y, kwargs...) end @@ -89,7 +86,7 @@ then call `by(df, group)` and construct one trace per SubDataFrame, passing all other keyword arguments. This means all keyword arguments are passed applied to all traces """ -function Plot(df::AbstractDataFrame, l::Layout=Layout(); +function Plot(df::DataFrames.AbstractDataFrame, l::Layout=Layout(); style::Style=CURRENT_STYLE[], kwargs...) Plot(GenericTrace(df; kwargs...), l, style=style) end @@ -99,7 +96,7 @@ $(SIGNATURES) Construct a plot from `df`, passing the provided values of x and y as keyword arguments. See docstring for other method for more information. """ -function Plot(d::AbstractDataFrame, x::Symbol, y::Symbol, l::Layout=Layout(); +function Plot(d::DataFrames.AbstractDataFrame, x::Symbol, y::Symbol, l::Layout=Layout(); style::Style=CURRENT_STYLE[], kwargs...) Plot(d, l; x=x, y=y, style=style, kwargs...) end @@ -109,7 +106,7 @@ $(SIGNATURES) Construct a plot from `df`, passing the provided value y as a keyword argument. See docstring for other method for more information. """ -function Plot(d::AbstractDataFrame, y::Symbol, l::Layout=Layout(); +function Plot(d::DataFrames.AbstractDataFrame, y::Symbol, l::Layout=Layout(); style::Style=CURRENT_STYLE[], kwargs...) Plot(d, l; y=y, style=style, kwargs...) end @@ -117,11 +114,5 @@ end for t in _TRACE_TYPES str_t = string(t) - @eval $t(df::AbstractDataFrame; kwargs...) = GenericTrace(df; kind=$(str_t), kwargs...) -end - - -@require Revise="295af30f-e4ad-537b-8983-00126c2a3abe" begin - import .Revise: track - track(PlotlyBase, @__FILE__) + @eval $t(df::DataFrames.AbstractDataFrame; kwargs...) = GenericTrace(df; kind=$(str_t), kwargs...) end diff --git a/src/distributions.jl b/src/distributions.jl index 94bce04..330e25d 100644 --- a/src/distributions.jl +++ b/src/distributions.jl @@ -1,12 +1,6 @@ -using Distributions - -@require Revise="295af30f-e4ad-537b-8983-00126c2a3abe" begin - Revise.track(PlotlyBase, @__FILE__) -end - _strip_module(s) = split(s, '.', limit=2)[end] _strip_type_param(s) = replace(s, r"{.+?}" => "") -_clean_name(d::Distribution) = _strip_module(_strip_type_param(repr(d))) +_clean_name(d::Distributions.Distribution) = _strip_module(_strip_type_param(repr(d))) function scatter(d::Distributions.ContinuousUnivariateDistribution) ls(a, b, c) = range(a, stop=b, length=c)