Skip to content

Commit 66694a6

Browse files
Format __init__ imports, avoid unnecessary spider log-y errors
1 parent c5f7611 commit 66694a6

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

pyrolite/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@
1212

1313
import matplotlib.style
1414

15-
from .util.log import Handle
16-
from .util.plot.style import _export_mplstyle # this import adds the style used below
17-
18-
logger = Handle(__name__)
19-
2015
# initialise pandas accessors
2116
from .comp import pyrocomp # noqa: E402
2217
from .geochem import pyrochem # noqa: E402
2318
from .plot import pyroplot # noqa: E402
19+
from .util.log import Handle
20+
from .util.plot.style import _export_mplstyle # this import adds the style used below
2421

22+
logger = Handle(__name__)
2523

2624
def load_extensions(base="pyrolite_", replace=["util"]):
2725
"""

pyrolite/plot/spider.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,18 +257,22 @@ def spider(
257257
# set the y range to lock to the outermost log-increments
258258
_ymin, _ymax = np.nanmin(arr), np.nanmax(arr)
259259

260-
if unity_line:
260+
if unity_line: # unity line is added at 1 - so may alter the total range
261261
_ymin, _ymax = min(_ymin, 1.0), max(_ymax, 1.0)
262262

263263
if logy:
264264
# at 5% range in log space, and clip to nearest 'minor' tick
265+
# except in the case where (logmin - 0.05 * logy_rng) <= 0
266+
# (to avoid errors on log-scaled plots)
265267
logmin, logmax = np.log10(_ymin), np.log10(_ymax)
266268
logy_rng = logmax - logmin
267269

268270
low, high = 10 ** np.floor(logmin), 10 ** np.floor(logmax)
269-
271+
270272
_ymin, _ymax = (
271-
np.floor(10 ** (logmin - 0.05 * logy_rng) / low) * low,
273+
np.floor(10 ** (logmin - 0.05 * logy_rng) / low) * low
274+
if (logmin - 0.05 * logy_rng) > 0
275+
else low,
272276
np.ceil(10 ** (logmax + 0.05 * logy_rng) / high) * high,
273277
)
274278
else:

0 commit comments

Comments
 (0)