From 110d90842e8d2cb9ae0ec8afa10e1a7cdfad06c2 Mon Sep 17 00:00:00 2001 From: smo Date: Thu, 30 Jan 2025 14:24:03 +0100 Subject: [PATCH 1/4] add error for df = nothing --- src/ParallelPlots.jl | 7 +++---- test/test_argument_errors.jl | 3 +++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ParallelPlots.jl b/src/ParallelPlots.jl index 454ecf6..e7468ca 100644 --- a/src/ParallelPlots.jl +++ b/src/ParallelPlots.jl @@ -18,9 +18,6 @@ checks the Input Data if the size is correct and no missing values are available Throws error on wrong DF """ function input_data_check(data::DataFrame) - if isnothing(data) - throw(ArgumentError("Data cannot be nothing")) - end if size(data, 2) < 2 # otherwise there will be a nullpointer exception later throw(ArgumentError("Data must have at least two columns, currently ("*string(size(data, 2))*")")) end @@ -119,7 +116,9 @@ function Makie.plot!(pp::ParallelPlot) # this helper function will update our observables # whenever df_observable change function update_plot(data) - + if isnothing(data) + throw(ArgumentError("Data cannot be nothing")) + end # check the given DataFrame input_data_check(data) diff --git a/test/test_argument_errors.jl b/test/test_argument_errors.jl index cd7151e..0cd27f8 100644 --- a/test/test_argument_errors.jl +++ b/test/test_argument_errors.jl @@ -25,4 +25,7 @@ using CairoMakie: save @test_throws ArgumentError begin parallelplot(df_one_line) end + @test_throws ArgumentError begin + parallelplot(nothing) + end end \ No newline at end of file From d7b14d568781ef4490721ed29674eefa33beba03 Mon Sep 17 00:00:00 2001 From: smo Date: Thu, 30 Jan 2025 16:11:26 +0100 Subject: [PATCH 2/4] add DrWatson to docs --- docs/Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Project.toml b/docs/Project.toml index fe9893a..f1240ab 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -2,3 +2,4 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" ParallelPlots = "79f8b2c9-78a2-4289-b087-49f7cf65a4c9" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" +DrWatson = "634d3b9d-ee7a-5ddf-bec9-22491ea816e1" From 66e970edf11ee924dc5c7e0d26cbd6bab33c797b Mon Sep 17 00:00:00 2001 From: smo Date: Thu, 30 Jan 2025 16:23:35 +0100 Subject: [PATCH 3/4] add dummy drwatson juliadoc test --- src/ParallelPlots.jl | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/ParallelPlots.jl b/src/ParallelPlots.jl index e7468ca..ada1152 100644 --- a/src/ParallelPlots.jl +++ b/src/ParallelPlots.jl @@ -59,13 +59,52 @@ FigureAxisPlot() julia> display(fig) CairoMakie.Screen{IMAGE} ``` +Using DrWatson with ParallelPlot +```jldoctest +julia> using DataFrames, DrWatson, ParallelPlots + +julia> function exec_simulation(d::Dict, results) + @unpack launch_angles, initial_velocities = d + max_height = initial_velocities * launch_angles + push!(results, [ + initial_velocities, + launch_angles, + max_height, + ]) + return results + end; + +julia> initial_velocities = [40.0, 50.0]; + +julia> launch_angles = [30.0, 60.0]; + +julia> allparams = Dict( + "initial_velocities" => initial_velocities, + "launch_angles" => launch_angles, + ); + +julia> dicts = dict_list(allparams); + +julia> results = DataFrame( + initial_velocity=Float64[], + launch_angle=Float64[], + max_height=Float64[], + ); + +julia> for d in dicts + results = exec_simulation(d, results) + end; + +julia> fig = parallelplot(results, curve=true, figure = (size = (1000, 600),)); + +julia> display(fig); ```@example # If you want to set the size of the plot julia> parallelplot( DataFrame(height=160:180,weight=60:80,age=20:40), figure = (resolution = (300, 300),) ) ``` ``` -# You can update as well the Graph with Observables +# You can update the Graph with Observables as well julia> df_observable = Observable(DataFrame(height=160:180,weight=60:80,age=20:40)) julia> fig, ax, sc = parallelplot(df_observable) ``` @@ -78,7 +117,7 @@ julia> parallelplot(DataFrame(height=160:180,weight=reverse(60:80),age=20:40),ti julia> parallelplot(DataFrame(height=160:180,weight=reverse(60:80),age=20:40), feature_labels=["Height","Weight","Age"]) ``` ``` -# Adjust Color and and feature +# Adjust Color and and Feature parallelplot(df, # You choose which axis/feature should be in charge for the coloring color_feature="weight", From 43344595da22b4a9d67682af9dc9704c552ee211 Mon Sep 17 00:00:00 2001 From: Leon Haufe Date: Thu, 30 Jan 2025 20:29:05 +0100 Subject: [PATCH 4/4] added missing ``` --- src/ParallelPlots.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ParallelPlots.jl b/src/ParallelPlots.jl index ada1152..42c26a8 100644 --- a/src/ParallelPlots.jl +++ b/src/ParallelPlots.jl @@ -98,7 +98,7 @@ julia> for d in dicts julia> fig = parallelplot(results, curve=true, figure = (size = (1000, 600),)); julia> display(fig); - +``` ```@example # If you want to set the size of the plot julia> parallelplot( DataFrame(height=160:180,weight=60:80,age=20:40), figure = (resolution = (300, 300),) )