Skip to content

Commit

Permalink
Drop python 2 support (#829)
Browse files Browse the repository at this point in the history
NeuroM is now supported from python 3.5 to 3.8
  • Loading branch information
Benoit Coste authored Jul 15, 2020
1 parent db50cf0 commit 25da093
Show file tree
Hide file tree
Showing 26 changed files with 34 additions and 102 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: python
python:
- "2.7"
- "3.6"
- "3.7"
- "3.8"
cache: pip
install:
- pip install tox-travis
Expand All @@ -18,4 +18,4 @@ deploy:
on:
tags: true
branch: master
condition: "$TRAVIS_PYTHON_VERSION == 2.7"
condition: "$TRAVIS_PYTHON_VERSION == 3.6"
2 changes: 1 addition & 1 deletion doc/source/developer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ Then, run the tests manually in the ``virtualenv``. For example,
Python compatibility
--------------------

We test the code against Python 2.7, 3.5 and 3.6.
We test the code against Python 3.6 and 3.7.
38 changes: 0 additions & 38 deletions neurom/_compat.py

This file was deleted.

1 change: 0 additions & 1 deletion neurom/check/morphtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from neurom.core.dataformat import COLS
from neurom import morphmath as mm
from neurom.morphmath import principal_direction_extent
from neurom._compat import range, filter


def is_monotonic(neurite, tol):
Expand Down
1 change: 0 additions & 1 deletion neurom/check/neuron_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import numpy as np

from neurom import NeuriteType
from neurom._compat import zip
from neurom.check import CheckResult
from neurom.check.morphtree import get_flat_neurites, get_nonmonotonic_neurites
from neurom.core import Tree, iter_neurites, iter_sections, iter_segments
Expand Down
5 changes: 2 additions & 3 deletions neurom/check/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@

"""Runner for neuron morphology checks."""

import logging
from collections import OrderedDict
from importlib import import_module

from future.moves.collections import OrderedDict
import logging

from neurom.check import check_wrapper
from neurom.exceptions import ConfigError
Expand Down
1 change: 0 additions & 1 deletion neurom/check/tests/test_morphtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from neurom.check import morphtree as mt
from neurom.core import Neurite, NeuriteType, Section
from neurom.core.dataformat import COLS
from neurom._compat import range
from nose import tools as nt
import numpy as np
import os
Expand Down
1 change: 0 additions & 1 deletion neurom/check/tests/test_neuron_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from numpy.testing import assert_array_equal

from neurom import check, load_neuron
from neurom._compat import range
from neurom.check import neuron_checks as nrn_chk
from neurom.core.dataformat import COLS
from neurom.core.types import dendrite_filter
Expand Down
1 change: 0 additions & 1 deletion neurom/core/_neuron.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import numpy as np

from neurom import morphmath
from neurom._compat import filter, map, zip
from neurom.core._soma import Soma
from neurom.core.dataformat import COLS
from neurom.utils import memoize
Expand Down
1 change: 0 additions & 1 deletion neurom/core/tests/test_iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

import neurom as nm
from neurom import COLS, core, load_neuron
from neurom._compat import filter
from neurom.core import NeuriteIter, Tree

_path = os.path.dirname(os.path.abspath(__file__))
Expand Down
3 changes: 1 addition & 2 deletions neurom/core/tests/test_neuron.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@

import os
from copy import deepcopy
from pathlib import Path

from pathlib2 import Path
import numpy as np
from nose import tools as nt

import neurom as nm
from neurom._compat import zip
from neurom.core import graft_neuron, iter_segments

_path = os.path.dirname(os.path.abspath(__file__))
Expand Down
1 change: 0 additions & 1 deletion neurom/core/tests/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import sys
from nose import tools as nt
from neurom.core.tree import Tree
from neurom._compat import range

REF_TREE = Tree()
T11 = REF_TREE.add_child(Tree())
Expand Down
2 changes: 0 additions & 2 deletions neurom/core/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
"""Generic tree class and iteration functions."""
from collections import deque

from neurom._compat import filter


class Tree(object):
"""Simple recursive tree class."""
Expand Down
1 change: 0 additions & 1 deletion neurom/features/sectionfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

from neurom import morphmath as mm
from neurom.core.dataformat import COLS
from neurom._compat import range
from neurom.morphmath import interval_lengths


Expand Down
2 changes: 0 additions & 2 deletions neurom/fst/tests/test_feature_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

"""Test neurom._neuritefunc functionality."""

from neurom.features.tests.test_feature_compat import *

from neurom.fst import _bifurcationfunc as bifurcation
from neurom.fst import _neuronfunc as neuronfunc
from neurom.fst import _neuritefunc as _nf
Expand Down
1 change: 0 additions & 1 deletion neurom/geom/tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from neurom import load_neuron
from neurom.fst import _neuritefunc as _nf
from nose import tools as nt
from neurom._compat import zip

import numpy as np
import os
Expand Down
3 changes: 2 additions & 1 deletion neurom/io/hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@
There is one such row per measured point.
"""

from itertools import zip_longest

import h5py
import numpy as np
from future.moves.itertools import zip_longest

from .datawrapper import BlockNeuronBuilder, DataWrapper

Expand Down
5 changes: 2 additions & 3 deletions neurom/io/neurolucida.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

import numpy as np

from neurom._compat import StringType
from neurom.core.dataformat import COLS, POINT_TYPE

from .datawrapper import DataWrapper
Expand Down Expand Up @@ -78,7 +77,7 @@ def _match_section(section, match):
for i in range(5):
if i >= len(section):
return None
if isinstance(section[i], StringType) and section[i] in match:
if isinstance(section[i], str) and section[i] in match:
return match[section[i]]
return None

Expand Down Expand Up @@ -159,7 +158,7 @@ def _flatten_subsection(subsection, _type, offset, parent):
if row in ('Low', 'Generated', 'High', ):
continue

if isinstance(row[0], StringType):
if isinstance(row[0], str):
if len(row) in (4, 5, ):
if len(row) == 5:
assert row[4][0] == 'S', \
Expand Down
11 changes: 4 additions & 7 deletions neurom/io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@
import shutil
import tempfile
import uuid
from functools import partial
from functools import partial, lru_cache
from io import IOBase, open

from pylru import FunctionCacheManager

from neurom._compat import StringType, filter
from neurom.core.population import Population
from neurom.exceptions import NeuroMError, RawDataError
from neurom.fst._core import FstNeuron
Expand Down Expand Up @@ -71,7 +68,7 @@ def __init__(self, directory, file_ext=None, cache_size=None):
self.directory = directory
self.file_ext = file_ext
if cache_size is not None:
self.get = FunctionCacheManager(self.get, size=cache_size)
self.get = lru_cache(maxsize=cache_size)(self.get)

def _filepath(self, name):
"""File path to `name` morphology file."""
Expand Down Expand Up @@ -116,7 +113,7 @@ def get_files_by_path(path):
def load_neuron(handle, reader=None):
"""Build section trees from an h5 or swc file."""
rdw = load_data(handle, reader)
if isinstance(handle, StringType):
if isinstance(handle, str):
name = os.path.splitext(os.path.basename(handle))[0]
else:
name = None
Expand Down Expand Up @@ -146,7 +143,7 @@ def load_neurons(neurons,
if isinstance(neurons, (list, tuple)):
files = neurons
name = name if name is not None else 'Population'
elif isinstance(neurons, StringType):
elif isinstance(neurons, str):
files = get_files_by_path(neurons)
name = name if name is not None else os.path.basename(neurons)

Expand Down
3 changes: 1 addition & 2 deletions neurom/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@
Nothing fancy. Just commonly used functions using scipy functionality.
"""

from collections import namedtuple
from collections import namedtuple, OrderedDict
from enum import Enum, unique

import numpy as np
from future.moves.collections import OrderedDict
from scipy import stats as _st

FitResults = namedtuple('FitResults', ['params', 'errs', 'type'])
Expand Down
2 changes: 1 addition & 1 deletion neurom/tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_fit_normal_regression():
nt.assert_almost_equal(fit_.params[0], 10.019332055822, 12)
nt.assert_almost_equal(fit_.params[1], 0.978726207747, 12)
nt.assert_almost_equal(fit_.errs[0], 0.021479979161, 12)
nt.assert_almost_equal(fit_.errs[1], 0.745431659944, 12)
nt.assert_almost_equal(fit_.errs[1], 0.7369569123250506, 12)


def test_fit_default_is_normal():
Expand Down
1 change: 0 additions & 1 deletion neurom/view/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from scipy.linalg import norm
from scipy.spatial import ConvexHull

from neurom._compat import map # pylint: disable=ungrouped-imports

plt = None # refer to _get_plt()

Expand Down
12 changes: 6 additions & 6 deletions neurom/view/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ def test_get_figure():
fig_old = plt.figure()
fig, ax = get_figure(new_fig=False)
nt.eq_(fig, fig_old)
nt.eq_(ax.colNum, 0)
nt.eq_(ax.rowNum, 0)
nt.eq_(ax.get_subplotspec().colspan.start, 0)
nt.eq_(ax.get_subplotspec().rowspan.start, 0)

fig1, ax1 = get_figure(new_fig=True, subplot=224)
nt.ok_(fig1 != fig_old)
nt.eq_(ax1.colNum, 1)
nt.eq_(ax1.rowNum, 1)
nt.eq_(ax1.get_subplotspec().colspan.start, 1)
nt.eq_(ax1.get_subplotspec().rowspan.start, 1)

fig2, ax2 = get_figure(new_fig=True, subplot=[1, 1, 1])
nt.eq_(ax2.colNum, 0)
nt.eq_(ax2.rowNum, 0)
nt.eq_(ax2.get_subplotspec().colspan.start, 0)
nt.eq_(ax2.get_subplotspec().rowspan.start, 0)
plt.close('all')

fig = plt.figure()
Expand Down
1 change: 0 additions & 1 deletion neurom/view/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

import numpy as np
from neurom import NeuriteType, geom
from neurom._compat import zip
from neurom.core import iter_neurites, iter_segments, iter_sections
from neurom.core._soma import SomaCylinders
from neurom.core.dataformat import COLS
Expand Down
30 changes: 11 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,28 @@
""" Distribution configuration for neurom
"""
# pylint: disable=R0801
import os
from setuptools import setup
from setuptools import find_packages


REQS = ['click>=7.0',
'enum-compat>=0.0.2',
'future>=0.16.0',
setup(
description='NeuroM: a light-weight neuron morphology analysis package',
author='Blue Brain Project, EPFL',
url='http://https://github.com/BlueBrain/NeuroM',
install_requires=[
'click>=7.0',
'h5py>=2.7.1',
'matplotlib>=1.3.1',
'matplotlib>=3.2.1',
'numpy>=1.8.0',
'pylru>=1.0',
'pyyaml>=3.10',
'scipy>=1.2.0',
'tqdm>=4.8.4',
]


setup(
description='NeuroM: a light-weight neuron morphology analysis package',
author='Blue Brain Project, EPFL',
url='http://https://github.com/BlueBrain/NeuroM',
install_requires=REQS,
],
packages=find_packages(),
license='BSD',
scripts=['apps/raw_data_check',
'apps/morph_check',
'apps/morph_stats',
'apps/morph_stats',
],
entry_points={
'console_scripts': ['neurom=apps.__main__:cli']
Expand All @@ -66,17 +60,15 @@
'plotly': ['plotly>=3.6.0'],
},
include_package_data=True,
python_requires='>=3.5',
classifiers=[
'Development Status :: 6 - Mature',
'Intended Audience :: Education',
'Intended Audience :: Science/Research',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Scientific/Engineering :: Bio-Informatics',
],
use_scm_version={"local_scheme": "no-local-version"},
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ name = neurom
testdeps =
mock
nose
pathlib2

[tox]
envlist =
{py27,py36}
{py36,py37,py38}
py36-lint
py36-coverage
py36-docs
Expand Down

0 comments on commit 25da093

Please sign in to comment.