Skip to content

Commit

Permalink
bugfix and update for DG 0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Feb 10, 2021
1 parent 2132dd6 commit 57b54d1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/electron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ DG.delay(o::ElectronOutput, x) = DG.delay(interface(o), x)

DG.minval(o::ElectronOutput) = DG.minval(interface(o))
DG.maxval(o::ElectronOutput) = DG.maxval(interface(o))
DG.processor(o::ElectronOutput) = DG.processor(interface(o))
DG.imagegen(o::ElectronOutput) = DG.imagegen(interface(o))

DG.storeframe!(o::ElectronOutput, data::DG.AbstractSimData) =
DG.storeframe!(interface(o), data)
Expand Down
26 changes: 14 additions & 12 deletions src/interact.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@ abstract type AbstractInteractOutput{T,F} <: ImageOutput{T,F} end


"""
InteractOutput(init; ruleset, fps=25.0, store=false,
processor=ColorProcessor(), minval=nothing, maxval=nothing,
extrainit=Dict())
InteractOutput <: DynamicGrids.ImageOutput
InteractOutput(init; ruleset, kw...)
An `Output` for Atom/Juno and Jupyter notebooks,
and the back-end for [`ElectronOutput`](@ref) and [`ServerOutput`](@ref).
### Arguments:
- `init`: initialisation Array or NamedTuple of arrays.
### Keyword Arguments:
- `ruleset`: the ruleset to run in the interface simulations.
- `tspan`: `AbstractRange` timespan for the simulation
- `init`: initialisation `Array` or `NamedTuple` of arrays.
### Keywords
- `ruleset::Ruleset`: the ruleset to run in the interface simulations.
- `tspan::AbstractRange`: timespan for the simulation
- `fps::Real`: frames per second to display the simulation
- `store::Bool`: whether ot store the simulation frames for later use
- `processor::GridProcessor
- `minval::Number`: minimum value to display in the simulation
- `maxval::Number`: maximum value to display in the simulation
- `store::Bool`: whether ot store the simulation frames for later use.
- `imagegen::ImageGenerator`: Converts the grid to an image, auto-detected by default.
- `minval::Number`: minimum value to display from a grid, `0` by default.
- `maxval::Number`: maximum value to display from a grid, `1` by default.
"""
mutable struct InteractOutput{T,F<:AbstractVector{T},E,GC,IC,RS<:Ruleset,Pa,IM,TI} <: AbstractInteractOutput{T,F}
frames::F
Expand Down
18 changes: 12 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ test5 = [0 0 0 0 0 0
0 0 0 0 0 1
0 0 0 0 0 0]

processor = ColorProcessor(
scheme=ColorSchemes.leonardo, zerocolor=nothing, maskcolor=nothing, textconfig=nothing,
imagegen = Image(
scheme=ColorSchemes.leonardo, zerocolor=nothing, maskcolor=nothing,
)

@testset "InteractOutput" begin
Expand All @@ -39,7 +39,9 @@ processor = ColorProcessor(
l0 l0 l0 l0 l0 l0]

ruleset = Ruleset(Life(); boundary=Wrap())
output = InteractOutput(init; tspan=1:2, ruleset=ruleset, store=true, processor=processor);
output = InteractOutput(init;
tspan=1:2, ruleset=ruleset, store=true, text=nothing, imagegen=imagegen
)
sim!(output, ruleset)
sleep(10)
resume!(output, ruleset; tstop=5)
Expand All @@ -54,7 +56,9 @@ processor = ColorProcessor(
end

@testset "output works with store=false" begin
output = InteractOutput(init; ruleset=ruleset, tspan=1:3, store=false, processor=processor);
output = InteractOutput(init;
ruleset=ruleset, tspan=1:3, store=false, text=nothing, imagegen=imagegen
)
sim!(output, ruleset)
output.graphicconfig.stoppedframe
DynamicGrids.stoppedframe(output)
Expand All @@ -69,7 +73,9 @@ end
if !Sys.islinux() # No graphic head loaded in CI: TODO add this
@testset "ElectronOutput" begin
ruleset = Ruleset(Life(); boundary=Wrap())
output = ElectronOutput(init; ruleset=ruleset, tspan=1:3, store=true, processor=processor)
output = ElectronOutput(init;
ruleset=ruleset, tspan=1:300, store=true, text=nothing, imagegen=imagegen
)
DynamicGrids.setrunning!(output, false)
sim!(output.interface, ruleset)
sleep(10)
Expand All @@ -84,6 +90,6 @@ end

@testset "ServerOutput" begin
ruleset = Ruleset(Life(); boundary=Wrap())
ServerOutput(init; ruleset=ruleset, port=8080, processor=processor)
ServerOutput(init; ruleset=ruleset, port=8080, imagegen=imagegen)
# TODO: test the server somehow
end

2 comments on commit 57b54d1

@rafaqz
Copy link
Member Author

@rafaqz rafaqz commented on 57b54d1 Feb 10, 2021

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 updated: JuliaRegistries/General/29773

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.5.2 -m "<description of version>" 57b54d1ce8421427c95172d5e53f6d41a6e43361
git push origin v0.5.2

Please sign in to comment.