Skip to content

Commit

Permalink
MAINT: make FIT_PARAMS and INIT_PARAMS private
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmainak committed Nov 8, 2018
1 parent cc4bd33 commit 81024fa
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions autoreject/autoreject.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
mem = Memory(cachedir='cachedir')
mem.clear(warn=False)

INIT_PARAMS = ('consensus', 'n_interpolate', 'picks',
'verbose', 'n_jobs', 'cv', 'random_state',
'thresh_method')
_INIT_PARAMS = ('consensus', 'n_interpolate', 'picks',
'verbose', 'n_jobs', 'cv', 'random_state',
'thresh_method')

FIT_PARAMS = ('threshes_', 'n_interpolate_', 'consensus_', 'picks_',
'loss_')
_FIT_PARAMS = ('threshes_', 'n_interpolate_', 'consensus_', 'picks_',
'loss_')


def _slicemean(obj, this_slice, axis):
Expand Down Expand Up @@ -103,7 +103,7 @@ def read_autoreject(fname):
ar : instance of autoreject.AutoReject
"""
state = read_hdf5(fname, title='autoreject')
init_kwargs = {param: state[param] for param in INIT_PARAMS}
init_kwargs = {param: state[param] for param in _INIT_PARAMS}
ar = AutoReject(**init_kwargs)
ar.__setstate__(state)
return ar
Expand Down Expand Up @@ -862,17 +862,17 @@ def __getstate__(self):
"""Get the state of autoreject as a dictionary."""
state = dict()

for param in INIT_PARAMS:
for param in _INIT_PARAMS:
state[param] = getattr(self, param)
for param in FIT_PARAMS:
for param in _FIT_PARAMS:
if hasattr(self, param):
state[param] = getattr(self, param)

if hasattr(self, 'local_reject_'):
state['local_reject_'] = dict()
for ch_type in self.local_reject_:
state['local_reject_'][ch_type] = dict()
for param in INIT_PARAMS[:4] + FIT_PARAMS[:3]:
for param in _INIT_PARAMS[:4] + _FIT_PARAMS[:3]:
state['local_reject_'][ch_type][param] = \
getattr(self.local_reject_[ch_type], param)
return state
Expand All @@ -885,14 +885,14 @@ def __setstate__(self, state):
for ch_type in state['local_reject_']:
init_kwargs = {
key: state['local_reject_'][ch_type][key]
for key in INIT_PARAMS[:4]
for key in _INIT_PARAMS[:4]
}
local_reject_[ch_type] = _AutoReject(**init_kwargs)
for key in FIT_PARAMS[:3]:
for key in _FIT_PARAMS[:3]:
setattr(local_reject_[ch_type], key,
state['local_reject_'][ch_type][key])
self.local_reject_ = local_reject_
elif param not in INIT_PARAMS:
elif param not in _INIT_PARAMS:
setattr(self, param, state[param])

def fit(self, epochs):
Expand Down

0 comments on commit 81024fa

Please sign in to comment.