Skip to content

TST: Fix makeObjectSeries data as object type #28444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 17, 2019

Conversation

jmg7173
Copy link
Contributor

@jmg7173 jmg7173 commented Sep 14, 2019

@gfyoung gfyoung added the Testing pandas testing functions or related to the test suite label Sep 15, 2019
@gfyoung gfyoung requested a review from WillAyd September 15, 2019 03:34
@WillAyd
Copy link
Member

WillAyd commented Sep 16, 2019

Cool this looks good. Any chance you looked at where this was ultimately used? Would be nice to clean up any casting that this required in the past

@WillAyd WillAyd added this to the 1.0 milestone Sep 16, 2019
@jmg7173
Copy link
Contributor Author

jmg7173 commented Sep 16, 2019

Umm, there is no casting about this.

One thing that I can doubt is usage on test_objarr_add_invalid. Because it tested about add and sub operation on object that made by datetime64[ns].
It is at pandas/tests/arithmetic/test_object.py L144.

Other things are used just representing a series made by object as I summarized at #28378.

Can you tell me more details about what should I do?

And should I add an entry at whatsnew on v1.0?

@WillAyd
Copy link
Member

WillAyd commented Sep 16, 2019

One thing that I can doubt is usage on test_objarr_add_invalid. Because it tested about add and sub operation on object that made by datetime64[ns].
It is at pandas/tests/arithmetic/test_object.py L144.

Yea that's a great find - thanks for being thorough. Can you see where that was introduced to see what the intention was? The fact that it blanket catches an Exception is a little bit of a red flag as to the intent.

Also looking these over I'm surprised that all of the makeABCSeries methods don't actually make a series of dtype ABC, but instead just contain an index of dtype ABC. Do you have any thoughts on how those methods are comprehensively used?

@jmg7173
Copy link
Contributor Author

jmg7173 commented Sep 16, 2019

Can you see where that was introduced to see what the intention was?

Although I can't find origin of test_objarr_add_invalid, but it's intention was raising error on numerical operator about datetime64[ns] like object. Here's my reference(91ee418). I can't find more deeply because file was deleted.(pandas/tests/test_series.py)

def test_operators_timedelta64(self):
# invalid ops
self.assertRaises(Exception, self.objSeries.__add__, 1)
self.assertRaises(Exception, self.objSeries.__add__,
np.array(1, dtype=np.int64))
self.assertRaises(Exception, self.objSeries.__sub__, 1)
self.assertRaises(Exception, self.objSeries.__sub__,
np.array(1, dtype=np.int64))

So, test would be modified as datetime64[ns] converted to base object.

Also looking these over I'm surprised that all of the makeABCSeries methods don't actually make a series of dtype ABC, but instead just contain an index of dtype ABC.

Yes, only makeObjectSeries returns a series that contains dtype=object... It is so weird. I think makeObjectSeries do correct job and other things are not. I think every makeABCSeries should return dtype=ABC with default index. What do you expect as exact result of makeABCSeries?

Do you have any thoughts on how those methods are comprehensively used?

About that, it's too hard question to me :)

@WillAyd
Copy link
Member

WillAyd commented Sep 16, 2019

I think makeObjectSeries do correct job and other things are not. I think every makeABCSeries should return dtype=ABC with default index.

Yea that seems logical to me though doesn't appear to be the case. cc @jreback in case of any historical knowledge as to why things are that way

@jreback jreback merged commit 25d71fe into pandas-dev:master Sep 17, 2019
@jreback
Copy link
Contributor

jreback commented Sep 17, 2019

thanks @jmg7173

yeah we likely have enough testing already in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tm.makeObjectSeries returns a Series with dtype="datetime64[ns]"
4 participants