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 #259 from ZELLMECHANIK-DRESDEN/develop
Browse files Browse the repository at this point in the history
0.9.7
  • Loading branch information
paulmueller committed Nov 13, 2019
2 parents 8b6f6b4 + b1afc7b commit 1eb4a00
Show file tree
Hide file tree
Showing 20 changed files with 150 additions and 78 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.9.7
- fix: batch statistical analysis used one measurement per folder (#252)
- fix: redrawing-issues of control panels (#253)
- docs: minor update
- setup: bump dclab from 0.14.7 to 0.18.0
0.9.6
- enh: improved support for tdms data (dclab 0.12.0 -> 0.14.7) (e.g. #249)
- enh: write Shape-Out version to exported .fcs and .tsv files (#250)
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ install:
#- "conda update -f conda"
# Anaconda client for searching packages?
#- "conda install anaconda-client"
- conda config --append channels anaconda
- "conda install --yes --quiet chaco enable kiwisolver numpy pip pyface pywin32 scipy wxpython"
# workaround for build failures, see
# https://ci.appveyor.com/project/paulmueller/shapeout/build/1.0.152#L504
Expand Down
9 changes: 9 additions & 0 deletions docs/shapeout.bib
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,13 @@ @Article{Otto2015
publisher = {Springer Nature},
}

@Misc{FigshareRef,
author = {Rosendahl, Philipp and Herold, Christoph and Müller, Paul and Guck, Jochen},
title = {Real-time deformability cytometry reference data},
month = {Feb},
year = {2019},
doi = {10.6084/m9.figshare.7771184.v2},
publisher = {figshare},
}

@Comment{jabref-meta: databaseType:bibtex;}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
],
},
install_requires=["appdirs",
"dclab[all]>=0.14.6",
"dclab[all]>=0.18.0",
"fcswrite>=0.5.0",
"h5py>=2.8.0",
"imageio>=2.3.0,<2.5.0",
Expand Down
102 changes: 79 additions & 23 deletions shapeout/_version.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,56 @@
#!/usr/bin/env python
"""Determine package version for git repositories from tags
Each time this file is imported it checks if the ".git" folder is
present and if so, obtains the version from the git history using
`git describe`. This information is then stored in the file
`_version_save.py` which is not versioned by git, but distributed
along e.g. on PyPI.
"""Determine package version from git repository tag
Each time this file is imported it checks whether the package version
can be determined using `git describe`. If this fails (because either
this file is not located at the 1st level down the repository root or
it is not under version control), the version is read from the script
"_version_save.py" which is not versioned by git, but always included
in the final distribution archive (e.g. via PyPI). If the git version
does not match the saved version, then "_version_save.py" is updated.
Usage
-----
1. Put this file in your main module directory:
REPO_ROOT/package_name/_version.py
2. Add this line to REPO_ROOT/package_name/__init__.py
from ._version import version as __version__ # noqa: F401
3. (Optional) Add this line to REPO_ROOT/.gitignore
_version_save.py
Features
--------
- supports Python 2 and 3
- supports frozen applications (e.g. PyInstaller)
- supports installing into a virtual environment that is located in
a git repository
- saved version is located in a python file and therefore no other
files (e.g. MANIFEST.in) need be edited
- fallback version is the creation date
- excluded from code coverage via "pragma: no cover"
Changelog
---------
2019-11-06.2
- use os.path.split instead of counting os.path.sep (Windows)
2019-11-06
- remove deprecated imp dependency (replace with parser)
- check whether this file is versioned and its location is correct
- code cleanup and docs update
"""
from __future__ import print_function

# Put the entire script into a `True` statement and add the hint
# `pragma: no cover` to ignore code coverage here.
if True: # pragma: no cover
import imp
import os
from os.path import abspath, basename, dirname, join
from os.path import abspath, basename, dirname, join, split
import subprocess
import sys
import time
Expand All @@ -33,7 +69,7 @@ def git_describe():
ourdir = dirname(abspath(__file__))

def _minimal_ext_cmd(cmd):
# construct minimal environment
# Construct minimal environment
env = {}
for k in ['SYSTEMROOT', 'PATH']:
v = os.environ.get(k)
Expand All @@ -48,19 +84,33 @@ def _minimal_ext_cmd(cmd):
stderr=subprocess.PIPE,
env=env)
out = pop.communicate()[0]
return out
return out.strip().decode('ascii', errors="ignore")

# change directory
olddir = abspath(os.curdir)
os.chdir(ourdir)

# Make sure that we are getting "git describe" from our own
# repository (and not from a repository where we just happen
# to be in the directory tree).
git_revision = ""
try:
out = _minimal_ext_cmd(['git', 'describe', '--tags', 'HEAD'])
git_revision = out.strip().decode('ascii')
# If this file is not under version control, "loc" will
# be empty.
loc = _minimal_ext_cmd(['git', 'ls-files', '--full-name',
__file__])
# If it is under version control, it should be located
# one hierarchy down from the repository root (either
# __file__ is "docs/conf.py" or "package_name/_version.py".
if len(split(loc)) == 2:
try:
git_revision = _minimal_ext_cmd(['git', 'describe',
'--tags', 'HEAD'])
except OSError:
pass
except OSError:
git_revision = ""

# go back to original directory
pass
# Go back to original directory
os.chdir(olddir)

return git_revision
Expand All @@ -69,8 +119,11 @@ def load_version(versionfile):
"""load version from version_save.py"""
longversion = ""
try:
_version_save = imp.load_source("_version_save", versionfile)
longversion = _version_save.longversion
with open(versionfile, "r") as fd:
data = fd.readlines()
for line in data:
if line.startswith("longversion"):
longversion = line.split("=")[1].strip().strip("'")
except BaseException:
try:
from ._version_save import longversion
Expand All @@ -82,7 +135,7 @@ def load_version(versionfile):

return longversion

def save_version(version, versionfile):
def write_version(version, versionfile):
"""save version to version_save.py"""
data = "#!/usr/bin/env python\n" \
+ "# This file was created automatically\n" \
Expand All @@ -91,8 +144,11 @@ def save_version(version, versionfile):
with open(versionfile, "w") as fd:
fd.write(data.format(VERSION=version))
except BaseException:
msg = "Could not write package version to {}.".format(versionfile)
warnings.warn(msg)
if not os.path.exists(versionfile):
# Only issue a warning if the file does not exist.
msg = "Could not write package version to {}.".format(
versionfile)
warnings.warn(msg)

hdir = dirname(abspath(__file__))
if basename(__file__) == "conf.py" and "name" in locals():
Expand All @@ -116,7 +172,7 @@ def save_version(version, versionfile):

# 2. previously created version file
if longversion == "":
# Either this is this is not a git repository or we are in the
# Either this is not a git repository or we are in the
# wrong git repository.
# Get the version from the previously generated `_version_save.py`
longversion = load_version(versionfile)
Expand All @@ -135,7 +191,7 @@ def save_version(version, versionfile):
# This is only done if the program is not frozen (with e.g.
# pyinstaller),
if longversion != load_version(versionfile):
save_version(longversion, versionfile)
write_version(longversion, versionfile)

# PEP 440-conform development version:
version = ".post".join(longversion.split("-")[:2])
4 changes: 1 addition & 3 deletions shapeout/gui/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,7 @@ def OnBrowse(self, e=None):
self.WXfold_text1.SetLabel(thepath)
self.parent.config.set_path(thepath, "BatchFD")
# Search directory
tree, _cols = meta_tool.collect_data_tree(thepath)
self.data_files = [ t[1][1] for t in tree ]

self.data_files = meta_tool.find_data(thepath)
if self.out_tsv_file is not None:
self.btnbatch.Enable()
wx.EndBusyCursor()
Expand Down
13 changes: 6 additions & 7 deletions shapeout/gui/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def AddSubpanels(self):
self.subpanels.append(page_info)
self.page_info = page_info

self.page_filter = SubPanelCalculate(notebook, funcparent=self)
notebook.AddPage(self.page_filter, "Calculate")
self.subpanels.append(self.page_filter)
self.page_calc = SubPanelCalculate(notebook, funcparent=self)
notebook.AddPage(self.page_calc, "Calculate")
self.subpanels.append(self.page_calc)

self.page_filter = SubPanelFilter(notebook, funcparent=self)
notebook.AddPage(self.page_filter, "Filter")
Expand Down Expand Up @@ -231,7 +231,7 @@ def OnPolygonFilter(self, result):
uid = pf.unique_id
mcur = result["measurement"]
# update list of polygon filters
self.UpdatePages()
self.page_filter.UpdatePanel()
# Determine the number of existing polygon filters
npol = len(dclab.PolygonFilter.instances)

Expand All @@ -243,7 +243,6 @@ def OnPolygonFilter(self, result):
else:
# apply only to this one data set
mcur.config["filtering"]["polygon filters"].append(uid)
self.OnChangeFilter()


def Reset(self, key, subkeys=[]):
Expand All @@ -262,6 +261,7 @@ def Reset(self, key, subkeys=[]):
def UpdatePages(self):
""" fills pages """
sel = self.notebook.GetSelection()
self.Freeze()

# Update page content
for page in self.subpanels:
Expand All @@ -280,6 +280,5 @@ def UpdatePages(self):
self.notebook.Layout()
self.notebook.Refresh()
self.notebook.Update()

self.Layout()

self.Thaw()
7 changes: 2 additions & 5 deletions shapeout/gui/controls_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,11 @@ def update_classification(self):
wxrep.SetValue(mm.config["analysis"]["regression repetition"])


def UpdatePanel(self, analysis=None):
def RepopulatePanel(self, analysis=None):
self.ClearSubPanel()
if analysis is None:
analysis = self.analysis
self.analysis = analysis

self.ClearSubPanel()

sizer = wx.BoxSizer(wx.HORIZONTAL)

Expand All @@ -332,5 +331,3 @@ def UpdatePanel(self, analysis=None):

self.SetSizer(sizer)
sizer.Fit(self)
self.Layout()
self.UpdateScrolling()
5 changes: 2 additions & 3 deletions shapeout/gui/controls_calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,11 @@ def OnComputeEmodulus(self, e=None):
self.funcparent.OnChangeFilter()


def UpdatePanel(self, analysis=None):
def RepopulatePanel(self, analysis=None):
self.ClearSubPanel()
if analysis is None:
analysis = self.analysis
self.analysis = analysis

self.ClearSubPanel()

sizer = wx.BoxSizer(wx.HORIZONTAL)
emodbox = self.make_emodulus_choices(analysis)
Expand Down
3 changes: 1 addition & 2 deletions shapeout/gui/controls_contourplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ def _box_from_cfg_contour(self, analysis):
return mastersizer


def UpdatePanel(self, analysis):
def RepopulatePanel(self, analysis):
self.ClearSubPanel()

# sizer
sizer = wx.BoxSizer(wx.HORIZONTAL)
fbox = self._box_from_cfg_contour(analysis)
Expand Down
5 changes: 2 additions & 3 deletions shapeout/gui/controls_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def OnPolygonWindow(self, e=None):
ldw.Show()


def UpdatePanel(self, analysis=None):
def RepopulatePanel(self, analysis=None):
if analysis is None:
# previous analysis is used
analysis = self.analysis
Expand All @@ -529,10 +529,9 @@ def UpdatePanel(self, analysis=None):
else:
old_meas_selection = 0

self.analysis = analysis

self.ClearSubPanel()

self.analysis = analysis

sizer = wx.BoxSizer(wx.HORIZONTAL)

Expand Down
5 changes: 1 addition & 4 deletions shapeout/gui/controls_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ class SubPanelInfo(SubPanel):
def __init__(self, *args, **kwargs):
SubPanel.__init__(self, *args, **kwargs)

def UpdatePanel(self, analysis):
""" """
def RepopulatePanel(self, analysis=None):
self.ClearSubPanel()

# Create three boxes containing information
sizer = wx.BoxSizer(wx.HORIZONTAL)
genbox = self._box_from_cfg_read(analysis, "experiment", ignore=HIDDEN)
Expand Down Expand Up @@ -56,4 +54,3 @@ def UpdatePanel(self, analysis):
sizer.Add(flbox)
self.SetSizer(sizer)
sizer.Fit(self)

5 changes: 1 addition & 4 deletions shapeout/gui/controls_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,8 @@ def OnApply(self, e=None):
self.funcparent.OnChangePlot(e)


def UpdatePanel(self, analysis):
""" """
def RepopulatePanel(self, analysis=None):
self.ClearSubPanel()

# sizer
sizer = wx.BoxSizer(wx.HORIZONTAL)
plotsizer = self._box_from_cfg_plotting(analysis)
ordersizer = self._box_order_plots(analysis, sizey=plotsizer.GetMinSize()[1]-25)
Expand Down
3 changes: 1 addition & 2 deletions shapeout/gui/controls_scatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ def _box_from_cfg_scatter(self, analysis):
return mastersizer


def UpdatePanel(self, analysis):
def RepopulatePanel(self, analysis):
"""Redraw the entire panel"""
self.ClearSubPanel()

# sizer
sizer = wx.BoxSizer(wx.HORIZONTAL)
fbox = self._box_from_cfg_scatter(analysis)
Expand Down
4 changes: 1 addition & 3 deletions shapeout/gui/controls_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ def _box_statistics(self, analysis):
sizer.Layout()
return sizer


def UpdatePanel(self, analysis):
""" """
def RepopulatePanel(self, analysis):
self.ClearSubPanel()
# Create three boxes containing information
sizer = wx.BoxSizer(wx.HORIZONTAL)
Expand Down

0 comments on commit 1eb4a00

Please sign in to comment.