Skip to content

Commit

Permalink
FIX: Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Jun 16, 2014
1 parent 58dee8f commit e01741f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion mne/epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def __init__(self, raw, events, event_id, tmin, tmax, baseline=(None, 0),
if on_missing == 'error':
raise ValueError(msg)
elif on_missing == 'warning':
logger.warn(msg)
logger.warning(msg)
warnings.warn(msg)
else: # on_missing == 'ignore':
pass
Expand Down
3 changes: 2 additions & 1 deletion mne/preprocessing/tests/test_ica.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ def test_ica_reject_buffer():
ica.fit(raw, picks[:5], reject=dict(mag=2.5e-12), decim=2,
tstep=0.01, verbose=True)
assert_true(raw._data[:5, ::2].shape[1] - 4 == ica.n_samples_)
log = [l for l in open(drop_log) if 'detected' in l]
with open(drop_log) as fid:
log = [l for l in fid if 'detected' in l]
assert_equal(len(log), 1)


Expand Down
2 changes: 1 addition & 1 deletion mne/source_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ def setup_source_space(subject, fname=True, spacing='oct6', surface='white',
"defaults to False, but the default will change to True in "
"release 0.9. Specify the parameter explicitly to avoid this "
"warning.")
logger.warn(msg)
logger.warning(msg)

cmd = ('setup_source_space(%s, fname=%s, spacing=%s, surface=%s, '
'overwrite=%s, subjects_dir=%s, add_dist=%s, verbose=%s)'
Expand Down
17 changes: 12 additions & 5 deletions mne/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
###############################################################################
# RANDOM UTILITIES

def _sort_keys(x):
"""Sort and return keys of dict"""
keys = list(x.keys()) # note: not thread-safe
idx = np.argsort([str(k) for k in keys])
keys = [keys[ii] for ii in idx]
return keys


def object_hash(x, h=None):
"""Hash a reasonable python object
Expand All @@ -60,9 +68,7 @@ def object_hash(x, h=None):
if h is None:
h = hashlib.md5()
if isinstance(x, dict):
keys = list(x.keys()) # note: not thread-safe
idx = np.argsort([str(k) for k in keys])
keys = [keys[ii] for ii in idx]
keys = _sort_keys(x)
for key in keys:
object_hash(key, h)
object_hash(x[key], h)
Expand Down Expand Up @@ -106,8 +112,8 @@ def object_diff(a, b, pre=''):
if type(a) != type(b):
out += pre + ' type mismatch (%s, %s)\n' % (type(a), type(b))
elif isinstance(a, dict):
k1s = sorted(a.keys())
k2s = sorted(b.keys())
k1s = _sort_keys(a)
k2s = _sort_keys(b)
m1 = set(k2s) - set(k1s)
if len(m1):
out += pre + ' x1 missing keys %s\n' % (m1)
Expand Down Expand Up @@ -1331,6 +1337,7 @@ def _chunk_read_ftp_resume(url, temp_file_name, local_file):
# chunk and will write it to file and update the progress bar
chunk_write = lambda chunk: _chunk_write(chunk, local_file, progress)
data.retrbinary(down_cmd, chunk_write)
data.close()


def _chunk_write(chunk, local_file, progress):
Expand Down

0 comments on commit e01741f

Please sign in to comment.