Skip to content

Conversation

@OlivierLuG
Copy link
Contributor

@OlivierLuG OlivierLuG commented May 28, 2020

I've tested intervals ms, s and min.
Note: the test raises an error for ms on v1.0.3, but is successful on master
Note: I did not choose to close this issue has the test fail for ns unit

[ ] #24444
[ 1 ] tests added / passed
[ x ] passes black pandas
[ x ] passes git diff upstream/master -u -- "*.py" | flake8 --diff


def test_to_timestamp_round(self):
# GH 24444
result = Period("2020-12-31 23:59:59.9995").to_timestamp().round("1 ms")
Copy link
Contributor

@dsaxton dsaxton May 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to avoid using round here and test the output of to_timestamp itself, perhaps parametrizing over different values of how. Also I think you'll want to explicitly construct expected using the Timestamp constructor instead of using to_timestamp again.

@dsaxton dsaxton added Period Period data type Testing pandas testing functions or related to the test suite labels May 28, 2020
@OlivierLuG
Copy link
Contributor Author

OlivierLuG commented May 29, 2020

As per your comment and my last comment on #24444, I think a good tests could be like the ones below. However, no one is passing correctly.

@pytest.mark.parametrize("period_str, freq, expected", [ ("2000-12-31 23:59:59.999999", "ms", 999999), ("2001-01-01 00:00:00.000001", "ms", 1), ], ) def test_to_timestamp_precision_ms(self, period_str, freq, expected): # GH 24444 result = Period(period_str).to_timestamp(freq=freq) assert result.microsecond == expected @pytest.mark.parametrize( "period_str, freq, expected", [ ("2000-12-31 23:59:59.999999999", "ns", 999999999), ("2001-01-01 00:00:00.000000001", "ns", 1), ], ) def test_to_timestamp_precision_ns(self, period_str, freq, expected): # GH 24444 result = Period(period_str).to_timestamp(freq=freq) assert result.nanosecond == expected 
@jreback
Copy link
Contributor

jreback commented May 31, 2020

@OlivierLuG these are just tests. but is this issue actually fixed?

@OlivierLuG
Copy link
Contributor Author

The issues are notre fixed. The tests all fail on master.
The flag need test mislead me. I've updated the main topic. Perhaps the flag bug is more appropriate.
Note: I tried to find a beginning point for this issue, but this is beyond my kwnoledge.

@OlivierLuG
Copy link
Contributor Author

I've managed to resolve the microsecond issue + added test.
I've made a new PR to update master. Sorry, there iare conflict. I don't know how to handle that.
[x] closes #24444
[x] black pandas passed
[x] news tests added
[x] passes git diff upstream/master -u -- "*.py" | flake8 --diff

Note, I'll will raise a new Issue. The nanosecond method returns 0 whatever I try.

@OlivierLuG OlivierLuG closed this Jun 7, 2020
@OlivierLuG OlivierLuG deleted the TST_24444 branch June 7, 2020 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Period Period data type Testing pandas testing functions or related to the test suite

3 participants