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

Commit

Permalink
fix: Allow to open measurement files that do not contain the features…
Browse files Browse the repository at this point in the history
… 'area_um' or 'deform' (close #245)
  • Loading branch information
paulmueller committed Jul 12, 2019
1 parent 433ce8f commit d7abe01
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.9.5
- fix: Allow to open measurement files that do not contain the features
"area_um" or "deform" (#245)
0.9.4
- fix: Wrong image/trace data shown for a selected event in the scatter
plot when working on a log-scale (#244)
Expand Down
32 changes: 20 additions & 12 deletions shapeout/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _complete_config(self, measurements=None):
accr = float("{:.1e}".format(acc))
pltng[var] = accr
# Check for missing min/max values and set them to zero
for item in dfn.scalar_feature_names:
for item in self.get_usable_features():
appends = [" min", " max"]
for a in appends:
if item + a not in mm.config["plotting"]:
Expand Down Expand Up @@ -405,7 +405,16 @@ def GetNames(self):

def GetPlotAxes(self, mid=0):
p = self.GetParameters("plotting", mid)
return [p["axis x"].lower(), p["axis y"].lower()]
allowed = self.get_usable_features()
if len(allowed) < 2:
raise ValueError("Analysis has less than two common features: "
"{}".format(allowed))
xax = p["axis x"].lower()
yax = p["axis y"].lower()
if xax not in allowed or yax not in allowed:
xax = allowed[0]
yax = allowed[-1]
return [xax, yax]

def GetPlotGeometry(self, mid=0):
p = self.GetParameters("Plotting", mid)
Expand Down Expand Up @@ -641,16 +650,15 @@ def SetParameters(self, newcfg):
warnings.warn(msg)
pl[fmin], pl[fmax] = pl[fmax], pl[fmin]
# make sure that x- and y-axes are present in all measurements
if "axis x" in pl:
for mm in self.measurements:
if pl["axis x"] not in mm:
pl["axis x"] = "area_um"
break
if "axis y" in pl:
for mm in self.measurements:
if pl["axis y"] not in mm:
pl["axis y"] = "deform"
break
allowed = self.get_usable_features()
if len(allowed) < 2:
raise ValueError("Analysis has less than two common features: "
"{}".format(allowed))
if "axis x" in pl or "axis y" in pl:
if pl["axis x"] not in allowed or pl["axis y"] not in allowed:
pl["axis x"] = allowed[0]
pl["axis y"] = allowed[-1]

if "analysis" in newcfg:
upcfg["analysis"] = newcfg["analysis"].copy()
ignorelist = ["regression treatment", "regression repetition"]
Expand Down
2 changes: 1 addition & 1 deletion shapeout/gui/plot_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def OnPlotRangeChanged(self, obj, name, new):
ctrls = self.frame.PanelTop.page_plot.GetChildren()
newfilt = {}
xax, yax = self.analysis.GetPlotAxes()

# identify controls via their name correspondence in the cfg
for c in ctrls:
name = c.GetName()
Expand Down

0 comments on commit d7abe01

Please sign in to comment.