Skip to content

Commit

Permalink
Minor fixes/format changes
Browse files Browse the repository at this point in the history
comp.aggregate - use explicit assertion error
Minor change in plot.density.grid
  • Loading branch information
morganjwilliams committed Jul 4, 2024
1 parent 3acbfd7 commit 71883a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pyrolite/comp/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
20 changes: 12 additions & 8 deletions pyrolite/plot/density/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 71883a8

Please sign in to comment.