Skip to content

Commit

Permalink
Fix unit tests after recognizer experimentation
Browse files Browse the repository at this point in the history
Issue #321 Changes to parameter values in config files require adjustments to unit test results.
  • Loading branch information
towsey authored and atruskie committed Jun 12, 2020
1 parent 6feb37c commit 4433ec4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Acoustics.Test.AnalysisPrograms.Recognizers
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Acoustics.Test.TestHelpers;
using Acoustics.Tools.Wav;
using global::AnalysisPrograms.Recognizers;
Expand Down Expand Up @@ -56,17 +57,30 @@ public void TestRecognizer()
this.SaveTestOutput(
outputDirectory => GenericRecognizer.SaveDebugSpectrogram(results, null, outputDirectory, Recognizer.SpeciesName));

Assert.AreEqual(5, events.Count);
//this test returns two false-positives with the current component parameters.
Assert.AreEqual(7, events.Count);
Assert.IsNull(scoreTrack);
Assert.AreEqual(1, plots.Count);
Assert.AreEqual(1874, sonogram.FrameCount);

Assert.IsInstanceOfType(events[1], typeof(CompositeEvent));
var ev = (CompositeEvent)events[1];
Assert.IsInstanceOfType(events[2], typeof(CompositeEvent));
var ev = (CompositeEvent)events[2];

// event 2 should be a composite event.
Assert.AreEqual(16.656, ev.EventStartSeconds);
Assert.AreEqual(17.024, ev.EventEndSeconds);
Assert.AreEqual(3689, ev.BandWidthHertz);
Assert.AreEqual(17.008, ev.EventEndSeconds);
Assert.AreEqual(3596, ev.BandWidthHertz);

// event 2 should contain 5 component events
var componentEvents = ev.ComponentEvents;
Assert.AreEqual(5, componentEvents.Count);

// This tests that the component tracks are correctly combined.
//THis can also be tested somewhere else, starting with just the comosite event in json file.
var points = EventExtentions.GetCompositeTrack(componentEvents).ToArray();
Assert.AreEqual(16.672, points[1].Seconds.Minimum);
Assert.AreEqual(5425, points[1].Hertz.Minimum);
Assert.AreEqual(23.71245325, points[1].Value, 0.001);
}
}
}
26 changes: 14 additions & 12 deletions tests/Acoustics.Test/AnalysisPrograms/Recognizers/CisticolaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public class CisticolaTests : OutputDirectoryTest
/// <summary>
/// The canonical recording used for this recognizer is a 31 second recording .
/// </summary>
//private static readonly FileInfo TestAsset = PathHelper.ResolveAsset("Recordings", "ms1_2559_630118_20170402_075841_30_0.wav");
private static readonly FileInfo TestAsset = new FileInfo(@"C:\Ecoacoustics\WavFiles\TestNoiseRecordings\Cisticola\ms1_2559_628362_20170408_074841_30_0.wav");
private static readonly FileInfo TestAsset = PathHelper.ResolveAsset("Recordings", "ms1_2559_630118_20170402_075841_30_0.wav");
//private static readonly FileInfo TestAsset = new FileInfo(@"C:\Ecoacoustics\WavFiles\TestNoiseRecordings\Cisticola\ms1_2559_628362_20170408_074841_30_0.wav");

private static readonly FileInfo ConfigFile = PathHelper.ResolveConfigFile("RecognizerConfigFiles", "Towsey.CisticolaExilis.yml");
private static readonly CisticolaExilis Recognizer = new CisticolaExilis();
Expand Down Expand Up @@ -58,21 +58,23 @@ public void TestRecognizer()
this.SaveTestOutput(
outputDirectory => GenericRecognizer.SaveDebugSpectrogram(results, null, outputDirectory, Recognizer.SpeciesName));

Assert.AreEqual(8, events.Count);
// this test returns with two false-negatives.
// It is possible to get all positive events but creates excess FPs on test data.
Assert.AreEqual(17, events.Count);
Assert.IsNull(scoreTrack);
Assert.AreEqual(1, plots.Count);
Assert.AreEqual(2667, sonogram.FrameCount);
Assert.AreEqual(3747, sonogram.FrameCount);

Assert.IsInstanceOfType(events[1], typeof(CompositeEvent));
Assert.IsInstanceOfType(events[3], typeof(CompositeEvent));

var secondEvent = (CompositeEvent)events[1];
var secondEvent = (CompositeEvent)events[3];

Assert.AreEqual(5.375419501133787, secondEvent.EventStartSeconds);
Assert.AreEqual(6.0720181405895692, secondEvent.EventEndSeconds);
Assert.AreEqual(483, secondEvent.LowFrequencyHertz);
Assert.AreEqual(735, secondEvent.HighFrequencyHertz);
Assert.AreEqual(20.901882476071698, secondEvent.Score, TestHelper.AllowedDelta);
Assert.AreEqual(0.20786700431266195, secondEvent.ScoreNormalized, TestHelper.AllowedDelta);
Assert.AreEqual(7.28, secondEvent.EventStartSeconds);
Assert.AreEqual(7.432, secondEvent.EventEndSeconds);
Assert.AreEqual(2542, secondEvent.LowFrequencyHertz);
Assert.AreEqual(3100, secondEvent.HighFrequencyHertz);
Assert.AreEqual(17.91649081319, secondEvent.Score, TestHelper.AllowedDelta);
Assert.AreEqual(0.07765486486, secondEvent.ScoreNormalized, TestHelper.AllowedDelta);
}
}
}

0 comments on commit 4433ec4

Please sign in to comment.