@@ -5,71 +5,71 @@ using BackendSelection: @Backend_str, AbstractBackend, Backend
55export @visualize , visualize
66
77macro visualize (x, kwargs... )
8- all (kwarg -> Meta. isexpr (kwarg, :(= )), kwargs) ||
9- throw (ArgumentError (" All keyword arguments must be of the form `kw=value`." ))
10- kwargs′ = if all (kwarg -> kwarg. args[1 ] ≠ :name , kwargs)
11- (kwargs... , :(name= $ (string (x))))
12- else
13- kwargs
14- end
15- return :(visualize ($ (esc (x)); $ (esc .(kwargs′)... )); $ (esc (x)))
8+ all (kwarg -> Meta. isexpr (kwarg, :(= )), kwargs) ||
9+ throw (ArgumentError (" All keyword arguments must be of the form `kw=value`." ))
10+ kwargs′ = if all (kwarg -> kwarg. args[1 ] ≠ :name , kwargs)
11+ (kwargs... , :(name = $ (string (x))))
12+ else
13+ kwargs
14+ end
15+ return :(visualize ($ (esc (x)); $ (esc .(kwargs′)... )); $ (esc (x)))
1616end
1717
18- function visualize (io:: IO , x; backend= Backend " Default" , name= nothing , kwargs... )
19- return visualize (io, to_backend (backend; kwargs... ), x; name)
18+ function visualize (io:: IO , x; backend = Backend " Default" , name = nothing , kwargs... )
19+ return visualize (io, to_backend (backend; kwargs... ), x; name)
2020end
2121
22- function visualize (x; backend= Backend " Default" , name= nothing , io:: IO = stdout , kwargs... )
23- return visualize (io, to_backend (backend; kwargs... ), x; name)
22+ function visualize (x; backend = Backend " Default" , name = nothing , io:: IO = stdout , kwargs... )
23+ return visualize (io, to_backend (backend; kwargs... ), x; name)
2424end
2525
26- function visualize (io:: IO , backend:: AbstractBackend , x; name= nothing )
27- name = get (backend, :name , name)
28- if isnothing (name)
29- visualize_unnamed (io, backend, x)
26+ function visualize (io:: IO , backend:: AbstractBackend , x; name = nothing )
27+ name = get (backend, :name , name)
28+ if isnothing (name)
29+ visualize_unnamed (io, backend, x)
30+ return nothing
31+ end
32+ visualize_named (io, backend, name, x)
3033 return nothing
31- end
32- visualize_named (io, backend, name, x)
33- return nothing
3434end
3535
36- function visualize (backend:: Backend"Default" , x; name= nothing )
37- io = get (backend, :io , stdout )
38- visualize (io, backend, x; name)
39- return nothing
36+ function visualize (backend:: Backend"Default" , x; name = nothing )
37+ io = get (backend, :io , stdout )
38+ visualize (io, backend, x; name)
39+ return nothing
4040end
4141
4242function visualize_named (io:: IO , backend:: Backend"Default" , name, x)
43- mime = get (backend, :mime , MIME " text/plain" ())
44- println (io, name, " = " )
45- show_indented (io, mime, x)
46- println (io)
47- return nothing
43+ mime = get (backend, :mime , MIME " text/plain" ())
44+ println (io, name, " = " )
45+ show_indented (io, mime, x)
46+ println (io)
47+ return nothing
4848end
4949
5050function visualize_unnamed (io:: IO , :: Backend"Default" , x)
51- show (io, MIME " text/plain" (), x)
52- println (io)
53- return nothing
51+ show (io, MIME " text/plain" (), x)
52+ println (io)
53+ return nothing
5454end
5555
56- function show_indented (io:: IO , mime:: MIME , x; indent= " " )
57- str = sprint (show, mime, x)
58- str = join ((indent * s for s in split (str, ' \n ' )), ' \n ' )
59- print (io, str)
60- return nothing
56+ function show_indented (io:: IO , mime:: MIME , x; indent = " " )
57+ str = sprint (show, mime, x)
58+ str = join ((indent * s for s in split (str, ' \n ' )), ' \n ' )
59+ print (io, str)
60+ return nothing
6161end
6262
6363function to_backend (:: Type{B} ; kwargs... ) where {B}
64- return B (; kwargs... )
64+ return B (; kwargs... )
6565end
66- function to_backend (backend:: Union{Symbol,String} ; kwargs... )
67- return Backend (backend; kwargs... )
66+ function to_backend (backend:: Union{Symbol, String} ; kwargs... )
67+ return Backend (backend; kwargs... )
6868end
6969function to_backend (backend:: AbstractBackend ; kwargs... )
70- isempty (kwargs) ||
71- throw (ArgumentError (" Keyword arguments must be passed as part of the backend object." ))
72- return backend
70+ isempty (kwargs) ||
71+ throw (ArgumentError (" Keyword arguments must be passed as part of the backend object." ))
72+ return backend
7373end
7474
7575end
0 commit comments