Skip to content

Commit

Permalink
Support running all examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
oubiwann committed Jul 11, 2023
1 parent ab6536b commit 5d6f17d
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,7 @@ jobs:
run: rebar3 compile && rebar3 as examples compile
- name: List Examples
run: rebar3 as examples list
- name: Run One
run: rebar3 as examples lfe run -- 3d-heatmap true
- name: Run All
run: rebar3 as examples lfe run -- all true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ rebar.lock
# misc
/priv/images/drafts/*
/doc/*
/priv/output/*
2 changes: 1 addition & 1 deletion examples/3d-heatmap.lfe
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#(#(z label) "z")
#(#(zlabel offset) "character 2, 0, 0 font '' textcolor lt -1 norotate")))

(defun vars ()
(defun funcs ()
'(#("sinc(x,y)" "sin(sqrt((x-20.)**2+(y-20.)**2))/sqrt((x-20.)**2+(y-20.)**2)")
#("Z(x,y)" "100. * (sinc(x,y) + 1.5)")
#("color(x,y)" "10. * (1.1 + sin((x-20.)/5.)*cos((y-20.)/10.))")))
Expand Down
67 changes: 54 additions & 13 deletions scripts/examples.lfe
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,73 @@ infescript
room-modes))

(defun run-example
((#"3d-heatmap")
(plottah:splot (3d-heatmap:splot-args)
((name '())
(run-example name #"false"))
((#"all" `(,to-file? . ,_))
(lists:map
(lambda (name)
(run-example (list_to_binary (atom_to_list name)) (list to-file?)))
(list-examples)))
(((= #"3d-heatmap" name) `(,to-file? . ,_))
(splot-example name
to-file?
(3d-heatmap:splot-args)
(3d-heatmap:opts)
(3d-heatmap:funcs)))
((#"3d-hidden")
(plottah:splot (3d-hidden:eqn)
(((= #"3d-hidden" name) `(,to-file? . ,_))
(splot-example name
to-file?
(3d-hidden:eqn)
(3d-hidden:opts)))
((#"fourier-approx")
(plottah:plot (fourier-approx:plot-args)
(((= #"fourier-approx" name) `(,to-file? . ,_))
(plot-example name
to-file?
(fourier-approx:plot-args)
(fourier-approx:opts)
(fourier-approx:funcs-and-vars))
;; This one's complex, so it need a bit more time to render
;; This one's complex, so it needs a bit more time to render
(timer:sleep 1000))
((#"histogram")
(plottah:plot (histogram:plot)
(((= #"histogram" name) `(,to-file? . ,_))
(plot-example name
to-file?
(histogram:plot)
(histogram:opts)))
((#"room-modes")
(plottah:plot (room-modes:plot)
(((= #"room-modes" name) `(,to-file? . ,_))
(plot-example name
to-file?
(room-modes:plot)
(room-modes:opts))))

(defun to-file-opts (opts name)
(lists:append opts
`(#(terminal "jpeg enhanced size 800,600")
#(output ,(++ "'priv/output/" (binary_to_list name) ".jpg'")))))

(defun update-opts (opts name to-file?)
(if (list_to_atom (binary_to_list to-file?))
(to-file-opts opts name)
opts))

(defun plot-example (name to-file? args opts)
(plot-example name to-file? args opts '()))

(defun plot-example (name to-file? args opts vars)
(let ((opts (update-opts opts name to-file?)))
(plottah:plot args opts vars)))

(defun splot-example (name to-file? args opts)
(splot-example name to-file? args opts '()))

(defun splot-example (name to-file? args opts vars)
(let ((opts (update-opts opts name to-file?)))
(plottah:splot args opts vars)))

(defun main
(('())
(lfe_io:format "~p~n" (list (list-examples))))
((`(,name . ,_))
((`(,name . ,args))
(plottah:start)
(timer:sleep 500)
(run-example name)
(run-example name args)
(timer:sleep 1000)
(plottah:stop)))

0 comments on commit 5d6f17d

Please sign in to comment.