Skip to content
This repository has been archived by the owner on Nov 5, 2020. It is now read-only.

Commit

Permalink
fix: MemoryError when plotting log-log data (#264) + some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Jan 28, 2020
1 parent 30c7f92 commit 674a74d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
1.0.1
- fix: MemoryError when plotting log-log data (#264)
1.0.0
- fix: change the way measurements are recognized (.rtdc files were
falsely grouped together when located in the same directory) (#262)
Expand Down
12 changes: 7 additions & 5 deletions shapeout/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ def _complete_config(self, measurements=None):
if var not in pltng:
data = mm[kk]
if sc == "log":
data = np.log(data)
# this does not seem to be necessary (issue #264)
#data = np.log(data)
pass
acc = l(data) * mult
# round to make it look pretty in the GUI
accr = float("{:.1e}".format(acc))
Expand All @@ -161,10 +163,10 @@ def _doanes_formula_acc(a):
bad = np.isnan(a) | np.isinf(a)
data = a[~bad]
n = data.size
g1 = scipy.stats.skew(data)
sigma_g1 = np.sqrt(6 * (n - 2) / ((n + 1) * (n + 3)))
k = 1 + np.log2(n) + np.log2(1 + np.abs(g1) / sigma_g1)
if len(data):
if n:
g1 = scipy.stats.skew(data)
sigma_g1 = np.sqrt(6 * (n - 2) / ((n + 1) * (n + 3)))
k = 1 + np.log2(n) + np.log2(1 + np.abs(g1) / sigma_g1)
acc = (data.max() - data.min()) / k
else:
acc = 1
Expand Down
6 changes: 3 additions & 3 deletions shapeout/gui/plot_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def get_kde_kwargs(x, y, kde_type, xacc, yacc):
biny = naninfminmaxdiff(y)/(1.8*yacc)
except:
biny = 5
binx = int(max(5, binx))
biny = int(max(5, biny))
binx = int(max(5, binx)) #if binx < x.size else 20
biny = int(max(5, biny)) #if biny < y.size else 20
kde_kwargs["bins"] = [binx, biny]
return kde_kwargs

Expand Down Expand Up @@ -113,7 +113,7 @@ def my_log_auto_ticks(data_low, data_high,


def naninfminmaxdiff(x):
bad = np.isnan(x)+np.isinf(x)
bad = np.isnan(x) | np.isinf(x)
x = x[~bad]
diff = (x.max()-x.min())
return diff
Expand Down
7 changes: 4 additions & 3 deletions shapeout/gui/plot_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,14 @@ def set_scatter_data(plot, mm):
downsample=downsample,
xscale=scalex,
yscale=scaley,
remove_invalid=True,
ret_mask=True,
)
if lx == x.shape:
positions = None
else:
print("...Downsampled from {} to {} in {:.2f}s".format(lx, x.shape[0], time.time()-a))
positions = np.vstack([x.ravel(), y.ravel()])
positions = (x, y)


kde_type = mm.config["plotting"]["kde"].lower()
Expand All @@ -236,10 +237,10 @@ def set_scatter_data(plot, mm):
density = mm.get_kde_scatter(xax=xax,
yax=yax,
positions=positions,
xscale=scalex,
yscale=scaley,
kde_type=kde_type,
kde_kwargs=kde_kwargs,
xscale=scalex,
yscale=scaley,
)
print("...KDE scatter time {}: {:.2f}s".format(kde_type, time.time()-a))

Expand Down

0 comments on commit 674a74d

Please sign in to comment.