Skip to content

Commit e7e15d6

Browse files
committed
convert all the NaN to nan
1 parent 8de1eac commit e7e15d6

File tree

7 files changed

+27
-26
lines changed

7 files changed

+27
-26
lines changed

CHANGES.rst

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Change Log
22
==========
33
Version 7
44
----------
5+
- **7.15**: change all the NaN to nan (followup of v7.12)
56
- **7.14**: micromed uses latin-1, not utf-8
67
- **7.13**: release to pypi
78
- **7.12**: tukey from scipy.signal.windows and nan instead of NaN for numpy

tests/test_ioeeg_utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
cumsum,
55
empty,
66
isnan,
7-
NaN
7+
nan
88
)
99
from numpy.testing import assert_array_equal
1010
from pytest import raises
@@ -59,10 +59,10 @@ def _assert_begsam_endsam(begsam, endsam):
5959
dat_on_disk, intervals = _generate_dat_on_disk()
6060

6161
expected_dat = arange(begsam, endsam).astype('float')
62-
expected_dat[(expected_dat < 0) & (expected_dat > intervals[-1])] = NaN
62+
expected_dat[(expected_dat < 0) & (expected_dat > intervals[-1])] = nan
6363

6464
dat = empty(endsam - begsam)
65-
dat.fill(NaN)
65+
dat.fill(nan)
6666

6767
for i_dat, blk, i_blk in _select_blocks(BLOCKS, begsam, endsam):
6868
# print('{: 3d}-{: 3d} = {: 3d}: {: 3d}-{: 3d}'.format(i_dat[0], i_dat[1], blk, i_blk[0], i_blk[1]))

wonambi/VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.14
1+
7.15

wonambi/source/linear.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from logging import getLogger
77
from multiprocessing import Pool
88

9-
from numpy import (arange, asarray, atleast_2d, empty, exp, isnan, NaN,
9+
from numpy import (arange, asarray, atleast_2d, empty, exp, isnan, nan,
1010
nansum)
1111
from numpy.linalg import norm
1212
try:
@@ -49,7 +49,7 @@ def __call__(self, data, parameter='chan'):
4949
for i, one_trl in enumerate(data):
5050
output.axis['surf'][i] = arange(self.inv.shape[0])
5151
output.data[i] = self.inv.dot(data.data[i])
52-
output.data[i][exclude_vert, ] = NaN
52+
output.data[i][exclude_vert, ] = nan
5353

5454
return output
5555

@@ -122,12 +122,12 @@ def calc_xyz2surf(surf, xyz, threshold=20, exponent=None, std=None):
122122
external_threshold_value = gauss(std, std) # this is around 0.607
123123
lg.debug('Values thresholded at ' + str(threshold_value))
124124

125-
xyz2surf[xyz2surf < threshold_value] = NaN
125+
xyz2surf[xyz2surf < threshold_value] = nan
126126

127127
# here we deal with vertices that are within the threshold value but far
128128
# from a single electrodes, so those remain empty
129129
sumval = nansum(xyz2surf, axis=1)
130-
sumval[sumval < external_threshold_value] = NaN
130+
sumval[sumval < external_threshold_value] = nan
131131

132132
# normalize by the number of electrodes
133133
xyz2surf /= atleast_2d(sumval).T

wonambi/trans/frequency.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from multiprocessing import Pool
77

88
from numpy import (arange, array, asarray, copy, empty, exp, isnan, log, max, mean,
9-
median, moveaxis, NaN, pi, real, reshape, sqrt, swapaxes, zeros)
9+
median, moveaxis, nan, pi, real, reshape, sqrt, swapaxes, zeros)
1010
from numpy.linalg import norm
1111
import numpy.fft as np_fft
1212
from scipy import fftpack
@@ -677,7 +677,7 @@ def _fft(x, s_freq, detrend='linear', taper=None, output='spectraldensity',
677677
x = detrend_func(x, axis=axis, type=detrend)
678678

679679
if has_nan.any():
680-
x[has_nan] = NaN
680+
x[has_nan] = nan
681681

682682
tapered = tapers * x[..., None, :]
683683

wonambi/trans/select.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from collections.abc import Iterable
1313
from logging import getLogger
1414

15-
from numpy import (arange, array, asarray, diff, empty, hstack, inf,
16-
issubsctype, linspace, nan_to_num, ndarray, ones, ravel,
15+
from numpy import (arange, array, asarray, diff, empty, hstack, inf,
16+
linspace, nan_to_num, ndarray, ones, ravel,
1717
setdiff1d, floor)
1818
from numpy.lib.stride_tricks import as_strided
1919
from math import isclose
@@ -78,7 +78,7 @@ def read_data(self, chan=[], ref_chan=[], grp_name=None, concat_chan=False,
7878
concat_chan : bool
7979
if True, data from all channels will be concatenated
8080
average_channels : bool
81-
if True, all channels will be averaged into a single virtual
81+
if True, all channels will be averaged into a single virtual
8282
channel with label 'avg_chan'
8383
max_s_freq: : int
8484
maximum sampling frequency
@@ -121,7 +121,7 @@ def read_data(self, chan=[], ref_chan=[], grp_name=None, concat_chan=False,
121121
t0, t1))
122122
active_chan = chan if chan else [seg['chan'].split(' (')[0]]
123123
if isinstance(active_chan, str):
124-
active_chan = [active_chan]
124+
active_chan = [active_chan]
125125
chan_to_read = active_chan + ref_chan
126126

127127
data = self.dataset.read_data(chan=chan_to_read, begtime=t0,
@@ -154,7 +154,7 @@ def read_data(self, chan=[], ref_chan=[], grp_name=None, concat_chan=False,
154154
[x(chan=ch)[0] for x in subseg])
155155

156156
if average_channels:
157-
one_segment.data[0] = one_segment.data[0].mean(0,
157+
one_segment.data[0] = one_segment.data[0].mean(0,
158158
keepdims=True)
159159
one_segment.axis['chan'][0] = array(['avg_chan'], dtype='<U2')
160160
active_chan = ['avg_chan']
@@ -248,7 +248,7 @@ def select(data, trial=None, invert=False, **axes_to_select):
248248
selected_values = asarray(values_to_select, dtype='U')
249249

250250
else:
251-
if isinstance(values_to_select, ndarray) and issubsctype(values_to_select.dtype, bool):
251+
if isinstance(values_to_select, ndarray) and issubclass(values_to_select.dtype, bool):
252252
bool_values = values_to_select
253253
elif (values_to_select[0] is None and
254254
values_to_select[1] is None):
@@ -325,7 +325,7 @@ def resample(data, s_freq, axis='time'):
325325
return output
326326

327327

328-
def smart_chan(dataset, simple_chan_name, test_chan=None):
328+
def smart_chan(dataset, simple_chan_name, test_chan=None):
329329
"""From a list of simple channel names, attempts to find the corresponding
330330
channel names in the dataset and returns a list (with same order).
331331
Parameters
@@ -334,19 +334,19 @@ def smart_chan(dataset, simple_chan_name, test_chan=None):
334334
info about record
335335
simple_chan_name : list of str
336336
simple names for channels, e.g. ['F3', 'Fp2', 'ECG']
337-
337+
338338
Returns
339339
-------
340340
list
341341
corresponding channel labels as they appear in dataset
342342
"""
343343
chan_key = {}
344-
344+
345345
if test_chan is None:
346346
orig_chan_name = dataset.header['chan_name']
347347
else:
348348
orig_chan_name = test_chan
349-
349+
350350
for s in simple_chan_name:
351351
# look for exact matches
352352
candidates = [x for x in orig_chan_name if s == x]
@@ -356,9 +356,9 @@ def smart_chan(dataset, simple_chan_name, test_chan=None):
356356
elif len(candidates) > 1:
357357
raise ValueError( f'The record contains {len(candidates)} '
358358
f'duplicates of channel label {s}')
359-
359+
360360
# look for s in first position
361-
candidates = [x for x in orig_chan_name if s == x[:min(len(s),
361+
candidates = [x for x in orig_chan_name if s == x[:min(len(s),
362362
len(x))]]
363363
if len(candidates) == 1:
364364
chan_key[s] = candidates[0]
@@ -367,7 +367,7 @@ def smart_chan(dataset, simple_chan_name, test_chan=None):
367367
# s appears in first position more than once
368368
raise ValueError(
369369
f'Too many candidates corresponding to {s}: {candidates}')
370-
370+
371371
# look for unique occurrences of s somewhere in chan label
372372
candidates = [x for x in orig_chan_name if s in x]
373373
if len(candidates) == 1:
@@ -383,7 +383,7 @@ def smart_chan(dataset, simple_chan_name, test_chan=None):
383383
raise ValueError(
384384
f'Too many candidates corresponding to {s}: {candidates}')
385385
raise ValueError(f'Unable to find channel containing {s}')
386-
386+
387387
return [chan_key[x] for x in simple_chan_name]
388388

389389

wonambi/widgets/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from ast import literal_eval
44
from logging import getLogger
55
from math import ceil, floor
6-
from numpy import arange, NaN
6+
from numpy import arange, nan
77
from os.path import dirname, join, realpath
88

99
from PyQt5.QtCore import QRectF, QSettings, Qt
@@ -302,7 +302,7 @@ def get_value(self, default=0):
302302
text = self.text()
303303

304304
if text == 'N/A':
305-
return NaN
305+
return nan
306306

307307
try:
308308
text = float(text)

0 commit comments

Comments
 (0)