ARROW-9967: [Python] Add compute module docs + expose more option classes#8145
ARROW-9967: [Python] Add compute module docs + expose more option classes#8145arw2019 wants to merge 18 commits intoapache:masterfrom
Conversation
|
Thanks for opening a pull request! Could you open an issue for this pull request on JIRA? Then could you also rename pull request title in the following format? See also: |
edb57cc to
3f99ae8
Compare
docs/source/cpp/compute.rst
Outdated
There was a problem hiding this comment.
Noticed that this was missing on the c++ page
There was a problem hiding this comment.
Ah, thank you! However, can you leave the table alphabetically-sorted?
There was a problem hiding this comment.
Actually my bad, you already had it there. Reverted
docs/source/python/api/compute.rst
Outdated
There was a problem hiding this comment.
this is not really a transform?
There was a problem hiding this comment.
Yeah that's fair. Would Structural Transforms be a good place for it?
docs/source/python/compute.rst
Outdated
There was a problem hiding this comment.
this array is not used? (maybe show pc.equals(a, b) ?)
e79559c to
d117ed1
Compare
python/pyarrow/compute.py
Outdated
There was a problem hiding this comment.
AFAIK we can't have methods named and and or in Python. For now I went with and_ and or_ here, for consistency with and_kleene and or_kleene, but for example numpy uses np.logical_and and np.logical_or
There was a problem hiding this comment.
We already have a function named "and":
>>> from pyarrow import compute
>>> getattr(compute, "and")
<function pyarrow.compute.and(left, right, *, memory_pool=None)>So you should just fix compute.py so that it's exported as and_.
docs/source/python/api/compute.rst
Outdated
There was a problem hiding this comment.
Will this render the docstrings?
There was a problem hiding this comment.
I think so. It's what's done on the other pages:
https://github.com/apache/arrow/blob/master/docs/source/python/api/datatypes.rst
I'm having trouble building the docs locally (related to ARROW-10018 I think) so haven't been able to check
There was a problem hiding this comment.
This won't render the docstring here, but it will create a separate page for each of those functions and link to that from this table.
(the separate pages might be a bit overkill since the docstrings here are often not that informative yet, but it's indeed how we do it for other functions as well)
c2445c1 to
c1c5846
Compare
|
Question: in 952649d I'm attempting to expose This is needed to make the |
|
Cython generally doesn't convert implicitly between arbitrary Python objects and C/C++ types, you have to type your code explicitly. Also, it is better to use def __cinit__(self, int64_t pivot):
self.partition_nth_options.reset(new CPartitionNthOptions(pivot)) |
Thanks @pitrou! That was the problem |
|
This is ready for re-review. I believe that I've addressed the feedback from previous reviews. I've also now exposed all the option classes so that all the kernels listed in the docs are usable from Python. |
docs/source/python/compute.rst
Outdated
There was a problem hiding this comment.
@jorisvandenbossche Will this work? I'm not 100% sure as I haven't yet compiled the docs to explicitly check
python/pyarrow/_compute.pyx
Outdated
There was a problem hiding this comment.
I'm not sure why unique_ptr is used in some of the other classes, but it shouldn't be necessary. See MinMaxOptions for an example without.
There was a problem hiding this comment.
In PartitionNthOptions we need it because it doesn't have a null constructor so it can't be allocated on the stack. That's not the case for VarianceOptions, though, so I'll take a look
There was a problem hiding this comment.
I've rewritten VarianceOptions without unique_ptr.
I think that with the other three options classes exposed in this PR (SetLookupOptions, PartitionNthOptions and StrptimeOptions) it's necessary to use unique_ptr or, alternatively, we would need to define default constructors
|
@github-actions crossbow submit test-ubuntu-18.04-docs |
|
Revision: 73272bf38f2d8406b60a6ebaa20c5f4e58dff075 Submitted crossbow builds: ursa-labs/crossbow @ actions-615
|
|
CI failures are unrelated. |
|
Thanks @pitrou @jorisvandenbossche for reviewing! |
#8163 exposes
pyarrow.computekernels and generates their docstrings. This PR adds documentation for the module in the User Guide and the Python API reference.