Skip to content

Commit

Permalink
Merge pull request #364 from BlueBrain/refactor-deprecated
Browse files Browse the repository at this point in the history
Refactor deprecated API calls
  • Loading branch information
ilkilic authored Feb 5, 2024
2 parents 49a3bab + c5a78e7 commit c70d471
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 180 deletions.
68 changes: 35 additions & 33 deletions efel/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,35 +56,35 @@ def reset():
_double_settings = {}
_string_settings = {}

setDoubleSetting('spike_skipf', 0.1)
setIntSetting('max_spike_skip', 2)
setDoubleSetting('Threshold', _settings.threshold)
setDoubleSetting('DerivativeThreshold', _settings.derivative_threshold)
setDoubleSetting(
set_double_setting('spike_skipf', 0.1)
set_int_setting('max_spike_skip', 2)
set_double_setting('Threshold', _settings.threshold)
set_double_setting('DerivativeThreshold', _settings.derivative_threshold)
set_double_setting(
'DownDerivativeThreshold',
_settings.down_derivative_threshold)
setDoubleSetting('interp_step', 0.1)
setDoubleSetting('burst_factor', 1.5)
setDoubleSetting('strict_burst_factor', 2.0)
setDoubleSetting('voltage_base_start_perc', 0.9)
setDoubleSetting('voltage_base_end_perc', 1.0)
setDoubleSetting('current_base_start_perc', 0.9)
setDoubleSetting('current_base_end_perc', 1.0)
setDoubleSetting('rise_start_perc', 0.0)
setDoubleSetting('rise_end_perc', 1.0)
setDoubleSetting("initial_perc", 0.1)
setDoubleSetting("min_spike_height", 20.0)
setIntSetting("strict_stiminterval", 0)
setDoubleSetting("initburst_freq_threshold", 50)
setDoubleSetting("initburst_sahp_start", 5)
setDoubleSetting("initburst_sahp_end", 100)
setIntSetting("DerivativeWindow", 3)
setStrSetting("voltage_base_mode", "mean")
setStrSetting("current_base_mode", "mean")
setDoubleSetting("precision_threshold", 1e-10)
setDoubleSetting("sahp_start", 5.0)
setIntSetting("ignore_first_ISI", 1)
setDoubleSetting("impedance_max_freq", 50.0)
set_double_setting('interp_step', 0.1)
set_double_setting('burst_factor', 1.5)
set_double_setting('strict_burst_factor', 2.0)
set_double_setting('voltage_base_start_perc', 0.9)
set_double_setting('voltage_base_end_perc', 1.0)
set_double_setting('current_base_start_perc', 0.9)
set_double_setting('current_base_end_perc', 1.0)
set_double_setting('rise_start_perc', 0.0)
set_double_setting('rise_end_perc', 1.0)
set_double_setting("initial_perc", 0.1)
set_double_setting("min_spike_height", 20.0)
set_int_setting("strict_stiminterval", 0)
set_double_setting("initburst_freq_threshold", 50)
set_double_setting("initburst_sahp_start", 5)
set_double_setting("initburst_sahp_end", 100)
set_int_setting("DerivativeWindow", 3)
set_str_setting("voltage_base_mode", "mean")
set_str_setting("current_base_mode", "mean")
set_double_setting("precision_threshold", 1e-10)
set_double_setting("sahp_start", 5.0)
set_int_setting("ignore_first_ISI", 1)
set_double_setting("impedance_max_freq", 50.0)

_initialise()

Expand Down Expand Up @@ -127,7 +127,7 @@ def set_threshold(new_threshold: float) -> None:
as the traces, e.g. mV).
"""
_settings.threshold = new_threshold
setDoubleSetting('Threshold', _settings.threshold)
set_double_setting('Threshold', _settings.threshold)


@deprecated("Use set_threshold instead")
Expand All @@ -146,7 +146,7 @@ def set_derivative_threshold(new_derivative_threshold: float) -> None:
as the traces, e.g. mV/ms).
"""
_settings.derivative_threshold = new_derivative_threshold
setDoubleSetting('DerivativeThreshold', _settings.derivative_threshold)
set_double_setting('DerivativeThreshold', _settings.derivative_threshold)


@deprecated("Use set_derivative_threshold instead")
Expand Down Expand Up @@ -228,7 +228,9 @@ def get_distance(
cppcore.setFeatureDouble(item, [x for x in trace[item]])

if trace_check:
trace_check_success = getFeatureValues([trace], ['trace_check'])[0]
trace_check_success = get_feature_values(
[trace], ['trace_check'])[0] # type: ignore

if trace_check_success["trace_check"] is None:
return error_dist

Expand Down Expand Up @@ -452,18 +454,18 @@ def get_mean_feature_values(
calculation of the feature, or if the feature value array
was empty.
"""
featureDicts = getFeatureValues(
featureDicts = get_feature_values(
traces,
feature_names,
raise_warnings=raise_warnings)
for featureDict in featureDicts:
for featureDict in featureDicts: # type: ignore
for (key, values) in list(featureDict.items()):
if values is None or len(values) == 0:
featureDict[key] = None
else:
featureDict[key] = np.mean(values)

return featureDicts
return featureDicts # type: ignore


@deprecated("Use get_mean_feature_values instead")
Expand Down
Loading

0 comments on commit c70d471

Please sign in to comment.