Skip to content

Closes #3329: hstack to match numpy - #4105

Merged
1RyanK merged 1 commit into
Bears-R-Us:masterfrom
1RyanK:3329_hstack_to_match_numpy
Apr 24, 2025
Merged

1RyanK merged 1 commit into
Bears-R-Us:masterfrom
1RyanK:3329_hstack_to_match_numpy

Conversation

@1RyanK

@1RyanK 1RyanK commented Feb 21, 2025 •

Copy link
Copy Markdown
Contributor

Since hstack uses concatenate in numpy, I redid concatenate on server side. It seems to work with normal pdarrays but not Strings or Categorical. I made some modifications on other things that also rely on ConcatenateMsg.chpl.

I also updated vstack because I somewhat doubt that functioned properly before. I noticed that the code where the vstack and delete tests were (tests/array_manipulation_tests.py) was not included in the pytest.ini, so I added it. The tests for delete failed, but I didn't touch it, so I suspect that was ongoing prior to my adding it.

While trying to clean things up a bit, I noticed some interesting behavior. Some things rely on the concatenate with ordered=False (meaning that when concatenating two arrays, the result may have the two arrays mixed together, rather than a whole block where you have the first, followed by everything in the second). Specifically, when comparing two Categorical objects together (i.e. for equality), it would concatenate the Strings of categories and also two aranges (which were, I guess, meant to associate the categories to numbers). Basically, it seemed to rely on the fact that they would get concatenated in the same way. This seems very sketchy to me. At some point we should probably further investigate set_categories in arkouda/categorical.py and the functions it calls. It takes a shockingly long time to test equality on two Categoricals with three things, but different categories. Definitely feels like optimizations are possible. Also ConcatenateMsg.chpl could probably benefit from optimization for Strings.

Closes #3329: hstack to match numpy

@1RyanK

1RyanK commented Feb 26, 2025

Copy link
Copy Markdown
Contributor Author

I keep getting arkouda/pdarraysetops.py:427: error: Cannot determine type of "shape" [has-type] approximately on the line shape1 = arrays[i - 1].shape. Wherever the first reference is to .shape mypy decides that it doesn't know what type that is, and that that's a problem. However, there is no problem in hstack's version. I tried printing out some info about the shape and got this:

(3,)
<class 'tuple'>
<class 'int'>

Note that I printed out the shape, type(shape), and then type(shape[0]).
I would greatly appreciate help resolving this and then after I add some tests for hstack and vstack it should be all set to be merged in.
Another thing I wasn't sure about came from here: #2802
Should I set max_bits to the minimum or maximum of the positive max_bits across the input arrays? In the example there's only one. I currently have it set to minimum, which would throw away bits. Kind of like in significant figures you don't pretend you have precision that you don't actually have.

@1RyanK
1RyanK marked this pull request as ready for review February 27, 2025 17:26
@1RyanK 1RyanK changed the title Draft PR: will close #3329 hstack to match numpy Closes #3329: hstack to match numpy Feb 27, 2025
@1RyanK 1RyanK added this to the Numpy Alignment milestone Feb 27, 2025
@1RyanK
1RyanK force-pushed the 3329_hstack_to_match_numpy branch from 9e355de to 4f878b9 Compare February 27, 2025 17:55
Comment thread src/ConcatenateMsg.chpl Resolved
@1RyanK
1RyanK force-pushed the 3329_hstack_to_match_numpy branch from 1c60d26 to 40d9b3b Compare March 6, 2025 16:57
Comment thread src/ConcatenateMsg.chpl Resolved
@1RyanK
1RyanK force-pushed the 3329_hstack_to_match_numpy branch from e30d41a to b33c809 Compare March 6, 2025 17:29
Comment thread arkouda/pdarraysetops.py Resolved
@1RyanK
1RyanK force-pushed the 3329_hstack_to_match_numpy branch from 7432abd to e37d732 Compare March 6, 2025 18:40
@ajpotts
ajpotts requested a review from e-kayrakli March 6, 2025 19:14
Comment thread tests/array_manipulation_tests.py Resolved
Comment thread src/ConcatenateMsg.chpl Resolved
Comment thread src/ConcatenateMsg.chpl Resolved
Comment thread arkouda/pdarraymanipulation.py Resolved
@1RyanK
1RyanK force-pushed the 3329_hstack_to_match_numpy branch 3 times, most recently from 5f61ff6 to ce80f3d Compare March 13, 2025 15:47
@1RyanK
1RyanK force-pushed the 3329_hstack_to_match_numpy branch 2 times, most recently from 387e17b to 5687f61 Compare April 14, 2025 18:51
@1RyanK
1RyanK force-pushed the 3329_hstack_to_match_numpy branch from 0d62a8c to f3d7fff Compare April 15, 2025 13:30

@jaketrookman jaketrookman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good

@ajpotts
ajpotts added this pull request to the merge queue Apr 23, 2025
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Apr 23, 2025
@1RyanK
1RyanK added this pull request to the merge queue Apr 23, 2025
Merged via the queue into Bears-R-Us:master with commit 280837d Apr 24, 2025
@1RyanK
1RyanK deleted the 3329_hstack_to_match_numpy branch April 29, 2025 17:04
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.

hstack to match numpy

4 participants