File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change
1
+ # A note on precompilation and __init__.
2
+ #
3
+ # If Sciplotlib is used in another module, then that module must be marked as
4
+ # `__precompile__(false)`. If not, during precompilation of that top-level module,
5
+ # Sciplotlib's `__init__` will be called [*], which is a function that cannot be called
6
+ # during a precompilation phase; it errors then.
7
+ #
8
+ # [*] Strange but true. Strange cause `__init__` is explicitly made to not be called during
9
+ # precompilation. It indeed is not called when precompiling Sciplotlib itself. But it
10
+ # _does_ get called when precompiling a downstream package.
11
+
1
12
module Sciplotlib
2
13
3
14
using Reexport
Original file line number Diff line number Diff line change 1
- # On `PyNULL()` and `copy!`:
2
- # https://github.com/JuliaPy/PyCall.jl/issues/699#issuecomment-504616552
3
-
4
1
"""
5
2
Matplotlib's style settings [1]. Note that directly editing `mpl.rcParams` has no effect
6
3
[2]. Editing this object however does work.
7
4
8
5
- [1] https://matplotlib.org/stable/tutorials/introductory/customizing.html#the-default-matplotlibrc-file
9
6
- [2] https://github.com/JuliaPy/PyPlot.jl#modifying-matplotlibrcparams
10
7
"""
11
- const rcParams = PyNULL ()
8
+ rcParams = nothing
12
9
13
10
"""
14
11
A copy of the initial `mpl.rcParams`. Note that we do not use `mpl.rcParamsDefault` or
15
12
`mpl.rcParamsOrig`, as these are different to what's actually used by default (e.g. in a
16
13
Jupyter notebook).
17
14
"""
18
- const rcParams_original = PyNULL ()
15
+ rcParams_original = nothing
19
16
20
17
function __init__ ()
21
- copy! (rcParams_original, mpl. rcParams)
22
- copy! (rcParams, PyPlot . PyDict (mpl. " rcParams " )) # String quotes prevent conversion from
23
- # # Python to Julia dict.
18
+ global rcParams = PyPlot . PyDict ( mpl." rcParams" ) # String quotes prevent conversion from
19
+ # # Python to Julia dict.
20
+ global rcParams_original = copy (mpl . rcParams)
24
21
set_mpl_style! (sciplotlib_style)
25
22
end
You can’t perform that action at this time.
0 commit comments