You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jorisvandenbossche (via GitHub)" <gi...@apache.org> on 2024/04/20 09:51:13 UTC

[PR] feat(python): function to inspect a single-chunk Array [arrow-nanoarrow]

jorisvandenbossche opened a new pull request, #436:
URL: https://github.com/apache/arrow-nanoarrow/pull/436

   Addresses https://github.com/apache/arrow-nanoarrow/issues/435
   
   Reusing the existing repr utilities, the current code gives this:
   
   ```
   In [1]: import nanoarrow as na
   
   In [2]: pa_arr = pa.array([[0, 1], [None, 3], None, [4]])
   
   In [3]: arr = na.Array(pa_arr)
   
   In [4]: arr.inspect()
   <ArrowArray list<item: int64>>
   - length: 4
   - offset: 0
   - null_count: 1
   - buffers[2]:
     - validity <bool[1 b] 11010000>
     - data_offset <int32[20 b] 0 2 4 4 5>
   - dictionary: NULL
   - children[1]:
     'item': <ArrowArray int64>
       - length: 5
       - offset: 0
       - null_count: 1
       - buffers[2]:
         - validity <bool[1 b] 11011000>
         - data <int64[40 b] 0 1 0 3 4>
       - dictionary: NULL
       - children[0]:
   ```


-- 
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


Re: [PR] feat(python): function to inspect a single-chunk Array [arrow-nanoarrow]

Posted by "jorisvandenbossche (via GitHub)" <gi...@apache.org>.
jorisvandenbossche merged PR #436:
URL: https://github.com/apache/arrow-nanoarrow/pull/436


-- 
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


Re: [PR] feat(python): function to inspect a single-chunk Array [arrow-nanoarrow]

Posted by "jorisvandenbossche (via GitHub)" <gi...@apache.org>.
jorisvandenbossche commented on code in PR #436:
URL: https://github.com/apache/arrow-nanoarrow/pull/436#discussion_r1575103422


##########
python/src/nanoarrow/array.py:
##########
@@ -490,3 +490,7 @@ def to_string(self, width_hint=80, items_hint=10) -> str:
 
     def __repr__(self) -> str:
         return self.to_string()
+
+    def inspect(self): # or dump?

Review Comment:
   > This could probably fairly easily be extended to multiple chunks (by printing out in a loop?)
   
   That's indeed true, that shouldn't be that hard. We don't need it right now, so would prefer to do it later



-- 
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


Re: [PR] feat(python): function to inspect a single-chunk Array [arrow-nanoarrow]

Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot commented on code in PR #436:
URL: https://github.com/apache/arrow-nanoarrow/pull/436#discussion_r1575119448


##########
python/src/nanoarrow/_repr_utils.py:
##########
@@ -248,3 +248,46 @@ def device_repr(device):
     device_type = f"- device_type: {device.device_type.name} <{device.device_type_id}>"
     device_id = f"- device_id: {device.device_id}"
     return "\n".join([title_line, device_type, device_id])
+
+
+def array_dump(array, indent=0, max_char_width=80):

Review Comment:
   ```suggestion
   def array_inspect(array, indent=0, max_char_width=80):
   ```



-- 
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


Re: [PR] feat(python): function to inspect a single-chunk Array [arrow-nanoarrow]

Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot commented on code in PR #436:
URL: https://github.com/apache/arrow-nanoarrow/pull/436#discussion_r1573245816


##########
python/src/nanoarrow/array.py:
##########
@@ -490,3 +490,7 @@ def to_string(self, width_hint=80, items_hint=10) -> str:
 
     def __repr__(self) -> str:
         return self.to_string()
+
+    def inspect(self): # or dump?

Review Comment:
   I quite like `inspect()`!
   
   This could probably fairly easily be extended to multiple chunks (by printing out in a loop?)



-- 
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