Skip to content

Conversation

@maresb
Copy link
Owner

@maresb maresb commented Oct 7, 2025


📚 Documentation preview 📚: https://pytensor--2.org.readthedocs.build/en/2/

@maresb maresb requested a review from Copilot October 7, 2025 11:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR drops support for Python 3.10 and older NumPy versions (< 2.0), standardizing the codebase on NumPy 2.x only. The changes remove compatibility code that was needed to support both NumPy 1.x and 2.x versions.

  • Removes the pytensor.npy_2_compat module which provided compatibility abstractions
  • Updates imports to use NumPy 2.x native functions directly
  • Updates minimum version requirements across all configuration files

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pytensor/npy_2_compat.py Removes most compatibility code, keeping only the old_np_unique function
Multiple Python files Replace compatibility imports with direct NumPy 2.x imports
Test files Remove conditional NumPy version checks and update exception handling
Configuration files Update Python and NumPy version requirements to 3.11+ and 2.0+
CI workflows Update test matrices to remove Python 3.10 and NumPy version variations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

The value of the numpy C API NPY_RAVEL_AXIS.
"""

NDARRAY_C_VERSION = np._core._multiarray_umath._get_ndarray_c_version() # type: ignore[attr-defined]
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct access to private NumPy attributes (np._core._multiarray_umath._get_ndarray_c_version()) is fragile and may break in future NumPy releases. Consider using a more stable public API or adding error handling for when this private attribute is unavailable.

Suggested change
NDARRAY_C_VERSION = np._core._multiarray_umath._get_ndarray_c_version() # type: ignore[attr-defined]
try:
NDARRAY_C_VERSION = np._core._multiarray_umath._get_ndarray_c_version() # type: ignore[attr-defined]
except AttributeError:
logging.warning("Could not access np._core._multiarray_umath._get_ndarray_c_version(); NDARRAY_C_VERSION set to None.")
NDARRAY_C_VERSION = None

Copilot uses AI. Check for mistakes.

)

def test_too_big_rank(self):
numpy_maxdims = 64
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded value 64 should be replaced with a named constant from a central location (like pytensor.utils) to avoid magic numbers and ensure consistency across the codebase.

Suggested change
numpy_maxdims = 64
numpy_maxdims = np.MAXDIMS

Copilot uses AI. Check for mistakes.

Comment on lines +9 to 12
from numpy._core.einsumfunc import ( # type: ignore[attr-defined]
_find_contraction,
_parse_einsum_input,
normalize_axis_index,
normalize_axis_tuple,
)
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct import from private NumPy modules (numpy._core.einsumfunc) is fragile and may break in future NumPy releases. Consider using public APIs or adding fallback imports with error handling.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants