Last active
December 30, 2018 00:54
-
-
Save spencerkclark/27ef5254434fc5c90e2ebbdd975930b9 to your computer and use it in GitHub Desktop.
Tests of first items
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
============================= test session starts ============================== | |
platform darwin -- Python 3.6.6, pytest-3.10.1, py-1.7.0, pluggy-0.8.0 -- //anaconda/envs/xarray-dev-37/bin/python | |
cachedir: .pytest_cache | |
rootdir: /Users/spencerclark/cftime-resample-simplifications, inifile: | |
collecting ... collected 64 items | |
test_first_items_current.py::test_first_items[downsampling-0-left-left-11M] PASSED [ 1%] | |
test_first_items_current.py::test_first_items[downsampling-0-left-left-8001H] PASSED [ 3%] | |
test_first_items_current.py::test_first_items[downsampling-0-left-left-600003T] PASSED [ 4%] | |
test_first_items_current.py::test_first_items[downsampling-0-left-left-3MS] PASSED [ 6%] | |
test_first_items_current.py::test_first_items[downsampling-0-left-right-11M] FAILED [ 7%] | |
test_first_items_current.py::test_first_items[downsampling-0-left-right-8001H] PASSED [ 9%] | |
test_first_items_current.py::test_first_items[downsampling-0-left-right-600003T] PASSED [ 10%] | |
test_first_items_current.py::test_first_items[downsampling-0-left-right-3MS] FAILED [ 12%] | |
test_first_items_current.py::test_first_items[downsampling-0-right-left-11M] PASSED [ 14%] | |
test_first_items_current.py::test_first_items[downsampling-0-right-left-8001H] PASSED [ 15%] | |
test_first_items_current.py::test_first_items[downsampling-0-right-left-600003T] PASSED [ 17%] | |
test_first_items_current.py::test_first_items[downsampling-0-right-left-3MS] PASSED [ 18%] | |
test_first_items_current.py::test_first_items[downsampling-0-right-right-11M] FAILED [ 20%] | |
test_first_items_current.py::test_first_items[downsampling-0-right-right-8001H] PASSED [ 21%] | |
test_first_items_current.py::test_first_items[downsampling-0-right-right-600003T] PASSED [ 23%] | |
test_first_items_current.py::test_first_items[downsampling-0-right-right-3MS] FAILED [ 25%] | |
test_first_items_current.py::test_first_items[downsampling-1-left-left-11M] PASSED [ 26%] | |
test_first_items_current.py::test_first_items[downsampling-1-left-left-8001H] PASSED [ 28%] | |
test_first_items_current.py::test_first_items[downsampling-1-left-left-600003T] PASSED [ 29%] | |
test_first_items_current.py::test_first_items[downsampling-1-left-left-3MS] PASSED [ 31%] | |
test_first_items_current.py::test_first_items[downsampling-1-left-right-11M] FAILED [ 32%] | |
test_first_items_current.py::test_first_items[downsampling-1-left-right-8001H] PASSED [ 34%] | |
test_first_items_current.py::test_first_items[downsampling-1-left-right-600003T] PASSED [ 35%] | |
test_first_items_current.py::test_first_items[downsampling-1-left-right-3MS] FAILED [ 37%] | |
test_first_items_current.py::test_first_items[downsampling-1-right-left-11M] PASSED [ 39%] | |
test_first_items_current.py::test_first_items[downsampling-1-right-left-8001H] PASSED [ 40%] | |
test_first_items_current.py::test_first_items[downsampling-1-right-left-600003T] PASSED [ 42%] | |
test_first_items_current.py::test_first_items[downsampling-1-right-left-3MS] PASSED [ 43%] | |
test_first_items_current.py::test_first_items[downsampling-1-right-right-11M] FAILED [ 45%] | |
test_first_items_current.py::test_first_items[downsampling-1-right-right-8001H] PASSED [ 46%] | |
test_first_items_current.py::test_first_items[downsampling-1-right-right-600003T] PASSED [ 48%] | |
test_first_items_current.py::test_first_items[downsampling-1-right-right-3MS] FAILED [ 50%] | |
test_first_items_current.py::test_first_items[upsampling-0-left-left-11M] FAILED [ 51%] | |
test_first_items_current.py::test_first_items[upsampling-0-left-left-8001H] FAILED [ 53%] | |
test_first_items_current.py::test_first_items[upsampling-0-left-left-600003T] PASSED [ 54%] | |
test_first_items_current.py::test_first_items[upsampling-0-left-left-3MS] FAILED [ 56%] | |
test_first_items_current.py::test_first_items[upsampling-0-left-right-11M] FAILED [ 57%] | |
test_first_items_current.py::test_first_items[upsampling-0-left-right-8001H] FAILED [ 59%] | |
test_first_items_current.py::test_first_items[upsampling-0-left-right-600003T] PASSED [ 60%] | |
test_first_items_current.py::test_first_items[upsampling-0-left-right-3MS] FAILED [ 62%] | |
test_first_items_current.py::test_first_items[upsampling-0-right-left-11M] FAILED [ 64%] | |
test_first_items_current.py::test_first_items[upsampling-0-right-left-8001H] FAILED [ 65%] | |
test_first_items_current.py::test_first_items[upsampling-0-right-left-600003T] PASSED [ 67%] | |
test_first_items_current.py::test_first_items[upsampling-0-right-left-3MS] FAILED [ 68%] | |
test_first_items_current.py::test_first_items[upsampling-0-right-right-11M] FAILED [ 70%] | |
test_first_items_current.py::test_first_items[upsampling-0-right-right-8001H] FAILED [ 71%] | |
test_first_items_current.py::test_first_items[upsampling-0-right-right-600003T] PASSED [ 73%] | |
test_first_items_current.py::test_first_items[upsampling-0-right-right-3MS] FAILED [ 75%] | |
test_first_items_current.py::test_first_items[upsampling-1-left-left-11M] FAILED [ 76%] | |
test_first_items_current.py::test_first_items[upsampling-1-left-left-8001H] FAILED [ 78%] | |
test_first_items_current.py::test_first_items[upsampling-1-left-left-600003T] PASSED [ 79%] | |
test_first_items_current.py::test_first_items[upsampling-1-left-left-3MS] FAILED [ 81%] | |
test_first_items_current.py::test_first_items[upsampling-1-left-right-11M] FAILED [ 82%] | |
test_first_items_current.py::test_first_items[upsampling-1-left-right-8001H] FAILED [ 84%] | |
test_first_items_current.py::test_first_items[upsampling-1-left-right-600003T] PASSED [ 85%] | |
test_first_items_current.py::test_first_items[upsampling-1-left-right-3MS] FAILED [ 87%] | |
test_first_items_current.py::test_first_items[upsampling-1-right-left-11M] FAILED [ 89%] | |
test_first_items_current.py::test_first_items[upsampling-1-right-left-8001H] FAILED [ 90%] | |
test_first_items_current.py::test_first_items[upsampling-1-right-left-600003T] PASSED [ 92%] | |
test_first_items_current.py::test_first_items[upsampling-1-right-left-3MS] FAILED [ 93%] | |
test_first_items_current.py::test_first_items[upsampling-1-right-right-11M] FAILED [ 95%] | |
test_first_items_current.py::test_first_items[upsampling-1-right-right-8001H] FAILED [ 96%] | |
test_first_items_current.py::test_first_items[upsampling-1-right-right-600003T] PASSED [ 98%] | |
test_first_items_current.py::test_first_items[upsampling-1-right-right-3MS] FAILED [100%] | |
=================================== FAILURES =================================== | |
_______________ test_first_items[downsampling-0-left-right-11M] ________________ | |
datetimeindex = DatetimeIndex(['2000-01-01 12:00:01', '2000-01-02 12:00:01', | |
'2000-01-03 12:00:01', '2000-01-04 12:00:0... '2002-06-18 12:00:01', '2002-06-19 12:00:01'], | |
dtype='datetime64[ns]', length=901, freq='D') | |
cftimeindex = CFTimeIndex([2000-01-01 12:00:01, 2000-01-02 12:00:01, 2000-01-03 12:00:01, | |
2000-01-04 12:00:01, 2000-01-...1, 2002-06-17 12:00:01, 2002-06-18 12:00:01, | |
2002-06-19 12:00:01], | |
dtype='object', length=901) | |
freq = '11M', closed = 'right', label = 'left', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 1999-02-28 0\n2000-01-31 30\n2000-12-31 365\n2001-11-30 699\ndtype: int64>(1999-02-28 0\n2000-01-31 31\n2000-12-31 366\n2001-11-30 700\nFreq: 11M, dtype: int64) | |
E + where <bound method NDFrame.equals of 1999-02-28 0\n2000-01-31 30\n2000-12-31 365\n2001-11-30 699\ndtype: int64> = 1999-02-28 0\n2000-01-31 30\n2000-12-31 365\n2001-11-30 699\ndtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
_______________ test_first_items[downsampling-0-left-right-3MS] ________________ | |
datetimeindex = DatetimeIndex(['2000-01-01 12:00:01', '2000-01-02 12:00:01', | |
'2000-01-03 12:00:01', '2000-01-04 12:00:0... '2002-06-18 12:00:01', '2002-06-19 12:00:01'], | |
dtype='datetime64[ns]', length=901, freq='D') | |
cftimeindex = CFTimeIndex([2000-01-01 12:00:01, 2000-01-02 12:00:01, 2000-01-03 12:00:01, | |
2000-01-04 12:00:01, 2000-01-...1, 2002-06-17 12:00:01, 2002-06-18 12:00:01, | |
2002-06-19 12:00:01], | |
dtype='object', length=901) | |
freq = '3MS', closed = 'right', label = 'left', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 1999-10-01 0.0\n2000-01-01 91.0\n2000-04-01 182.0\n2000-07-01 274.0\n2000-1...6.0\n2001-04-01 547.0\n2001-07-01 639.0\n2001-10-01 731.0\n2002-01-01 821.0\n2002-04-01 NaN\ndtype: float64>(1999-10-01 NaN\n2000-01-01 0.0\n2000-04-01 91.0\n2000-07-01 182.0\n2000-10-01 274.0\n2001-01-01 366....4-01 456.0\n2001-07-01 547.0\n2001-10-01 639.0\n2002-01-01 731.0\n2002-04-01 821.0\nFreq: 3MS, dtype: float64) | |
E + where <bound method NDFrame.equals of 1999-10-01 0.0\n2000-01-01 91.0\n2000-04-01 182.0\n2000-07-01 274.0\n2000-1...6.0\n2001-04-01 547.0\n2001-07-01 639.0\n2001-10-01 731.0\n2002-01-01 821.0\n2002-04-01 NaN\ndtype: float64> = 1999-10-01 0.0\n2000-01-01 91.0\n2000-04-01 182.0\n2000-07-01 274.0\n2000-10-01 366.0\n2001-01-01 456.0\n2001-04-01 547.0\n2001-07-01 639.0\n2001-10-01 731.0\n2002-01-01 821.0\n2002-04-01 NaN\ndtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
_______________ test_first_items[downsampling-0-right-right-11M] _______________ | |
datetimeindex = DatetimeIndex(['2000-01-01 12:00:01', '2000-01-02 12:00:01', | |
'2000-01-03 12:00:01', '2000-01-04 12:00:0... '2002-06-18 12:00:01', '2002-06-19 12:00:01'], | |
dtype='datetime64[ns]', length=901, freq='D') | |
cftimeindex = CFTimeIndex([2000-01-01 12:00:01, 2000-01-02 12:00:01, 2000-01-03 12:00:01, | |
2000-01-04 12:00:01, 2000-01-...1, 2002-06-17 12:00:01, 2002-06-18 12:00:01, | |
2002-06-19 12:00:01], | |
dtype='object', length=901) | |
freq = '11M', closed = 'right', label = 'right', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-01-31 0\n2000-12-31 30\n2001-11-30 365\n2002-10-31 699\ndtype: int64>(2000-01-31 0\n2000-12-31 31\n2001-11-30 366\n2002-10-31 700\nFreq: 11M, dtype: int64) | |
E + where <bound method NDFrame.equals of 2000-01-31 0\n2000-12-31 30\n2001-11-30 365\n2002-10-31 699\ndtype: int64> = 2000-01-31 0\n2000-12-31 30\n2001-11-30 365\n2002-10-31 699\ndtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
_______________ test_first_items[downsampling-0-right-right-3MS] _______________ | |
datetimeindex = DatetimeIndex(['2000-01-01 12:00:01', '2000-01-02 12:00:01', | |
'2000-01-03 12:00:01', '2000-01-04 12:00:0... '2002-06-18 12:00:01', '2002-06-19 12:00:01'], | |
dtype='datetime64[ns]', length=901, freq='D') | |
cftimeindex = CFTimeIndex([2000-01-01 12:00:01, 2000-01-02 12:00:01, 2000-01-03 12:00:01, | |
2000-01-04 12:00:01, 2000-01-...1, 2002-06-17 12:00:01, 2002-06-18 12:00:01, | |
2002-06-19 12:00:01], | |
dtype='object', length=901) | |
freq = '3MS', closed = 'right', label = 'right', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-01-01 0.0\n2000-04-01 91.0\n2000-07-01 182.0\n2000-10-01 274.0\n2001-0...6.0\n2001-07-01 547.0\n2001-10-01 639.0\n2002-01-01 731.0\n2002-04-01 821.0\n2002-07-01 NaN\ndtype: float64>(2000-01-01 NaN\n2000-04-01 0.0\n2000-07-01 91.0\n2000-10-01 182.0\n2001-01-01 274.0\n2001-04-01 366....7-01 456.0\n2001-10-01 547.0\n2002-01-01 639.0\n2002-04-01 731.0\n2002-07-01 821.0\nFreq: 3MS, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-01-01 0.0\n2000-04-01 91.0\n2000-07-01 182.0\n2000-10-01 274.0\n2001-0...6.0\n2001-07-01 547.0\n2001-10-01 639.0\n2002-01-01 731.0\n2002-04-01 821.0\n2002-07-01 NaN\ndtype: float64> = 2000-01-01 0.0\n2000-04-01 91.0\n2000-07-01 182.0\n2000-10-01 274.0\n2001-01-01 366.0\n2001-04-01 456.0\n2001-07-01 547.0\n2001-10-01 639.0\n2002-01-01 731.0\n2002-04-01 821.0\n2002-07-01 NaN\ndtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
_______________ test_first_items[downsampling-1-left-right-11M] ________________ | |
datetimeindex = DatetimeIndex(['2000-01-01 12:00:01', '2000-01-02 12:00:01', | |
'2000-01-03 12:00:01', '2000-01-04 12:00:0... '2002-06-18 12:00:01', '2002-06-19 12:00:01'], | |
dtype='datetime64[ns]', length=901, freq='D') | |
cftimeindex = CFTimeIndex([2000-01-01 12:00:01, 2000-01-02 12:00:01, 2000-01-03 12:00:01, | |
2000-01-04 12:00:01, 2000-01-...1, 2002-06-17 12:00:01, 2002-06-18 12:00:01, | |
2002-06-19 12:00:01], | |
dtype='object', length=901) | |
freq = '11M', closed = 'right', label = 'left', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 1999-02-28 0\n2000-01-31 30\n2000-12-31 365\n2001-11-30 699\ndtype: int64>(1999-02-28 0\n2000-01-31 31\n2000-12-31 366\n2001-11-30 700\nFreq: 11M, dtype: int64) | |
E + where <bound method NDFrame.equals of 1999-02-28 0\n2000-01-31 30\n2000-12-31 365\n2001-11-30 699\ndtype: int64> = 1999-02-28 0\n2000-01-31 30\n2000-12-31 365\n2001-11-30 699\ndtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
_______________ test_first_items[downsampling-1-left-right-3MS] ________________ | |
datetimeindex = DatetimeIndex(['2000-01-01 12:00:01', '2000-01-02 12:00:01', | |
'2000-01-03 12:00:01', '2000-01-04 12:00:0... '2002-06-18 12:00:01', '2002-06-19 12:00:01'], | |
dtype='datetime64[ns]', length=901, freq='D') | |
cftimeindex = CFTimeIndex([2000-01-01 12:00:01, 2000-01-02 12:00:01, 2000-01-03 12:00:01, | |
2000-01-04 12:00:01, 2000-01-...1, 2002-06-17 12:00:01, 2002-06-18 12:00:01, | |
2002-06-19 12:00:01], | |
dtype='object', length=901) | |
freq = '3MS', closed = 'right', label = 'left', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 1999-10-01 0.0\n2000-01-01 91.0\n2000-04-01 182.0\n2000-07-01 274.0\n2000-1...6.0\n2001-04-01 547.0\n2001-07-01 639.0\n2001-10-01 731.0\n2002-01-01 821.0\n2002-04-01 NaN\ndtype: float64>(1999-10-01 NaN\n2000-01-01 0.0\n2000-04-01 91.0\n2000-07-01 182.0\n2000-10-01 274.0\n2001-01-01 366....4-01 456.0\n2001-07-01 547.0\n2001-10-01 639.0\n2002-01-01 731.0\n2002-04-01 821.0\nFreq: 3MS, dtype: float64) | |
E + where <bound method NDFrame.equals of 1999-10-01 0.0\n2000-01-01 91.0\n2000-04-01 182.0\n2000-07-01 274.0\n2000-1...6.0\n2001-04-01 547.0\n2001-07-01 639.0\n2001-10-01 731.0\n2002-01-01 821.0\n2002-04-01 NaN\ndtype: float64> = 1999-10-01 0.0\n2000-01-01 91.0\n2000-04-01 182.0\n2000-07-01 274.0\n2000-10-01 366.0\n2001-01-01 456.0\n2001-04-01 547.0\n2001-07-01 639.0\n2001-10-01 731.0\n2002-01-01 821.0\n2002-04-01 NaN\ndtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
_______________ test_first_items[downsampling-1-right-right-11M] _______________ | |
datetimeindex = DatetimeIndex(['2000-01-01 12:00:01', '2000-01-02 12:00:01', | |
'2000-01-03 12:00:01', '2000-01-04 12:00:0... '2002-06-18 12:00:01', '2002-06-19 12:00:01'], | |
dtype='datetime64[ns]', length=901, freq='D') | |
cftimeindex = CFTimeIndex([2000-01-01 12:00:01, 2000-01-02 12:00:01, 2000-01-03 12:00:01, | |
2000-01-04 12:00:01, 2000-01-...1, 2002-06-17 12:00:01, 2002-06-18 12:00:01, | |
2002-06-19 12:00:01], | |
dtype='object', length=901) | |
freq = '11M', closed = 'right', label = 'right', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-01-31 0\n2000-12-31 30\n2001-11-30 365\n2002-10-31 699\ndtype: int64>(2000-01-31 0\n2000-12-31 31\n2001-11-30 366\n2002-10-31 700\nFreq: 11M, dtype: int64) | |
E + where <bound method NDFrame.equals of 2000-01-31 0\n2000-12-31 30\n2001-11-30 365\n2002-10-31 699\ndtype: int64> = 2000-01-31 0\n2000-12-31 30\n2001-11-30 365\n2002-10-31 699\ndtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
_______________ test_first_items[downsampling-1-right-right-3MS] _______________ | |
datetimeindex = DatetimeIndex(['2000-01-01 12:00:01', '2000-01-02 12:00:01', | |
'2000-01-03 12:00:01', '2000-01-04 12:00:0... '2002-06-18 12:00:01', '2002-06-19 12:00:01'], | |
dtype='datetime64[ns]', length=901, freq='D') | |
cftimeindex = CFTimeIndex([2000-01-01 12:00:01, 2000-01-02 12:00:01, 2000-01-03 12:00:01, | |
2000-01-04 12:00:01, 2000-01-...1, 2002-06-17 12:00:01, 2002-06-18 12:00:01, | |
2002-06-19 12:00:01], | |
dtype='object', length=901) | |
freq = '3MS', closed = 'right', label = 'right', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-01-01 0.0\n2000-04-01 91.0\n2000-07-01 182.0\n2000-10-01 274.0\n2001-0...6.0\n2001-07-01 547.0\n2001-10-01 639.0\n2002-01-01 731.0\n2002-04-01 821.0\n2002-07-01 NaN\ndtype: float64>(2000-01-01 NaN\n2000-04-01 0.0\n2000-07-01 91.0\n2000-10-01 182.0\n2001-01-01 274.0\n2001-04-01 366....7-01 456.0\n2001-10-01 547.0\n2002-01-01 639.0\n2002-04-01 731.0\n2002-07-01 821.0\nFreq: 3MS, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-01-01 0.0\n2000-04-01 91.0\n2000-07-01 182.0\n2000-10-01 274.0\n2001-0...6.0\n2001-07-01 547.0\n2001-10-01 639.0\n2002-01-01 731.0\n2002-04-01 821.0\n2002-07-01 NaN\ndtype: float64> = 2000-01-01 0.0\n2000-04-01 91.0\n2000-07-01 182.0\n2000-10-01 274.0\n2001-01-01 366.0\n2001-04-01 456.0\n2001-07-01 547.0\n2001-10-01 639.0\n2002-01-01 731.0\n2002-04-01 821.0\n2002-07-01 NaN\ndtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
_________________ test_first_items[upsampling-0-left-left-11M] _________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '11M', closed = 'left', label = 'left', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-12-31 0\n2001-11-30 1\n2002-10-31 2\n2003-09-30 3\n2004-08-31 4\n2... 31\n2032-02-29 32\n2033-01-31 33\n2033-12-31 33\n2034-11-30 34\n2035-10-31 35\n2036-09-30 36\ndtype: int64>(2000-12-31 0.0\n2001-11-30 1.0\n2002-10-31 2.0\n2003-09-30 3.0\n2004-08-31 4.0\n2005-07-31 5.0\n2006...033-01-31 NaN\n2033-12-31 33.0\n2034-11-30 34.0\n2035-10-31 35.0\n2036-09-30 36.0\nFreq: 11M, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-12-31 0\n2001-11-30 1\n2002-10-31 2\n2003-09-30 3\n2004-08-31 4\n2... 31\n2032-02-29 32\n2033-01-31 33\n2033-12-31 33\n2034-11-30 34\n2035-10-31 35\n2036-09-30 36\ndtype: int64> = 2000-12-31 0\n2001-11-30 1\n2002-10-31 2\n2003-09-30 3\n2004-08-31 4\n2005-07-31 5\n2006-06-30 6... 31\n2032-02-29 32\n2033-01-31 33\n2033-12-31 33\n2034-11-30 34\n2035-10-31 35\n2036-09-30 36\ndtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
________________ test_first_items[upsampling-0-left-left-8001H] ________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '8001H', closed = 'left', label = 'left', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-12-31 00:00:00 0\n2001-11-29 09:00:00 1\n2002-10-28 18:00:00 2\n2003-09-...2\n2033-11-09 12:00:00 33\n2034-10-08 21:00:00 34\n2035-09-07 06:00:00 35\n2036-08-05 15:00:00 36\ndtype: int64>(2000-12-31 00:00:00 0.0\n2001-11-29 09:00:00 1.0\n2002-10-28 18:00:00 2.0\n2003-09-27 03:00:00 3.0\n2004-0... 33.0\n2034-10-08 21:00:00 34.0\n2035-09-07 06:00:00 35.0\n2036-08-05 15:00:00 36.0\nFreq: 8001H, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-12-31 00:00:00 0\n2001-11-29 09:00:00 1\n2002-10-28 18:00:00 2\n2003-09-...2\n2033-11-09 12:00:00 33\n2034-10-08 21:00:00 34\n2035-09-07 06:00:00 35\n2036-08-05 15:00:00 36\ndtype: int64> = 2000-12-31 00:00:00 0\n2001-11-29 09:00:00 1\n2002-10-28 18:00:00 2\n2003-09-27 03:00:00 3\n2004-08-25 12:...32\n2033-11-09 12:00:00 33\n2034-10-08 21:00:00 34\n2035-09-07 06:00:00 35\n2036-08-05 15:00:00 36\ndtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
_________________ test_first_items[upsampling-0-left-left-3MS] _________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '3MS', closed = 'left', label = 'left', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-12-01 0\n2001-03-01 1\n2001-06-01 1\n2001-09-01 1\n2001-12-01 1\n2...1 35\n2035-12-01 35\n2036-03-01 36\n2036-06-01 36\n2036-09-01 36\n2036-12-01 36\nLength: 145, dtype: int64>(2000-12-01 0.0\n2001-03-01 NaN\n2001-06-01 NaN\n2001-09-01 NaN\n2001-12-01 1.0\n2002-03-01 NaN\n2002...35.0\n2036-03-01 NaN\n2036-06-01 NaN\n2036-09-01 NaN\n2036-12-01 36.0\nFreq: 3MS, Length: 145, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-12-01 0\n2001-03-01 1\n2001-06-01 1\n2001-09-01 1\n2001-12-01 1\n2...1 35\n2035-12-01 35\n2036-03-01 36\n2036-06-01 36\n2036-09-01 36\n2036-12-01 36\nLength: 145, dtype: int64> = 2000-12-01 0\n2001-03-01 1\n2001-06-01 1\n2001-09-01 1\n2001-12-01 1\n2002-03-01 2\n2002-06-01 2...01 35\n2035-12-01 35\n2036-03-01 36\n2036-06-01 36\n2036-09-01 36\n2036-12-01 36\nLength: 145, dtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
________________ test_first_items[upsampling-0-left-right-11M] _________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '11M', closed = 'right', label = 'left', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-01-31 0.0\n2000-12-31 1.0\n2001-11-30 2.0\n2002-10-31 3.0\n2003-09-30... 33.0\n2033-01-31 33.0\n2033-12-31 34.0\n2034-11-30 35.0\n2035-10-31 36.0\n2036-09-30 NaN\ndtype: float64>(2000-01-31 0.0\n2000-12-31 NaN\n2001-11-30 1.0\n2002-10-31 2.0\n2003-09-30 3.0\n2004-08-31 4.0\n2005...033-01-31 33.0\n2033-12-31 NaN\n2034-11-30 34.0\n2035-10-31 35.0\n2036-09-30 36.0\nFreq: 11M, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-01-31 0.0\n2000-12-31 1.0\n2001-11-30 2.0\n2002-10-31 3.0\n2003-09-30... 33.0\n2033-01-31 33.0\n2033-12-31 34.0\n2034-11-30 35.0\n2035-10-31 36.0\n2036-09-30 NaN\ndtype: float64> = 2000-01-31 0.0\n2000-12-31 1.0\n2001-11-30 2.0\n2002-10-31 3.0\n2003-09-30 4.0\n2004-08-31 5.0\n2005...9 33.0\n2033-01-31 33.0\n2033-12-31 34.0\n2034-11-30 35.0\n2035-10-31 36.0\n2036-09-30 NaN\ndtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
_______________ test_first_items[upsampling-0-left-right-8001H] ________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '8001H', closed = 'right', label = 'left', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-12-31 00:00:00 0.0\n2001-11-29 09:00:00 1.0\n2002-10-28 18:00:00 2.0\n20...09 12:00:00 33.0\n2034-10-08 21:00:00 34.0\n2035-09-07 06:00:00 35.0\n2036-08-05 15:00:00 36.0\ndtype: float64>(2000-12-31 00:00:00 0.0\n2001-11-29 09:00:00 1.0\n2002-10-28 18:00:00 2.0\n2003-09-27 03:00:00 3.0\n2004-0... 33.0\n2034-10-08 21:00:00 34.0\n2035-09-07 06:00:00 35.0\n2036-08-05 15:00:00 36.0\nFreq: 8001H, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-12-31 00:00:00 0.0\n2001-11-29 09:00:00 1.0\n2002-10-28 18:00:00 2.0\n20...09 12:00:00 33.0\n2034-10-08 21:00:00 34.0\n2035-09-07 06:00:00 35.0\n2036-08-05 15:00:00 36.0\ndtype: float64> = 2000-12-31 00:00:00 0.0\n2001-11-29 09:00:00 1.0\n2002-10-28 18:00:00 2.0\n2003-09-27 03:00:00 3.0\n2004-0...-09 12:00:00 33.0\n2034-10-08 21:00:00 34.0\n2035-09-07 06:00:00 35.0\n2036-08-05 15:00:00 36.0\ndtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
________________ test_first_items[upsampling-0-left-right-3MS] _________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '3MS', closed = 'right', label = 'left', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-10-01 0.0\n2001-01-01 1.0\n2001-04-01 1.0\n2001-07-01 1.0\n2001-10-01...-10-01 35.0\n2036-01-01 36.0\n2036-04-01 36.0\n2036-07-01 36.0\n2036-10-01 36.0\nLength: 145, dtype: float64>(2000-10-01 0.0\n2001-01-01 NaN\n2001-04-01 NaN\n2001-07-01 NaN\n2001-10-01 1.0\n2002-01-01 NaN\n2002...35.0\n2036-01-01 NaN\n2036-04-01 NaN\n2036-07-01 NaN\n2036-10-01 36.0\nFreq: 3MS, Length: 145, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-10-01 0.0\n2001-01-01 1.0\n2001-04-01 1.0\n2001-07-01 1.0\n2001-10-01...-10-01 35.0\n2036-01-01 36.0\n2036-04-01 36.0\n2036-07-01 36.0\n2036-10-01 36.0\nLength: 145, dtype: float64> = 2000-10-01 0.0\n2001-01-01 1.0\n2001-04-01 1.0\n2001-07-01 1.0\n2001-10-01 1.0\n2002-01-01 2.0\n2002...5-10-01 35.0\n2036-01-01 36.0\n2036-04-01 36.0\n2036-07-01 36.0\n2036-10-01 36.0\nLength: 145, dtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
________________ test_first_items[upsampling-0-right-left-11M] _________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '11M', closed = 'left', label = 'right', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2001-11-30 0\n2002-10-31 1\n2003-09-30 2\n2004-08-31 3\n2005-07-31 4\n2... 31\n2033-01-31 32\n2033-12-31 33\n2034-11-30 33\n2035-10-31 34\n2036-09-30 35\n2037-08-31 36\ndtype: int64>(2001-11-30 0.0\n2002-10-31 1.0\n2003-09-30 2.0\n2004-08-31 3.0\n2005-07-31 4.0\n2006-06-30 5.0\n2007...033-12-31 NaN\n2034-11-30 33.0\n2035-10-31 34.0\n2036-09-30 35.0\n2037-08-31 36.0\nFreq: 11M, dtype: float64) | |
E + where <bound method NDFrame.equals of 2001-11-30 0\n2002-10-31 1\n2003-09-30 2\n2004-08-31 3\n2005-07-31 4\n2... 31\n2033-01-31 32\n2033-12-31 33\n2034-11-30 33\n2035-10-31 34\n2036-09-30 35\n2037-08-31 36\ndtype: int64> = 2001-11-30 0\n2002-10-31 1\n2003-09-30 2\n2004-08-31 3\n2005-07-31 4\n2006-06-30 5\n2007-05-31 6... 31\n2033-01-31 32\n2033-12-31 33\n2034-11-30 33\n2035-10-31 34\n2036-09-30 35\n2037-08-31 36\ndtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
_______________ test_first_items[upsampling-0-right-left-8001H] ________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '8001H', closed = 'left', label = 'right', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2001-11-29 09:00:00 0\n2002-10-28 18:00:00 1\n2003-09-27 03:00:00 2\n2004-08-...2\n2034-10-08 21:00:00 33\n2035-09-07 06:00:00 34\n2036-08-05 15:00:00 35\n2037-07-05 00:00:00 36\ndtype: int64>(2001-11-29 09:00:00 0.0\n2002-10-28 18:00:00 1.0\n2003-09-27 03:00:00 2.0\n2004-08-25 12:00:00 3.0\n2005-0... 33.0\n2035-09-07 06:00:00 34.0\n2036-08-05 15:00:00 35.0\n2037-07-05 00:00:00 36.0\nFreq: 8001H, dtype: float64) | |
E + where <bound method NDFrame.equals of 2001-11-29 09:00:00 0\n2002-10-28 18:00:00 1\n2003-09-27 03:00:00 2\n2004-08-...2\n2034-10-08 21:00:00 33\n2035-09-07 06:00:00 34\n2036-08-05 15:00:00 35\n2037-07-05 00:00:00 36\ndtype: int64> = 2001-11-29 09:00:00 0\n2002-10-28 18:00:00 1\n2003-09-27 03:00:00 2\n2004-08-25 12:00:00 3\n2005-07-24 21:...32\n2034-10-08 21:00:00 33\n2035-09-07 06:00:00 34\n2036-08-05 15:00:00 35\n2037-07-05 00:00:00 36\ndtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
________________ test_first_items[upsampling-0-right-left-3MS] _________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '3MS', closed = 'left', label = 'right', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2001-03-01 0\n2001-06-01 1\n2001-09-01 1\n2001-12-01 1\n2002-03-01 1\n2...1 35\n2036-03-01 35\n2036-06-01 36\n2036-09-01 36\n2036-12-01 36\n2037-03-01 36\nLength: 145, dtype: int64>(2001-03-01 0.0\n2001-06-01 NaN\n2001-09-01 NaN\n2001-12-01 NaN\n2002-03-01 1.0\n2002-06-01 NaN\n2002...35.0\n2036-06-01 NaN\n2036-09-01 NaN\n2036-12-01 NaN\n2037-03-01 36.0\nFreq: 3MS, Length: 145, dtype: float64) | |
E + where <bound method NDFrame.equals of 2001-03-01 0\n2001-06-01 1\n2001-09-01 1\n2001-12-01 1\n2002-03-01 1\n2...1 35\n2036-03-01 35\n2036-06-01 36\n2036-09-01 36\n2036-12-01 36\n2037-03-01 36\nLength: 145, dtype: int64> = 2001-03-01 0\n2001-06-01 1\n2001-09-01 1\n2001-12-01 1\n2002-03-01 1\n2002-06-01 2\n2002-09-01 2...01 35\n2036-03-01 35\n2036-06-01 36\n2036-09-01 36\n2036-12-01 36\n2037-03-01 36\nLength: 145, dtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
________________ test_first_items[upsampling-0-right-right-11M] ________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '11M', closed = 'right', label = 'right', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-12-31 0.0\n2001-11-30 1.0\n2002-10-31 2.0\n2003-09-30 3.0\n2004-08-31... 33.0\n2033-12-31 33.0\n2034-11-30 34.0\n2035-10-31 35.0\n2036-09-30 36.0\n2037-08-31 NaN\ndtype: float64>(2000-12-31 0.0\n2001-11-30 NaN\n2002-10-31 1.0\n2003-09-30 2.0\n2004-08-31 3.0\n2005-07-31 4.0\n2006...033-12-31 33.0\n2034-11-30 NaN\n2035-10-31 34.0\n2036-09-30 35.0\n2037-08-31 36.0\nFreq: 11M, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-12-31 0.0\n2001-11-30 1.0\n2002-10-31 2.0\n2003-09-30 3.0\n2004-08-31... 33.0\n2033-12-31 33.0\n2034-11-30 34.0\n2035-10-31 35.0\n2036-09-30 36.0\n2037-08-31 NaN\ndtype: float64> = 2000-12-31 0.0\n2001-11-30 1.0\n2002-10-31 2.0\n2003-09-30 3.0\n2004-08-31 4.0\n2005-07-31 5.0\n2006...1 33.0\n2033-12-31 33.0\n2034-11-30 34.0\n2035-10-31 35.0\n2036-09-30 36.0\n2037-08-31 NaN\ndtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
_______________ test_first_items[upsampling-0-right-right-8001H] _______________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '8001H', closed = 'right', label = 'right', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2001-11-29 09:00:00 0.0\n2002-10-28 18:00:00 1.0\n2003-09-27 03:00:00 2.0\n20...08 21:00:00 33.0\n2035-09-07 06:00:00 34.0\n2036-08-05 15:00:00 35.0\n2037-07-05 00:00:00 36.0\ndtype: float64>(2001-11-29 09:00:00 0.0\n2002-10-28 18:00:00 1.0\n2003-09-27 03:00:00 2.0\n2004-08-25 12:00:00 3.0\n2005-0... 33.0\n2035-09-07 06:00:00 34.0\n2036-08-05 15:00:00 35.0\n2037-07-05 00:00:00 36.0\nFreq: 8001H, dtype: float64) | |
E + where <bound method NDFrame.equals of 2001-11-29 09:00:00 0.0\n2002-10-28 18:00:00 1.0\n2003-09-27 03:00:00 2.0\n20...08 21:00:00 33.0\n2035-09-07 06:00:00 34.0\n2036-08-05 15:00:00 35.0\n2037-07-05 00:00:00 36.0\ndtype: float64> = 2001-11-29 09:00:00 0.0\n2002-10-28 18:00:00 1.0\n2003-09-27 03:00:00 2.0\n2004-08-25 12:00:00 3.0\n2005-0...-08 21:00:00 33.0\n2035-09-07 06:00:00 34.0\n2036-08-05 15:00:00 35.0\n2037-07-05 00:00:00 36.0\ndtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
________________ test_first_items[upsampling-0-right-right-3MS] ________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '3MS', closed = 'right', label = 'right', base = 0 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2001-01-01 0.0\n2001-04-01 1.0\n2001-07-01 1.0\n2001-10-01 1.0\n2002-01-01...-01-01 35.0\n2036-04-01 36.0\n2036-07-01 36.0\n2036-10-01 36.0\n2037-01-01 36.0\nLength: 145, dtype: float64>(2001-01-01 0.0\n2001-04-01 NaN\n2001-07-01 NaN\n2001-10-01 NaN\n2002-01-01 1.0\n2002-04-01 NaN\n2002...35.0\n2036-04-01 NaN\n2036-07-01 NaN\n2036-10-01 NaN\n2037-01-01 36.0\nFreq: 3MS, Length: 145, dtype: float64) | |
E + where <bound method NDFrame.equals of 2001-01-01 0.0\n2001-04-01 1.0\n2001-07-01 1.0\n2001-10-01 1.0\n2002-01-01...-01-01 35.0\n2036-04-01 36.0\n2036-07-01 36.0\n2036-10-01 36.0\n2037-01-01 36.0\nLength: 145, dtype: float64> = 2001-01-01 0.0\n2001-04-01 1.0\n2001-07-01 1.0\n2001-10-01 1.0\n2002-01-01 1.0\n2002-04-01 2.0\n2002...6-01-01 35.0\n2036-04-01 36.0\n2036-07-01 36.0\n2036-10-01 36.0\n2037-01-01 36.0\nLength: 145, dtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
_________________ test_first_items[upsampling-1-left-left-11M] _________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '11M', closed = 'left', label = 'left', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-12-31 0\n2001-11-30 1\n2002-10-31 2\n2003-09-30 3\n2004-08-31 4\n2... 31\n2032-02-29 32\n2033-01-31 33\n2033-12-31 33\n2034-11-30 34\n2035-10-31 35\n2036-09-30 36\ndtype: int64>(2000-12-31 0.0\n2001-11-30 1.0\n2002-10-31 2.0\n2003-09-30 3.0\n2004-08-31 4.0\n2005-07-31 5.0\n2006...033-01-31 NaN\n2033-12-31 33.0\n2034-11-30 34.0\n2035-10-31 35.0\n2036-09-30 36.0\nFreq: 11M, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-12-31 0\n2001-11-30 1\n2002-10-31 2\n2003-09-30 3\n2004-08-31 4\n2... 31\n2032-02-29 32\n2033-01-31 33\n2033-12-31 33\n2034-11-30 34\n2035-10-31 35\n2036-09-30 36\ndtype: int64> = 2000-12-31 0\n2001-11-30 1\n2002-10-31 2\n2003-09-30 3\n2004-08-31 4\n2005-07-31 5\n2006-06-30 6... 31\n2032-02-29 32\n2033-01-31 33\n2033-12-31 33\n2034-11-30 34\n2035-10-31 35\n2036-09-30 36\ndtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
________________ test_first_items[upsampling-1-left-left-8001H] ________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '8001H', closed = 'left', label = 'left', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-12-31 01:00:00 0\n2001-11-29 10:00:00 1\n2002-10-28 19:00:00 2\n2003-09-...2\n2033-11-09 13:00:00 33\n2034-10-08 22:00:00 34\n2035-09-07 07:00:00 35\n2036-08-05 16:00:00 36\ndtype: int64>(2000-12-31 01:00:00 0.0\n2001-11-29 10:00:00 1.0\n2002-10-28 19:00:00 2.0\n2003-09-27 04:00:00 3.0\n2004-0... 33.0\n2034-10-08 22:00:00 34.0\n2035-09-07 07:00:00 35.0\n2036-08-05 16:00:00 36.0\nFreq: 8001H, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-12-31 01:00:00 0\n2001-11-29 10:00:00 1\n2002-10-28 19:00:00 2\n2003-09-...2\n2033-11-09 13:00:00 33\n2034-10-08 22:00:00 34\n2035-09-07 07:00:00 35\n2036-08-05 16:00:00 36\ndtype: int64> = 2000-12-31 01:00:00 0\n2001-11-29 10:00:00 1\n2002-10-28 19:00:00 2\n2003-09-27 04:00:00 3\n2004-08-25 13:...32\n2033-11-09 13:00:00 33\n2034-10-08 22:00:00 34\n2035-09-07 07:00:00 35\n2036-08-05 16:00:00 36\ndtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
_________________ test_first_items[upsampling-1-left-left-3MS] _________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '3MS', closed = 'left', label = 'left', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-12-01 0\n2001-03-01 1\n2001-06-01 1\n2001-09-01 1\n2001-12-01 1\n2...1 35\n2035-12-01 35\n2036-03-01 36\n2036-06-01 36\n2036-09-01 36\n2036-12-01 36\nLength: 145, dtype: int64>(2000-12-01 0.0\n2001-03-01 NaN\n2001-06-01 NaN\n2001-09-01 NaN\n2001-12-01 1.0\n2002-03-01 NaN\n2002...35.0\n2036-03-01 NaN\n2036-06-01 NaN\n2036-09-01 NaN\n2036-12-01 36.0\nFreq: 3MS, Length: 145, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-12-01 0\n2001-03-01 1\n2001-06-01 1\n2001-09-01 1\n2001-12-01 1\n2...1 35\n2035-12-01 35\n2036-03-01 36\n2036-06-01 36\n2036-09-01 36\n2036-12-01 36\nLength: 145, dtype: int64> = 2000-12-01 0\n2001-03-01 1\n2001-06-01 1\n2001-09-01 1\n2001-12-01 1\n2002-03-01 2\n2002-06-01 2...01 35\n2035-12-01 35\n2036-03-01 36\n2036-06-01 36\n2036-09-01 36\n2036-12-01 36\nLength: 145, dtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
________________ test_first_items[upsampling-1-left-right-11M] _________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '11M', closed = 'right', label = 'left', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-01-31 0.0\n2000-12-31 1.0\n2001-11-30 2.0\n2002-10-31 3.0\n2003-09-30... 33.0\n2033-01-31 33.0\n2033-12-31 34.0\n2034-11-30 35.0\n2035-10-31 36.0\n2036-09-30 NaN\ndtype: float64>(2000-01-31 0.0\n2000-12-31 NaN\n2001-11-30 1.0\n2002-10-31 2.0\n2003-09-30 3.0\n2004-08-31 4.0\n2005...033-01-31 33.0\n2033-12-31 NaN\n2034-11-30 34.0\n2035-10-31 35.0\n2036-09-30 36.0\nFreq: 11M, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-01-31 0.0\n2000-12-31 1.0\n2001-11-30 2.0\n2002-10-31 3.0\n2003-09-30... 33.0\n2033-01-31 33.0\n2033-12-31 34.0\n2034-11-30 35.0\n2035-10-31 36.0\n2036-09-30 NaN\ndtype: float64> = 2000-01-31 0.0\n2000-12-31 1.0\n2001-11-30 2.0\n2002-10-31 3.0\n2003-09-30 4.0\n2004-08-31 5.0\n2005...9 33.0\n2033-01-31 33.0\n2033-12-31 34.0\n2034-11-30 35.0\n2035-10-31 36.0\n2036-09-30 NaN\ndtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
_______________ test_first_items[upsampling-1-left-right-8001H] ________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '8001H', closed = 'right', label = 'left', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-12-31 01:00:00 0.0\n2001-11-29 10:00:00 1.0\n2002-10-28 19:00:00 2.0\n20...09 13:00:00 33.0\n2034-10-08 22:00:00 34.0\n2035-09-07 07:00:00 35.0\n2036-08-05 16:00:00 36.0\ndtype: float64>(2000-12-31 01:00:00 0.0\n2001-11-29 10:00:00 1.0\n2002-10-28 19:00:00 2.0\n2003-09-27 04:00:00 3.0\n2004-0... 33.0\n2034-10-08 22:00:00 34.0\n2035-09-07 07:00:00 35.0\n2036-08-05 16:00:00 36.0\nFreq: 8001H, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-12-31 01:00:00 0.0\n2001-11-29 10:00:00 1.0\n2002-10-28 19:00:00 2.0\n20...09 13:00:00 33.0\n2034-10-08 22:00:00 34.0\n2035-09-07 07:00:00 35.0\n2036-08-05 16:00:00 36.0\ndtype: float64> = 2000-12-31 01:00:00 0.0\n2001-11-29 10:00:00 1.0\n2002-10-28 19:00:00 2.0\n2003-09-27 04:00:00 3.0\n2004-0...-09 13:00:00 33.0\n2034-10-08 22:00:00 34.0\n2035-09-07 07:00:00 35.0\n2036-08-05 16:00:00 36.0\ndtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
________________ test_first_items[upsampling-1-left-right-3MS] _________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '3MS', closed = 'right', label = 'left', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-10-01 0.0\n2001-01-01 1.0\n2001-04-01 1.0\n2001-07-01 1.0\n2001-10-01...-10-01 35.0\n2036-01-01 36.0\n2036-04-01 36.0\n2036-07-01 36.0\n2036-10-01 36.0\nLength: 145, dtype: float64>(2000-10-01 0.0\n2001-01-01 NaN\n2001-04-01 NaN\n2001-07-01 NaN\n2001-10-01 1.0\n2002-01-01 NaN\n2002...35.0\n2036-01-01 NaN\n2036-04-01 NaN\n2036-07-01 NaN\n2036-10-01 36.0\nFreq: 3MS, Length: 145, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-10-01 0.0\n2001-01-01 1.0\n2001-04-01 1.0\n2001-07-01 1.0\n2001-10-01...-10-01 35.0\n2036-01-01 36.0\n2036-04-01 36.0\n2036-07-01 36.0\n2036-10-01 36.0\nLength: 145, dtype: float64> = 2000-10-01 0.0\n2001-01-01 1.0\n2001-04-01 1.0\n2001-07-01 1.0\n2001-10-01 1.0\n2002-01-01 2.0\n2002...5-10-01 35.0\n2036-01-01 36.0\n2036-04-01 36.0\n2036-07-01 36.0\n2036-10-01 36.0\nLength: 145, dtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
________________ test_first_items[upsampling-1-right-left-11M] _________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '11M', closed = 'left', label = 'right', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2001-11-30 0\n2002-10-31 1\n2003-09-30 2\n2004-08-31 3\n2005-07-31 4\n2... 31\n2033-01-31 32\n2033-12-31 33\n2034-11-30 33\n2035-10-31 34\n2036-09-30 35\n2037-08-31 36\ndtype: int64>(2001-11-30 0.0\n2002-10-31 1.0\n2003-09-30 2.0\n2004-08-31 3.0\n2005-07-31 4.0\n2006-06-30 5.0\n2007...033-12-31 NaN\n2034-11-30 33.0\n2035-10-31 34.0\n2036-09-30 35.0\n2037-08-31 36.0\nFreq: 11M, dtype: float64) | |
E + where <bound method NDFrame.equals of 2001-11-30 0\n2002-10-31 1\n2003-09-30 2\n2004-08-31 3\n2005-07-31 4\n2... 31\n2033-01-31 32\n2033-12-31 33\n2034-11-30 33\n2035-10-31 34\n2036-09-30 35\n2037-08-31 36\ndtype: int64> = 2001-11-30 0\n2002-10-31 1\n2003-09-30 2\n2004-08-31 3\n2005-07-31 4\n2006-06-30 5\n2007-05-31 6... 31\n2033-01-31 32\n2033-12-31 33\n2034-11-30 33\n2035-10-31 34\n2036-09-30 35\n2037-08-31 36\ndtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
_______________ test_first_items[upsampling-1-right-left-8001H] ________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '8001H', closed = 'left', label = 'right', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2001-11-29 10:00:00 0\n2002-10-28 19:00:00 1\n2003-09-27 04:00:00 2\n2004-08-...2\n2034-10-08 22:00:00 33\n2035-09-07 07:00:00 34\n2036-08-05 16:00:00 35\n2037-07-05 01:00:00 36\ndtype: int64>(2001-11-29 10:00:00 0.0\n2002-10-28 19:00:00 1.0\n2003-09-27 04:00:00 2.0\n2004-08-25 13:00:00 3.0\n2005-0... 33.0\n2035-09-07 07:00:00 34.0\n2036-08-05 16:00:00 35.0\n2037-07-05 01:00:00 36.0\nFreq: 8001H, dtype: float64) | |
E + where <bound method NDFrame.equals of 2001-11-29 10:00:00 0\n2002-10-28 19:00:00 1\n2003-09-27 04:00:00 2\n2004-08-...2\n2034-10-08 22:00:00 33\n2035-09-07 07:00:00 34\n2036-08-05 16:00:00 35\n2037-07-05 01:00:00 36\ndtype: int64> = 2001-11-29 10:00:00 0\n2002-10-28 19:00:00 1\n2003-09-27 04:00:00 2\n2004-08-25 13:00:00 3\n2005-07-24 22:...32\n2034-10-08 22:00:00 33\n2035-09-07 07:00:00 34\n2036-08-05 16:00:00 35\n2037-07-05 01:00:00 36\ndtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
________________ test_first_items[upsampling-1-right-left-3MS] _________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '3MS', closed = 'left', label = 'right', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2001-03-01 0\n2001-06-01 1\n2001-09-01 1\n2001-12-01 1\n2002-03-01 1\n2...1 35\n2036-03-01 35\n2036-06-01 36\n2036-09-01 36\n2036-12-01 36\n2037-03-01 36\nLength: 145, dtype: int64>(2001-03-01 0.0\n2001-06-01 NaN\n2001-09-01 NaN\n2001-12-01 NaN\n2002-03-01 1.0\n2002-06-01 NaN\n2002...35.0\n2036-06-01 NaN\n2036-09-01 NaN\n2036-12-01 NaN\n2037-03-01 36.0\nFreq: 3MS, Length: 145, dtype: float64) | |
E + where <bound method NDFrame.equals of 2001-03-01 0\n2001-06-01 1\n2001-09-01 1\n2001-12-01 1\n2002-03-01 1\n2...1 35\n2036-03-01 35\n2036-06-01 36\n2036-09-01 36\n2036-12-01 36\n2037-03-01 36\nLength: 145, dtype: int64> = 2001-03-01 0\n2001-06-01 1\n2001-09-01 1\n2001-12-01 1\n2002-03-01 1\n2002-06-01 2\n2002-09-01 2...01 35\n2036-03-01 35\n2036-06-01 36\n2036-09-01 36\n2036-12-01 36\n2037-03-01 36\nLength: 145, dtype: int64.equals | |
test_first_items_current.py:125: AssertionError | |
________________ test_first_items[upsampling-1-right-right-11M] ________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '11M', closed = 'right', label = 'right', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2000-12-31 0.0\n2001-11-30 1.0\n2002-10-31 2.0\n2003-09-30 3.0\n2004-08-31... 33.0\n2033-12-31 33.0\n2034-11-30 34.0\n2035-10-31 35.0\n2036-09-30 36.0\n2037-08-31 NaN\ndtype: float64>(2000-12-31 0.0\n2001-11-30 NaN\n2002-10-31 1.0\n2003-09-30 2.0\n2004-08-31 3.0\n2005-07-31 4.0\n2006...033-12-31 33.0\n2034-11-30 NaN\n2035-10-31 34.0\n2036-09-30 35.0\n2037-08-31 36.0\nFreq: 11M, dtype: float64) | |
E + where <bound method NDFrame.equals of 2000-12-31 0.0\n2001-11-30 1.0\n2002-10-31 2.0\n2003-09-30 3.0\n2004-08-31... 33.0\n2033-12-31 33.0\n2034-11-30 34.0\n2035-10-31 35.0\n2036-09-30 36.0\n2037-08-31 NaN\ndtype: float64> = 2000-12-31 0.0\n2001-11-30 1.0\n2002-10-31 2.0\n2003-09-30 3.0\n2004-08-31 4.0\n2005-07-31 5.0\n2006...1 33.0\n2033-12-31 33.0\n2034-11-30 34.0\n2035-10-31 35.0\n2036-09-30 36.0\n2037-08-31 NaN\ndtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
_______________ test_first_items[upsampling-1-right-right-8001H] _______________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '8001H', closed = 'right', label = 'right', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2001-11-29 10:00:00 0.0\n2002-10-28 19:00:00 1.0\n2003-09-27 04:00:00 2.0\n20...08 22:00:00 33.0\n2035-09-07 07:00:00 34.0\n2036-08-05 16:00:00 35.0\n2037-07-05 01:00:00 36.0\ndtype: float64>(2001-11-29 10:00:00 0.0\n2002-10-28 19:00:00 1.0\n2003-09-27 04:00:00 2.0\n2004-08-25 13:00:00 3.0\n2005-0... 33.0\n2035-09-07 07:00:00 34.0\n2036-08-05 16:00:00 35.0\n2037-07-05 01:00:00 36.0\nFreq: 8001H, dtype: float64) | |
E + where <bound method NDFrame.equals of 2001-11-29 10:00:00 0.0\n2002-10-28 19:00:00 1.0\n2003-09-27 04:00:00 2.0\n20...08 22:00:00 33.0\n2035-09-07 07:00:00 34.0\n2036-08-05 16:00:00 35.0\n2037-07-05 01:00:00 36.0\ndtype: float64> = 2001-11-29 10:00:00 0.0\n2002-10-28 19:00:00 1.0\n2003-09-27 04:00:00 2.0\n2004-08-25 13:00:00 3.0\n2005-0...-08 22:00:00 33.0\n2035-09-07 07:00:00 34.0\n2036-08-05 16:00:00 35.0\n2037-07-05 01:00:00 36.0\ndtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
________________ test_first_items[upsampling-1-right-right-3MS] ________________ | |
datetimeindex = DatetimeIndex(['2000-12-31 12:00:01', '2001-12-31 12:00:01', | |
'2002-12-31 12:00:01', '2003-12-31 12:00:0...:01', '2035-12-31 12:00:01', | |
'2036-12-31 12:00:01'], | |
dtype='datetime64[ns]', freq='A-DEC') | |
cftimeindex = CFTimeIndex([2000-12-31 12:00:01, 2001-12-31 12:00:01, 2002-12-31 12:00:01, | |
2003-12-31 12:00:01, 2004-12-...2-31 12:00:01, 2034-12-31 12:00:01, 2035-12-31 12:00:01, | |
2036-12-31 12:00:01], | |
dtype='object') | |
freq = '3MS', closed = 'right', label = 'right', base = 1 | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
> assert result_first_items.equals(expected_first_items) | |
E assert False | |
E + where False = <bound method NDFrame.equals of 2001-01-01 0.0\n2001-04-01 1.0\n2001-07-01 1.0\n2001-10-01 1.0\n2002-01-01...-01-01 35.0\n2036-04-01 36.0\n2036-07-01 36.0\n2036-10-01 36.0\n2037-01-01 36.0\nLength: 145, dtype: float64>(2001-01-01 0.0\n2001-04-01 NaN\n2001-07-01 NaN\n2001-10-01 NaN\n2002-01-01 1.0\n2002-04-01 NaN\n2002...35.0\n2036-04-01 NaN\n2036-07-01 NaN\n2036-10-01 NaN\n2037-01-01 36.0\nFreq: 3MS, Length: 145, dtype: float64) | |
E + where <bound method NDFrame.equals of 2001-01-01 0.0\n2001-04-01 1.0\n2001-07-01 1.0\n2001-10-01 1.0\n2002-01-01...-01-01 35.0\n2036-04-01 36.0\n2036-07-01 36.0\n2036-10-01 36.0\n2037-01-01 36.0\nLength: 145, dtype: float64> = 2001-01-01 0.0\n2001-04-01 1.0\n2001-07-01 1.0\n2001-10-01 1.0\n2002-01-01 1.0\n2002-04-01 2.0\n2002...6-01-01 35.0\n2036-04-01 36.0\n2036-07-01 36.0\n2036-10-01 36.0\n2037-01-01 36.0\nLength: 145, dtype: float64.equals | |
test_first_items_current.py:125: AssertionError | |
==================== 32 failed, 32 passed in 10.25 seconds ===================== |
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
import datetime | |
import numpy as np | |
import pandas as pd | |
import pytest | |
import xarray as xr | |
from xarray import CFTimeIndex | |
from xarray.coding.cftime_offsets import to_offset | |
from xarray.core.resample_cftime import ( | |
_get_time_bins, _adjust_binner_for_upsample) | |
# Test both downsampling and upsampling for the tested resample | |
# frequencies. Use an unusual starting time to stress the logic. | |
@pytest.fixture(params=[dict(start='2000-01-01T12:00:01', periods=901), | |
dict(start='2000-01-01T12:00:01', periods=37, freq='A')], | |
ids=['downsampling', 'upsampling']) | |
def time_range_kwargs(request): | |
return request.param | |
@pytest.fixture() | |
def datetimeindex(time_range_kwargs): | |
return pd.date_range(**time_range_kwargs) | |
@pytest.fixture() | |
def cftimeindex(time_range_kwargs): | |
return xr.cftime_range(**time_range_kwargs) | |
def _grouper(index, freq, closed, label, base): | |
"""Code to produce the grouper object used for resampling | |
either with a DatetimeIndex or a CFTimeIndex. | |
""" | |
if isinstance(index, CFTimeIndex): | |
offset = to_offset(freq) | |
times = index | |
binner, labels = _get_time_bins(index, | |
offset, | |
closed, label, base) | |
if times.size > labels.size: | |
# if we're downsampling CFTimeIndex, do this: | |
if closed == 'right': | |
fill_method = 'bfill' | |
else: | |
fill_method = 'ffill' | |
binner = (pd.Series(binner, index=binner) | |
.reindex(times, method=fill_method)) | |
bin_actual = np.unique(binner.values) | |
label_dict = dict(zip(bin_actual, labels.values)) | |
# np.unique returns --sorted-- unique values | |
binner = binner.map(label_dict) | |
grouper = ('downsampling', pd.Index(labels), binner) | |
else: | |
# if we're upsampling CFTimeIndex, do this: | |
binner = _adjust_binner_for_upsample(binner, closed) | |
grouper = ('upsampling', pd.Index(labels), binner, closed) | |
else: | |
grouper = pd.Grouper(freq=freq, closed=closed, label=label, | |
base=base) | |
return grouper | |
def _first_items(index, grouper): | |
"""Logic from xarray/core/groupby.py to compute first_items""" | |
s = pd.Series(np.arange(index.size), index) | |
if isinstance(grouper, tuple): | |
if grouper[0] == 'downsampling': | |
# if we're downsampling CFTimeIndex, do this: | |
labels = grouper[1] | |
binner = grouper[2] | |
first_items = s.groupby(binner).first().reindex(labels) | |
# reindex(grouper[1]) adds empty np.nan bins to | |
# emulate pandas behavior | |
elif grouper[0] == 'upsampling': | |
# if we're upsampling CFTimeIndex, do this: | |
labels = grouper[1] | |
binner = grouper[2] | |
closed = grouper[3] | |
if closed == 'right': | |
binner = CFTimeIndex([x + datetime.timedelta(seconds=1) | |
for x in binner]) | |
first_items = s.reindex(pd.Index(binner), | |
method='bfill') | |
if first_items.values[0] != 0: | |
first_items = pd.Series( | |
data=np.concatenate(([0], | |
first_items.values[:-1])), | |
index=first_items.index) | |
first_items.index = labels | |
else: | |
binner = CFTimeIndex([x - datetime.timedelta(seconds=1) | |
for x in binner]) | |
first_items = s.reindex(pd.Index(binner), | |
method='bfill') | |
if first_items.values[0] != 0: | |
first_items = pd.Series( | |
data=np.concatenate(([0], | |
first_items.values[:-1])), | |
index=first_items.index) | |
first_items.index = labels | |
else: | |
first_items = s.groupby(grouper).first() | |
return first_items | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = CFTimeIndex( | |
result_first_items.index).to_datetimeindex() | |
assert result_first_items.equals(expected_first_items) |
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
============================= test session starts ============================== | |
platform darwin -- Python 3.6.6, pytest-3.10.1, py-1.7.0, pluggy-0.8.0 -- //anaconda/envs/xarray-dev-37/bin/python | |
cachedir: .pytest_cache | |
rootdir: /Users/spencerclark/cftime-resample-simplifications, inifile: | |
collecting ... collected 64 items | |
test_first_items_simplified.py::test_first_items[downsampling-0-left-left-11M] PASSED [ 1%] | |
test_first_items_simplified.py::test_first_items[downsampling-0-left-left-8001H] PASSED [ 3%] | |
test_first_items_simplified.py::test_first_items[downsampling-0-left-left-600003T] PASSED [ 4%] | |
test_first_items_simplified.py::test_first_items[downsampling-0-left-left-3MS] PASSED [ 6%] | |
test_first_items_simplified.py::test_first_items[downsampling-0-left-right-11M] PASSED [ 7%] | |
test_first_items_simplified.py::test_first_items[downsampling-0-left-right-8001H] PASSED [ 9%] | |
test_first_items_simplified.py::test_first_items[downsampling-0-left-right-600003T] PASSED [ 10%] | |
test_first_items_simplified.py::test_first_items[downsampling-0-left-right-3MS] PASSED [ 12%] | |
test_first_items_simplified.py::test_first_items[downsampling-0-right-left-11M] PASSED [ 14%] | |
test_first_items_simplified.py::test_first_items[downsampling-0-right-left-8001H] PASSED [ 15%] | |
test_first_items_simplified.py::test_first_items[downsampling-0-right-left-600003T] PASSED [ 17%] | |
test_first_items_simplified.py::test_first_items[downsampling-0-right-left-3MS] PASSED [ 18%] | |
test_first_items_simplified.py::test_first_items[downsampling-0-right-right-11M] PASSED [ 20%] | |
test_first_items_simplified.py::test_first_items[downsampling-0-right-right-8001H] PASSED [ 21%] | |
test_first_items_simplified.py::test_first_items[downsampling-0-right-right-600003T] PASSED [ 23%] | |
test_first_items_simplified.py::test_first_items[downsampling-0-right-right-3MS] PASSED [ 25%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-left-left-11M] PASSED [ 26%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-left-left-8001H] PASSED [ 28%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-left-left-600003T] PASSED [ 29%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-left-left-3MS] PASSED [ 31%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-left-right-11M] PASSED [ 32%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-left-right-8001H] PASSED [ 34%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-left-right-600003T] PASSED [ 35%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-left-right-3MS] PASSED [ 37%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-right-left-11M] PASSED [ 39%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-right-left-8001H] PASSED [ 40%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-right-left-600003T] PASSED [ 42%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-right-left-3MS] PASSED [ 43%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-right-right-11M] PASSED [ 45%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-right-right-8001H] PASSED [ 46%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-right-right-600003T] PASSED [ 48%] | |
test_first_items_simplified.py::test_first_items[downsampling-1-right-right-3MS] PASSED [ 50%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-left-left-11M] PASSED [ 51%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-left-left-8001H] PASSED [ 53%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-left-left-600003T] PASSED [ 54%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-left-left-3MS] PASSED [ 56%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-left-right-11M] PASSED [ 57%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-left-right-8001H] PASSED [ 59%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-left-right-600003T] PASSED [ 60%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-left-right-3MS] PASSED [ 62%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-right-left-11M] PASSED [ 64%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-right-left-8001H] PASSED [ 65%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-right-left-600003T] PASSED [ 67%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-right-left-3MS] PASSED [ 68%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-right-right-11M] PASSED [ 70%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-right-right-8001H] PASSED [ 71%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-right-right-600003T] PASSED [ 73%] | |
test_first_items_simplified.py::test_first_items[upsampling-0-right-right-3MS] PASSED [ 75%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-left-left-11M] PASSED [ 76%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-left-left-8001H] PASSED [ 78%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-left-left-600003T] PASSED [ 79%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-left-left-3MS] PASSED [ 81%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-left-right-11M] PASSED [ 82%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-left-right-8001H] PASSED [ 84%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-left-right-600003T] PASSED [ 85%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-left-right-3MS] PASSED [ 87%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-right-left-11M] PASSED [ 89%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-right-left-8001H] PASSED [ 90%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-right-left-600003T] PASSED [ 92%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-right-left-3MS] PASSED [ 93%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-right-right-11M] PASSED [ 95%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-right-right-8001H] PASSED [ 96%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-right-right-600003T] PASSED [ 98%] | |
test_first_items_simplified.py::test_first_items[upsampling-1-right-right-3MS] PASSED [100%] | |
========================== 64 passed in 8.60 seconds =========================== |
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
import datetime | |
import numpy as np | |
import pandas as pd | |
import pytest | |
import xarray as xr | |
from xarray import CFTimeIndex, cftime_range | |
from xarray.coding.cftime_offsets import (CFTIME_TICKS, normalize_date, | |
to_offset, Day, MonthEnd, YearEnd) | |
from xarray.core.resample_cftime import (_default_closed_or_label, | |
_get_range_edges, | |
_adjust_dates_anchored) | |
# Test both downsampling and upsampling for the tested resample | |
# frequencies. Use an unusual starting time to stress the logic. | |
@pytest.fixture(params=[dict(start='2000-01-01T12:07:01', periods=901), | |
dict(start='2000-01-01T12:07:01', periods=37, freq='A')], | |
ids=['downsampling', 'upsampling']) | |
def time_range_kwargs(request): | |
return request.param | |
@pytest.fixture() | |
def datetimeindex(time_range_kwargs): | |
return pd.date_range(**time_range_kwargs) | |
@pytest.fixture() | |
def cftimeindex(time_range_kwargs): | |
return cftime_range(**time_range_kwargs) | |
def _get_time_bins(index, freq, closed, label, base): | |
"""This is basically the same with the exception of the call to | |
_adjust_bin_edges.""" | |
# This portion of code comes from TimeGrouper __init__ # | |
if closed is None: | |
closed = _default_closed_or_label(freq) | |
if label is None: | |
label = _default_closed_or_label(freq) | |
# This portion of code comes from TimeGrouper __init__ # | |
if not isinstance(index, CFTimeIndex): | |
raise TypeError('index must be a CFTimeIndex, but got ' | |
'an instance of %r' % type(index).__name__) | |
if len(index) == 0: | |
datetime_bins = labels = CFTimeIndex(data=[], name=index.name) | |
return datetime_bins, labels | |
first, last = _get_range_edges(index.min(), index.max(), freq, | |
closed=closed, | |
base=base) | |
datetime_bins = labels = cftime_range(freq=freq, | |
start=first, | |
end=last, | |
name=index.name) | |
datetime_bins = _adjust_bin_edges(datetime_bins, freq, closed) | |
if closed == 'right': | |
if label == 'right': | |
labels = labels[1:] | |
else: | |
labels = labels[:-1] | |
else: | |
if label == 'right': | |
labels = labels[1:] | |
else: | |
labels = labels[:-1] | |
return datetime_bins, labels | |
def _adjust_bin_edges(datetime_bins, offset, closed): | |
"""This is required for determining the bin edges resampling with | |
daily frequencies greater than one day, month end, and year end | |
frequencies. | |
Consider the following example. Let's say you want to downsample the | |
time series with the following coordinates to month end frequency: | |
CFTimeIndex([2000-01-01 12:00:00, 2000-01-31 12:00:00, 2000-02-01 12:00:00], dtype='object') | |
Without this adjustment, _get_time_bins with month-end frequency will | |
return the following index for the bin edges (default closed='right' and | |
label='right' in this case): | |
CFTimeIndex([1999-12-31 00:00:00, 2000-01-31 00:00:00, 2000-02-29 00:00:00], dtype='object') | |
If 2000-01-31 is used as a bound for a bin, the value on | |
2000-01-31T12:00:00 (at noon on January 31st), will not be included in the | |
month of January. To account for this, pandas adds a day minus one worth | |
of microseconds to the bin edges generated by cftime range, so that we do | |
bin the value at noon on January 31st in the January bin. This results in | |
an index with bin edges like the following: | |
CFTimeIndex([1999-12-31 23:59:59, 2000-01-31 23:59:59, 2000-02-29 23:59:59], dtype='object') | |
The labels are still: | |
CFTimeIndex([2000-01-31 00:00:00, 2000-02-29 00:00:00], dtype='object') | |
This is also required for daily frequencies longer than one day and | |
year-end frequencies. | |
""" | |
is_super_daily = (isinstance(offset, (MonthEnd, YearEnd)) or | |
(isinstance(offset, Day) and offset.n > 1)) | |
if is_super_daily and closed == 'right': | |
datetime_bins = datetime_bins + datetime.timedelta(days=1, microseconds=-1) | |
return datetime_bins | |
class CFTimeGrouper(object): | |
"""This is a simple container for the grouping parameters that implements a | |
single method, the only one required for resampling in xarray. It cannot | |
be used in a call to groupby like a pandas.Grouper object can.""" | |
def __init__(self, freq, closed, label, base): | |
self.freq = to_offset(freq) | |
self.closed = closed | |
self.label = label | |
self.base = base | |
def first_items(self, index): | |
"""Meant to reproduce the results of the following | |
grouper = pandas.Grouper(...) | |
first_items = pd.Series(np.arange(len(index)), index).groupby(grouper).first() | |
with index being a CFTimeIndex instead of a DatetimeIndex. | |
""" | |
datetime_bins, labels = _get_time_bins(index, self.freq, self.closed, | |
self.label, self.base) | |
integer_bins = np.searchsorted(index, datetime_bins, side=self.closed)[:-1] | |
first_items = pd.Series(integer_bins, labels) | |
# Mask duplicate values with NaNs, preserving the last values | |
non_duplicate = ~first_items.duplicated('last') | |
return first_items.where(non_duplicate) | |
def _grouper(index, freq, closed, label, base): | |
"""This would generate the grouper returned by resample in common.py.""" | |
if isinstance(index, CFTimeIndex): | |
return CFTimeGrouper(freq, closed, label, base) | |
else: | |
return pd.Grouper(freq=freq, closed=closed, label=label, base=base) | |
def _first_items(index, grouper): | |
"""This would be the way first_items could be generated in groupby.py.""" | |
if isinstance(grouper, CFTimeGrouper): | |
return grouper.first_items(index) | |
else: | |
return pd.Series(np.arange(len(index)), index).groupby(grouper).first() | |
@pytest.mark.parametrize('freq', ['11M', '8001H', '600003T', '3MS']) | |
@pytest.mark.parametrize('closed', ['left', 'right']) | |
@pytest.mark.parametrize('label', ['left', 'right']) | |
@pytest.mark.parametrize('base', [0, 1]) | |
def test_first_items(datetimeindex, cftimeindex, freq, closed, label, base): | |
pandas_grouper = _grouper(datetimeindex, freq, closed, label, base) | |
expected_first_items = _first_items(datetimeindex, pandas_grouper) | |
cftime_grouper = _grouper(cftimeindex, freq, closed, label, base) | |
result_first_items = _first_items(cftimeindex, cftime_grouper) | |
# Convert CFTimeIndex to DatetimeIndex for comparison | |
result_first_items.index = result_first_items.index.to_datetimeindex() | |
assert result_first_items.equals(expected_first_items) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment