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 2020/08/28 09:44:54 UTC

[GitHub] [arrow] xhochy opened a new pull request #8072: ARROW-9879: [Python] Add support for numpy scalars to ChunkedArray.__getitem__

xhochy opened a new pull request #8072:
URL: https://github.com/apache/arrow/pull/8072


   FYI @marc9595 


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

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



[GitHub] [arrow] xhochy commented on pull request #8072: ARROW-9879: [Python] Add support for numpy scalars to ChunkedArray.__getitem__

Posted by GitBox <gi...@apache.org>.
xhochy commented on pull request #8072:
URL: https://github.com/apache/arrow/pull/8072#issuecomment-701392525


   Maybe Friday or Monday 


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

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



[GitHub] [arrow] pitrou commented on a change in pull request #8072: ARROW-9879: [Python] Add support for numpy scalars to ChunkedArray.__getitem__

Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #8072:
URL: https://github.com/apache/arrow/pull/8072#discussion_r481103093



##########
File path: python/pyarrow/table.pxi
##########
@@ -160,6 +160,8 @@ cdef class ChunkedArray(_PandasConvertible):
             return _normalize_slice(self, key)
         elif isinstance(key, int):
             return self.getitem(key)
+        elif np.isscalar(key) and np.issubdtype(key.dtype, np.integer):
+            return self.getitem(key)

Review comment:
       Yes, we should probably use the same solution everywhere (and possibly avoid manual handling of Numpy scalars).




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

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



[GitHub] [arrow] kszucs commented on a change in pull request #8072: ARROW-9879: [Python] Add support for numpy scalars to ChunkedArray.__getitem__

Posted by GitBox <gi...@apache.org>.
kszucs commented on a change in pull request #8072:
URL: https://github.com/apache/arrow/pull/8072#discussion_r501312248



##########
File path: python/pyarrow/table.pxi
##########
@@ -160,6 +160,8 @@ cdef class ChunkedArray(_PandasConvertible):
             return _normalize_slice(self, key)
         elif isinstance(key, int):

Review comment:
       I think we could use the python conversion helper  [CIntFromPython](https://github.com/apache/arrow/blob/master/cpp/src/arrow/python/helpers.h#L92) which should handle numpy scalars as well.




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

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



[GitHub] [arrow] kszucs closed pull request #8072: ARROW-9879: [Python] Add support for numpy scalars to ChunkedArray.__getitem__

Posted by GitBox <gi...@apache.org>.
kszucs closed pull request #8072:
URL: https://github.com/apache/arrow/pull/8072


   


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

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



[GitHub] [arrow] kszucs commented on a change in pull request #8072: ARROW-9879: [Python] Add support for numpy scalars to ChunkedArray.__getitem__

Posted by GitBox <gi...@apache.org>.
kszucs commented on a change in pull request #8072:
URL: https://github.com/apache/arrow/pull/8072#discussion_r501312248



##########
File path: python/pyarrow/table.pxi
##########
@@ -160,6 +160,8 @@ cdef class ChunkedArray(_PandasConvertible):
             return _normalize_slice(self, key)
         elif isinstance(key, int):

Review comment:
       I think we could use the python conversion helper  [CIntFromPython](https://github.com/apache/arrow/blob/master/cpp/src/arrow/python/helpers.h#L92) which should handle numpy scalars as well.




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

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



[GitHub] [arrow] kszucs closed pull request #8072: ARROW-9879: [Python] Add support for numpy scalars to ChunkedArray.__getitem__

Posted by GitBox <gi...@apache.org>.
kszucs closed pull request #8072:
URL: https://github.com/apache/arrow/pull/8072


   


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

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



[GitHub] [arrow] github-actions[bot] commented on pull request #8072: ARROW-9879: [Python] Add support for numpy scalars to ChunkedArray.__getitem__

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #8072:
URL: https://github.com/apache/arrow/pull/8072#issuecomment-682434733


   https://issues.apache.org/jira/browse/ARROW-9879


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

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



[GitHub] [arrow] jorisvandenbossche commented on a change in pull request #8072: ARROW-9879: [Python] Add support for numpy scalars to ChunkedArray.__getitem__

Posted by GitBox <gi...@apache.org>.
jorisvandenbossche commented on a change in pull request #8072:
URL: https://github.com/apache/arrow/pull/8072#discussion_r480942913



##########
File path: python/pyarrow/table.pxi
##########
@@ -160,6 +160,8 @@ cdef class ChunkedArray(_PandasConvertible):
             return _normalize_slice(self, key)
         elif isinstance(key, int):
             return self.getitem(key)
+        elif np.isscalar(key) and np.issubdtype(key.dtype, np.integer):
+            return self.getitem(key)

Review comment:
       Alternative is to do like `array.pxi`, and let python/cython handle the cast to integer (and let it raise error otherwise:
   
   ```suggestion
           return self.getitem(_normalize_index(key, self.chunked_array.length()))
   ```
   
   (minor downside is that the error message will only speak about "integer", and not "slice", but then anything convertible to int will be accepted automatically)




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

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



[GitHub] [arrow] jorisvandenbossche commented on pull request #8072: ARROW-9879: [Python] Add support for numpy scalars to ChunkedArray.__getitem__

Posted by GitBox <gi...@apache.org>.
jorisvandenbossche commented on pull request #8072:
URL: https://github.com/apache/arrow/pull/8072#issuecomment-701392054


   @xhochy do you have time to update this?


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

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



[GitHub] [arrow] kszucs commented on a change in pull request #8072: ARROW-9879: [Python] Add support for numpy scalars to ChunkedArray.__getitem__

Posted by GitBox <gi...@apache.org>.
kszucs commented on a change in pull request #8072:
URL: https://github.com/apache/arrow/pull/8072#discussion_r501312248



##########
File path: python/pyarrow/table.pxi
##########
@@ -160,6 +160,8 @@ cdef class ChunkedArray(_PandasConvertible):
             return _normalize_slice(self, key)
         elif isinstance(key, int):

Review comment:
       I think we could use the python conversion helper  [CIntFromPython](https://github.com/apache/arrow/blob/master/cpp/src/arrow/python/helpers.h#L92) which should handle numpy scalars as well.




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

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