Skip to content
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

toolbox: handle object arrays in pmm (closes #183) #239

Merged
merged 5 commits into from Nov 7, 2019

Conversation

drsteve
Copy link
Member

@drsteve drsteve commented Nov 5, 2019

Closes #183

This PR provides:

Any suggestions for wording on the warning? Or other implementation issues?

@TravisBuddy
Copy link

Hey @drsteve,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 20dccdd0-fff6-11e9-bdc5-7d173ed77079

@jtniehof
Copy link
Member

jtniehof commented Nov 5, 2019

Rather than arange I would probably use ind = Ellipsis to get the whole array. It makes it a little more obvious what you're doing and dodges any potential problem with multidimensional arrays (I didn't find any in testing, but you never know.)

For the warning, there's little idea of the implications. Unable to exclude infinite values, which may result in wrong output?

This only works for a. If the b args are object type, they still fail. Any reason we can't just rewrite the whole thing as *args and loop for a in args appending to ans each time?

Finally, this doesn't work for strings. That would be a different PR except it does work for objects. Patch attached.

string.txt

@drsteve
Copy link
Member Author

drsteve commented Nov 6, 2019

Thanks, updates made.

Your string-type test gave me numpy FutureWarnings like:

 FutureWarning: Conversion of the second argument of issubdtype from `'U'` to `str` is deprecated.
In future, it will be treated as `np.str_ == np.dtype('U').type`.
  if np.issubdtype(a_tmp.dtype, 'S') or np.issubdtype(a_tmp.dtype, 'U'):

So I've also switched that test to

a_tmp.dtype.type in [np.dtype('S').type, np.dtype('U').type]

which should do the same thing, but avoids the warning.

@TravisBuddy
Copy link

Hey @drsteve,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 2b9d3c20-002b-11ea-8b9e-5d36b4f25336

@TravisBuddy
Copy link

Hey @drsteve,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 8c75c1b0-002c-11ea-8b9e-5d36b4f25336

@jtniehof
Copy link
Member

jtniehof commented Nov 7, 2019

Good catch on the deprecation. Thoughts on the b arguments? I can probably just push to your branch....

@drsteve
Copy link
Member Author

drsteve commented Nov 7, 2019

Right, forgot about that...
Why not just get rid of the code for the bs and loop the current code for the a argument over all inputs, appending to the answer list?

If that sounds sensible then I can give it a crack later? If you have other ideas, or wanted to push something then I'm good with that too.

@jtniehof
Copy link
Member

jtniehof commented Nov 7, 2019

That's exactly what I was thinking, just make the function signature *args, start with ans=[], and then for a in args BLAH append to ans, remove the whole "for val in b" loop.

@jtniehof
Copy link
Member

jtniehof commented Nov 7, 2019

Looks good. Since @balarsen hasn't chimed in I'll assume he doesn't object and will merge once Travis is happy.

@TravisBuddy
Copy link

Hey @drsteve,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: c6530870-0185-11ea-82f1-cf3ba55cf6d0

@jtniehof jtniehof merged commit 4167c58 into spacepy:master Nov 7, 2019
@balarsen
Copy link
Contributor

balarsen commented Nov 7, 2019 via email

@drsteve drsteve deleted the issue183 branch November 26, 2019 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Toolbox.pmm does not work with date or object arrays
4 participants