Skip to content

Commit

Permalink
Modified failing tests to no longer fail
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Sol committed Jan 14, 2025
1 parent 324ca4d commit 8f555aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using MassSpectrometry;
using MzLibUtil;
using NUnit.Framework;
Expand Down Expand Up @@ -135,7 +136,8 @@ public void TestWriting(string filePath, string outfile, int loop)
Assert.That(readInScan.OneBasedScanNumber.Equals(writtenScan.OneBasedScanNumber));
Assert.That(readInScan.MsnOrder.Equals(writtenScan.MsnOrder));
Assert.That(readInScan.IsCentroid.Equals(writtenScan.IsCentroid));
Assert.That(readInScan.MassSpectrum.Equals(writtenScan.MassSpectrum));
Assert.That(readInScan.MassSpectrum.YArray, Is.EquivalentTo(writtenScan.MassSpectrum.YArray));
Assert.That(readInScan.MassSpectrum.XArray, Is.EquivalentTo(writtenScan.MassSpectrum.XArray.Select(x => Math.Round(x, 4, MidpointRounding.AwayFromZero))));
}

File.Delete(outfile);
Expand Down
3 changes: 2 additions & 1 deletion mzLib/Test/FileReadingTests/TestMzML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,8 @@ public void WriteMzmlTest()
Assert.AreEqual(2, reader.GetClosestOneBasedSpectrumNumber(2));

var newFirstValue = reader.GetOneBasedScan(1).MassSpectrum.FirstX;
Assert.AreEqual(oldFirstValue.Value, newFirstValue.Value, 1e-9);
Assert.AreNotEqual(oldFirstValue.Value, newFirstValue.Value);
Assert.AreEqual(Math.Round((double)oldFirstValue, 4, MidpointRounding.AwayFromZero), newFirstValue.Value, 1e-6);

var secondScan2 = reader.GetOneBasedScan(2);

Expand Down
10 changes: 5 additions & 5 deletions mzLib/Test/FileReadingTests/TestRawFileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ public static void TestPeakFilteringRawFileReader(string infile)

for (int j = 0; j < mzmlScan.MassSpectrum.XArray.Length; j++)
{
double roundedMzmlMz = Math.Round(mzmlScan.MassSpectrum.XArray[j], 2);
double roundedRawMz = Math.Round(rawScan.MassSpectrum.XArray[j], 2);
double roundedRawMz = Math.Round(rawScan.MassSpectrum.XArray[j], 4, MidpointRounding.AwayFromZero);

Assert.AreEqual(roundedMzmlMz, roundedRawMz);
// XArray is rounded to the 4th digit during CreateAndWrite
Assert.AreEqual(mzmlScan.MassSpectrum.XArray[j], roundedRawMz);

double roundedMzmlIntensity = Math.Round(mzmlScan.MassSpectrum.XArray[j], 0);
double roundedRawIntensity = Math.Round(rawScan.MassSpectrum.XArray[j], 0);
double roundedMzmlIntensity = Math.Round(mzmlScan.MassSpectrum.XArray[j], 0, MidpointRounding.AwayFromZero);
double roundedRawIntensity = Math.Round(rawScan.MassSpectrum.XArray[j], 0, MidpointRounding.AwayFromZero);

Assert.AreEqual(roundedMzmlIntensity, roundedRawIntensity);
}
Expand Down

0 comments on commit 8f555aa

Please sign in to comment.