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

Commit

Permalink
Merge pull request #101 from ZELLMECHANIK-DRESDEN/develop
Browse files Browse the repository at this point in the history
Version 0.6.5
  • Loading branch information
paulmueller authored Nov 16, 2016
2 parents f371dae + 9987592 commit 3c20850
Show file tree
Hide file tree
Showing 12 changed files with 320 additions and 140 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
0.6.5
- Sessions are now autosaved every 60s (#97)
- Bugfixes:
- Loading of sessions with hierarchy children failed (#99)
- Reduced a memory leak for new analyses that resulted in frequent
memory errors (should be less frequent now)
0.6.4
- Bugfixes:
- Batch analysis: Individual measurement parameters not preserved (#96)
- Legend plot: >9 measurements cannot be displayed in legend at
the same time. Introduced new config key "Legend Autoscaled" (#91)
- New filter hierarchy allows to investigate subpopulations (#87, #63)
- dclab
- Add InertiaRatio and InertiaRatioRaw to tdms files (typo)
0.6.3
- Bugfixes:
- Regression: Excluded events plotted on top of filtered events (#86)
Expand Down
4 changes: 3 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

# Do not use shallow_clone, because coveralls needs a git repository
#shallow_clone: true
clone_depth: 10
# Use large clone depth so that a tag is included for versioning
clone_depth: 256


# Only build master branch
Expand Down Expand Up @@ -86,6 +87,7 @@ install:
# https://ci.appveyor.com/project/paulmueller/shapeout/build/1.0.152#L504
- "pip freeze"
# PIP installs
- "pip install appdirs"
- "pip install nptdms"
# install pyper (R)
- "pip install pyper"
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
appdirs
chaco>=4.1.0
cffi>=0.8.2
dclab>=0.1.0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'GUI': ["wxPython", "chaco", "opencv"],
# kiwisolver?
},
install_requires=["dclab", "NumPy>=1.7.0", "SciPy>=0.10.0",
install_requires=["appdirs", "dclab", "NumPy>=1.7.0", "SciPy>=0.10.0",
"pyper"],
setup_requires=['pytest-runner'],
tests_require=["pytest", "urllib3"],
Expand Down
1 change: 1 addition & 0 deletions shapeout/ShapeOut.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def main():
# close the splash screen
splash.terminate()
# launch application
app.frame.InitRun()
app.MainLoop()


Expand Down
13 changes: 7 additions & 6 deletions shapeout/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,20 @@ def prepare_app():
warnings.warn(_("Could not determine ShapeOut version."))
version = None

app.frame = frontend.Frame(version)

return app

if __name__ == "__main__":
# get session file
session_file = None
for arg in sys.argv:
if arg.endswith(".zmso"):
print("\nLoading Session "+arg)
print("\nUsing Session "+arg)
session_file=arg
else:
print("Ignoring command line parameter: "+arg)

app.frame = frontend.Frame(version, session_file=session_file)

return app

if __name__ == "__main__":
app = prepare_app()
app.frame.InitRun(session_file=session_file)
app.MainLoop()
45 changes: 42 additions & 3 deletions shapeout/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import copy
import numpy as np
import os
import sys
import warnings

# dclab imports
Expand Down Expand Up @@ -53,6 +54,41 @@ def __init__(self, data, search_path="./"):
" .tdms files: {}".format(data))


def _clear(self):
"""Remove all attributes from this instance, making it unusable
It is difficult to control how the chaco plots refer to a measurement
object.
"""
import gc
for _i in range(len(self.measurements)):
mm = self.measurements.pop(0)
# Deleting all the data in measurements!
attrs = dclab.definitions.rdv
attrs += ["_filter_"+a for a in attrs]
attrs += ["_filter", "_plot_filter", "_Downsampled_Scatter"]
for a in attrs:
if hasattr(mm, a):
b = getattr(mm, a)
del b
# Also delete fluorescence curves
for tr in list(mm.traces.keys()):
t = mm.traces.pop(tr)
del t
del mm.traces
refs = gc.get_referrers(mm)
for r in refs:
if hasattr(r, "delplot"):
r.delplot()
import IPython
IPython.embed()
del r
del mm
dclab.cached.Cache.clear_cache()
gc.collect()


def _ImportDumped(self, indexname, search_path="./"):
""" Loads data from index file as saved using `self.DumpData`.
Expand Down Expand Up @@ -96,8 +132,12 @@ def _ImportDumped(self, indexname, search_path="./"):
ids = [mm.identifier for mm in measmts if mm is not None]
mms = [mm for mm in measmts if mm is not None]
if idhp in ids:
# parent exists
hparent = mms[ids.index(idhp)]
mm = RTDC_DataSet(hparent=hparent)
else:
# parent doesn't exist - try again in next loop
continue
else:
tloc = session_get_tdms_file(data, search_path)
mm = RTDC_DataSet(tloc)
Expand Down Expand Up @@ -195,9 +235,8 @@ def DumpData(self, directory, fullout=False, rel_path="./"):
for i in range(len(out)):
out[i] += "\r\n"

index = codecs.open(indexname, "w", "utf-8")
index.writelines(out)
index.close()
with codecs.open(indexname, "w", "utf-8") as index:
index.writelines(out)

# Dump polygons
if len(PolygonFilter.instances) > 0:
Expand Down
77 changes: 77 additions & 0 deletions shapeout/gui/autosave.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
""" ShapeOut - autosaving of sessions
"""
from __future__ import division, print_function

import appdirs
import os
import time
import wx
import wx.lib.delayedresult as delayedresult

from . import session

cache_dir = appdirs.user_cache_dir(appname="ShapeOut")
autosave_file = os.path.join(cache_dir, "autosave.zmso")


def mkdir_p(adir):
"""Recursively create a directory"""
adir = os.path.abspath(adir)
while not os.path.exists(adir):
try:
os.mkdir(adir)
except:
mkdir_p(os.path.dirname(adir))


def _autosave_consumer(delayedresult, parent):
parent.StatusBar.SetStatusText("Autosaving...")
tempname = autosave_file+".tmp"
mkdir_p(cache_dir)
try:
session.save_session(tempname, parent.analysis)
except:
parent.StatusBar.SetStatusText("Autosaving failed!")
if os.path.exists(tempname):
os.remove(tempname)
else:
if os.path.exists(autosave_file):
os.remove(autosave_file)
os.rename(tempname, autosave_file)
parent.StatusBar.SetStatusText("")
autosave_run(parent)


def _autosave_worker(parent, interval):
"""Runs in the background and performs autosaving"""
time.sleep(interval)


def autosave_run(parent, interval=60):
"""Runs in the background and performs autosaving"""
delayedresult.startWorker(_autosave_consumer,
_autosave_worker,
wargs=(parent, interval,),
cargs=(parent,))


def check_recover(parent):
"""Check for a recovery file and ask if user wants to restore
Returns True if a session was restored. False otherwise.
"""
if os.path.exists(autosave_file):
message="Autosaved session found. Restore?"
dlg = wx.MessageDialog(parent,
caption=_("Missing tdms files for session"),
message=message,
style=wx.YES|wx.NO,
)
mod = dlg.ShowModal()
dlg.Destroy()
if mod == wx.ID_YES:
session.open_session(autosave_file, parent)
return True
return False
Loading

0 comments on commit 3c20850

Please sign in to comment.