You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/12/30 17:45:01 UTC

[GitHub] [arrow] lidavidm commented on a change in pull request #12054: ARROW-15219: [Python] Export the random compute function

lidavidm commented on a change in pull request #12054:
URL: https://github.com/apache/arrow/pull/12054#discussion_r776817289



##########
File path: python/pyarrow/_compute.pyx
##########
@@ -1331,6 +1331,32 @@ class Utf8NormalizeOptions(_Utf8NormalizeOptions):
         self._set_options(form)
 
 
+cdef class _RandomOptions(FunctionOptions):
+    def _set_options(self, length, initializer):
+        if initializer == 'system':
+            self.wrapped.reset(new CRandomOptions(
+                CRandomOptions.FromSystemRandom(length)))
+            return
+
+        if not isinstance(initializer, int):
+            try:
+                initializer = hash(initializer)
+            except TypeError:
+                raise TypeError(
+                    f"initializer should be 'system', an integer, "
+                    f"or a hashable object; got {initializer!r}")

Review comment:
       Is it useful to `raise from` here to preserve the original context?




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org