Skip to content

Commit

Permalink
Merge pull request #17 in INF/allensdk from import_check_improvements…
Browse files Browse the repository at this point in the history
… to dev

* commit '6782dc5fb432ce3dbd27619c52d0887f19066f4b':
  IT-14563; better import checking, remove leftover extra imports.
  • Loading branch information
tfliss committed Feb 28, 2017
2 parents 8ca828f + 6782dc5 commit 3c2656e
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 46 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ pypi_deploy:
python setup.py sdist upload --repository https://testpypi.python.org/pypi

pytest:
find -L . -name "test_*.py" -exec py.test --boxed --pep8 --cov-config coveragerc --cov=allensdk --cov-report html --junitxml=test-reports/test.xml {} \+
find -L . -name "test_*.py" -exec py.test --boxed --pep8 --cov-config coveragerc --cov=allensdk --cov-report html --assert=reinterp --junitxml=test-reports/test.xml {} \+

pytest_lax:
find -L . -name "test_*.py" -exec py.test --boxed --cov-config coveragerc --cov=allensdk --cov-report html --junitxml=test-reports/test.xml {} \+
find -L . -name "test_*.py" -exec py.test --boxed --cov-config coveragerc --cov=allensdk --cov-report html --assert=reinterp --junitxml=test-reports/test.xml {} \+

pytest_lite:
find -L . -name "test_*.py" -exec py.test --boxed --assert=rewrite --junitxml=test-reports/test.xml {} \+
find -L . -name "test_*.py" -exec py.test --boxed --assert=reinterp --junitxml=test-reports/test.xml {} \+

pylint:
pylint --disable=C allensdk > htmlcov/pylint.txt || exit 0
egrep '(import-error)|(Unable to import)|(Undefined variable)' htmlcov/pylint.txt > htmlcov/pylint_imports.txt
grep import-error htmlcov/pylint.txt > htmlcov/pylint_imports.txt

flake8:
flake8 --ignore=E201,E202,E226 --max-line-length=200 allensdk | grep -v "local variable '_' is assigned to but never used" > htmlcov/flake8.txt
grep "imported but unused" htmlcov/flake8.txt > htmlcov/imports.txt
flake8 --ignore=E201,E202,E226 --max-line-length=200 --filename 'allensdk/**/*.py' allensdk | grep -v "local variable '_' is assigned to but never used" > htmlcov/flake8.txt
grep -i "import" htmlcov/flake8.txt > htmlcov/imports.txt || exit 0

EXAMPLES=doc/_static/examples

Expand Down
1 change: 0 additions & 1 deletion allensdk/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import os
import errno
import warnings
from allensdk.deprecated import deprecated


class Api(object):
Expand Down
3 changes: 1 addition & 2 deletions allensdk/api/queries/glif_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@

import json
import logging

from ...deprecated import deprecated
from .rma_template import RmaTemplate
from ..cache import cacheable


class GlifApi(RmaTemplate):

Expand Down
10 changes: 4 additions & 6 deletions allensdk/brain_observatory/circle_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import pandas as pd
import math
import h5py

from matplotlib.colors import LinearSegmentedColormap, rgb2hex
from matplotlib.colors import LinearSegmentedColormap
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from matplotlib.path import Path
from matplotlib.collections import PatchCollection, LineCollection
import matplotlib.transforms as mxfms
import matplotlib.colors as mcolors
Expand Down Expand Up @@ -125,7 +123,7 @@ def build_hex_pack(n):
while len(pos) < n:
layer_pos = [ ]

for i,v in enumerate(vs):
for i,v in enumerate(vs):
x = - N * v[1] * sq32
y = N * v[0] * sq32

Expand All @@ -134,7 +132,7 @@ def build_hex_pack(n):
y -= 0.5 * v[1]

layer_pos.append([])
layer_pos[i].append([x,y])
layer_pos[i].append([x,y])
mag = 1
sign = 1

Expand All @@ -143,7 +141,7 @@ def build_hex_pack(n):
y += v[1] * mag * sign
mag += 1
sign = -sign
layer_pos[i].append([x,y])
layer_pos[i].append([x,y])

for j in range(N):
for i in range(len(vs)):
Expand Down
7 changes: 1 addition & 6 deletions allensdk/brain_observatory/observatory_plots.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import matplotlib

import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.collections import PatchCollection, LineCollection
from matplotlib.collections import PatchCollection
import matplotlib.patches as mpatches
import scipy.interpolate as si
from scipy.stats.mstats import zscore

import allensdk.brain_observatory.circle_plots as cplots
from contextlib import contextmanager

import h5py
import pandas as pd
import logging
import numpy as np

SI_RANGE = [ 0, 1.5 ]
Expand Down
4 changes: 2 additions & 2 deletions allensdk/core/brain_observatory_nwb_data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ def get_roi_mask_array(self, cell_specimen_ids=None):
roi_arr = np.zeros((len(roi_list), roi_list[0].shape[
0], roi_list[0].shape[1]), dtype=np.uint8)

for i, roi in enumerate(roi_list):
roi_arr[i, :, :] = roi
for i, an_roi in enumerate(roi_list):
roi_arr[i, :, :] = an_roi

return roi_arr

Expand Down
4 changes: 2 additions & 2 deletions allensdk/model/glif/glif_neuron_methods.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
""" The methods in this module are used for configuring dynamics and reset rules for the GlifNeuron.
For more details on how to use these methods, see :doc:`glif_models`.
"""
import logging
import functools
import numpy as np
from numpy.distutils.npy_pkg_config import VariableSet


#fast_threshold=[]
#slow_threshold=[]


class GlifNeuronMethod( object ):
""" A simple class to keep track of the name and parameters associated with a neuron method.
This class is initialized with a name, function, and parameters to pass to the function. The
Expand Down
2 changes: 1 addition & 1 deletion allensdk/test/brain_observatory/test_drifting_gratings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with Allen SDK. If not, see <http://www.gnu.org/licenses/>.

import matplotlib

from allensdk.brain_observatory.drifting_gratings import DriftingGratings
from allensdk.brain_observatory.stimulus_analysis import StimulusAnalysis

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with Allen SDK. If not, see <http://www.gnu.org/licenses/>.

import matplotlib

from allensdk.brain_observatory.locally_sparse_noise import LocallySparseNoise
from allensdk.brain_observatory.stimulus_analysis import StimulusAnalysis
import pytest
Expand Down
2 changes: 1 addition & 1 deletion allensdk/test/brain_observatory/test_natural_movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with Allen SDK. If not, see <http://www.gnu.org/licenses/>.

import matplotlib

from allensdk.brain_observatory.natural_movie import NaturalMovie
from allensdk.brain_observatory.stimulus_analysis import StimulusAnalysis
import pytest
Expand Down
2 changes: 1 addition & 1 deletion allensdk/test/brain_observatory/test_natural_scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with Allen SDK. If not, see <http://www.gnu.org/licenses/>.

import matplotlib

from allensdk.brain_observatory.natural_scenes import NaturalScenes
from allensdk.brain_observatory.stimulus_analysis import StimulusAnalysis
import pytest
Expand Down
2 changes: 0 additions & 2 deletions allensdk/test/brain_observatory/test_observatory_plots.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import pytest
import matplotlib
import os
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
from allensdk.core.brain_observatory_nwb_data_set import BrainObservatoryNwbDataSet
Expand Down
2 changes: 1 addition & 1 deletion allensdk/test/brain_observatory/test_session_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with Allen SDK. If not, see <http://www.gnu.org/licenses/>.

import matplotlib

import pytest
from mock import patch
from allensdk.core.brain_observatory_nwb_data_set import BrainObservatoryNwbDataSet
Expand Down
2 changes: 1 addition & 1 deletion allensdk/test/brain_observatory/test_static_gratings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with Allen SDK. If not, see <http://www.gnu.org/licenses/>.

import matplotlib

from allensdk.brain_observatory.static_gratings import StaticGratings
from allensdk.brain_observatory.stimulus_analysis import StimulusAnalysis
import pytest
Expand Down
3 changes: 1 addition & 2 deletions allensdk/test/brain_observatory/test_stimulus_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
# You should have received a copy of the GNU General Public License
# along with Allen SDK. If not, see <http://www.gnu.org/licenses/>.

import matplotlib

from allensdk.brain_observatory.stimulus_analysis import StimulusAnalysis
import pytest
from mock import patch, MagicMock
import itertools as it


@pytest.fixture
Expand Down
3 changes: 3 additions & 0 deletions allensdk/test/core/test_brain_observatory_nwb_data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
# You should have received a copy of the GNU General Public License
# along with Allen SDK. If not, see <http://www.gnu.org/licenses/>.


import numpy as np
from pkg_resources import resource_filename # @UnresolvedImport
from allensdk.core.brain_observatory_nwb_data_set import BrainObservatoryNwbDataSet
import pytest
import os


NWB_FLAVORS = []


if 'TEST_NWB_FILES' in os.environ:
nwb_list_file = os.environ['TEST_NWB_FILES']
else:
Expand Down
4 changes: 2 additions & 2 deletions allensdk/test/core/test_mouse_connectivity_manifest.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import pytest
from mock import Mock, MagicMock, patch
import numpy as np
import nrrd
import nrrd # noqa: F401
from allensdk.core import mouse_connectivity_cache
from allensdk.api.queries import mouse_connectivity_api


@pytest.fixture(scope='module', autouse=True)
def mock_imports():
import nrrd
import nrrd # noqa: F401
nrrd.read = MagicMock(name='nrrd_read_file_mcm',
return_value=('mock_annotation_data',
'mock_annotation_image'))
Expand Down
16 changes: 8 additions & 8 deletions allensdk/test/glif_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
from allensdk.api.queries.glif_api import GlifApi
import allensdk.core.json_utilities as json_utilities
from allensdk.model.glif.glif_neuron import GlifNeuron
from allensdk.model.glif.simulate_neuron import simulate_neuron
import os
import shutil
import logging
import matplotlib.pyplot as plt # noqa: #402
from allensdk.api.queries.glif_api import GlifApi # noqa: #402
import allensdk.core.json_utilities as json_utilities # noqa: #402
from allensdk.model.glif.glif_neuron import GlifNeuron # noqa: #402
from allensdk.model.glif.simulate_neuron import simulate_neuron # noqa: #402
import os # noqa: #402
import shutil # noqa: #402
import logging # noqa: #402


# NEURONAL_MODEL_ID = 491547163 # level 1 LIF
Expand Down
4 changes: 3 additions & 1 deletion allensdk/test/model/test_biophysical_perisomatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
# You should have received a copy of the GNU General Public License
# along with Allen SDK. If not, see <http://www.gnu.org/licenses/>.

import pytest, os, numpy
import pytest
import os
import numpy
from allensdk.model.biophys_sim.config import Config
from allensdk.model.biophysical.utils import Utils
from allensdk.core.dat_utilities import DatUtilities
Expand Down

0 comments on commit 3c2656e

Please sign in to comment.