diff --git a/src/ReinforcementLearningCore/NEWS.md b/src/ReinforcementLearningCore/NEWS.md index a44325896..9265d749c 100644 --- a/src/ReinforcementLearningCore/NEWS.md +++ b/src/ReinforcementLearningCore/NEWS.md @@ -1,5 +1,9 @@ # ReinforcementLearningCore.jl Release Notes +#### v0.15.5 + +- Move `UnicodePlots` to package extension + #### v0.15.4 - Update `Flux.jl` to `v0.16` and fix deprecation warnings and method errors diff --git a/src/ReinforcementLearningCore/Project.toml b/src/ReinforcementLearningCore/Project.toml index 70fc380da..e68d17158 100644 --- a/src/ReinforcementLearningCore/Project.toml +++ b/src/ReinforcementLearningCore/Project.toml @@ -4,7 +4,6 @@ version = "0.15.4" [deps] AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" -Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" CircularArrayBuffers = "9de3a189-e0c0-4e15-ba3b-b14b9fb0aec1" Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f" @@ -21,11 +20,15 @@ ReinforcementLearningTrajectories = "6486599b-a3cd-4e92-a99a-2cea90cc8c3c" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f" + +[weakdeps] UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" +[extensions] +UnicodePlotsExt = "UnicodePlots" + [compat] AbstractTrees = "0.3, 0.4" -Adapt = "3, 4" ChainRulesCore = "1" CircularArrayBuffers = "0.1.12" Crayons = "4" @@ -57,4 +60,4 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" [targets] -test = ["CommonRLInterface", "CUDA", "cuDNN", "DomainSets", "Metal", "Preferences", "ReinforcementLearningEnvironments", "Test", "UUIDs"] +test = ["CommonRLInterface", "CUDA", "cuDNN", "DomainSets", "Metal", "Preferences", "ReinforcementLearningEnvironments", "Test", "UnicodePlots", "UUIDs"] diff --git a/src/ReinforcementLearningCore/ext/UnicodePlotsExt.jl b/src/ReinforcementLearningCore/ext/UnicodePlotsExt.jl new file mode 100644 index 000000000..a2511e2df --- /dev/null +++ b/src/ReinforcementLearningCore/ext/UnicodePlotsExt.jl @@ -0,0 +1,18 @@ +module UnicodePlotsExt + using ReinforcementLearningCore + using UnicodePlots: lineplot, lineplot! + + function Base.show(io::IO, hook::TotalRewardPerEpisode{true, F}) where {F<:Number} + if length(hook.rewards) > 0 + println(io, lineplot( + hook.rewards, + title="Total reward per episode", + xlabel="Episode", + ylabel="Score", + )) + else + println(io, typeof(hook)) + end + return + end +end diff --git a/src/ReinforcementLearningCore/src/core/hooks.jl b/src/ReinforcementLearningCore/src/core/hooks.jl index 91500b7b9..a8ecae986 100644 --- a/src/ReinforcementLearningCore/src/core/hooks.jl +++ b/src/ReinforcementLearningCore/src/core/hooks.jl @@ -10,7 +10,6 @@ export AbstractHook, DoEveryNSteps, DoOnExit -using UnicodePlots: lineplot, lineplot! using Statistics: mean, std using CircularArrayBuffers: CircularVectorBuffer import ReinforcementLearningBase: RLBase @@ -172,20 +171,6 @@ function Base.push!(hook::TotalRewardPerEpisode, return end -function Base.show(io::IO, hook::TotalRewardPerEpisode{true, F}) where {F<:Number} - if length(hook.rewards) > 0 - println(io, lineplot( - hook.rewards, - title="Total reward per episode", - xlabel="Episode", - ylabel="Score", - )) - else - println(io, typeof(hook)) - end - return -end - function Base.push!(hook::TotalRewardPerEpisode{true, F}, ::PostExperimentStage, agent::AbstractPolicy, diff --git a/src/ReinforcementLearningCore/test/runtests.jl b/src/ReinforcementLearningCore/test/runtests.jl index f3420f230..ca71c8686 100644 --- a/src/ReinforcementLearningCore/test/runtests.jl +++ b/src/ReinforcementLearningCore/test/runtests.jl @@ -1,4 +1,5 @@ using Test +using UnicodePlots using UUIDs using Preferences