-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Largely refactoring. Code is non functional at this point. I did swap the underlying implementation for the Spectrogram matrix reading function. I covered it with unit tests to ensure compatibility.
- Loading branch information
Showing
19 changed files
with
321 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
Acoustics/Acoustics.Test/AudioAnalysisTools/Indices/IndexMatricesTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// <copyright file="IndexMatricesTests.cs" company="QutEcoacoustics"> | ||
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group). | ||
// </copyright> | ||
|
||
namespace Acoustics.Test.AudioAnalysisTools.Indices | ||
{ | ||
using System; | ||
using Acoustics.Shared.Csv; | ||
using Acoustics.Shared.Extensions; | ||
using global::AudioAnalysisTools.Indices; | ||
using global::TowseyLibrary; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using TestHelpers; | ||
|
||
[TestClass] | ||
public class IndexMatricesTests : OutputDirectoryTest | ||
{ | ||
[TestMethod] | ||
public void TestReadSpectrogram() | ||
{ | ||
var testSpectra = PathHelper.ResolveAssetPath("20160725_203006_continuous1__Towsey.Acoustic.ACI.csv"); | ||
|
||
var matrix = IndexMatrices.ReadSpectrogram(testSpectra.ToFileInfo(), out var binCount); | ||
|
||
Assert.AreEqual(30, matrix.GetLength(0)); | ||
Assert.AreEqual(256, matrix.GetLength(1)); | ||
Assert.AreEqual(256, binCount); | ||
|
||
Assert.AreEqual(0.462924678189025, matrix[0, 0]); | ||
Assert.AreEqual(0.42779069684277, matrix[0, 1]); | ||
Assert.AreEqual(0.46412042529103, matrix[1, 0]); | ||
Assert.AreEqual(0.444650614488611, matrix[1, 1]); | ||
} | ||
|
||
[TestMethod] | ||
public void TestWriteReadSpectrogram() | ||
{ | ||
var random = TestHelpers.Random.GetRandom(); | ||
var testSpectra = random.NextMatrix(100, 50); | ||
|
||
var testFile = this.outputDirectory.CombineFile("test.matrix.csv"); | ||
Csv.WriteMatrixToCsv(testFile, testSpectra); | ||
|
||
var matrix = IndexMatrices.ReadSpectrogram(testFile, out var binCount); | ||
|
||
Assert.AreEqual(100, matrix.GetLength(0)); | ||
Assert.AreEqual(50, matrix.GetLength(1)); | ||
Assert.AreEqual(50, binCount); | ||
|
||
var actualEnumerator = matrix.GetEnumerator(); | ||
foreach (var expected in testSpectra) | ||
{ | ||
actualEnumerator.MoveNext(); | ||
|
||
Assert.AreEqual(expected, (double)actualEnumerator.Current, 1E-14, $"delta: {expected - (double)actualEnumerator.Current}"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.