Skip to content

Commit

Permalink
Merge pull request #149 from csu-hmc/python3
Browse files Browse the repository at this point in the history
Changes to support Python 3
  • Loading branch information
moorepants authored Jun 19, 2021
2 parents d12c1d7 + 51a78cd commit 55019bb
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
- DEP_VERSIONS="latest"
before_install:
- if [[ $DEP_VERSIONS == "oldest" ]]; then
sudo apt-get install -y -qq python-pip python-setuptools python-numpy python-scipy python-matplotlib python-tables python-nose python-coverage python-pandas python-sphinx python-mock python-numpydoc python-yaml;
sudo apt-get install -y -qq python-tk python-pip python-setuptools python-numpy python-scipy python-matplotlib python-tables python-nose python-coverage python-pandas python-sphinx python-mock python-numpydoc python-yaml;
sudo pip install --no-deps oct2py==2.4.2 DynamicistToolKit==0.4.0;
elif [[ $DEP_VERSIONS == "latest" ]]; then
MINICONDA_URL="https://repo.continuum.io/miniconda";
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2014-2015 Cleveland State University
Copyright 2014-2021 Cleveland State University

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
Expand Down
13 changes: 7 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,18 @@ Several Octave routines are included in the ``gaitanalysis/octave`` directory.
Installation
============

You will need Python 2.7 and setuptools to install the packages. Its best to
install the dependencies first (NumPy, SciPy, matplotlib, Pandas, PyTables).
The SciPy Stack instructions are helpful for this:
http://www.scipy.org/stackspec.html.
You will need Python 2.7 or 3.7+ and setuptools to install the packages. Its
best to install the dependencies first (NumPy, SciPy, matplotlib, Pandas,
PyTables).

Supported versions:

- python >= 2.7
- python >= 2.7 or >= 3.7
- numpy >= 1.8.2
- scipy >= 0.13.3
- matplotlib >= 1.3.1
- tables >= 3.1.1
- pandas >= 0.13.1
- pandas >= 0.13.1, <= 0.24.0
- pyyaml >= 3.10
- DynamicistToolKit >= 0.4.0
- oct2py >= 2.4.2
Expand Down Expand Up @@ -201,6 +200,7 @@ Release Notes
0.2.0
-----

- Support Python 3. [PR `#149`_]
- Minimum dependencies bumped to Ubuntu 14.04 LTS versions and tests run on
latest conda forge packages as of 2018/08/30. [PR `#140`_]
- The minimum version of the required dependency, DynamicistToolKit, was bumped
Expand All @@ -211,6 +211,7 @@ Release Notes
- Added note and setup.py check about higher oct2py versions required for
Windows.

.. _#149: https://github.com/csu-hmc/GaitAnalysisToolKit/pull/149
.. _#134: https://github.com/csu-hmc/GaitAnalysisToolKit/pull/134
.. _#135: https://github.com/csu-hmc/GaitAnalysisToolKit/pull/135
.. _#140: https://github.com/csu-hmc/GaitAnalysisToolKit/pull/140
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __getattr__(cls, name):

# General information about the project.
project = u'GaitAnalysisToolKit'
copyright = u'2013, Jason K. Moore'
copyright = u'2013-2021, Jason K. Moore'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
21 changes: 11 additions & 10 deletions env-dev-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ name: gaitanalysis-dev-latest
channels:
- conda-forge
dependencies:
- python =2.7.*
- numpy
- scipy
- coverage
- dynamicisttoolkit
- ipython
- matplotlib
- mock
- nose
- numpy
- numpydoc
- oct2py
- pandas <0.24
- pytables
- pandas
- python
- pyyaml
- dynamicisttoolkit
- oct2py
- nose
- scipy
- sphinx
- coverage
- mock
- numpydoc
2 changes: 1 addition & 1 deletion gaitanalysis/controlid.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, data, sensors, controls, validation_data=None):
self.controls = controls

if validation_data is None:
num_gait_cycles = data.shape[0] / 2
num_gait_cycles = data.shape[0] // 2
self.identification_data = data.iloc[:num_gait_cycles]
self.validation_data = data.iloc[num_gait_cycles:]
else:
Expand Down
15 changes: 9 additions & 6 deletions gaitanalysis/motek.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-

# standard library
from __future__ import division
import re
import os
from distutils.version import LooseVersion
Expand Down Expand Up @@ -190,7 +191,7 @@ def statistics(self):
try:
self.columns
except AttributeError:
raise StandardError("You must run the `identify()` method " +
raise AttributeError("You must run the `identify()` method " +
"before computing the statistics.")

df = self.data_frame[self.columns]
Expand Down Expand Up @@ -324,9 +325,10 @@ class DFlowData(object):
'rfoot', 'rtoes']

rotation_suffixes = ['.Rot' + c for c in ['X', 'Y', 'Z']]
segment_labels = [_segment + _suffix for _segment in dflow_segments for
_suffix in marker_coordinate_suffixes +
rotation_suffixes]
segment_labels = []
for _segment in dflow_segments:
for _suffix in marker_coordinate_suffixes + rotation_suffixes:
segment_labels.append(_segment + _suffix)

# TODO: These should be stored in the meta data for each trial because
# the names could theorectically change, as they are selected by the
Expand Down Expand Up @@ -771,7 +773,8 @@ def _relabel_analog_columns(self, data_frame):
'.Anlg': 'Sensor' + str(i+1).zfill(2) + '_' +
signal for i in range(num_sensors) for j,signal in enumerate(signals)}

channel_names = dict(force_channels.items() + sensor_channels.items())
channel_names = dict(tuple(force_channels.items()) +
tuple(sensor_channels.items()))

# update labels from meta file
try:
Expand Down Expand Up @@ -1220,7 +1223,7 @@ def orient_accelerometer(orientation, x_prime, y_prime, z_prime):

return x_inertial, y_inertial, z_inertial

for sensor, rot_matrix in self.meta['trial']['sensor-orientation'].iteritems():
for sensor, rot_matrix in self.meta['trial']['sensor-orientation'].items():
ax, ay, az = orient_accelerometer(np.array(rot_matrix),
data_frame[sensor + '_AccX'],
data_frame[sensor + '_AccY'],
Expand Down
2 changes: 1 addition & 1 deletion gaitanalysis/tests/test_controlid.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setup(self):
self.p = len(self.sensors)
self.q = len(self.controls)
self.r = 10
self.m = self.r / 2
self.m = self.r // 2

self.gain_inclusion_matrix = np.array(self.q * [self.p * [True]])
self.gain_inclusion_matrix[0, 1] = False
Expand Down
4 changes: 2 additions & 2 deletions gaitanalysis/tests/test_gait.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ def test_grf_landmarks(self, plot=False):
# Test for force plate version
gait_data = GaitData(self.data_frame)

min_idx = len(self.data_frame) / 3
max_idx = 2*len(self.data_frame) / 3
min_idx = len(self.data_frame) // 3
max_idx = 2*len(self.data_frame) // 3

min_time = self.data_frame.index.values.astype(float)[min_idx]
max_time = self.data_frame.index.values.astype(float)[max_idx]
Expand Down
14 changes: 7 additions & 7 deletions gaitanalysis/tests/test_motek.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

# builtin
import os
from time import strptime
from distutils.version import LooseVersion
from random import sample, choice

Expand Down Expand Up @@ -123,7 +122,7 @@ def test_statistics(self):

identifier = \
MissingMarkerIdentifier(self.with_constant[marker_columns])
assert_raises(StandardError, identifier.statistics)
assert_raises(AttributeError, identifier.statistics)


class TestSplineInterpolateOverMissing:
Expand Down Expand Up @@ -322,7 +321,7 @@ class TestDFlowData():
'Sitting', 'Standing', 'Relaxing']

meta_data = {'trial': {'id': 5,
'datetime': strptime('2013-10-03', "%Y-%m-%d"),
'datetime': '2013-10-03',
'notes': 'All about this trial.',
'nominal-speed': 5.0,
'nominal-speed-units': 'meters per second',
Expand Down Expand Up @@ -581,7 +580,8 @@ def create_sample_record_file(self):

time = self.record_data_frame['Time']

self.n_event_times = sorted(sample(time, self.number_of_events))
self.n_event_times = sorted(sample(time.values.tolist(),
self.number_of_events))
event_letters = self.possible_event_names[:self.number_of_events]
self.event_times = dict(zip(event_letters, self.n_event_times))

Expand Down Expand Up @@ -760,9 +760,9 @@ def test_hbm_column_labels(self):
hbm_lab, hbm_i, non_hbm_i = dflow_data._hbm_column_labels(all_labels)

assert self.dflow_hbm_labels == hbm_lab
assert hbm_i == range(len(self.mocap_labels_without_hbm),
len(self.mocap_labels_with_hbm))
assert non_hbm_i == range(len(self.mocap_labels_without_hbm))
assert hbm_i == list(range(len(self.mocap_labels_without_hbm),
len(self.mocap_labels_with_hbm)))
assert non_hbm_i == list(range(len(self.mocap_labels_without_hbm)))

def test_analog_channel_labels(self):
dflow_data = DFlowData(self.path_to_mocap_data_file)
Expand Down
13 changes: 6 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from os.path import join

from setuptools import setup, find_packages

exec(open('gaitanalysis/version.py').read())

description = \
"""Various tools for gait analysis used at the Cleveland State
University Human Motion and Control Lab."""
description = ("Various tools for gait analysis used at the Cleveland State "
"University Human Motion and Control Lab.")

octave_sub_dirs = ['2d_inverse_dynamics',
join('2d_inverse_dynamics', 'test'),
Expand All @@ -31,7 +29,7 @@
'scipy>=0.13.3',
'matplotlib>=1.3.1',
'tables>=3.1.1',
'pandas>=0.13.1',
'pandas>=0.13.1,<0.24',
'pyyaml>=3.10',
'DynamicistToolKit>=0.4.0',
'oct2py>=2.4.2']
Expand All @@ -53,8 +51,8 @@
# The following ensures that any of these files are installed to the
# system location.
package_data={'gaitanalysis': octave_rel_paths,
'gaitanalysis.tests': [join('data', glob)
for glob in ['*.txt', '*.csv', '*.yml']]},
'gaitanalysis.tests': [join('data', glob) for glob in
['*.txt', '*.csv', '*.yml']]},
tests_require=['nose>1.3.1'],
test_suite='nose.collector',
long_description=open('README.rst').read(),
Expand All @@ -63,6 +61,7 @@
'Intended Audience :: Science/Research',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.7',
'Topic :: Scientific/Engineering :: Physics',
],
)

0 comments on commit 55019bb

Please sign in to comment.