Periodic mask fix
MR adresses:
#332 (closed) : mask swap upon include_bouds=True
is fixed
#322 (closed) : maskTime actually performs a selection and should be named accordingly (selectTime)
Some minor cleanups in the documentation of selectTime
(reference to false/non-existing parameters)
closes #332 (closed) #322 (closed)
Edited by Bert Palm
Merge request reports
Activity
Filter activity
changed milestone to %2.1.0
added BUG accepted category: lib cleanup/refactoring python usability labels
requested review from @palmb
assigned to @luenensc
added 1 commit
- 5cb706e2 - added reuse compliance to test periodic mask
removed python label
this is the current test output..
=========================== short test summary info ============================ FAILED test_periodicMask.py::test_bounds[01-01T00:00:00-01-03T00:00:00-True-exp0-index0] FAILED test_periodicMask.py::test_bounds[01-01T00:00:00-01-03T00:00:00-False-exp1-index0] FAILED test_periodicMask.py::test_bounds[01-03T00:00:00-01-01T00:00:00-True-exp2-index0] FAILED test_periodicMask.py::test_bounds[01-03T00:00:00-01-01T00:00:00-False-exp3-index0] ========================= 4 failed, 2 passed in 1.88s ==========================
Expand all
/home/palmb/.virtualenvs/saqc3.9/bin/python /snap/pycharm-professional/278/plugins/python/helpers/pycharm/_jb_pytest_runner.py --path /home/palmb/projects/saqc/tests/lib/test_periodicMask.py -- --jb-show-summary Testing started at 11:20 ... Launching pytest with arguments /home/palmb/projects/saqc/tests/lib/test_periodicMask.py in /home/palmb/projects/saqc/tests/lib ============================= test session starts ============================== platform linux -- Python 3.9.5, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 -- /home/palmb/.virtualenvs/saqc3.9/bin/python cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/palmb/projects/saqc/tests/lib/.hypothesis/examples') rootdir: /home/palmb/projects/saqc plugins: hypothesis-6.17.4, lazy-fixture-0.6.3 collecting ... collected 6 items test_periodicMask.py::test_bounds[01-01T00:00:00-01-03T00:00:00-True-exp0-index0] FAILED [ 16%] result exp 1999-10-01 True True 1999-11-01 True True 1999-12-01 True True 2000-01-01 False False 2000-02-01 True False 2000-03-01 True False tests/lib/test_periodicMask.py:26 (test_bounds[01-01T00:00:00-01-03T00:00:00-True-exp0-index0]) index = DatetimeIndex(['1999-10-01', '1999-11-01', '1999-12-01', '2000-01-01', '2000-02-01', '2000-03-01'], dtype='datetime64[ns]', freq=None) start = '01-01T00:00:00', end = '01-03T00:00:00', closed = True exp = 1999-10-01 True 1999-11-01 True 1999-12-01 True 2000-01-01 False 2000-02-01 False 2000-03-01 False dtype: bool @pytest.mark.parametrize( "index", [ pd.DatetimeIndex( [ "1999-10", "1999-11", "1999-12", "2000-01", "2000-02", "2000-03", ] ) ], ) @pytest.mark.parametrize( "start, end, closed, exp", [ ( "01-01T00:00:00", "01-03T00:00:00", True, [unmasked, unmasked, unmasked, masked, masked, masked], ), ( "01-01T00:00:00", "01-03T00:00:00", False, [unmasked, unmasked, unmasked, unmasked, masked, unmasked], ), ( "01-03T00:00:00", "01-01T00:00:00", True, [masked, masked, masked, masked, unmasked, masked], ), ( "01-03T00:00:00", "01-01T00:00:00", False, [masked, masked, masked, unmasked, unmasked, unmasked], ), ], ) def test_bounds(index, start, end, closed, exp): exp = pd.Series(exp, index=index, dtype=bool) result = periodicMask(index, start, end, closed) > assert_equal(result, exp) test_periodicMask.py:74: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ result = 1999-10-01 True 1999-11-01 True 1999-12-01 True 2000-01-01 False 2000-02-01 True 2000-03-01 True dtype: bool exp = 1999-10-01 True 1999-11-01 True 1999-12-01 True 2000-01-01 False 2000-02-01 False 2000-03-01 False dtype: bool def assert_equal(result, exp): assert exp.index.equals(result.index) assert result.dtype == exp.dtype if result.equals(exp): return df = pd.DataFrame( data=np.array([result, exp]).T, index=exp.index, columns=["result", "exp"] ) print("\n", df) > assert result.equals(exp) E assert False E + where False = <bound method NDFrame.equals of 1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 False\n2000-02-01 True\n2000-03-01 True\ndtype: bool>(1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 False\n2000-02-01 False\n2000-03-01 False\ndtype: bool) E + where <bound method NDFrame.equals of 1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 False\n2000-02-01 True\n2000-03-01 True\ndtype: bool> = 1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 False\n2000-02-01 True\n2000-03-01 True\ndtype: bool.equals test_periodicMask.py:24: AssertionError FAILED [ 33%] result exp 1999-10-01 True True 1999-11-01 True True 1999-12-01 True True 2000-01-01 True True 2000-02-01 True False 2000-03-01 True True tests/lib/test_periodicMask.py:26 (test_bounds[01-01T00:00:00-01-03T00:00:00-False-exp1-index0]) index = DatetimeIndex(['1999-10-01', '1999-11-01', '1999-12-01', '2000-01-01', '2000-02-01', '2000-03-01'], dtype='datetime64[ns]', freq=None) start = '01-01T00:00:00', end = '01-03T00:00:00', closed = False exp = 1999-10-01 True 1999-11-01 True 1999-12-01 True 2000-01-01 True 2000-02-01 False 2000-03-01 True dtype: bool @pytest.mark.parametrize( "index", [ pd.DatetimeIndex( [ "1999-10", "1999-11", "1999-12", "2000-01", "2000-02", "2000-03", ] ) ], ) @pytest.mark.parametrize( "start, end, closed, exp", [ ( "01-01T00:00:00", "01-03T00:00:00", True, [unmasked, unmasked, unmasked, masked, masked, masked], ), ( "01-01T00:00:00", "01-03T00:00:00", False, [unmasked, unmasked, unmasked, unmasked, masked, unmasked], ), ( "01-03T00:00:00", "01-01T00:00:00", True, [masked, masked, masked, masked, unmasked, masked], ), ( "01-03T00:00:00", "01-01T00:00:00", False, [masked, masked, masked, unmasked, unmasked, unmasked], ), ], ) def test_bounds(index, start, end, closed, exp): exp = pd.Series(exp, index=index, dtype=bool) result = periodicMask(index, start, end, closed) > assert_equal(result, exp) test_periodicMask.py:74: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ result = 1999-10-01 True 1999-11-01 True 1999-12-01 True 2000-01-01 True 2000-02-01 True 2000-03-01 True dtype: bool exp = 1999-10-01 True 1999-11-01 True 1999-12-01 True 2000-01-01 True 2000-02-01 False 2000-03-01 True dtype: bool def assert_equal(result, exp): assert exp.index.equals(result.index) assert result.dtype == exp.dtype if result.equals(exp): return df = pd.DataFrame( data=np.array([result, exp]).T, index=exp.index, columns=["result", "exp"] ) print("\n", df) > assert result.equals(exp) E assert False E + where False = <bound method NDFrame.equals of 1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 True\n2000-02-01 True\n2000-03-01 True\ndtype: bool>(1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 True\n2000-02-01 False\n2000-03-01 True\ndtype: bool) E + where <bound method NDFrame.equals of 1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 True\n2000-02-01 True\n2000-03-01 True\ndtype: bool> = 1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 True\n2000-02-01 True\n2000-03-01 True\ndtype: bool.equals test_periodicMask.py:24: AssertionError FAILED [ 50%] result exp 1999-10-01 False False 1999-11-01 False False 1999-12-01 False False 2000-01-01 False False 2000-02-01 False True 2000-03-01 False False tests/lib/test_periodicMask.py:26 (test_bounds[01-03T00:00:00-01-01T00:00:00-True-exp2-index0]) index = DatetimeIndex(['1999-10-01', '1999-11-01', '1999-12-01', '2000-01-01', '2000-02-01', '2000-03-01'], dtype='datetime64[ns]', freq=None) start = '01-03T00:00:00', end = '01-01T00:00:00', closed = True exp = 1999-10-01 False 1999-11-01 False 1999-12-01 False 2000-01-01 False 2000-02-01 True 2000-03-01 False dtype: bool @pytest.mark.parametrize( "index", [ pd.DatetimeIndex( [ "1999-10", "1999-11", "1999-12", "2000-01", "2000-02", "2000-03", ] ) ], ) @pytest.mark.parametrize( "start, end, closed, exp", [ ( "01-01T00:00:00", "01-03T00:00:00", True, [unmasked, unmasked, unmasked, masked, masked, masked], ), ( "01-01T00:00:00", "01-03T00:00:00", False, [unmasked, unmasked, unmasked, unmasked, masked, unmasked], ), ( "01-03T00:00:00", "01-01T00:00:00", True, [masked, masked, masked, masked, unmasked, masked], ), ( "01-03T00:00:00", "01-01T00:00:00", False, [masked, masked, masked, unmasked, unmasked, unmasked], ), ], ) def test_bounds(index, start, end, closed, exp): exp = pd.Series(exp, index=index, dtype=bool) result = periodicMask(index, start, end, closed) > assert_equal(result, exp) test_periodicMask.py:74: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ result = 1999-10-01 False 1999-11-01 False 1999-12-01 False 2000-01-01 False 2000-02-01 False 2000-03-01 False dtype: bool exp = 1999-10-01 False 1999-11-01 False 1999-12-01 False 2000-01-01 False 2000-02-01 True 2000-03-01 False dtype: bool def assert_equal(result, exp): assert exp.index.equals(result.index) assert result.dtype == exp.dtype if result.equals(exp): return df = pd.DataFrame( data=np.array([result, exp]).T, index=exp.index, columns=["result", "exp"] ) print("\n", df) > assert result.equals(exp) E assert False E + where False = <bound method NDFrame.equals of 1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 False\n2000-02-01 False\n2000-03-01 False\ndtype: bool>(1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 False\n2000-02-01 True\n2000-03-01 False\ndtype: bool) E + where <bound method NDFrame.equals of 1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 False\n2000-02-01 False\n2000-03-01 False\ndtype: bool> = 1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 False\n2000-02-01 False\n2000-03-01 False\ndtype: bool.equals test_periodicMask.py:24: AssertionError FAILED [ 66%] result exp 1999-10-01 False False 1999-11-01 False False 1999-12-01 False False 2000-01-01 True True 2000-02-01 False True 2000-03-01 False True tests/lib/test_periodicMask.py:26 (test_bounds[01-03T00:00:00-01-01T00:00:00-False-exp3-index0]) index = DatetimeIndex(['1999-10-01', '1999-11-01', '1999-12-01', '2000-01-01', '2000-02-01', '2000-03-01'], dtype='datetime64[ns]', freq=None) start = '01-03T00:00:00', end = '01-01T00:00:00', closed = False exp = 1999-10-01 False 1999-11-01 False 1999-12-01 False 2000-01-01 True 2000-02-01 True 2000-03-01 True dtype: bool @pytest.mark.parametrize( "index", [ pd.DatetimeIndex( [ "1999-10", "1999-11", "1999-12", "2000-01", "2000-02", "2000-03", ] ) ], ) @pytest.mark.parametrize( "start, end, closed, exp", [ ( "01-01T00:00:00", "01-03T00:00:00", True, [unmasked, unmasked, unmasked, masked, masked, masked], ), ( "01-01T00:00:00", "01-03T00:00:00", False, [unmasked, unmasked, unmasked, unmasked, masked, unmasked], ), ( "01-03T00:00:00", "01-01T00:00:00", True, [masked, masked, masked, masked, unmasked, masked], ), ( "01-03T00:00:00", "01-01T00:00:00", False, [masked, masked, masked, unmasked, unmasked, unmasked], ), ], ) def test_bounds(index, start, end, closed, exp): exp = pd.Series(exp, index=index, dtype=bool) result = periodicMask(index, start, end, closed) > assert_equal(result, exp) test_periodicMask.py:74: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ result = 1999-10-01 False 1999-11-01 False 1999-12-01 False 2000-01-01 True 2000-02-01 False 2000-03-01 False dtype: bool exp = 1999-10-01 False 1999-11-01 False 1999-12-01 False 2000-01-01 True 2000-02-01 True 2000-03-01 True dtype: bool def assert_equal(result, exp): assert exp.index.equals(result.index) assert result.dtype == exp.dtype if result.equals(exp): return df = pd.DataFrame( data=np.array([result, exp]).T, index=exp.index, columns=["result", "exp"] ) print("\n", df) > assert result.equals(exp) E assert False E + where False = <bound method NDFrame.equals of 1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 True\n2000-02-01 False\n2000-03-01 False\ndtype: bool>(1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 True\n2000-02-01 True\n2000-03-01 True\ndtype: bool) E + where <bound method NDFrame.equals of 1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 True\n2000-02-01 False\n2000-03-01 False\ndtype: bool> = 1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 True\n2000-02-01 False\n2000-03-01 False\ndtype: bool.equals test_periodicMask.py:24: AssertionError PASSED [ 83%]PASSED [100%] test_periodicMask.py::test_bounds[01-01T00:00:00-01-03T00:00:00-False-exp1-index0] test_periodicMask.py::test_bounds[01-03T00:00:00-01-01T00:00:00-True-exp2-index0] test_periodicMask.py::test_bounds[01-03T00:00:00-01-01T00:00:00-False-exp3-index0] test_periodicMask.py::test_season[01-01T00:00:00-03-01T00:00:00-True-exp0-index0] test_periodicMask.py::test_season[01-01T00:00:00-03-01T00:00:00-False-exp1-index0] =================================== FAILURES =================================== _________ test_bounds[01-01T00:00:00-01-03T00:00:00-True-exp0-index0] __________ index = DatetimeIndex(['1999-10-01', '1999-11-01', '1999-12-01', '2000-01-01', '2000-02-01', '2000-03-01'], dtype='datetime64[ns]', freq=None) start = '01-01T00:00:00', end = '01-03T00:00:00', closed = True exp = 1999-10-01 True 1999-11-01 True 1999-12-01 True 2000-01-01 False 2000-02-01 False 2000-03-01 False dtype: bool @pytest.mark.parametrize( "index", [ pd.DatetimeIndex( [ "1999-10", "1999-11", "1999-12", "2000-01", "2000-02", "2000-03", ] ) ], ) @pytest.mark.parametrize( "start, end, closed, exp", [ ( "01-01T00:00:00", "01-03T00:00:00", True, [unmasked, unmasked, unmasked, masked, masked, masked], ), ( "01-01T00:00:00", "01-03T00:00:00", False, [unmasked, unmasked, unmasked, unmasked, masked, unmasked], ), ( "01-03T00:00:00", "01-01T00:00:00", True, [masked, masked, masked, masked, unmasked, masked], ), ( "01-03T00:00:00", "01-01T00:00:00", False, [masked, masked, masked, unmasked, unmasked, unmasked], ), ], ) def test_bounds(index, start, end, closed, exp): exp = pd.Series(exp, index=index, dtype=bool) result = periodicMask(index, start, end, closed) > assert_equal(result, exp) test_periodicMask.py:74: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ result = 1999-10-01 True 1999-11-01 True 1999-12-01 True 2000-01-01 False 2000-02-01 True 2000-03-01 True dtype: bool exp = 1999-10-01 True 1999-11-01 True 1999-12-01 True 2000-01-01 False 2000-02-01 False 2000-03-01 False dtype: bool def assert_equal(result, exp): assert exp.index.equals(result.index) assert result.dtype == exp.dtype if result.equals(exp): return df = pd.DataFrame( data=np.array([result, exp]).T, index=exp.index, columns=["result", "exp"] ) print("\n", df) > assert result.equals(exp) E assert False E + where False = <bound method NDFrame.equals of 1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 False\n2000-02-01 True\n2000-03-01 True\ndtype: bool>(1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 False\n2000-02-01 False\n2000-03-01 False\ndtype: bool) E + where <bound method NDFrame.equals of 1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 False\n2000-02-01 True\n2000-03-01 True\ndtype: bool> = 1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 False\n2000-02-01 True\n2000-03-01 True\ndtype: bool.equals test_periodicMask.py:24: AssertionError ----------------------------- Captured stdout call ----------------------------- result exp 1999-10-01 True True 1999-11-01 True True 1999-12-01 True True 2000-01-01 False False 2000-02-01 True False 2000-03-01 True False _________ test_bounds[01-01T00:00:00-01-03T00:00:00-False-exp1-index0] _________ index = DatetimeIndex(['1999-10-01', '1999-11-01', '1999-12-01', '2000-01-01', '2000-02-01', '2000-03-01'], dtype='datetime64[ns]', freq=None) start = '01-01T00:00:00', end = '01-03T00:00:00', closed = False exp = 1999-10-01 True 1999-11-01 True 1999-12-01 True 2000-01-01 True 2000-02-01 False 2000-03-01 True dtype: bool @pytest.mark.parametrize( "index", [ pd.DatetimeIndex( [ "1999-10", "1999-11", "1999-12", "2000-01", "2000-02", "2000-03", ] ) ], ) @pytest.mark.parametrize( "start, end, closed, exp", [ ( "01-01T00:00:00", "01-03T00:00:00", True, [unmasked, unmasked, unmasked, masked, masked, masked], ), ( "01-01T00:00:00", "01-03T00:00:00", False, [unmasked, unmasked, unmasked, unmasked, masked, unmasked], ), ( "01-03T00:00:00", "01-01T00:00:00", True, [masked, masked, masked, masked, unmasked, masked], ), ( "01-03T00:00:00", "01-01T00:00:00", False, [masked, masked, masked, unmasked, unmasked, unmasked], ), ], ) def test_bounds(index, start, end, closed, exp): exp = pd.Series(exp, index=index, dtype=bool) result = periodicMask(index, start, end, closed) > assert_equal(result, exp) test_periodicMask.py:74: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ result = 1999-10-01 True 1999-11-01 True 1999-12-01 True 2000-01-01 True 2000-02-01 True 2000-03-01 True dtype: bool exp = 1999-10-01 True 1999-11-01 True 1999-12-01 True 2000-01-01 True 2000-02-01 False 2000-03-01 True dtype: bool def assert_equal(result, exp): assert exp.index.equals(result.index) assert result.dtype == exp.dtype if result.equals(exp): return df = pd.DataFrame( data=np.array([result, exp]).T, index=exp.index, columns=["result", "exp"] ) print("\n", df) > assert result.equals(exp) E assert False E + where False = <bound method NDFrame.equals of 1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 True\n2000-02-01 True\n2000-03-01 True\ndtype: bool>(1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 True\n2000-02-01 False\n2000-03-01 True\ndtype: bool) E + where <bound method NDFrame.equals of 1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 True\n2000-02-01 True\n2000-03-01 True\ndtype: bool> = 1999-10-01 True\n1999-11-01 True\n1999-12-01 True\n2000-01-01 True\n2000-02-01 True\n2000-03-01 True\ndtype: bool.equals test_periodicMask.py:24: AssertionError ----------------------------- Captured stdout call ----------------------------- result exp 1999-10-01 True True 1999-11-01 True True 1999-12-01 True True 2000-01-01 True True 2000-02-01 True False 2000-03-01 True True _________ test_bounds[01-03T00:00:00-01-01T00:00:00-True-exp2-index0] __________ index = DatetimeIndex(['1999-10-01', '1999-11-01', '1999-12-01', '2000-01-01', '2000-02-01', '2000-03-01'], dtype='datetime64[ns]', freq=None) start = '01-03T00:00:00', end = '01-01T00:00:00', closed = True exp = 1999-10-01 False 1999-11-01 False 1999-12-01 False 2000-01-01 False 2000-02-01 True 2000-03-01 False dtype: bool @pytest.mark.parametrize( "index", [ pd.DatetimeIndex( [ "1999-10", "1999-11", "1999-12", "2000-01", "2000-02", "2000-03", ] ) ], ) @pytest.mark.parametrize( "start, end, closed, exp", [ ( "01-01T00:00:00", "01-03T00:00:00", True, [unmasked, unmasked, unmasked, masked, masked, masked], ), ( "01-01T00:00:00", "01-03T00:00:00", False, [unmasked, unmasked, unmasked, unmasked, masked, unmasked], ), ( "01-03T00:00:00", "01-01T00:00:00", True, [masked, masked, masked, masked, unmasked, masked], ), ( "01-03T00:00:00", "01-01T00:00:00", False, [masked, masked, masked, unmasked, unmasked, unmasked], ), ], ) def test_bounds(index, start, end, closed, exp): exp = pd.Series(exp, index=index, dtype=bool) result = periodicMask(index, start, end, closed) > assert_equal(result, exp) test_periodicMask.py:74: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ result = 1999-10-01 False 1999-11-01 False 1999-12-01 False 2000-01-01 False 2000-02-01 False 2000-03-01 False dtype: bool exp = 1999-10-01 False 1999-11-01 False 1999-12-01 False 2000-01-01 False 2000-02-01 True 2000-03-01 False dtype: bool def assert_equal(result, exp): assert exp.index.equals(result.index) assert result.dtype == exp.dtype if result.equals(exp): return df = pd.DataFrame( data=np.array([result, exp]).T, index=exp.index, columns=["result", "exp"] ) print("\n", df) > assert result.equals(exp) E assert False E + where False = <bound method NDFrame.equals of 1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 False\n2000-02-01 False\n2000-03-01 False\ndtype: bool>(1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 False\n2000-02-01 True\n2000-03-01 False\ndtype: bool) E + where <bound method NDFrame.equals of 1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 False\n2000-02-01 False\n2000-03-01 False\ndtype: bool> = 1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 False\n2000-02-01 False\n2000-03-01 False\ndtype: bool.equals test_periodicMask.py:24: AssertionError ----------------------------- Captured stdout call ----------------------------- result exp 1999-10-01 False False 1999-11-01 False False 1999-12-01 False False 2000-01-01 False False 2000-02-01 False True 2000-03-01 False False _________ test_bounds[01-03T00:00:00-01-01T00:00:00-False-exp3-index0] _________ index = DatetimeIndex(['1999-10-01', '1999-11-01', '1999-12-01', '2000-01-01', '2000-02-01', '2000-03-01'], dtype='datetime64[ns]', freq=None) start = '01-03T00:00:00', end = '01-01T00:00:00', closed = False exp = 1999-10-01 False 1999-11-01 False 1999-12-01 False 2000-01-01 True 2000-02-01 True 2000-03-01 True dtype: bool @pytest.mark.parametrize( "index", [ pd.DatetimeIndex( [ "1999-10", "1999-11", "1999-12", "2000-01", "2000-02", "2000-03", ] ) ], ) @pytest.mark.parametrize( "start, end, closed, exp", [ ( "01-01T00:00:00", "01-03T00:00:00", True, [unmasked, unmasked, unmasked, masked, masked, masked], ), ( "01-01T00:00:00", "01-03T00:00:00", False, [unmasked, unmasked, unmasked, unmasked, masked, unmasked], ), ( "01-03T00:00:00", "01-01T00:00:00", True, [masked, masked, masked, masked, unmasked, masked], ), ( "01-03T00:00:00", "01-01T00:00:00", False, [masked, masked, masked, unmasked, unmasked, unmasked], ), ], ) def test_bounds(index, start, end, closed, exp): exp = pd.Series(exp, index=index, dtype=bool) result = periodicMask(index, start, end, closed) > assert_equal(result, exp) test_periodicMask.py:74: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ result = 1999-10-01 False 1999-11-01 False 1999-12-01 False 2000-01-01 True 2000-02-01 False 2000-03-01 False dtype: bool exp = 1999-10-01 False 1999-11-01 False 1999-12-01 False 2000-01-01 True 2000-02-01 True 2000-03-01 True dtype: bool def assert_equal(result, exp): assert exp.index.equals(result.index) assert result.dtype == exp.dtype if result.equals(exp): return df = pd.DataFrame( data=np.array([result, exp]).T, index=exp.index, columns=["result", "exp"] ) print("\n", df) > assert result.equals(exp) E assert False E + where False = <bound method NDFrame.equals of 1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 True\n2000-02-01 False\n2000-03-01 False\ndtype: bool>(1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 True\n2000-02-01 True\n2000-03-01 True\ndtype: bool) E + where <bound method NDFrame.equals of 1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 True\n2000-02-01 False\n2000-03-01 False\ndtype: bool> = 1999-10-01 False\n1999-11-01 False\n1999-12-01 False\n2000-01-01 True\n2000-02-01 False\n2000-03-01 False\ndtype: bool.equals test_periodicMask.py:24: AssertionError ----------------------------- Captured stdout call ----------------------------- result exp 1999-10-01 False False 1999-11-01 False False 1999-12-01 False False 2000-01-01 True True 2000-02-01 False True 2000-03-01 False True =========================== short test summary info ============================ FAILED test_periodicMask.py::test_bounds[01-01T00:00:00-01-03T00:00:00-True-exp0-index0] FAILED test_periodicMask.py::test_bounds[01-01T00:00:00-01-03T00:00:00-False-exp1-index0] FAILED test_periodicMask.py::test_bounds[01-03T00:00:00-01-01T00:00:00-True-exp2-index0] FAILED test_periodicMask.py::test_bounds[01-03T00:00:00-01-01T00:00:00-False-exp3-index0] ========================= 4 failed, 2 passed in 1.88s ========================== Process finished with exit code 1
Edited by Bert Palmmentioned in commit 0fd879c6
mentioned in commit 63b55c6d
mentioned in commit 684dc8a0
mentioned in commit 8f7a90e4
Please register or sign in to reply