diff --git a/ci/deps/azure-36-32bit.yaml b/ci/deps/azure-36-32bit.yaml index 2dc53f8181ac4..3a661beb34f48 100644 --- a/ci/deps/azure-36-32bit.yaml +++ b/ci/deps/azure-36-32bit.yaml @@ -22,5 +22,5 @@ dependencies: # see comment above - pip - pip: - - cython>=0.29.16 + - Cython==3.0a5 - pytest>=5.0.1,<6.0.0rc0 diff --git a/ci/deps/azure-36-locale.yaml b/ci/deps/azure-36-locale.yaml index d31015fde4741..9c9b861b67a1c 100644 --- a/ci/deps/azure-36-locale.yaml +++ b/ci/deps/azure-36-locale.yaml @@ -6,7 +6,6 @@ dependencies: - python=3.6.* # tools - - cython>=0.29.16 - pytest>=5.0.1,<6.0.0rc0 - pytest-xdist>=1.21 - pytest-asyncio @@ -36,3 +35,6 @@ dependencies: - xlsxwriter - xlwt - moto + + - pip: + - Cython==3.0a5 diff --git a/ci/deps/azure-36-locale_slow.yaml b/ci/deps/azure-36-locale_slow.yaml index 23121b985492e..75710dfc301b3 100644 --- a/ci/deps/azure-36-locale_slow.yaml +++ b/ci/deps/azure-36-locale_slow.yaml @@ -6,7 +6,6 @@ dependencies: - python=3.6.* # tools - - cython>=0.29.16 - pytest>=5.0.1,<6.0.0rc0 - pytest-xdist>=1.21 - hypothesis>=3.58.0 @@ -29,4 +28,5 @@ dependencies: - xlwt=1.2.0 - pip - pip: + - Cython==3.0a5 - html5lib==1.0b2 diff --git a/ci/deps/azure-36-minimum_versions.yaml b/ci/deps/azure-36-minimum_versions.yaml index f5af7bcf36189..e8183ee579a34 100644 --- a/ci/deps/azure-36-minimum_versions.yaml +++ b/ci/deps/azure-36-minimum_versions.yaml @@ -5,7 +5,6 @@ dependencies: - python=3.6.1 # tools - - cython=0.29.16 - pytest=5.0.1 - pytest-xdist>=1.21 - hypothesis>=3.58.0 @@ -28,3 +27,6 @@ dependencies: - xlsxwriter=0.9.8 - xlwt=1.2.0 - html5lib=1.0.1 + + - pip: + - Cython==3.0a5 diff --git a/ci/deps/azure-36-slow.yaml b/ci/deps/azure-36-slow.yaml index 0a6d1d13c8549..ae1aa0143b4fc 100644 --- a/ci/deps/azure-36-slow.yaml +++ b/ci/deps/azure-36-slow.yaml @@ -6,7 +6,6 @@ dependencies: - python=3.6.* # tools - - cython>=0.29.16 - pytest>=5.0.1,<6.0.0rc0 - pytest-xdist>=1.21 - hypothesis>=3.58.0 @@ -33,3 +32,5 @@ dependencies: - xlsxwriter - xlwt - moto + - pip: + - Cython==3.0a5 diff --git a/ci/deps/azure-37-locale.yaml b/ci/deps/azure-37-locale.yaml index 77aae791a47c1..6c3452d43d8f3 100644 --- a/ci/deps/azure-37-locale.yaml +++ b/ci/deps/azure-37-locale.yaml @@ -5,7 +5,6 @@ dependencies: - python=3.7.* # tools - - cython>=0.29.16 - pytest>=5.0.1,<6.0.0rc0 - pytest-xdist>=1.21 - pytest-asyncio @@ -35,4 +34,5 @@ dependencies: - pyarrow>=0.15 - pip - pip: + - Cython==3.0a5 - pyxlsb diff --git a/ci/deps/azure-37-numpydev.yaml b/ci/deps/azure-37-numpydev.yaml index 451fb5884a4af..87bdf8825e5d3 100644 --- a/ci/deps/azure-37-numpydev.yaml +++ b/ci/deps/azure-37-numpydev.yaml @@ -14,7 +14,7 @@ dependencies: - pytz - pip - pip: - - cython==0.29.16 # GH#34014 + - Cython==3.0a5 - "git+git://github.com/dateutil/dateutil.git" - "--extra-index-url https://pypi.anaconda.org/scipy-wheels-nightly/simple" - "--pre" diff --git a/ci/deps/azure-macos-36.yaml b/ci/deps/azure-macos-36.yaml index 81a27465f9e61..cdbaa8fa7892a 100644 --- a/ci/deps/azure-macos-36.yaml +++ b/ci/deps/azure-macos-36.yaml @@ -31,6 +31,6 @@ dependencies: - xlwt - pip - pip: - - cython>=0.29.16 + - Cython==3.0a5 - pyreadstat - pyxlsb diff --git a/ci/deps/azure-windows-36.yaml b/ci/deps/azure-windows-36.yaml index 4d7e1d821037b..ab49a9caef77e 100644 --- a/ci/deps/azure-windows-36.yaml +++ b/ci/deps/azure-windows-36.yaml @@ -6,7 +6,6 @@ dependencies: - python=3.6.* # tools - - cython>=0.29.16 - pytest>=5.0.1,<6.0.0rc0 - pytest-xdist>=1.21 - hypothesis>=3.58.0 @@ -30,3 +29,5 @@ dependencies: - xlrd - xlsxwriter - xlwt + - pip: + - Cython==3.0a5 \ No newline at end of file diff --git a/ci/deps/azure-windows-37.yaml b/ci/deps/azure-windows-37.yaml index 34fca631df6c1..73cdb0ff1bd14 100644 --- a/ci/deps/azure-windows-37.yaml +++ b/ci/deps/azure-windows-37.yaml @@ -6,7 +6,6 @@ dependencies: - python=3.7.* # tools - - cython>=0.29.16 - pytest>=5.0.1,<6.0.0rc0 - pytest-xdist>=1.21 - hypothesis>=3.58.0 @@ -38,4 +37,5 @@ dependencies: - pyreadstat - pip - pip: + - Cython==3.0a5 - pyxlsb diff --git a/ci/deps/travis-36-cov.yaml b/ci/deps/travis-36-cov.yaml index 5f5ea8034cddf..78b721d0fc7b4 100644 --- a/ci/deps/travis-36-cov.yaml +++ b/ci/deps/travis-36-cov.yaml @@ -6,7 +6,6 @@ dependencies: - python=3.6.* # tools - - cython>=0.29.16 - pytest>=5.0.1,<6.0.0rc0 - pytest-xdist>=1.21 - hypothesis>=3.58.0 @@ -15,7 +14,6 @@ dependencies: # pandas dependencies - beautifulsoup4 - botocore>=1.11 - - cython>=0.29.16 - dask - fastparquet>=0.3.2 - fsspec>=0.7.4 @@ -47,6 +45,7 @@ dependencies: - xlwt - pip - pip: + - Cython==3.0a5 - brotlipy - coverage - pandas-datareader diff --git a/ci/deps/travis-36-locale.yaml b/ci/deps/travis-36-locale.yaml index 6bc4aba733ee5..e31a83d2b02fb 100644 --- a/ci/deps/travis-36-locale.yaml +++ b/ci/deps/travis-36-locale.yaml @@ -6,7 +6,6 @@ dependencies: - python=3.6.* # tools - - cython>=0.29.16 - pytest>=5.0.1,<6.0.0rc0 - pytest-xdist>=1.21 - hypothesis>=3.58.0 @@ -38,3 +37,5 @@ dependencies: - xlrd - xlsxwriter - xlwt + - pip: + - Cython==3.0a5 \ No newline at end of file diff --git a/ci/deps/travis-37-arm64.yaml b/ci/deps/travis-37-arm64.yaml index f434a03609b26..2f7cf2d975ed1 100644 --- a/ci/deps/travis-37-arm64.yaml +++ b/ci/deps/travis-37-arm64.yaml @@ -6,7 +6,6 @@ dependencies: - python=3.7.* # tools - - cython>=0.29.13 - pytest>=5.0.1,<6.0.0rc0 - pytest-xdist>=1.21 - hypothesis>=3.58.0 @@ -18,4 +17,5 @@ dependencies: - pytz - pip - pip: + - Cython==3.0a5 - moto diff --git a/ci/deps/travis-37.yaml b/ci/deps/travis-37.yaml index aaf706d61fe5c..ce02a546deddd 100644 --- a/ci/deps/travis-37.yaml +++ b/ci/deps/travis-37.yaml @@ -6,7 +6,6 @@ dependencies: - python=3.7.* # tools - - cython>=0.29.16 - pytest>=5.0.1,<6.0.0rc0 - pytest-xdist>=1.21 - hypothesis>=3.58.0 @@ -24,4 +23,5 @@ dependencies: - pyreadstat - pip - pip: + - Cython==3.0a5 - moto diff --git a/ci/deps/travis-38.yaml b/ci/deps/travis-38.yaml index ac39a223cd086..1f5a0ade9444d 100644 --- a/ci/deps/travis-38.yaml +++ b/ci/deps/travis-38.yaml @@ -6,7 +6,6 @@ dependencies: - python=3.8.* # tools - - cython>=0.29.16 - pytest>=5.0.1,<6.0.0rc0 - pytest-xdist>=1.21 - hypothesis>=3.58.0 @@ -18,3 +17,5 @@ dependencies: - pytz - pip - tabulate==0.8.3 + - pip: + - Cython==3.0a5 \ No newline at end of file diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index c861d25afd13f..2f3773671e24f 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -555,13 +555,13 @@ def __setitem__(self, key, value): # Need to ensure that left and right are updated atomically, so we're # forced to copy, update the copy, and swap in the new values. - left = self.left.copy(deep=True) - left._values[key] = value_left - self._left = left + left_data = self.left._data.copy() + left_data[key] = value_left + self._left = self.left._shallow_copy(left_data) - right = self.right.copy(deep=True) - right._values[key] = value_right - self._right = right + right_data = self.right._data.copy() + right_data[key] = value_right + self._right = self.right._shallow_copy(right_data) def __eq__(self, other): # ensure pandas array for list-like and eliminate non-interval scalars diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 986d6323e704e..6496a47af318e 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -3849,7 +3849,9 @@ def values(self) -> np.ndarray: Index.array : Reference to the underlying data. Index.to_numpy : A NumPy array representing the underlying data. """ - return self._data.view(np.ndarray) + vals = self._data.view(np.ndarray) + vals.setflags(write=False) + return vals @cache_readonly @doc(IndexOpsMixin.array) @@ -3858,7 +3860,7 @@ def array(self) -> ExtensionArray: if isinstance(array, np.ndarray): from pandas.core.arrays.numpy_ import PandasArray - array = PandasArray(array) + array = PandasArray(self.values) return array @property diff --git a/pandas/tests/indexes/test_any_index.py b/pandas/tests/indexes/test_any_index.py index 5e7065f785309..5ce72ae153c49 100644 --- a/pandas/tests/indexes/test_any_index.py +++ b/pandas/tests/indexes/test_any_index.py @@ -33,6 +33,20 @@ def test_mutability(index): index[0] = index[0] +def test_values_mutability(index): + if not len(index): + return + with pytest.raises(ValueError): + index.values[0] = index[0] + + +def test_array_mutability(index): + if not len(index): + return + with pytest.raises(ValueError): + index.array[0] = index[0] + + def test_wrong_number_names(index): names = index.nlevels * ["apple", "banana", "carrot"] with pytest.raises(ValueError, match="^Length"):