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_dateCollectionWithNull() { ICollection <LocalDate> dates = Arrays.asList(DATE_2011_01_01, null); ICollection <double> values = SparseLocalDateDoubleTimeSeriesTest.values(2d, 3d); 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_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 test_of_collectionCollection_dateCollectionNull() { ICollection <double> values = SparseLocalDateDoubleTimeSeriesTest.values(2d, 3d); assertThrowsIllegalArg(() => LocalDateDoubleTimeSeries.builder().putAll((ICollection <LocalDate>)null, values).build()); }