From 71883a86e3a783fcb9cd2dec287f5bf34f052ebd Mon Sep 17 00:00:00 2001 From: Morgan Williams Date: Thu, 4 Jul 2024 16:20:04 +1000 Subject: [PATCH] Minor fixes/format changes comp.aggregate - use explicit assertion error Minor change in plot.density.grid --- pyrolite/comp/aggregate.py | 2 +- pyrolite/plot/density/grid.py | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pyrolite/comp/aggregate.py b/pyrolite/comp/aggregate.py index 54f90b1b..8abb7285 100644 --- a/pyrolite/comp/aggregate.py +++ b/pyrolite/comp/aggregate.py @@ -233,7 +233,7 @@ def np_cross_ratios(X: np.ndarray, debug=False): diags = ratios[:, np.arange(dims), np.arange(dims)] # check all diags are 1. assert np.allclose(diags, 1.0) - except: + except AssertionError: # check all diags are 1. or nan assert np.allclose(diags[~np.isnan(diags)], 1.0) diff --git a/pyrolite/plot/density/grid.py b/pyrolite/plot/density/grid.py index 7edcfaa2..38279ed7 100644 --- a/pyrolite/plot/density/grid.py +++ b/pyrolite/plot/density/grid.py @@ -47,11 +47,13 @@ def __init__( else: self.xmin, self.xmax, self.ymin, self.ymax = extent # validation - self.xmin, self.xmax = min([self.xmin, self.xmax]), max( - [self.xmin, self.xmax] + self.xmin, self.xmax = ( + min([self.xmin, self.xmax]), + max([self.xmin, self.xmax]), ) - self.ymin, self.ymax = min([self.ymin, self.ymax]), max( - [self.ymin, self.ymax] + self.ymin, self.ymax = ( + min([self.ymin, self.ymax]), + max([self.ymin, self.ymax]), ) self.xstep = self.get_xstep() @@ -72,15 +74,17 @@ def calculate_grid(self): def get_ystep(self): if self.logy: - return (self.ymax / self.ymin) / self.ybins + step = (self.ymax / self.ymin) / self.ybins else: - return (self.ymax - self.ymin) / self.ybins + step = (self.ymax - self.ymin) / self.ybins + return step def get_xstep(self): if self.logx: - return (self.xmax / self.xmin) / self.xbins + step = (self.xmax / self.xmin) / self.xbins else: - return (self.xmax - self.xmin) / self.xbins + step = (self.xmax - self.xmin) / self.xbins + return step def extent_from_xy(self, x, y, coverage_scale=None): cov = coverage_scale or self.coverage_scale