pitrou commented on code in PR #38499:
URL: https://github.com/apache/arrow/pull/38499#discussion_r1446463609


##########
python/pyarrow/compute.py:
##########
@@ -661,7 +661,7 @@ def random(n, *, initializer='system', options=None, 
memory_pool=None):
     memory_pool : pyarrow.MemoryPool, optional
         If not passed, will allocate memory from the default memory pool.
     """
-    options = RandomOptions(initializer=initializer)
+    options = options or RandomOptions(initializer=initializer)

Review Comment:
   We should ideally raise an error if passing both `options` and 
`initializer`, can you add that and a test for it?
   Similar example:
   ```python
   >>> pc.sum([1,2,None], skip_nulls=False)
   <pyarrow.Int64Scalar: None>
   >>> pc.sum([1,2,None], options=pc.ScalarAggregateOptions(skip_nulls=False))
   <pyarrow.Int64Scalar: None>
   >>> pc.sum([1,2,None], skip_nulls=False, 
options=pc.ScalarAggregateOptions(skip_nulls=False))
   Traceback (most recent call last):
     Cell In[8], line 1
       pc.sum([1,2,None], skip_nulls=False, 
options=pc.ScalarAggregateOptions(skip_nulls=False))
     File ~/arrow/dev/python/pyarrow/compute.py:259 in wrapper
       options = _handle_options(func_name, options_class, options,
     File ~/arrow/dev/python/pyarrow/compute.py:218 in _handle_options
       raise TypeError(
   TypeError: Function 'sum' called with both an 'options' argument and 
additional arguments
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to