Skip to content

Commit

Permalink
add test to cover single spike case in min_voltage_between_spikes
Browse files Browse the repository at this point in the history
  • Loading branch information
anilbey committed Dec 14, 2023
1 parent 83a57b1 commit 444bfe7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
5 changes: 2 additions & 3 deletions efel/cppcore/LibV5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,9 +1295,8 @@ int LibV5::min_voltage_between_spikes(mapStr2intVec& IntFeatureData,
const auto& intFeatures = getFeatures(IntFeatureData, {"peak_indices"});

if (intFeatures.at("peak_indices").size() < 2) {
setVec(DoubleFeatureData, StringData, "min_voltage_between_spikes",
vector<double>());
return 0;
throw FeatureComputationError(
"Size of peak_indices should be >= 2 for min_voltage_between_spikes");
}

vector<double> min_voltage_between_spikes;
Expand Down
20 changes: 20 additions & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,26 @@ def test_min_voltage_between_spikes1():
min_voltage_between_spikes_value)


def test_min_voltage_between_spikes_single_spike():
"""basic: Test min_voltage_between_spikes testing the edge case of 1 spike."""
import efel
efel.reset()

time, voltage = load_ascii_input(meanfrequency1_url)
# get the last 45% of time and voltage (contains a single spike)
time = time[-int(len(time) * 0.45):]
voltage = voltage[-int(len(voltage) * 0.45):]
# stim_start and stim_end are not effective for this feature
trace = {'T': time, 'V': voltage, 'stim_start': [-2], 'stim_end': [-1]}

features = ['min_voltage_between_spikes']
feature_values = \
efel.getFeatureValues(
[trace],
features)
assert feature_values[0]['min_voltage_between_spikes'] is None


def test_getFeatureNames():
"""basic: Test getting all feature names"""
import efel
Expand Down

0 comments on commit 444bfe7

Please sign in to comment.