<commit_before>﻿using InternalLogicEngineLayer;
using NUnit.Framework;
using Spectra;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Test
{
    [TestFixture]
    public class SearchModesTest
    {

        #region Public Methods

        [Test]
        public void TestSearchModeTest()
        {
            SearchMode sm = new TestSearchMode("My custom");
            Assert.IsTrue(sm.Accepts(2, 2));
            Assert.IsTrue(sm.Accepts(0.5, 4));
            Assert.IsFalse(sm.Accepts(0.5, 0.5));
            Assert.IsTrue(sm.Accepts(1, 1));
            Assert.AreEqual(2, sm.GetAllowedPrecursorMassIntervals(0.5).First().Minimum);
            Assert.AreEqual(0.5, sm.GetAllowedPrecursorMassIntervals(2).First().Minimum);
        }

        [Test]
        public void TestDotSearchMode()
        {
            DotSearchMode dsm1 = new DotSearchMode("test1", new double[] { 0, 1 }, new Tolerance(ToleranceUnit.Absolute, 0.1));

            Assert.IsTrue(dsm1.Accepts(1000, 1000));
            Assert.IsTrue(dsm1.Accepts(1000, 1000 + 0.1 / 2));
            Assert.IsFalse(dsm1.Accepts(1000, 1000 + 0.1 * 2));
            Assert.IsTrue(dsm1.Accepts(1000 + 0.1 / 2, 1000));
            Assert.IsFalse(dsm1.Accepts(1000 + 0.1 * 2, 1000));

            Assert.IsTrue(dsm1.Accepts(1000 + 1, 1000 + 0.1 / 2));
            Assert.IsFalse(dsm1.Accepts(1000 + 1, 1000 + 0.1 * 2));
            Assert.IsTrue(dsm1.Accepts(1000 + 1 + 0.1 / 2, 1000));
            Assert.IsFalse(dsm1.Accepts(1000 + 1 + 0.1 * 2, 1000));

            var theList = dsm1.GetAllowedPrecursorMassIntervals(100).ToList();

            Assert.AreEqual(99.9, theList[0].Minimum);
            Assert.AreEqual(100.1, theList[0].Maximum);
            Assert.AreEqual(100.9, theList[1].Minimum);
            Assert.AreEqual(101.1, theList[1].Maximum);

            DotSearchMode dsm2 = new DotSearchMode("test2", new double[] { 0, 1 }, new Tolerance(ToleranceUnit.PPM, 5));

            Assert.IsTrue(dsm2.Accepts(1000, 1000));
            Assert.IsTrue(dsm2.Accepts(1000, 1000 * (1 + 5.0 / 1e6 / 1.0000000001)));
            Assert.IsFalse(dsm2.Accepts(1000, 1000 * (1 + 5.0 / 1e6 * 1.0000000001)));
			Assert.IsTrue(dsm2.Accepts(1000* (1 - 5.0 / 1e6 / 1.0000000001), 1000 ));
            Assert.IsTrue(dsm2.Accepts(1000, 1000 * (1 - 5.0 / 1e6 / 1.0000000001)));
            Assert.IsFalse(dsm2.Accepts(1000, 1000 * (1 - 5.0 / 1e6 * 1.0000000001)));

            Assert.IsTrue(dsm2.Accepts(1, 1));
            Assert.IsTrue(dsm2.Accepts(1, 1 * (1 + 5.0 / 1e6 / 1.0000000001)));
            Assert.IsFalse(dsm2.Accepts(1, 1 * (1 + 5.0 / 1e6 * 1.0000000001)));
            Assert.IsTrue(dsm2.Accepts(1, 1 * (1 - 5.0 / 1e6 / 1.0000000001)));
            Assert.IsFalse(dsm2.Accepts(1, 1 * (1 - 5.0 / 1e6 * 1.0000000001)));

            Assert.IsTrue(dsm2.Accepts(1000000, 1000000));
            Assert.IsTrue(dsm2.Accepts(1000000, 1000000 * (1 + 5.0 / 1e6 /1.0000000001)));
            Assert.IsFalse(dsm2.Accepts(1000000, 1000000 * (1 + 5.0 / 1e6 * 1.0000000001)));
            Assert.IsTrue(dsm2.Accepts(1000000, 1000000 * (1 - 5.0 / 1e6 / 1.0000000001)));
            Assert.IsFalse(dsm2.Accepts(1000000, 1000000 * (1 - 5.0 / 1e6 * 1.0000000001)));

            var theList2 = dsm2.GetAllowedPrecursorMassIntervals(100).ToList();

            Assert.IsTrue(theList2[0].Contains(100));
            Assert.IsTrue(theList2[1].Contains(101));
        }

        [Test]
        public void TestIntervalsSearchMode()<commit_msg>attempt to fix test<commit_after>﻿using InternalLogicEngineLayer;
using NUnit.Framework;
using Spectra;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Test
{
    [TestFixture]
    public class SearchModesTest
    {

        #region Public Methods

        [Test]
        public void TestSearchModeTest()
        {
            SearchMode sm = new TestSearchMode("My custom");
            Assert.IsTrue(sm.Accepts(2, 2));
            Assert.IsTrue(sm.Accepts(0.5, 4));
            Assert.IsFalse(sm.Accepts(0.5, 0.5));
            Assert.IsTrue(sm.Accepts(1, 1));
            Assert.AreEqual(2, sm.GetAllowedPrecursorMassIntervals(0.5).First().Minimum);
            Assert.AreEqual(0.5, sm.GetAllowedPrecursorMassIntervals(2).First().Minimum);
        }

        [Test]
        public void TestDotSearchMode()
        {
            DotSearchMode dsm1 = new DotSearchMode("test1", new double[] { 0, 1 }, new Tolerance(ToleranceUnit.Absolute, 0.1));

            Assert.IsTrue(dsm1.Accepts(1000, 1000));
            Assert.IsTrue(dsm1.Accepts(1000, 1000 + 0.1 / 2));
            Assert.IsFalse(dsm1.Accepts(1000, 1000 + 0.1 * 2));
            Assert.IsTrue(dsm1.Accepts(1000 + 0.1 / 2, 1000));
            Assert.IsFalse(dsm1.Accepts(1000 + 0.1 * 2, 1000));

            Assert.IsTrue(dsm1.Accepts(1000 + 1, 1000 + 0.1 / 2));
            Assert.IsFalse(dsm1.Accepts(1000 + 1, 1000 + 0.1 * 2));
            Assert.IsTrue(dsm1.Accepts(1000 + 1 + 0.1 / 2, 1000));
            Assert.IsFalse(dsm1.Accepts(1000 + 1 + 0.1 * 2, 1000));

            var theList = dsm1.GetAllowedPrecursorMassIntervals(100).ToList();

            Assert.AreEqual(99.9, theList[0].Minimum);
            Assert.AreEqual(100.1, theList[0].Maximum);
            Assert.AreEqual(100.9, theList[1].Minimum);
            Assert.AreEqual(101.1, theList[1].Maximum);

            DotSearchMode dsm2 = new DotSearchMode("test2", new double[] { 0, 1 }, new Tolerance(ToleranceUnit.PPM, 5));

            Assert.IsTrue(dsm2.Accepts(1000, 1000));
            Assert.IsTrue(dsm2.Accepts(1000, 1000 * (1 + 5.0 / 1e6 / 1.0000001)));
            Assert.IsFalse(dsm2.Accepts(1000, 1000 * (1 + 5.0 / 1e6 * 1.0000001)));
			Assert.IsTrue(dsm2.Accepts(1000* (1 - 5.0 / 1e6 / 1.0000001), 1000 ));
            Assert.IsTrue(dsm2.Accepts(1000, 1000 * (1 - 5.0 / 1e6 / 1.0000001)));
            Assert.IsFalse(dsm2.Accepts(1000, 1000 * (1 - 5.0 / 1e6 * 1.0000001)));

            Assert.IsTrue(dsm2.Accepts(1, 1));
            Assert.IsTrue(dsm2.Accepts(1, 1 * (1 + 5.0 / 1e6 / 1.0000001)));
            Assert.IsFalse(dsm2.Accepts(1, 1 * (1 + 5.0 / 1e6 * 1.0000001)));
            Assert.IsTrue(dsm2.Accepts(1, 1 * (1 - 5.0 / 1e6 / 1.0000001)));
            Assert.IsFalse(dsm2.Accepts(1, 1 * (1 - 5.0 / 1e6 * 1.0000001)));

            Assert.IsTrue(dsm2.Accepts(1000000, 1000000));
            Assert.IsTrue(dsm2.Accepts(1000000, 1000000 * (1 + 5.0 / 1e6 /1.0000001)));
            Assert.IsFalse(dsm2.Accepts(1000000, 1000000 * (1 + 5.0 / 1e6 * 1.0000001)));
            Assert.IsTrue(dsm2.Accepts(1000000, 1000000 * (1 - 5.0 / 1e6 / 1.0000001)));
            Assert.IsFalse(dsm2.Accepts(1000000, 1000000 * (1 - 5.0 / 1e6 * 1.0000001)));

            var theList2 = dsm2.GetAllowedPrecursorMassIntervals(100).ToList();

            Assert.IsTrue(theList2[0].Contains(100));
            Assert.IsTrue(theList2[1].Contains(101));
        }

        [Test]
        public void TestIntervalsSearchMode()
{'fraction_non_alphanumeric': 0.15415415415415415, 'fraction_numerical': 0.14514514514514515, 'mean_word_length': 2.2682242990654204, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 13, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6401560', 'n_tokens_mistral': 3180, 'n_tokens_neox': 2451, 'n_words': 422}