Skip to content

Commit

Permalink
Wrote unit tests for Event filters
Browse files Browse the repository at this point in the history
Issue #390 While writing tests for unit methods made some changes to boundary conditions for hertz and duration values.
More unit tests could be done.
  • Loading branch information
towsey authored and atruskie committed Nov 1, 2020
1 parent 7c4cf23 commit f080005
Show file tree
Hide file tree
Showing 2 changed files with 369 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/AudioAnalysisTools/Events/EventFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ public static List<EventCommon> FilterOnBandwidth(List<EventCommon> events, doub
}

var maxBandwidth = average + (sd * sigmaThreshold);
var outputEvents = events.Where(ev => ((SpectralEvent)ev).BandWidthHertz > minBandwidth && ((SpectralEvent)ev).BandWidthHertz < maxBandwidth).ToList();
var outputEvents = events.Where(ev => ((SpectralEvent)ev).BandWidthHertz >= minBandwidth && ((SpectralEvent)ev).BandWidthHertz <= maxBandwidth).ToList();
return outputEvents;
}

public static List<EventCommon> FilterOnBandwidth(List<EventCommon> events, double minBandwidth, double maxBandwidth)
{
var outputEvents = events.Where(ev => ((SpectralEvent)ev).BandWidthHertz > minBandwidth && ((SpectralEvent)ev).BandWidthHertz < maxBandwidth).ToList();
var outputEvents = events.Where(ev => ((SpectralEvent)ev).BandWidthHertz >= minBandwidth && ((SpectralEvent)ev).BandWidthHertz <= maxBandwidth).ToList();
return outputEvents;
}

Expand All @@ -77,7 +77,7 @@ public static List<EventCommon> FilterOnBandwidth(List<EventCommon> events, doub
/// </summary>
public static List<SpectralEvent> FilterShortEvents(List<SpectralEvent> events, double minimumDurationSeconds)
{
var outputEvents = events.Where(ev => ev.EventDurationSeconds > minimumDurationSeconds).ToList();
var outputEvents = events.Where(ev => ev.EventDurationSeconds >= minimumDurationSeconds).ToList();
return outputEvents;
}

Expand All @@ -86,7 +86,7 @@ public static List<SpectralEvent> FilterShortEvents(List<SpectralEvent> events,
/// </summary>
public static List<SpectralEvent> FilterLongEvents(List<SpectralEvent> events, double maximumDurationSeconds)
{
var outputEvents = events.Where(ev => ev.EventDurationSeconds < maximumDurationSeconds).ToList();
var outputEvents = events.Where(ev => ev.EventDurationSeconds <= maximumDurationSeconds).ToList();
return outputEvents;
}

Expand All @@ -95,7 +95,7 @@ public static List<SpectralEvent> FilterLongEvents(List<SpectralEvent> events, d
/// </summary>
public static List<EventCommon> FilterOnDuration(List<EventCommon> events, double minimumDurationSeconds, double maximumDurationSeconds)
{
var outputEvents = events.Where(ev => ((SpectralEvent)ev).EventDurationSeconds > minimumDurationSeconds && ((SpectralEvent)ev).EventDurationSeconds < maximumDurationSeconds).ToList();
var outputEvents = events.Where(ev => ((SpectralEvent)ev).EventDurationSeconds >= minimumDurationSeconds && ((SpectralEvent)ev).EventDurationSeconds <= maximumDurationSeconds).ToList();
return outputEvents;
}

Expand All @@ -117,7 +117,7 @@ public static List<EventCommon> FilterOnDuration(List<EventCommon> events, doubl
}

var maxDuration = average + (sd * sigmaThreshold);
var outputEvents = events.Where(ev => ((SpectralEvent)ev).EventDurationSeconds > minDuration && ((SpectralEvent)ev).EventDurationSeconds < maxDuration).ToList();
var outputEvents = events.Where(ev => ((SpectralEvent)ev).EventDurationSeconds >= minDuration && ((SpectralEvent)ev).EventDurationSeconds <= maxDuration).ToList();
return outputEvents;
}

Expand Down
Loading

0 comments on commit f080005

Please sign in to comment.