From b14186ba889f3ca6377a4bee8d952816b68f5fb2 Mon Sep 17 00:00:00 2001 From: Jason Li Date: Wed, 2 Nov 2016 09:48:06 +0800 Subject: [PATCH 1/6] Converted the codes to be Python 3.x-compatible --- biosppy/biometrics.py | 60 ++++++++++++++++++++-------------------- biosppy/clustering.py | 18 ++++++------ biosppy/metrics.py | 4 +-- biosppy/plotting.py | 10 +++---- biosppy/signals/bvp.py | 2 +- biosppy/signals/ecg.py | 8 +++--- biosppy/signals/eda.py | 4 +-- biosppy/signals/eeg.py | 12 ++++---- biosppy/signals/tools.py | 6 ++-- biosppy/storage.py | 12 ++++---- biosppy/utils.py | 18 ++++++------ docs/conf.py | 14 +++++----- 12 files changed, 84 insertions(+), 84 deletions(-) diff --git a/biosppy/biometrics.py b/biosppy/biometrics.py index 24c68e0a..a6c5210e 100644 --- a/biosppy/biometrics.py +++ b/biosppy/biometrics.py @@ -247,7 +247,7 @@ def list_subjects(self): """ - subjects = self._subject2label.keys() + subjects = list(self._subject2label.keys()) return subjects @@ -356,7 +356,7 @@ def batch_train(self, data=None): if data is None: raise TypeError("Please specify the data to train.") - for sub, val in data.iteritems(): + for sub, val in data.items(): if val is None: try: self.dismiss(sub, deferred=True) @@ -399,10 +399,10 @@ def update_thresholds(self, fraction=1.): # gather data to test data = {} - for subject, label in self._subject2label.iteritems(): + for subject, label in self._subject2label.items(): # select a random fraction of the training data aux = self.io_load(label) - indx = range(len(aux)) + indx = list(range(len(aux))) use, _ = utils.random_fraction(indx, fraction, sort=True) data[subject] = aux[use] @@ -411,7 +411,7 @@ def update_thresholds(self, fraction=1.): _, res = self.evaluate(data, ths) # choose thresholds at EER - for subject, label in self._subject2label.iteritems(): + for subject, label in self._subject2label.items(): EER_auth = res['subject'][subject]['authentication']['rates']['EER'] self.set_auth_thr(label, EER_auth[self.EER_IDX, 0], ready=True) @@ -639,7 +639,7 @@ def evaluate(self, data, thresholds=None, show=False): thresholds = self.get_thresholds() # get subjects - subjects = filter(lambda item: self.check_subject(item), data.keys()) + subjects = [item for item in list(data.keys()) if self.check_subject(item)] if len(subjects) == 0: raise ValueError("No enrolled subjects in test set.") @@ -722,7 +722,7 @@ def cross_validation(cls, data, labels, cv, thresholds=None, **kwargs): lbl = labels[item] train_idx[lbl].append(item) - train_data = {sub: data[idx] for sub, idx in train_idx.iteritems()} + train_data = {sub: data[idx] for sub, idx in train_idx.items()} # test data set test_idx = collections.defaultdict(list) @@ -730,7 +730,7 @@ def cross_validation(cls, data, labels, cv, thresholds=None, **kwargs): lbl = labels[item] test_idx[lbl].append(item) - test_data = {sub: data[idx] for sub, idx in test_idx.iteritems()} + test_data = {sub: data[idx] for sub, idx in test_idx.items()} # instantiate classifier clf = cls(**kwargs) @@ -832,8 +832,8 @@ def _prepare(self, data, targets=None): # target class labels if targets is None: - targets = self._subject2label.values() - elif isinstance(targets, basestring): + targets = list(self._subject2label.values()) + elif isinstance(targets, str): targets = [targets] return data @@ -975,7 +975,7 @@ def _authenticate(self, data, label, threshold): # select based on subject label aux = [] ns = len(dists) - for i in xrange(ns): + for i in range(ns): aux.append(dists[i, train_labels[i, :] == label]) dists = np.array(aux) @@ -984,7 +984,7 @@ def _authenticate(self, data, label, threshold): dists = dists[:, :self.k] decision = np.zeros(ns, dtype='bool') - for i in xrange(ns): + for i in range(ns): # compare distances to threshold count = np.sum(dists[i, :] <= threshold) @@ -1014,8 +1014,8 @@ def _get_thresholds(self): return np.linspace(self.min_thr, 1., 100) maxD = [] - for _ in xrange(3): - for label in self._subject2label.values(): + for _ in range(3): + for label in list(self._subject2label.values()): # randomly select samples aux = self.io_load(label) ind = np.random.randint(0, aux.shape[0], 3) @@ -1064,7 +1064,7 @@ def _identify(self, data, threshold=None): ns = len(dists) labels = [] - for i in xrange(ns): + for i in range(ns): lbl, _ = majority_rule(train_labels[i, :], random=True) # compare distances to threshold @@ -1102,8 +1102,8 @@ def _prepare(self, data, targets=None): # target class labels if targets is None: - targets = self._subject2label.values() - elif isinstance(targets, basestring): + targets = list(self._subject2label.values()) + elif isinstance(targets, str): targets = [targets] dists = [] @@ -1415,7 +1415,7 @@ def _authenticate(self, data, label, threshold): aux = aux[sel, :] decision = [] - for i in xrange(ns): + for i in range(ns): # determine majority predMax, count = majority_rule(aux[:, i], random=True) rate = float(count) / norm @@ -1483,7 +1483,7 @@ def _identify(self, data, threshold=None): norm = 1.0 labels = [] - for i in xrange(ns): + for i in range(ns): # determine majority predMax, count = majority_rule(aux[:, i], random=True) rate = float(count) / norm @@ -1524,11 +1524,11 @@ def _prepare(self, data, targets=None): # target class labels if self._nbSubjects == 1: - pairs = self._models.keys() + pairs = list(self._models.keys()) else: if targets is None: - pairs = self._models.keys() - elif isinstance(targets, basestring): + pairs = list(self._models.keys()) + elif isinstance(targets, str): labels = list( set(self._subject2label.values()) - set([targets])) pairs = [[targets, lbl] for lbl in labels] @@ -1563,9 +1563,9 @@ def _train(self, enroll=None, dismiss=None): dismiss = [] # process dismiss - pairs = self._models.keys() + pairs = list(self._models.keys()) for t in dismiss: - pairs = filter(lambda p: t in p, pairs) + pairs = [p for p in pairs if t in p] for p in pairs: self._del_clf(p) @@ -1590,11 +1590,11 @@ def _train(self, enroll=None, dismiss=None): # check singles if self._nbSubjects == 1: - label = self._subject2label.values()[0] + label = list(self._subject2label.values())[0] X = self.io_load(label) self._get_single_clf(X, label) elif self._nbSubjects > 1: - aux = filter(lambda p: '' in p, self._models.keys()) + aux = [p for p in list(self._models.keys()) if '' in p] if len(aux) != 0: for p in aux: self._del_clf(p) @@ -1850,7 +1850,7 @@ def get_subject_results(results=None, R = np.zeros(nth, dtype='float') CM = [] - for i in xrange(nth): # for each threshold + for i in range(nth): # for each threshold # authentication for k, lbl in enumerate(subject_idx): # for each subject subject_tst = subjects[k] @@ -2163,7 +2163,7 @@ def combination(results=None, weights=None): weights = {} # compile results to find all classes - vec = results.values() + vec = list(results.values()) if len(vec) == 0: raise CombinationError("No keys found.") @@ -2182,13 +2182,13 @@ def combination(results=None, weights=None): # multi-class counts = np.zeros(nb, dtype='float') - for n in results.iterkeys(): + for n in results.keys(): # ensure array res = np.array(results[n]) ns = float(len(res)) # get count for each unique class - for i in xrange(nb): + for i in range(nb): aux = float(np.sum(res == unq[i])) w = weights.get(n, 1.) counts[i] += ((aux / ns) * w) diff --git a/biosppy/clustering.py b/biosppy/clustering.py index 5071cc28..2d15aa34 100644 --- a/biosppy/clustering.py +++ b/biosppy/clustering.py @@ -134,7 +134,7 @@ def hierarchical(data=None, 'ward', 'weighted']: raise ValueError("Unknown linkage criterion '%r'." % linkage) - if not isinstance(metric, basestring): + if not isinstance(metric, str): raise TypeError("Please specify the distance metric as a string.") N = len(data) @@ -405,7 +405,7 @@ def create_coassoc(ensemble=None, N=None): nparts = len(ensemble) assoc = 0 for part in ensemble: - nsamples = np.array([len(part[key]) for key in part.iterkeys()]) + nsamples = np.array([len(part[key]) for key in part.keys()]) dim = np.sum(nsamples * (nsamples - 1)) / 2 I = np.zeros(dim) @@ -413,11 +413,11 @@ def create_coassoc(ensemble=None, N=None): X = np.ones(dim) ntriplets = 0 - for v in part.itervalues(): + for v in part.values(): nb = len(v) if nb > 0: - for h in xrange(nb): - for f in xrange(h + 1, nb): + for h in range(nb): + for f in range(h + 1, nb): I[ntriplets] = v[h] J[ntriplets] = v[f] ntriplets += 1 @@ -539,7 +539,7 @@ def mdist_templates(data=None, clusters = {0: np.arange(len(data), dtype='int')} # cluster labels - ks = clusters.keys() + ks = list(clusters.keys()) # remove the outliers' cluster, if present if '-1' in ks: @@ -631,7 +631,7 @@ def centroid_templates(data=None, clusters=None, ntemplates=1): raise TypeError("Please specify a data clustering.") # cluster labels - ks = clusters.keys() + ks = list(clusters.keys()) # remove the outliers' cluster, if present if '-1' in ks: @@ -839,7 +839,7 @@ def outliers_dmean(data=None, outliers.append(i) outliers = np.unique(outliers) - normal = np.setdiff1d(range(len(data)), outliers, assume_unique=True) + normal = np.setdiff1d(list(range(len(data))), outliers, assume_unique=True) # output clusters = {-1: outliers, 0: normal} @@ -987,7 +987,7 @@ def _merge_clusters(clusters): """ - keys = clusters.keys() + keys = list(clusters.keys()) # outliers if -1 in keys: diff --git a/biosppy/metrics.py b/biosppy/metrics.py index b06debb8..876442ac 100644 --- a/biosppy/metrics.py +++ b/biosppy/metrics.py @@ -83,7 +83,7 @@ def pdist(X, metric='euclidean', p=2, w=None, V=None, VI=None): """ - if isinstance(metric, basestring): + if isinstance(metric, str): if metric == 'pcosine': metric = pcosine @@ -127,7 +127,7 @@ def cdist(XA, XB, metric='euclidean', p=2, V=None, VI=None, w=None): """ - if isinstance(metric, basestring): + if isinstance(metric, str): if metric == 'pcosine': metric = pcosine diff --git a/biosppy/plotting.py b/biosppy/plotting.py index 0d07b2a9..47bf578b 100644 --- a/biosppy/plotting.py +++ b/biosppy/plotting.py @@ -770,7 +770,7 @@ def _plot_multichannel(ts=None, # check labels if labels is None: - labels = ['Ch. %d' % i for i in xrange(nch)] + labels = ['Ch. %d' % i for i in range(nch)] if nch < nrows: nrows = nch @@ -794,7 +794,7 @@ def _plot_multichannel(ts=None, ax0.grid() axs = {(0, 0): ax0} - for i in xrange(1, nch - 1): + for i in range(1, nch - 1): a = i % nrows b = int(np.floor(i / float(nrows))) ax = fig.add_subplot(gs[a, b], sharex=ax0) @@ -822,7 +822,7 @@ def _plot_multichannel(ts=None, if xlabel is not None: ax.set_xlabel(xlabel) - for b in xrange(0, ncols - 1): + for b in range(0, ncols - 1): a = nrows - 1 ax = axs[(a, b)] ax.set_xlabel(xlabel) @@ -1042,7 +1042,7 @@ def plot_biometrics(assessment=None, eer_idx=None, path=None, show=False): id_ax = fig.add_subplot(122) # subject results - for sub in assessment['subject'].iterkeys(): + for sub in assessment['subject'].keys(): auth_rates = assessment['subject'][sub]['authentication']['rates'] _ = _plot_rates(ths, auth_rates, ['FAR', 'FRR'], lw=MINOR_LW, @@ -1134,7 +1134,7 @@ def plot_clustering(data=None, clusters=None, path=None, show=False): ymin, ymax = _yscaling(data, alpha=1.2) # determine number of clusters - keys = clusters.keys() + keys = list(clusters.keys()) nc = len(keys) if nc <= 4: diff --git a/biosppy/signals/bvp.py b/biosppy/signals/bvp.py index 82bce919..95f4aa6f 100644 --- a/biosppy/signals/bvp.py +++ b/biosppy/signals/bvp.py @@ -181,7 +181,7 @@ def find_onsets(signal=None, sampling_rate=1000., sm_size=None, size=None, # analyze between maxima of 2nd derivative of ss detected = False - for i in xrange(1, len(dpidx) + 1): + for i in range(1, len(dpidx) + 1): try: v, u = dpidx[i - 1], dpidx[i] except IndexError: diff --git a/biosppy/signals/ecg.py b/biosppy/signals/ecg.py index 58d27d9d..00ef0310 100644 --- a/biosppy/signals/ecg.py +++ b/biosppy/signals/ecg.py @@ -664,11 +664,11 @@ def engzee_segmenter(signal=None, sampling_rate=1000., threshold=0.48): mmp = 0.2 # Differentiator (1) - y1 = map(lambda i: signal[i] - signal[i - 4], xrange(4, len(signal))) + y1 = [signal[i] - signal[i - 4] for i in range(4, len(signal))] # Low pass filter (2) c = [1, 4, 6, 4, 1, -1, -4, -6, -4, -1] - y2 = np.array(map(lambda n: np.dot(c, y1[n - 9:n + 1]), xrange(9, len(y1)))) + y2 = np.array([np.dot(c, y1[n - 9:n + 1]) for n in range(9, len(y1))]) y2_len = len(y2) # vars @@ -1087,7 +1087,7 @@ def hamilton_segmenter(signal=None, sampling_rate=1000.): pass # getting positive peaks - for i in xrange(len(pospeaks) - 1): + for i in range(len(pospeaks) - 1): if abs(pospeaks[0][1] - pospeaks[i + 1][1]) > adjacency: twopeaks.append(pospeaks[i + 1]) break @@ -1097,7 +1097,7 @@ def hamilton_segmenter(signal=None, sampling_rate=1000.): error[0] = True # getting negative peaks - for i in xrange(len(negpeaks) - 1): + for i in range(len(negpeaks) - 1): if abs(negpeaks[0][1] - negpeaks[i + 1][1]) > adjacency: twonegpeaks.append(negpeaks[i + 1]) break diff --git a/biosppy/signals/eda.py b/biosppy/signals/eda.py index 82d4c827..1514cdc7 100644 --- a/biosppy/signals/eda.py +++ b/biosppy/signals/eda.py @@ -156,7 +156,7 @@ def basic_scr(signal=None, sampling_rate=1000.): i0[0] = 0 # amplitude - a = np.array(map(lambda i: np.max(signal[i1[i]:i3[i]]), range(li))) + a = np.array([np.max(signal[i1[i]:i3[i]]) for i in range(li)]) # output args = (i3, i1, a) @@ -217,7 +217,7 @@ def kbk_scr(signal=None, sampling_rate=1000.): thr = 0.1 * np.max(df) scrs, amps, ZC, pks = [], [], [], [] - for i in xrange(0, len(zeros) - 1, 2): + for i in range(0, len(zeros) - 1, 2): scrs += [df[zeros[i]:zeros[i + 1]]] aux = scrs[-1].max() if aux > thr: diff --git a/biosppy/signals/eeg.py b/biosppy/signals/eeg.py index dcaa6e0b..4b9c2927 100644 --- a/biosppy/signals/eeg.py +++ b/biosppy/signals/eeg.py @@ -75,7 +75,7 @@ def eeg(signal=None, sampling_rate=1000., labels=None, show=True): nch = signal.shape[1] if labels is None: - labels = ['Ch. %d' % i for i in xrange(nch)] + labels = ['Ch. %d' % i for i in range(nch)] else: if len(labels) != nch: raise ValueError( @@ -261,8 +261,8 @@ def get_power_features(signal=None, # must be odd md_size += 1 - for i in xrange(nb): - for j in xrange(nch): + for i in range(nb): + for j in range(nch): values[:, i, j], _ = st.smoother(signal=values[:, i, j], kernel='median', size=md_size) @@ -331,7 +331,7 @@ def get_plf_features(signal=None, sampling_rate=1000., size=0.25, overlap=0.5): N = min_pad # PLF pairs - pairs = [(i, j) for i in xrange(nch) for j in xrange(i + 1, nch)] + pairs = [(i, j) for i in range(nch) for j in range(i + 1, nch)] nb = len(pairs) # windower @@ -349,7 +349,7 @@ def get_plf_features(signal=None, sampling_rate=1000., size=0.25, overlap=0.5): # must be odd md_size += 1 - for i in xrange(nb): + for i in range(nb): values[:, i], _ = st.smoother(signal=values[:, i], kernel='median', size=md_size) @@ -389,7 +389,7 @@ def _power_features(signal=None, sampling_rate=1000., bands=None, pad=0): nch = signal.shape[1] out = np.zeros((len(bands), nch), dtype='float') - for i in xrange(nch): + for i in range(nch): # compute power spectrum freqs, power = st.power_spectrum(signal=signal[:, i], sampling_rate=sampling_rate, diff --git a/biosppy/signals/tools.py b/biosppy/signals/tools.py index 31011bed..75a964ce 100644 --- a/biosppy/signals/tools.py +++ b/biosppy/signals/tools.py @@ -479,7 +479,7 @@ def smoother(signal=None, kernel='boxzen', size=10, mirror=True, **kwargs): length = len(signal) - if isinstance(kernel, basestring): + if isinstance(kernel, str): # check length if size > length: size = length - 1 @@ -998,7 +998,7 @@ def windower(signal=None, length = len(signal) - if isinstance(kernel, basestring): + if isinstance(kernel, str): # check size if size > length: raise ValueError("Window size must be smaller than signal length.") @@ -1029,7 +1029,7 @@ def windower(signal=None, index = [] values = [] - for i in xrange(nb): + for i in range(nb): start = i * step stop = start + size index.append(start) diff --git a/biosppy/storage.py b/biosppy/storage.py index 4fbff053..a89f0015 100644 --- a/biosppy/storage.py +++ b/biosppy/storage.py @@ -320,7 +320,7 @@ def store_txt(path, data, sampling_rate=1000., resolution=None, date=None, if resolution is not None: header += "Resolution:= %d\n" % resolution if date is not None: - if isinstance(date, basestring): + if isinstance(date, str): header += "Date:= %s\n" % date elif isinstance(date, datetime.datetime): header += "Date:= %s\n" % date.isoformat() @@ -338,7 +338,7 @@ def store_txt(path, data, sampling_rate=1000., resolution=None, date=None, ncols = data.shape[1] if labels is None: - labels = ['%d' % i for i in xrange(ncols)] + labels = ['%d' % i for i in range(ncols)] elif len(labels) != ncols: raise ValueError("Inconsistent number of labels.") @@ -720,7 +720,7 @@ def del_signal_group(self, group=''): if node.name == '/signals': # delete all elements - for _, item in node.iteritems(): + for _, item in node.items(): try: del self._file[item.name] except IOError: @@ -759,7 +759,7 @@ def list_signals(self, group='', recursive=False): raise KeyError("Inexistent signal group.") out = [] - for name, item in node.iteritems(): + for name, item in node.items(): if isinstance(item, h5py.Dataset): out.append((group, name)) elif recursive and isinstance(item, h5py.Group): @@ -972,7 +972,7 @@ def del_event_group(self, group=''): if node.name == '/events': # delete all elements - for _, item in node.iteritems(): + for _, item in node.items(): try: del self._file[item.name] except IOError: @@ -1011,7 +1011,7 @@ def list_events(self, group='', recursive=False): raise KeyError("Inexistent event group.") out = [] - for name, item in node.iteritems(): + for name, item in node.items(): if isinstance(item, h5py.Group): try: _ = item.attrs['json'] diff --git a/biosppy/utils.py b/biosppy/utils.py index be9dfeed..f3ca6f20 100644 --- a/biosppy/utils.py +++ b/biosppy/utils.py @@ -87,7 +87,7 @@ def remainderAllocator(votes, k, reverse=True, check=False): else: ind = np.argsort(aux - seats) - for i in xrange(nb): + for i in range(nb): seats[ind[i % length]] += 1 return seats.tolist() @@ -137,9 +137,9 @@ def highestAveragesAllocator(votes, k, divisor='dHondt', check=False): # compute coefficients tab = [] length = len(votes) - D = [fcn(i) for i in xrange(1, k + 1)] - for i in xrange(length): - for j in xrange(k): + D = [fcn(i) for i in range(1, k + 1)] + for i in range(length): + for j in range(k): tab.append((i, votes[i] / D[j])) # sort @@ -148,7 +148,7 @@ def highestAveragesAllocator(votes, k, divisor='dHondt', check=False): tab = np.array([item[0] for item in tab], dtype='int') seats = np.zeros(length, dtype='int') - for i in xrange(length): + for i in range(length): seats[i] = np.sum(tab == i) return seats.tolist() @@ -230,14 +230,14 @@ def __init__(self, values, names=None): if names is None: # create names - names = ['_%d' % i for i in xrange(nargs)] + names = ['_%d' % i for i in range(nargs)] else: # check length if len(names) != nargs: raise ValueError("Number of names and values mismatch.") # convert to str - names = map(str, names) + names = list(map(str, names)) # check for keywords, alphanumeric, digits, repeats seen = set() @@ -270,7 +270,7 @@ def as_dict(self): """ - return collections.OrderedDict(zip(self._names, self)) + return collections.OrderedDict(list(zip(self._names, self))) __dict__ = property(as_dict) @@ -291,7 +291,7 @@ def __getitem__(self, key): """ - if isinstance(key, basestring): + if isinstance(key, str): if key not in self._names: raise KeyError("Unknown key: %r." % key) diff --git a/docs/conf.py b/docs/conf.py index 28b48300..00ce1be9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -76,9 +76,9 @@ def __getattr__(cls, name): master_doc = 'index' # General information about the project. -project = u'BioSPPy' -copyright = u'2015, Instituto de Telecomunicacoes' -author = u'Instituto de Telecomunicacoes' +project = 'BioSPPy' +copyright = '2015, Instituto de Telecomunicacoes' +author = 'Instituto de Telecomunicacoes' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -252,8 +252,8 @@ def __getattr__(cls, name): # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'BioSPPy.tex', u'BioSPPy Documentation', - u'Instituto de Telecomunicacoes', 'manual'), + (master_doc, 'BioSPPy.tex', 'BioSPPy Documentation', + 'Instituto de Telecomunicacoes', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -282,7 +282,7 @@ def __getattr__(cls, name): # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'biosppy', u'BioSPPy Documentation', + (master_doc, 'biosppy', 'BioSPPy Documentation', [author], 1) ] @@ -296,7 +296,7 @@ def __getattr__(cls, name): # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'BioSPPy', u'BioSPPy Documentation', + (master_doc, 'BioSPPy', 'BioSPPy Documentation', author, 'BioSPPy', 'One line description of project.', 'Miscellaneous'), ] From a00a1f8c7839ef4868d1351b9d207166aaa81a40 Mon Sep 17 00:00:00 2001 From: Dominique Makowski Date: Sun, 13 Nov 2016 15:45:28 +0100 Subject: [PATCH 2/6] Update __init__.py --- biosppy/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/biosppy/__init__.py b/biosppy/__init__.py index 46cee343..0276d173 100644 --- a/biosppy/__init__.py +++ b/biosppy/__init__.py @@ -11,3 +11,11 @@ # get version from .version import version as __version__ + +# Allow lazy loading +from biosppy.signals import ecg +from biosppy.signals import eda +from biosppy.signals import eeg +from biosppy.signals import emg +from biosppy.signals import bvp +from biosppy.signals import resp From 7aeb91144d09db8a4ff06d138875498cf498f22e Mon Sep 17 00:00:00 2001 From: Carlos Carreiras Date: Thu, 29 Dec 2016 18:32:12 +0000 Subject: [PATCH 3/6] Enhanced compatibility with Python 2 and 3. --- biosppy/__init__.py | 12 ++++------ biosppy/biometrics.py | 47 ++++++++++++++++++++----------------- biosppy/clustering.py | 19 +++++++++------ biosppy/metrics.py | 8 +++++-- biosppy/plotting.py | 11 ++++++--- biosppy/signals/__init__.py | 6 +++++ biosppy/signals/bvp.py | 4 ++++ biosppy/signals/ecg.py | 6 +++++ biosppy/signals/eda.py | 4 ++++ biosppy/signals/eeg.py | 4 ++++ biosppy/signals/emg.py | 3 +++ biosppy/signals/resp.py | 3 +++ biosppy/signals/tools.py | 13 ++++++---- biosppy/storage.py | 15 ++++++++---- biosppy/utils.py | 9 +++++-- setup.py | 21 +++++++++++++---- 16 files changed, 130 insertions(+), 55 deletions(-) diff --git a/biosppy/__init__.py b/biosppy/__init__.py index 0276d173..ac2f22e1 100644 --- a/biosppy/__init__.py +++ b/biosppy/__init__.py @@ -9,13 +9,11 @@ :license: BSD 3-clause, see LICENSE for more details. """ +# compat +from __future__ import absolute_import, division, print_function + # get version from .version import version as __version__ -# Allow lazy loading -from biosppy.signals import ecg -from biosppy.signals import eda -from biosppy.signals import eeg -from biosppy.signals import emg -from biosppy.signals import bvp -from biosppy.signals import resp +# allow lazy loading +from .signals import bvp, ecg, eda, eeg, emg, resp, tools diff --git a/biosppy/biometrics.py b/biosppy/biometrics.py index a6c5210e..1b62c152 100644 --- a/biosppy/biometrics.py +++ b/biosppy/biometrics.py @@ -15,6 +15,11 @@ """ # Imports +# compat +from __future__ import absolute_import, division, print_function +from six.moves import range +import six + # built-in import collections @@ -247,7 +252,7 @@ def list_subjects(self): """ - subjects = list(self._subject2label.keys()) + subjects = list(self._subject2label) return subjects @@ -356,7 +361,7 @@ def batch_train(self, data=None): if data is None: raise TypeError("Please specify the data to train.") - for sub, val in data.items(): + for sub, val in six.iteritems(data): if val is None: try: self.dismiss(sub, deferred=True) @@ -399,7 +404,7 @@ def update_thresholds(self, fraction=1.): # gather data to test data = {} - for subject, label in self._subject2label.items(): + for subject, label in six.iteritems(self._subject2label): # select a random fraction of the training data aux = self.io_load(label) indx = list(range(len(aux))) @@ -411,7 +416,7 @@ def update_thresholds(self, fraction=1.): _, res = self.evaluate(data, ths) # choose thresholds at EER - for subject, label in self._subject2label.items(): + for subject, label in six.iteritems(self._subject2label): EER_auth = res['subject'][subject]['authentication']['rates']['EER'] self.set_auth_thr(label, EER_auth[self.EER_IDX, 0], ready=True) @@ -639,7 +644,7 @@ def evaluate(self, data, thresholds=None, show=False): thresholds = self.get_thresholds() # get subjects - subjects = [item for item in list(data.keys()) if self.check_subject(item)] + subjects = [item for item in data if self.check_subject(item)] if len(subjects) == 0: raise ValueError("No enrolled subjects in test set.") @@ -722,7 +727,7 @@ def cross_validation(cls, data, labels, cv, thresholds=None, **kwargs): lbl = labels[item] train_idx[lbl].append(item) - train_data = {sub: data[idx] for sub, idx in train_idx.items()} + train_data = {sub: data[idx] for sub, idx in six.iteritems(train_idx)} # test data set test_idx = collections.defaultdict(list) @@ -730,7 +735,7 @@ def cross_validation(cls, data, labels, cv, thresholds=None, **kwargs): lbl = labels[item] test_idx[lbl].append(item) - test_data = {sub: data[idx] for sub, idx in test_idx.items()} + test_data = {sub: data[idx] for sub, idx in six.iteritems(test_idx)} # instantiate classifier clf = cls(**kwargs) @@ -833,7 +838,7 @@ def _prepare(self, data, targets=None): # target class labels if targets is None: targets = list(self._subject2label.values()) - elif isinstance(targets, str): + elif isinstance(targets, six.string_types): targets = [targets] return data @@ -989,7 +994,7 @@ def _authenticate(self, data, label, threshold): count = np.sum(dists[i, :] <= threshold) # decide accept - if count > (self.k / 2): + if count > (self.k // 2): decision[i] = True return decision @@ -1015,7 +1020,7 @@ def _get_thresholds(self): maxD = [] for _ in range(3): - for label in list(self._subject2label.values()): + for label in list(six.itervalues(self._subject2label)): # randomly select samples aux = self.io_load(label) ind = np.random.randint(0, aux.shape[0], 3) @@ -1071,7 +1076,7 @@ def _identify(self, data, threshold=None): count = np.sum(dists[i, :] <= thrFcn(lbl)) # decide - if count > (self.k / 2): + if count > (self.k // 2): # accept labels.append(lbl) else: @@ -1102,8 +1107,8 @@ def _prepare(self, data, targets=None): # target class labels if targets is None: - targets = list(self._subject2label.values()) - elif isinstance(targets, str): + targets = list(six.itervalues(self._subject2label)) + elif isinstance(targets, six.string_types): targets = [targets] dists = [] @@ -1524,11 +1529,11 @@ def _prepare(self, data, targets=None): # target class labels if self._nbSubjects == 1: - pairs = list(self._models.keys()) + pairs = list(self._models) else: if targets is None: - pairs = list(self._models.keys()) - elif isinstance(targets, str): + pairs = list(self._models) + elif isinstance(targets, six.string_types): labels = list( set(self._subject2label.values()) - set([targets])) pairs = [[targets, lbl] for lbl in labels] @@ -1563,7 +1568,7 @@ def _train(self, enroll=None, dismiss=None): dismiss = [] # process dismiss - pairs = list(self._models.keys()) + pairs = list(self._models) for t in dismiss: pairs = [p for p in pairs if t in p] @@ -1590,11 +1595,11 @@ def _train(self, enroll=None, dismiss=None): # check singles if self._nbSubjects == 1: - label = list(self._subject2label.values())[0] + label = list(six.itervalues(self._subject2label))[0] X = self.io_load(label) self._get_single_clf(X, label) elif self._nbSubjects > 1: - aux = [p for p in list(self._models.keys()) if '' in p] + aux = [p for p in self._models if '' in p] if len(aux) != 0: for p in aux: self._del_clf(p) @@ -2163,7 +2168,7 @@ def combination(results=None, weights=None): weights = {} # compile results to find all classes - vec = list(results.values()) + vec = list(six.itervalues(results)) if len(vec) == 0: raise CombinationError("No keys found.") @@ -2182,7 +2187,7 @@ def combination(results=None, weights=None): # multi-class counts = np.zeros(nb, dtype='float') - for n in results.keys(): + for n in results: # ensure array res = np.array(results[n]) ns = float(len(res)) diff --git a/biosppy/clustering.py b/biosppy/clustering.py index 2d15aa34..8a950ccd 100644 --- a/biosppy/clustering.py +++ b/biosppy/clustering.py @@ -11,6 +11,11 @@ """ # Imports +# compat +from __future__ import absolute_import, division, print_function +from six.moves import map, range, zip +import six + # 3rd party import numpy as np import scipy.cluster.hierarchy as sch @@ -134,7 +139,7 @@ def hierarchical(data=None, 'ward', 'weighted']: raise ValueError("Unknown linkage criterion '%r'." % linkage) - if not isinstance(metric, str): + if not isinstance(metric, six.string_types): raise TypeError("Please specify the distance metric as a string.") N = len(data) @@ -405,15 +410,15 @@ def create_coassoc(ensemble=None, N=None): nparts = len(ensemble) assoc = 0 for part in ensemble: - nsamples = np.array([len(part[key]) for key in part.keys()]) - dim = np.sum(nsamples * (nsamples - 1)) / 2 + nsamples = np.array([len(part[key]) for key in part]) + dim = np.sum(nsamples * (nsamples - 1)) // 2 I = np.zeros(dim) J = np.zeros(dim) X = np.ones(dim) ntriplets = 0 - for v in part.values(): + for v in six.itervalues(part): nb = len(v) if nb > 0: for h in range(nb): @@ -539,7 +544,7 @@ def mdist_templates(data=None, clusters = {0: np.arange(len(data), dtype='int')} # cluster labels - ks = list(clusters.keys()) + ks = list(clusters) # remove the outliers' cluster, if present if '-1' in ks: @@ -631,7 +636,7 @@ def centroid_templates(data=None, clusters=None, ntemplates=1): raise TypeError("Please specify a data clustering.") # cluster labels - ks = list(clusters.keys()) + ks = list(clusters) # remove the outliers' cluster, if present if '-1' in ks: @@ -987,7 +992,7 @@ def _merge_clusters(clusters): """ - keys = list(clusters.keys()) + keys = list(clusters) # outliers if -1 in keys: diff --git a/biosppy/metrics.py b/biosppy/metrics.py index 876442ac..1d731f54 100644 --- a/biosppy/metrics.py +++ b/biosppy/metrics.py @@ -10,6 +10,10 @@ """ # Imports +# compat +from __future__ import absolute_import, division, print_function +import six + # 3rd party import numpy as np import scipy.spatial.distance as ssd @@ -83,7 +87,7 @@ def pdist(X, metric='euclidean', p=2, w=None, V=None, VI=None): """ - if isinstance(metric, str): + if isinstance(metric, six.string_types): if metric == 'pcosine': metric = pcosine @@ -127,7 +131,7 @@ def cdist(XA, XB, metric='euclidean', p=2, V=None, VI=None, w=None): """ - if isinstance(metric, str): + if isinstance(metric, six.string_types): if metric == 'pcosine': metric = pcosine diff --git a/biosppy/plotting.py b/biosppy/plotting.py index 47bf578b..9a741ab3 100644 --- a/biosppy/plotting.py +++ b/biosppy/plotting.py @@ -10,6 +10,11 @@ """ # Imports +# compat +from __future__ import absolute_import, division, print_function +from six.moves import range, zip +import six + # built-in import os @@ -829,7 +834,7 @@ def _plot_multichannel(ts=None, if ylabel is not None: # middle left - a = nrows / 2 + a = nrows // 2 ax = axs[(a, 0)] ax.set_ylabel(ylabel) @@ -1042,7 +1047,7 @@ def plot_biometrics(assessment=None, eer_idx=None, path=None, show=False): id_ax = fig.add_subplot(122) # subject results - for sub in assessment['subject'].keys(): + for sub in six.iterkeys(assessment['subject']): auth_rates = assessment['subject'][sub]['authentication']['rates'] _ = _plot_rates(ths, auth_rates, ['FAR', 'FRR'], lw=MINOR_LW, @@ -1134,7 +1139,7 @@ def plot_clustering(data=None, clusters=None, path=None, show=False): ymin, ymax = _yscaling(data, alpha=1.2) # determine number of clusters - keys = list(clusters.keys()) + keys = list(clusters) nc = len(keys) if nc <= 4: diff --git a/biosppy/signals/__init__.py b/biosppy/signals/__init__.py index 4075ba43..4974a902 100644 --- a/biosppy/signals/__init__.py +++ b/biosppy/signals/__init__.py @@ -15,3 +15,9 @@ :copyright: (c) 2015 by Instituto de Telecomunicacoes :license: BSD 3-clause, see LICENSE for more details. """ + +# compat +from __future__ import absolute_import, division, print_function + +# allow lazy loading +from . import bvp, ecg, eda, eeg, emg, resp, tools diff --git a/biosppy/signals/bvp.py b/biosppy/signals/bvp.py index 95f4aa6f..d9dd4777 100644 --- a/biosppy/signals/bvp.py +++ b/biosppy/signals/bvp.py @@ -10,6 +10,10 @@ """ # Imports +# compat +from __future__ import absolute_import, division, print_function +from six.moves import range + # 3rd party import numpy as np diff --git a/biosppy/signals/ecg.py b/biosppy/signals/ecg.py index 00ef0310..d9dc89c4 100644 --- a/biosppy/signals/ecg.py +++ b/biosppy/signals/ecg.py @@ -12,6 +12,10 @@ """ # Imports +# compat +from __future__ import absolute_import, division, print_function +from six.moves import range, zip + # 3rd party import numpy as np import scipy.signal as ss @@ -280,6 +284,8 @@ def compare_segmentation(reference=None, test=None, sampling_rate=1000., if minRR is None: minRR = np.inf + sampling_rate = float(sampling_rate) + # ensure numpy reference = np.array(reference) test = np.array(test) diff --git a/biosppy/signals/eda.py b/biosppy/signals/eda.py index 1514cdc7..9da64bcb 100644 --- a/biosppy/signals/eda.py +++ b/biosppy/signals/eda.py @@ -11,6 +11,10 @@ """ # Imports +# compat +from __future__ import absolute_import, division, print_function +from six.moves import range + # 3rd party import numpy as np diff --git a/biosppy/signals/eeg.py b/biosppy/signals/eeg.py index 4b9c2927..f24a725d 100644 --- a/biosppy/signals/eeg.py +++ b/biosppy/signals/eeg.py @@ -11,6 +11,10 @@ """ # Imports +# compat +from __future__ import absolute_import, division, print_function +from six.moves import range + # 3rd party import numpy as np diff --git a/biosppy/signals/emg.py b/biosppy/signals/emg.py index 3416a8d0..49dbba32 100644 --- a/biosppy/signals/emg.py +++ b/biosppy/signals/emg.py @@ -10,6 +10,9 @@ """ # Imports +# compat +from __future__ import absolute_import, division, print_function + # 3rd party import numpy as np diff --git a/biosppy/signals/resp.py b/biosppy/signals/resp.py index 8c405e76..112a72fb 100644 --- a/biosppy/signals/resp.py +++ b/biosppy/signals/resp.py @@ -10,6 +10,9 @@ """ # Imports +# compat +from __future__ import absolute_import, division, print_function + # 3rd party import numpy as np diff --git a/biosppy/signals/tools.py b/biosppy/signals/tools.py index 75a964ce..76d81f11 100644 --- a/biosppy/signals/tools.py +++ b/biosppy/signals/tools.py @@ -11,6 +11,11 @@ """ # Imports +# compat +from __future__ import absolute_import, division, print_function +from six.moves import range +import six + # 3rd party import numpy as np import scipy.signal as ss @@ -479,7 +484,7 @@ def smoother(signal=None, kernel='boxzen', size=10, mirror=True, **kwargs): length = len(signal) - if isinstance(kernel, str): + if isinstance(kernel, six.string_types): # check length if size > length: size = length - 1 @@ -684,7 +689,7 @@ def power_spectrum(signal=None, npoints = 2 ** (np.ceil(np.log2(npoints))) Nyq = float(sampling_rate) / 2 - hpoints = npoints / 2 + hpoints = npoints // 2 freqs = np.linspace(0, Nyq, hpoints) power = np.abs(np.fft.fft(signal, npoints)) / npoints @@ -998,7 +1003,7 @@ def windower(signal=None, length = len(signal) - if isinstance(kernel, str): + if isinstance(kernel, six.string_types): # check size if size > length: raise ValueError("Window size must be smaller than signal length.") @@ -1019,7 +1024,7 @@ def windower(signal=None, raise ValueError("Step size must be at least 1.") # number of windows - nb = 1 + (length - size) / step + nb = 1 + (length - size) // step # check signal dimensionality if np.ndim(signal) == 2: diff --git a/biosppy/storage.py b/biosppy/storage.py index a89f0015..a8af03e5 100644 --- a/biosppy/storage.py +++ b/biosppy/storage.py @@ -10,6 +10,11 @@ """ # Imports +# compat +from __future__ import absolute_import, division, print_function +from six.moves import range +import six + # built-in import datetime import json @@ -320,7 +325,7 @@ def store_txt(path, data, sampling_rate=1000., resolution=None, date=None, if resolution is not None: header += "Resolution:= %d\n" % resolution if date is not None: - if isinstance(date, str): + if isinstance(date, six.string_types): header += "Date:= %s\n" % date elif isinstance(date, datetime.datetime): header += "Date:= %s\n" % date.isoformat() @@ -720,7 +725,7 @@ def del_signal_group(self, group=''): if node.name == '/signals': # delete all elements - for _, item in node.items(): + for _, item in six.iteritems(node): try: del self._file[item.name] except IOError: @@ -759,7 +764,7 @@ def list_signals(self, group='', recursive=False): raise KeyError("Inexistent signal group.") out = [] - for name, item in node.items(): + for name, item in six.iteritems(node): if isinstance(item, h5py.Dataset): out.append((group, name)) elif recursive and isinstance(item, h5py.Group): @@ -972,7 +977,7 @@ def del_event_group(self, group=''): if node.name == '/events': # delete all elements - for _, item in node.items(): + for _, item in six.iteritems(node): try: del self._file[item.name] except IOError: @@ -1011,7 +1016,7 @@ def list_events(self, group='', recursive=False): raise KeyError("Inexistent event group.") out = [] - for name, item in node.items(): + for name, item in six.iteritems(node): if isinstance(item, h5py.Group): try: _ = item.attrs['json'] diff --git a/biosppy/utils.py b/biosppy/utils.py index f3ca6f20..79f6aa97 100644 --- a/biosppy/utils.py +++ b/biosppy/utils.py @@ -10,6 +10,11 @@ """ # Imports +# compat +from __future__ import absolute_import, division, print_function +from six.moves import map, range, zip +import six + # built-in import collections import copy @@ -270,7 +275,7 @@ def as_dict(self): """ - return collections.OrderedDict(list(zip(self._names, self))) + return collections.OrderedDict(zip(self._names, self)) __dict__ = property(as_dict) @@ -291,7 +296,7 @@ def __getitem__(self, key): """ - if isinstance(key, str): + if isinstance(key, six.string_types): if key not in self._names: raise KeyError("Unknown key: %r." % key) diff --git a/setup.py b/setup.py index c9fb0212..9a7a906e 100644 --- a/setup.py +++ b/setup.py @@ -8,9 +8,9 @@ """ # Imports -import biosppy -import os from setuptools import find_packages, setup +import os +import re def read(*paths): @@ -21,9 +21,22 @@ def read(*paths): def get_version(): - """Get the module version""" + """Get the module version.""" + + with open('biosppy/version.py', 'rb') as fid: + txt = fid.read() + + m = re.search("version\s*=\s*'([\w.]+)'", txt) + + if m: + try: + ver = m.group(1) + except IndexError: + raise Exception("Could not parse version string.") + + ver = ver.strip() - return biosppy.__version__ + return ver setup(name='biosppy', From 8e6e8202f3f2decc99b49461acb73364a47a59bf Mon Sep 17 00:00:00 2001 From: Carlos Carreiras Date: Fri, 30 Dec 2016 17:06:40 +0000 Subject: [PATCH 4/6] Tweaked the module docstring format, updating the copyright year. --- biosppy/__init__.py | 10 +++++----- biosppy/biometrics.py | 24 ++++++++++++------------ biosppy/clustering.py | 12 ++++++------ biosppy/metrics.py | 10 +++++----- biosppy/plotting.py | 10 +++++----- biosppy/signals/__init__.py | 24 ++++++++++++------------ biosppy/signals/bvp.py | 10 +++++----- biosppy/signals/ecg.py | 12 ++++++------ biosppy/signals/eda.py | 12 ++++++------ biosppy/signals/eeg.py | 12 ++++++------ biosppy/signals/emg.py | 10 +++++----- biosppy/signals/resp.py | 10 +++++----- biosppy/signals/tools.py | 12 ++++++------ biosppy/storage.py | 10 +++++----- biosppy/utils.py | 10 +++++----- biosppy/version.py | 10 +++++----- docs/conf.py | 2 +- 17 files changed, 100 insertions(+), 100 deletions(-) diff --git a/biosppy/__init__.py b/biosppy/__init__.py index ac2f22e1..71efa12e 100644 --- a/biosppy/__init__.py +++ b/biosppy/__init__.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- """ - biosppy - ------- +biosppy +------- - A toolbox for biosignal processing written in Python. +A toolbox for biosignal processing written in Python. - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ # compat diff --git a/biosppy/biometrics.py b/biosppy/biometrics.py index 1b62c152..b87824fc 100644 --- a/biosppy/biometrics.py +++ b/biosppy/biometrics.py @@ -1,17 +1,17 @@ # -*- coding: utf-8 -*- """ - biosppy.biometrics - ------------------ - - This module provides classifier interfaces for identity recognition - (biometrics) applications. The core API methods are: - * enroll: add a new subject; - * dismiss: remove an existing subject; - * identify: determine the identity of collected biometric dataset; - * authenticate: verify the identity of collected biometric dataset. - - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +biosppy.biometrics +------------------ + +This module provides classifier interfaces for identity recognition +(biometrics) applications. The core API methods are: +* enroll: add a new subject; +* dismiss: remove an existing subject; +* identify: determine the identity of collected biometric dataset; +* authenticate: verify the identity of collected biometric dataset. + +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ # Imports diff --git a/biosppy/clustering.py b/biosppy/clustering.py index 8a950ccd..cbc74cb6 100644 --- a/biosppy/clustering.py +++ b/biosppy/clustering.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- """ - biosppy.clustering - ------------------ +biosppy.clustering +------------------ - This module provides various unsupervised machine learning (clustering) - algorithms. +This module provides various unsupervised machine learning (clustering) +algorithms. - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ # Imports diff --git a/biosppy/metrics.py b/biosppy/metrics.py index 1d731f54..f932c068 100644 --- a/biosppy/metrics.py +++ b/biosppy/metrics.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- """ - biosppy.metrics - --------------- +biosppy.metrics +--------------- - This module provides pairwise distance computation methods. +This module provides pairwise distance computation methods. - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ # Imports diff --git a/biosppy/plotting.py b/biosppy/plotting.py index 9a741ab3..118aedc9 100644 --- a/biosppy/plotting.py +++ b/biosppy/plotting.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- """ - biosppy.plotting - ---------------- +biosppy.plotting +---------------- - This module provides utilities to plot data. +This module provides utilities to plot data. - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ # Imports diff --git a/biosppy/signals/__init__.py b/biosppy/signals/__init__.py index 4974a902..27880fb5 100644 --- a/biosppy/signals/__init__.py +++ b/biosppy/signals/__init__.py @@ -1,19 +1,19 @@ # -*- coding: utf-8 -*- """ - biosppy.signals - --------------- +biosppy.signals +--------------- - This package provides methods to process common - physiological signals (biosignals): - * Blood Volume Pulse (BVP) - * Electrocardiogram (ECG) - * Electrodermal Activity (EDA) - * Electroencephalogram (EEG) - * Electromyogram (EMG) - * Respiration (Resp) +This package provides methods to process common +physiological signals (biosignals): + * Blood Volume Pulse (BVP) + * Electrocardiogram (ECG) + * Electrodermal Activity (EDA) + * Electroencephalogram (EEG) + * Electromyogram (EMG) + * Respiration (Resp) - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ # compat diff --git a/biosppy/signals/bvp.py b/biosppy/signals/bvp.py index d9dd4777..ea85c290 100644 --- a/biosppy/signals/bvp.py +++ b/biosppy/signals/bvp.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- """ - biosppy.signals.bvp - ------------------- +biosppy.signals.bvp +------------------- - This module provides methods to process Blood Volume Pulse (BVP) signals. +This module provides methods to process Blood Volume Pulse (BVP) signals. - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ # Imports diff --git a/biosppy/signals/ecg.py b/biosppy/signals/ecg.py index d9dc89c4..a60d96cb 100644 --- a/biosppy/signals/ecg.py +++ b/biosppy/signals/ecg.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- """ - biosppy.signals.ecg - ------------------- +biosppy.signals.ecg +------------------- - This module provides methods to process Electrocardiographic (ECG) signals. - Implemented code assumes a single-channel Lead I like ECG signal. +This module provides methods to process Electrocardiographic (ECG) signals. +Implemented code assumes a single-channel Lead I like ECG signal. - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ diff --git a/biosppy/signals/eda.py b/biosppy/signals/eda.py index 9da64bcb..0faff353 100644 --- a/biosppy/signals/eda.py +++ b/biosppy/signals/eda.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- """ - biosppy.signals.eda - ------------------- +biosppy.signals.eda +------------------- - This module provides methods to process Electrodermal Activity (EDA) - signals, also known as Galvanic Skin Response (GSR). +This module provides methods to process Electrodermal Activity (EDA) +signals, also known as Galvanic Skin Response (GSR). - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ # Imports diff --git a/biosppy/signals/eeg.py b/biosppy/signals/eeg.py index f24a725d..e8f09b5e 100644 --- a/biosppy/signals/eeg.py +++ b/biosppy/signals/eeg.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- """ - biosppy.signals.eeg - ------------------- +biosppy.signals.eeg +------------------- - This module provides methods to process Electroencephalographic (EEG) - signals. +This module provides methods to process Electroencephalographic (EEG) +signals. - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ # Imports diff --git a/biosppy/signals/emg.py b/biosppy/signals/emg.py index 49dbba32..d2db60f5 100644 --- a/biosppy/signals/emg.py +++ b/biosppy/signals/emg.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- """ - biosppy.signals.emg - ------------------- +biosppy.signals.emg +------------------- - This module provides methods to process Electromyographic (EMG) signals. +This module provides methods to process Electromyographic (EMG) signals. - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ # Imports diff --git a/biosppy/signals/resp.py b/biosppy/signals/resp.py index 112a72fb..c5abdba0 100644 --- a/biosppy/signals/resp.py +++ b/biosppy/signals/resp.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- """ - biosppy.signals.resp - -------------------- +biosppy.signals.resp +-------------------- - This module provides methods to process Respiration (Resp) signals. +This module provides methods to process Respiration (Resp) signals. - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ # Imports diff --git a/biosppy/signals/tools.py b/biosppy/signals/tools.py index 76d81f11..bfe12011 100644 --- a/biosppy/signals/tools.py +++ b/biosppy/signals/tools.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- """ - biosppy.signals.tools - --------------------- +biosppy.signals.tools +--------------------- - This module provides various signal analysis methods in the time and - frequency domains. +This module provides various signal analysis methods in the time and +frequency domains. - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ # Imports diff --git a/biosppy/storage.py b/biosppy/storage.py index a8af03e5..7368e776 100644 --- a/biosppy/storage.py +++ b/biosppy/storage.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- """ - biosppy.storage - --------------- +biosppy.storage +--------------- - This module provides several data storage methods. +This module provides several data storage methods. - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ # Imports diff --git a/biosppy/utils.py b/biosppy/utils.py index 79f6aa97..329ba843 100644 --- a/biosppy/utils.py +++ b/biosppy/utils.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- """ - biosppy.utils - ------------- +biosppy.utils +------------- - This module provides several frequently used functions and hacks. +This module provides several frequently used functions and hacks. - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ # Imports diff --git a/biosppy/version.py b/biosppy/version.py index 6c02122e..b651a602 100644 --- a/biosppy/version.py +++ b/biosppy/version.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- """ - biosppy.version - --------------- +biosppy.version +--------------- - Version tracker. +Version tracker. - :copyright: (c) 2015 by Instituto de Telecomunicacoes - :license: BSD 3-clause, see LICENSE for more details. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ version = '0.2.2' diff --git a/docs/conf.py b/docs/conf.py index 00ce1be9..b5f040e9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -77,7 +77,7 @@ def __getattr__(cls, name): # General information about the project. project = 'BioSPPy' -copyright = '2015, Instituto de Telecomunicacoes' +copyright = '2015-2017, Instituto de Telecomunicacoes' author = 'Instituto de Telecomunicacoes' # The version info for the project you're documenting, acts as replacement for From 11dd0b94324387e93b74468b06c3f53d21374987 Mon Sep 17 00:00:00 2001 From: Carlos Carreiras Date: Fri, 30 Dec 2016 17:07:56 +0000 Subject: [PATCH 5/6] Updated setup.py with compatibility for Python 3. --- setup.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 9a7a906e..690dfe30 100644 --- a/setup.py +++ b/setup.py @@ -5,6 +5,8 @@ A toolbox for biosignal processing written in Python. +:copyright: (c) 2015-2017 by Instituto de Telecomunicacoes +:license: BSD 3-clause, see LICENSE for more details. """ # Imports @@ -23,7 +25,7 @@ def read(*paths): def get_version(): """Get the module version.""" - with open('biosppy/version.py', 'rb') as fid: + with open('biosppy/version.py', 'r') as fid: txt = fid.read() m = re.search("version\s*=\s*'([\w.]+)'", txt) @@ -50,13 +52,18 @@ def get_version(): packages=find_packages(exclude=['tests*', 'docs*', 'examples']), # install_requires=[], include_package_data=True, - classifiers=['Development Status :: 3 - Alpha', + classifiers=['Development Status :: 4 - Beta', 'Intended Audience :: Developers', + 'Intended Audience :: Education', + 'Intended Audience :: Science/Research', 'License :: OSI Approved :: BSD License', 'Natural Language :: English', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.5', 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Education', + 'Topic :: Scientific/Engineering', ], ) From ab1f0e89d02fc53ad910f3006ec8431edd2034f0 Mon Sep 17 00:00:00 2001 From: Carlos Carreiras Date: Fri, 30 Dec 2016 17:08:16 +0000 Subject: [PATCH 6/6] Updated requirements file. --- requirements.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/requirements.txt b/requirements.txt index 2a9f8be3..884ea72f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,13 +1,13 @@ -bidict==0.11.0 -h5py==2.5.0 -matplotlib==1.5.1 +bidict==0.12.0 +h5py==2.6.0 +matplotlib==1.5.3 nose==1.3.7 -numpy==1.10.4 -pyparsing==2.0.3 -python-dateutil==2.4.2 -pytz==2015.4 -scikit-learn==0.17 -scipy==0.17.0 +numpy==1.11.1 +pyparsing==2.1.4 +python-dateutil==2.5.3 +pytz==2016.6.1 +scikit-learn==0.17.1 +scipy==0.18.1 shortuuid==0.4.3 -six==1.9.0 -wheel==0.24.0 +six==1.10.0 +wheel==0.29.0