Skip to content

Commit 5d66cce

Browse files
authored
Merge pull request #1486 from zm711/tidy-up
Clean-up unused imports and standardized order
2 parents d78ebb5 + a3c549d commit 5d66cce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+147
-188
lines changed

neo/core/analogsignal.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,13 @@
1818
"""
1919

2020
import logging
21-
22-
try:
23-
import scipy.signal
24-
except ImportError as err:
25-
HAVE_SCIPY = False
26-
else:
27-
HAVE_SCIPY = True
21+
from copy import deepcopy
2822

2923
import numpy as np
3024
import quantities as pq
3125

3226
from neo.core.baseneo import BaseNeo, MergeError, merge_annotations, intersect_annotations
3327
from neo.core.dataobject import DataObject
34-
from copy import copy, deepcopy
35-
3628
from neo.core.basesignal import BaseSignal
3729

3830
logger = logging.getLogger("Neo")
@@ -612,8 +604,9 @@ def downsample(self, downsampling_factor, **kwargs):
612604
-----
613605
For resampling the signal with a fixed number of samples, see `resample` method.
614606
"""
615-
616-
if not HAVE_SCIPY:
607+
try:
608+
import scipy.signal
609+
except ImportError as err:
617610
raise ImportError("Decimating requires availability of scipy.signal")
618611

619612
# Resampling is only permitted along the time axis (axis=0)
@@ -655,8 +648,10 @@ def resample(self, sample_count, **kwargs):
655648
For reducing the number of samples to a fraction of the original, see `downsample` method
656649
"""
657650

658-
if not HAVE_SCIPY:
659-
raise ImportError("Resampling requires availability of scipy.signal")
651+
try:
652+
import scipy.signal
653+
except ImportError as err:
654+
raise ImportError("Decimating requires availability of scipy.signal")
660655

661656
# Resampling is only permitted along the time axis (axis=0)
662657
if "axis" in kwargs:

neo/core/basesignal.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
can be created.
1515
"""
1616

17-
import copy
1817
import logging
1918
from copy import deepcopy
2019

@@ -123,7 +122,7 @@ def _apply_operator(self, other, op, *args):
123122
new_signal._copy_data_complement(self)
124123
# _copy_data_complement can't always copy array annotations,
125124
# so this needs to be done locally
126-
new_signal.array_annotations = copy.deepcopy(self.array_annotations)
125+
new_signal.array_annotations = deepcopy(self.array_annotations)
127126
return new_signal
128127

129128
def _get_required_attributes(self, signal, units):

neo/core/dataobject.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import quantities as pq
1212
import numpy as np
13+
1314
from neo.core.baseneo import BaseNeo, _check_annotations
1415

1516

neo/core/epoch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:module:`neo.core.baseneo`.
66
"""
77

8-
from copy import deepcopy, copy
8+
from copy import deepcopy
99
from numbers import Number
1010

1111
import numpy as np

neo/core/event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:module:`neo.core.baseneo`.
66
"""
77

8-
from copy import deepcopy, copy
8+
from copy import deepcopy
99

1010
import numpy as np
1111
import quantities as pq

neo/core/group.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
and :class:`Unit`.
77
"""
88

9-
from os import close
109
from neo.core.container import Container
1110
from neo.core.analogsignal import AnalogSignal
1211
from neo.core.container import Container

neo/core/imagesequence.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
the old object.
1818
"""
1919

20-
from neo.core.analogsignal import AnalogSignal, _get_sampling_rate
20+
2121
import quantities as pq
2222
import numpy as np
23+
24+
from neo.core.analogsignal import AnalogSignal, _get_sampling_rate
2325
from neo.core.baseneo import BaseNeo
2426
from neo.core.basesignal import BaseSignal
2527
from neo.core.dataobject import DataObject

neo/core/irregularlysampledsignal.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,8 @@
1919
the old object.
2020
"""
2121

22-
from copy import deepcopy, copy
22+
from copy import deepcopy
2323

24-
try:
25-
import scipy.signal
26-
except ImportError as err:
27-
HAVE_SCIPY = False
28-
else:
29-
HAVE_SCIPY = True
3024

3125
import numpy as np
3226
import quantities as pq
@@ -457,7 +451,9 @@ def resample(self, sample_count, **kwargs):
457451
The original :class:`AnalogSignal` is not modified.
458452
"""
459453

460-
if not HAVE_SCIPY:
454+
try:
455+
import scipy.signal
456+
except ImportError:
461457
raise ImportError("Resampling requires availability of scipy.signal")
462458

463459
# Resampling is only permitted along the time axis (axis=0)

neo/core/objectlist.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import sys
7+
78
from neo.core.baseneo import BaseNeo
89

910

neo/core/segment.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
from datetime import datetime
1010
from copy import deepcopy
1111

12-
import numpy as np
13-
1412

1513
from neo.core.analogsignal import AnalogSignal
1614
from neo.core.container import Container

0 commit comments

Comments
 (0)