Skip to content

Commit

Permalink
Fixing broken Unit tests
Browse files Browse the repository at this point in the history
Issue #370 Some unit tests broken because changes to one of the Generic Algorithms have compromised others.
  • Loading branch information
towsey committed Sep 18, 2020
1 parent 8bab74f commit 190e770
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/AnalysisPrograms/Recognizers/GenericRecognizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public override RecognizerResults Recognize(
// Such combinations will increase bandwidth of the event and this property can be used later to weed out unlikely events.
var sequenceConfig = configuration.SyllableSequence;

if (sequenceConfig.CombinePossibleSyllableSequence)
if (sequenceConfig.NotNull() && sequenceConfig.CombinePossibleSyllableSequence)
{
// Must first convert events to spectral events.
var spectralEvents1 = allResults.NewEvents.Cast<SpectralEvent>().ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ public void TestOscillationAlgorithm()
},
};

config.CombineOverlappingEvents = false;

// filter on bandwidth
config.ExpectedBandwidth = 350;
config.BandwidthStandardDeviation = 20;

// filter on acousstic activity in nside bands.
// zero indicates no filtering.
config.NeighbourhoodUpperHertzBuffer = 0;
config.NeighbourhoodLowerHertzBuffer = 0;
config.NeighbourhoodDecibelBuffer = 0;

var results = recognizer.Recognize(recording, config, 100.Seconds(), null, this.TestOutputDirectory, null);

Assert.AreEqual(1, results.NewEvents.Count);
Expand All @@ -144,6 +156,7 @@ public void TestOscillationAlgorithm()
Assert.AreEqual(113.15, @event.EventEndSeconds, 0.5);
Assert.AreEqual(700, @event.LowFrequencyHertz, 0.1);
Assert.AreEqual(1050, @event.HighFrequencyHertz, 0.1);
Assert.AreEqual(350, @event.BandWidthHertz);
Assert.AreEqual("LowerBandDTMF_z", @event.Profile);
Assert.AreEqual("DTMF", @event.Name);
}
Expand Down Expand Up @@ -176,6 +189,18 @@ public void TestWhistleAlgorithm()
},
};

config.CombineOverlappingEvents = false;

// filter on bandwidth
config.ExpectedBandwidth = 90;
config.BandwidthStandardDeviation = 10;

// filter on acousstic activity in nside bands.
// zero indicates no filtering.
config.NeighbourhoodUpperHertzBuffer = 0;
config.NeighbourhoodLowerHertzBuffer = 0;
config.NeighbourhoodDecibelBuffer = 0;

var results = recognizer.Recognize(recording, config, 100.Seconds(), null, this.TestOutputDirectory, null);

Assert.AreEqual(1, results.NewEvents.Count);
Expand Down

0 comments on commit 190e770

Please sign in to comment.