You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "graingert (via GitHub)" <gi...@apache.org> on 2023/10/05 13:14:10 UTC

[PR] fix for numpy2 [arrow]

graingert opened a new pull request, #38040:
URL: https://github.com/apache/arrow/pull/38040

   <!--
   Thanks for opening a pull request!
   If this is your first pull request you can find detailed information on how 
   to contribute here:
     * [New Contributor's Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
     * [Contributing Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
   
   
   If this is not a [minor PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose
   
   Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
   
   Then could you also rename the pull request title in the following format?
   
       GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   or
   
       MINOR: [${COMPONENT}] ${SUMMARY}
   
   In the case of PARQUET issues on JIRA the title also supports:
   
       PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   -->
   
   ### Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   ### What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ### Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ### Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please uncomment the line below and explain which changes are breaking.
   -->
   <!-- **This PR includes breaking changes to public APIs.** -->
   
   <!--
   Please uncomment the line below (and provide explanation) if the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld). We use this to highlight fixes to issues that may affect users without their knowledge. For this reason, fixing bugs that cause errors don't count, since those are usually obvious.
   -->
   <!-- **This PR contains a "Critical Fix".** -->


-- 
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] GH-37574: [Python] fix for numpy2 [arrow]

Posted by "graingert (via GitHub)" <gi...@apache.org>.
graingert commented on code in PR #38040:
URL: https://github.com/apache/arrow/pull/38040#discussion_r1347591247


##########
python/pyarrow/pandas_compat.py:
##########
@@ -36,6 +36,17 @@
 from pyarrow.lib import _pandas_api, frombytes  # noqa
 
 
+try:
+    _np_unicode = np.unicode_
+except AttributeError:
+    _np_unicode = np.str_
+
+try:
+    _np_sctypes = np.sctypes
+except AttributeError:
+    from numpy.core.numerictypes import sctypes as _np_sctypes

Review Comment:
   yep looks like this code can be simplified a lot
   ```python
   >>> import numpy as np
   >>> np.__version__
   '1.16.6'
   >>> np.unicode_ is np.str_
   True
   >>> np.NaN is np.nan
   True
   >>> from numpy.core.numerictypes import sctypes
   >>> np.sctypes is sctypes
   True
   >>> 
   ```



-- 
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] GH-37574: [Python] Compatibility with numpy 2.0 [arrow]

Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #38040:
URL: https://github.com/apache/arrow/pull/38040#issuecomment-1750542956

   After merging your PR, Conbench analyzed the 6 benchmarking runs that have been run so far on merge-commit 1eec38d833ca57ad826cea57f85d68532172c88c.
   
   There were 5 benchmark results indicating a performance regression:
   
   - Commit Run on `ursa-i9-9960x` at [2023-10-06 05:02:36Z](https://conbench.ursa.dev/compare/runs/8016d5c3fc3e413ca0e8ab7f7bb52e1c...141651da421049f3b1669d7a3f5a4d88/)
     - [`tpch` (R) with engine=arrow, format=native, language=R, memory_map=False, query_id=TPCH-07, scale_factor=1](https://conbench.ursa.dev/compare/benchmarks/0651f8114b497d0a800064c2516f52f3...0651fad401c47b0c800019d79aa0c361)
     - [`tpch` (R) with engine=arrow, format=parquet, language=R, memory_map=False, query_id=TPCH-07, scale_factor=1](https://conbench.ursa.dev/compare/benchmarks/0651f811f62b7ccb8000cfbedc258f7b...0651fad4fab279098000eed8dccd2985)
   - and 3 more (see the report linked below)
   
   The [full Conbench report](https://github.com/apache/arrow/runs/17464494472) has more details. It also includes information about 6 possible false positives for unstable benchmarks that are known to sometimes produce them.


-- 
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] GH-37574: [Python] fix for numpy2 [arrow]

Posted by "graingert (via GitHub)" <gi...@apache.org>.
graingert commented on code in PR #38040:
URL: https://github.com/apache/arrow/pull/38040#discussion_r1347585510


##########
python/pyarrow/pandas_compat.py:
##########
@@ -36,6 +36,17 @@
 from pyarrow.lib import _pandas_api, frombytes  # noqa
 
 
+try:
+    _np_unicode = np.unicode_
+except AttributeError:
+    _np_unicode = np.str_
+
+try:
+    _np_sctypes = np.sctypes
+except AttributeError:
+    from numpy.core.numerictypes import sctypes as _np_sctypes

Review Comment:
   I'm just trying out a run locally with numpy 1.16.6



-- 
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] GH-37574: [Python] Compatibilty with numpy 2.0 [arrow]

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


-- 
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] GH-37574: [PYARROW] fix for numpy2 [arrow]

Posted by "graingert (via GitHub)" <gi...@apache.org>.
graingert commented on code in PR #38040:
URL: https://github.com/apache/arrow/pull/38040#discussion_r1347469139


##########
ci/scripts/install_pandas.sh:
##########
@@ -28,7 +28,7 @@ pandas=$1
 numpy=${2:-"latest"}
 
 if [ "${numpy}" = "nightly" ]; then
-  pip install --extra-index-url https://pypi.anaconda.org/scipy-wheels-nightly/simple --pre numpy

Review Comment:
   scipy-wheels-nightly only has up to [pandas-2.1.0.dev0+926](https://pypi.anaconda.org/scipy-wheels-nightly/simple/pandas/2.1.0.dev0%2B926.g4e8306690e/pandas-2.1.0.dev0%2B926.g4e8306690e-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl)
   
   scientific-python-nightly-wheels has up to
   [pandas-2.2.0.dev0+325](https://pypi.anaconda.org/scientific-python-nightly-wheels/simple/pandas/2.2.0.dev0%2B325.g6c58a217f5/pandas-2.2.0.dev0%2B325.g6c58a217f5-cp39-cp39-macosx_11_0_arm64.whl)



-- 
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] GH-37574: [Python] fix for numpy2 [arrow]

Posted by "AlenkaF (via GitHub)" <gi...@apache.org>.
AlenkaF commented on code in PR #38040:
URL: https://github.com/apache/arrow/pull/38040#discussion_r1347578569


##########
python/pyarrow/pandas_compat.py:
##########
@@ -36,6 +36,17 @@
 from pyarrow.lib import _pandas_api, frombytes  # noqa
 
 
+try:
+    _np_unicode = np.unicode_
+except AttributeError:
+    _np_unicode = np.str_
+
+try:
+    _np_sctypes = np.sctypes
+except AttributeError:
+    from numpy.core.numerictypes import sctypes as _np_sctypes

Review Comment:
   Thank you for contributing, much appreciated!
   
   One question, is the reason for the Try Except older Python version (or numpy?) or can we just replace `np.unicode_` with `np.str_` and `np.sctypes` with `sctypes` (like `np.NaN` with `np.nan`)?



-- 
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] GH-37574: [Python] fix for numpy2 [arrow]

Posted by "jorisvandenbossche (via GitHub)" <gi...@apache.org>.
jorisvandenbossche commented on PR #38040:
URL: https://github.com/apache/arrow/pull/38040#issuecomment-1749146687

   @github-actions crossbow submit test-conda-python-3.10-pandas-nightly


-- 
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] GH-37574: [Python] fix for numpy2 [arrow]

Posted by "graingert (via GitHub)" <gi...@apache.org>.
graingert commented on PR #38040:
URL: https://github.com/apache/arrow/pull/38040#issuecomment-1749186149

   @jorisvandenbossche the nightly build passed!


-- 
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] fix for numpy2 [arrow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #38040:
URL: https://github.com/apache/arrow/pull/38040#issuecomment-1748876254

   <!--
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
     distributed with this work for additional information
     regarding copyright ownership.  The ASF licenses this file
     to you under the Apache License, Version 2.0 (the
     "License"); you may not use this file except in compliance
     with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
     Unless required by applicable law or agreed to in writing,
     software distributed under the License is distributed on an
     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
     specific language governing permissions and limitations
     under the License.
   -->
   
   Thanks for opening a pull request!
   
   If this is not a [minor PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose
   
   Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
   
   Then could you also rename the pull request title in the following format?
   
       GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   or
   
       MINOR: [${COMPONENT}] ${SUMMARY}
   
   In the case of PARQUET issues on JIRA the title also supports:
   
       PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   See also:
   
     * [Other pull requests](https://github.com/apache/arrow/pulls/)
     * [Contribution Guidelines - How to contribute patches](https://arrow.apache.org/docs/developers/contributing.html#how-to-contribute-patches)
   


-- 
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] GH-37574: [Python] fix for numpy2 [arrow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #38040:
URL: https://github.com/apache/arrow/pull/38040#issuecomment-1749152262

   Revision: 3c1c6aa3f9afa63c543549268435c0d983c58fcb
   
   Submitted crossbow builds: [ursacomputing/crossbow @ actions-64438424d7](https://github.com/ursacomputing/crossbow/branches/all?query=actions-64438424d7)
   
   |Task|Status|
   |----|------|
   |test-conda-python-3.10-pandas-nightly|[![Github Actions](https://github.com/ursacomputing/crossbow/actions/workflows/crossbow.yml/badge.svg?branch=actions-64438424d7-github-test-conda-python-3.10-pandas-nightly)](https://github.com/ursacomputing/crossbow/actions/runs/6421253207/job/17435177620)|


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