public virtual void test_mapDates_notAscending()
        {
            IList <double>            values = SparseLocalDateDoubleTimeSeriesTest.values(1, 2, 4);
            LocalDateDoubleTimeSeries @base  = LocalDateDoubleTimeSeries.builder().putAll(DATES_2010_12, values).build();

            assertThrowsIllegalArg(() => @base.mapDates(date => date(2016, 1, 6)));
        }
        public virtual void test_of_collectionCollection_collectionsOfDifferentSize()
        {
            ICollection <LocalDate> dates  = SparseLocalDateDoubleTimeSeriesTest.dates(DATE_2011_01_01);
            ICollection <double>    values = SparseLocalDateDoubleTimeSeriesTest.values(2d, 3d);

            assertThrowsIllegalArg(() => LocalDateDoubleTimeSeries.builder().putAll(dates, values).build());
        }
        public virtual void test_of_collectionCollection_valueCollectionWithNull()
        {
            ICollection <LocalDate> dates  = SparseLocalDateDoubleTimeSeriesTest.dates(DATE_2011_01_01, DATE_2012_01_01);
            ICollection <double>    values = Arrays.asList(2d, null);

            assertThrowsIllegalArg(() => LocalDateDoubleTimeSeries.builder().putAll(dates, values).build());
        }
        public virtual void test_mapValues_invertSeries()
        {
            IList <double>            values         = SparseLocalDateDoubleTimeSeriesTest.values(1, 2, 4, 5, 8);
            LocalDateDoubleTimeSeries @base          = LocalDateDoubleTimeSeries.builder().putAll(DATES_2010_14, values).build();
            LocalDateDoubleTimeSeries test           = @base.mapValues(d => 1 / d);
            IList <double>            expectedValues = SparseLocalDateDoubleTimeSeriesTest.values(1, 0.5, 0.25, 0.2, 0.125);

            assertEquals(test, LocalDateDoubleTimeSeries.builder().putAll(DATES_2010_14, expectedValues).build());
        }
        public virtual void test_mapDates()
        {
            IList <double>            values        = SparseLocalDateDoubleTimeSeriesTest.values(1, 2, 4, 5, 8);
            LocalDateDoubleTimeSeries @base         = LocalDateDoubleTimeSeries.builder().putAll(DATES_2010_14, values).build();
            LocalDateDoubleTimeSeries test          = @base.mapDates(date => date.plusYears(1));
            ImmutableList <LocalDate> expectedDates = ImmutableList.of(DATE_2011_01_01, DATE_2012_01_01, DATE_2013_01_01, DATE_2014_01_01, LocalDate.of(2015, 1, 1));
            LocalDateDoubleTimeSeries expected      = LocalDateDoubleTimeSeries.builder().putAll(expectedDates, @base.values().boxed().collect(toList())).build();

            assertEquals(test, expected);
        }
        public virtual void test_filter_byDateAndValue()
        {
            IList <LocalDate>         dates  = SparseLocalDateDoubleTimeSeriesTest.dates(DATE_2010_01_01, DATE_2011_06_01, DATE_2012_01_01, DATE_2013_06_01, DATE_2014_01_01);
            LocalDateDoubleTimeSeries series = LocalDateDoubleTimeSeries.builder().putAll(dates, VALUES_10_14).build();

            LocalDateDoubleTimeSeries test = series.filter((ld, v) => ld.Year >= 2012 && v % 2 == 0);

            assertEquals(test.size(), 2);
            assertEquals(test.get(DATE_2012_01_01), double?.of(12d));
            assertEquals(test.get(DATE_2014_01_01), double?.of(14d));
        }
        //-------------------------------------------------------------------------
        public virtual void test_filter_byDate()
        {
            IList <LocalDate>         dates = SparseLocalDateDoubleTimeSeriesTest.dates(DATE_2010_01_01, DATE_2011_06_01, DATE_2012_01_01, DATE_2013_06_01, DATE_2014_01_01);
            LocalDateDoubleTimeSeries @base = LocalDateDoubleTimeSeries.builder().putAll(dates, VALUES_10_14).build();
            LocalDateDoubleTimeSeries test  = @base.filter((ld, v) => ld.MonthValue != 6);

            assertEquals(test.size(), 3);
            assertEquals(test.get(DATE_2010_01_01), double?.of(10d));
            assertEquals(test.get(DATE_2012_01_01), double?.of(12d));
            assertEquals(test.get(DATE_2014_01_01), double?.of(14d));
        }
        //-------------------------------------------------------------------------
        public virtual void test_of_collectionCollection()
        {
            ICollection <LocalDate>   dates  = SparseLocalDateDoubleTimeSeriesTest.dates(DATE_2011_01_01, DATE_2012_01_01);
            ICollection <double>      values = SparseLocalDateDoubleTimeSeriesTest.values(2d, 3d);
            LocalDateDoubleTimeSeries test   = LocalDateDoubleTimeSeries.builder().putAll(dates, values).build();

            assertEquals(test.Empty, false);
            assertEquals(test.size(), 2);
            assertEquals(test.containsDate(DATE_2010_01_01), false);
            assertEquals(test.containsDate(DATE_2011_01_01), true);
            assertEquals(test.containsDate(DATE_2012_01_01), true);
            assertEquals(test.get(DATE_2010_01_01), double?.empty());
            assertEquals(test.get(DATE_2011_01_01), double?.of(2d));
            assertEquals(test.get(DATE_2012_01_01), double?.of(3d));
            assertEquals(test.dates().toArray(), new object[] { DATE_2011_01_01, DATE_2012_01_01 });
            assertEquals(test.values().toArray(), new double[] { 2d, 3d });
        }
        public virtual void partitionByValue()
        {
            IList <LocalDate>         dates  = SparseLocalDateDoubleTimeSeriesTest.dates(DATE_2010_01_01, DATE_2011_06_01, DATE_2012_01_01, DATE_2013_06_01, DATE_2014_01_01);
            LocalDateDoubleTimeSeries series = LocalDateDoubleTimeSeries.builder().putAll(dates, VALUES_10_14).build();

            Pair <LocalDateDoubleTimeSeries, LocalDateDoubleTimeSeries> partition = series.partitionByValue(d => d > 10 && d < 14);

            LocalDateDoubleTimeSeries mid     = partition.First;
            LocalDateDoubleTimeSeries extreme = partition.Second;

            assertThat(mid.size()).isEqualTo(3);
            assertThat(extreme.size()).isEqualTo(2);

            assertThat(mid.get(DATE_2011_06_01)).hasValue(11);
            assertThat(mid.get(DATE_2012_01_01)).hasValue(12);
            assertThat(mid.get(DATE_2013_06_01)).hasValue(13);

            assertThat(extreme.get(DATE_2010_01_01)).hasValue(10);
            assertThat(extreme.get(DATE_2014_01_01)).hasValue(14);
        }
        public virtual void partition()
        {
            IList <LocalDate>         dates  = SparseLocalDateDoubleTimeSeriesTest.dates(DATE_2010_01_01, DATE_2011_06_01, DATE_2012_01_01, DATE_2013_06_01, DATE_2014_01_01);
            LocalDateDoubleTimeSeries series = LocalDateDoubleTimeSeries.builder().putAll(dates, VALUES_10_14).build();

            Pair <LocalDateDoubleTimeSeries, LocalDateDoubleTimeSeries> partition = series.partition((ld, d) => ld.Year % 2 == 0);

            LocalDateDoubleTimeSeries even = partition.First;
            LocalDateDoubleTimeSeries odd  = partition.Second;

            assertThat(even.size()).isEqualTo(3);
            assertThat(odd.size()).isEqualTo(2);

            assertThat(even.get(DATE_2010_01_01)).hasValue(10);
            assertThat(even.get(DATE_2012_01_01)).hasValue(12);
            assertThat(even.get(DATE_2014_01_01)).hasValue(14);

            assertThat(odd.get(DATE_2011_06_01)).hasValue(11);
            assertThat(odd.get(DATE_2013_06_01)).hasValue(13);
        }
        public virtual void test_of_collectionCollection_dateCollectionNull()
        {
            ICollection <double> values = SparseLocalDateDoubleTimeSeriesTest.values(2d, 3d);

            assertThrowsIllegalArg(() => LocalDateDoubleTimeSeries.builder().putAll((ICollection <LocalDate>)null, values).build());
        }