westonpace commented on code in PR #43488:
URL: https://github.com/apache/arrow/pull/43488#discussion_r1706984046


##########
python/pyarrow/array.pxi:
##########
@@ -4447,6 +4447,69 @@ cdef class FixedShapeTensorArray(ExtensionArray):
             FixedSizeListArray.from_arrays(values, shape[1:].prod())
         )
 
+cdef class Bool8Array(ExtensionArray):
+    """
+    Concrete class for bool8 extension arrays.
+    Examples
+    --------
+    Define the extension type for an bool8 array
+    >>> import pyarrow as pa
+    >>> bool8_type = pa.bool8()
+    Create an extension array
+    >>> arr = [-1, 0, 1, 2, None]
+    >>> storage = pa.array(arr, pa.int8())
+    >>> pa.ExtensionArray.from_storage(bool8_type, storage)
+    <pyarrow.lib.Bool8Array object at ...>
+    [
+      -1,
+      0,
+      1,
+      2,
+      null
+    ]
+    """
+
+    def to_numpy(self, zero_copy_only=True, writable=False):
+        try:
+            return self.storage.to_numpy().view(np.bool_)
+        except ArrowInvalid as e:
+            if zero_copy_only:
+                raise e
+
+        return _pc().not_equal(self.storage, 
0).to_numpy(zero_copy_only=zero_copy_only, writable=writable)

Review Comment:
   Got it.  Thanks for the explanation!



-- 
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-unsubscr...@arrow.apache.org

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

Reply via email to