diff --git a/.github/actions/ets_toolkit/action.yml b/.github/actions/ets_toolkit/action.yml new file mode 100644 index 000000000..e0dc5f36a --- /dev/null +++ b/.github/actions/ets_toolkit/action.yml @@ -0,0 +1,46 @@ +name: Set ETS_TOOLKIT +description: 'Set the ETS_TOOLKIT environment variable' +inputs: + toolkit: + required: true + description: 'The GUI toolkit to use (wx, null, pyqt5, pyqt6, pyside2, pyside6)' + kiva: + default: 'image' + description: 'The kiva toolkit to set' + shell: + default: 'bash' +runs: + using: composite + steps: + - name: Null toolkit + if: inputs.toolkit == 'null' + run: echo "ETS_TOOLKIT=null.${{ inputs.kiva }}" >> $GITHUB_ENV + shell: ${{ inputs.shell }} + - name: WxPython toolkit + if: inputs.toolkit == 'wx' + run: echo "ETS_TOOLKIT=wx.${{ inputs.kiva }}" >> $GITHUB_ENV + shell: ${{ inputs.shell }} + - name: PyQT5 toolkit + if: inputs.toolkit == 'pyqt5' + run: | + echo "ETS_TOOLKIT=qt.${{ inputs.kiva }}" >> $GITHUB_ENV + echo "QT_API=pyqt5" >> $GITHUB_ENV + shell: ${{ inputs.shell }} + - name: PyQT6 toolkit + if: inputs.toolkit == 'pyqt6' + run: | + echo "ETS_TOOLKIT=qt.${{ inputs.kiva }}" >> $GITHUB_ENV + echo "QT_API=pyqt6" >> $GITHUB_ENV + shell: ${{ inputs.shell }} + - name: PySide2 toolkit + if: inputs.toolkit == 'pyside2' + run: | + echo "ETS_TOOLKIT=qt.${{ inputs.kiva }}" >> $GITHUB_ENV + echo "QT_API=pyside2" >> $GITHUB_ENV + shell: ${{ inputs.shell }} + - name: PySide6 toolkit + if: inputs.toolkit == 'pyside6' + run: | + echo "ETS_TOOLKIT=qt.${{ inputs.kiva }}" >> $GITHUB_ENV + echo "QT_API=pyside6" >> $GITHUB_ENV + shell: ${{ inputs.shell }} diff --git a/.github/actions/install-qt-support/action.yml b/.github/actions/install-qt-support/action.yml index 66b98ab7e..a974048d7 100644 --- a/.github/actions/install-qt-support/action.yml +++ b/.github/actions/install-qt-support/action.yml @@ -7,10 +7,6 @@ runs: if: runner.os == 'Linux' run: | sudo apt-get update - sudo apt-get install qtbase5-dev - sudo apt-get install qtchooser - sudo apt-get install qt5-qmake - sudo apt-get install qtbase5-dev-tools sudo apt-get install libegl1 sudo apt-get install libxkbcommon-x11-0 sudo apt-get install libxcb-icccm4 diff --git a/.github/workflows/test-with-edm.yml b/.github/workflows/test-with-edm.yml index 544a23e32..19d06f6af 100644 --- a/.github/workflows/test-with-edm.yml +++ b/.github/workflows/test-with-edm.yml @@ -2,66 +2,62 @@ # Note that some packages may not actually be installed from EDM but from # PyPI, see ci/edmtool.py implementations. -name: Test with EDM on Python 3.8 +name: Test with EDM on: pull_request env: - INSTALL_EDM_VERSION: 3.5.0 + INSTALL_EDM_VERSION: 4.1.1 + PYTHONUNBUFFERED: 1 + EDM_CONFIG: '${{ github.workspace }}/ci/edm.yaml' jobs: - # Test against EDM packages on Linux - test-edm-linux-38: + test-edm: strategy: matrix: - toolkit: ['null', 'pyside6'] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install Qt dependencies - uses: ./.github/actions/install-qt-support - if: matrix.toolkit != 'null' - - name: Cache EDM packages - uses: actions/cache@v2 - with: - path: ~/.cache - key: ${{ runner.os }}-3.8-${{ matrix.toolkit }}-${{ hashFiles('ci/edmtool.py') }} - - name: Setup EDM - uses: enthought/setup-edm-action@v2 - with: - edm-version: ${{ env.INSTALL_EDM_VERSION }} - - name: Install click to the default EDM environment - run: edm install -y wheel click coverage - - name: Install test environment - run: edm run -- python ci/edmtool.py install --runtime=3.8 --toolkit=${{ matrix.toolkit }} - - name: Flake8 - run: edm run -- python ci/edmtool.py flake8 --runtime=3.8 --toolkit=${{ matrix.toolkit }} - if: matrix.toolkit == 'null' - - name: Run tests - run: xvfb-run -a --server-args="-screen 0 1024x768x24" edm run -- python ci/edmtool.py test --runtime=3.8 --toolkit=${{ matrix.toolkit }} - - # Test against EDM packages on Windows and OSX - test-with-edm-38: - strategy: - matrix: - os: [windows-latest] - toolkit: ['null', 'pyside6'] + toolkit: ['null', 'pyside6', 'wx'] + runtime: ['3.11'] + os: ['ubuntu-latest', 'windows-latest'] + include: + - toolkit: 'null' + runtime: '3.11' + os: macos-latest + - toolkit: 'pyside6' + runtime: '3.11' + os: macos-latest runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Cache EDM packages - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.cache - key: ${{ runner.os }}-3.8-${{ matrix.toolkit }}-${{ hashFiles('ci/edmtool.py') }} + key: ${{ runner.os }}-${{ matrix.toolkit }}-${{ matrix.runtime }}-${{ hashFiles('ci/edmtool.py') }} - name: Setup EDM - uses: enthought/setup-edm-action@v1 + uses: enthought/setup-edm-action@v4.1 with: edm-version: ${{ env.INSTALL_EDM_VERSION }} + - name: Install opengl for Linux + run: | + sudo apt-get update + sudo apt-get install libopengl0 libegl1 + if: matrix.os == 'ubuntu-latest' && matrix.toolkit != 'null' - name: Install click to the default EDM environment run: edm install -y wheel click coverage + - name: Set ETS_TOOLKIT + uses: ./.github/actions/ets_toolkit + with: + toolkit: ${{ matrix.toolkit }} - name: Install test environment - run: edm run -- python ci/edmtool.py install --runtime=3.8 --toolkit=${{ matrix.toolkit }} + run: edm run -- python ci/edmtool.py install --toolkit=${{ matrix.toolkit }} --runtime=${{ matrix.runtime }} + - name: Run tests on Linux + if: matrix.os == 'ubuntu-latest' + env: + PYTHONFAULTHANDLER: 1 + run: xvfb-run -a --server-args="-screen 0 1024x768x24" edm run -- python ci/edmtool.py test --toolkit=${{ matrix.toolkit }} --runtime=${{ matrix.runtime }} - name: Run tests - run: edm run -- python ci/edmtool.py test --runtime=3.8 --toolkit=${{ matrix.toolkit }} + if: matrix.os != 'ubuntu-latest' + env: + PYTHONFAULTHANDLER: 1 + run: edm run -- python ci/edmtool.py test --toolkit=${{ matrix.toolkit }} --runtime=${{ matrix.runtime }} diff --git a/.github/workflows/test-with-pip.yml b/.github/workflows/test-with-pip.yml index 0c4d92bb9..9eb01d0e3 100644 --- a/.github/workflows/test-with-pip.yml +++ b/.github/workflows/test-with-pip.yml @@ -1,4 +1,3 @@ - # This workflow installs dependencies from main branch name: Test with pip @@ -14,153 +13,43 @@ jobs: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - toolkit: ['pyside6'] + toolkit: ['pyside2', 'pyside6', 'pyqt5', 'wx', 'null'] kiva-backend: ['image'] - python-version: ['3.8', '3.11'] - include: - # Do more Python versions on linux - - os: 'ubuntu-latest' - toolkit: 'pyside6' - kiva-backend: 'image' - python-version: '3.9' - - os: 'ubuntu-latest' - toolkit: 'pyside6' - kiva-backend: 'image' - python-version: '3.10' + python-version: ['3.10', '3.11'] + exclude: + # No PySide2 wheels available for Python 3.11 + - toolkit: 'pyside2' + python-version: '3.11' + # No PyQt5 wheels available for Python 3.11 + - toolkit: 'pyqt5' + python-version: '3.11' + # No PySide2 wheels for macos-latest + - os: 'macos-latest' + toolkit: 'pyside2' runs-on: ${{ matrix.os }} - env: - ETS_TOOLKIT: qt4.${{ matrix.kiva-backend }} - QT_API: ${{ matrix.toolkit }} steps: - name: Check out - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - name: Install Qt dependencies - uses: ./.github/actions/install-qt-support - if: matrix.toolkit == 'pyside6' - - name: Install dependencies for Linux - run: | - # needed for Celiagg - sudo apt-get install libfreetype-dev libharfbuzz-dev - # needed for Cairo - sudo apt-get install libcairo2-dev - if: matrix.os == 'ubuntu-latest' - - name: Install dependencies for Mac - run: | - brew install cairo - if: matrix.os == 'macos-latest' - - name: Install build dependencies - run: | - python -m pip install --upgrade pip wheel - - name: Install local enable main (temporary) - run: pip install --force "enable[celiagg,layout,svg] @ git+https://github.com/enthought/enable.git" - - name: Install local packages - run: pip install ".[tests,${{ matrix.toolkit }}]" - - name: Sanity check package version - run: pip list - - name: Run chaco test suite (Linux) - env: - PYTHONFAULTHANDLER: 1 - # kiva agg requires at least 15-bit color depth. - run: xvfb-run -a --server-args="-screen 0 1024x768x24" python -m unittest discover -v chaco - if: matrix.os == 'ubuntu-latest' - working-directory: ${{ runner.temp }} - - name: Run enable test suite (not Linux) - env: - PYTHONFAULTHANDLER: 1 - run: python -m unittest discover -v chaco - if: matrix.os != 'ubuntu-latest' - working-directory: ${{ runner.temp }} - - test-wx: - strategy: - fail-fast: false - matrix: - os: ['windows-latest'] - toolkit: ['wx'] - kiva-backend: ['image'] - python-version: ['3.8', '3.10'] - runs-on: ${{ matrix.os }} - env: - ETS_TOOLKIT: ${{ matrix.toolkit }}.${{ matrix.kiva-backend }} - steps: - - name: Check out - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 + cache: 'pip' + - name: Set ETS_TOOLKIT + uses: ./.github/actions/ets_toolkit with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies for Linux - run: | - # needed for Celiagg - sudo apt-get install libfreetype-dev libharfbuzz-dev - # needed for Cairo - sudo apt-get install libcairo2-dev - if: matrix.os == 'ubuntu-latest' - - name: Install dependencies for Mac - run: | - brew install cairo - if: matrix.os == 'macos-latest' + toolkit: ${{ matrix.toolkit }} - name: Install build dependencies run: | - python -m pip install --upgrade pip wheel - - name: Install local enable main (temporary) - run: pip install --force "enable[celiagg,layout,svg] @ git+https://github.com/enthought/enable.git" - - name: Install local packages - run: pip install ".[tests,${{ matrix.toolkit }}]" - - name: Sanity check package version - run: pip list - - name: Run chaco test suite (Linux) - env: - PYTHONFAULTHANDLER: 1 - # kiva agg requires at least 15-bit color depth. - run: xvfb-run -a --server-args="-screen 0 1024x768x24" python -m unittest discover -v chaco - if: matrix.os == 'ubuntu-latest' - working-directory: ${{ runner.temp }} - - name: Run enable test suite (not Linux) - env: - PYTHONFAULTHANDLER: 1 - run: python -m unittest discover -v chaco - if: matrix.os != 'ubuntu-latest' - working-directory: ${{ runner.temp }} - - test-null: - strategy: - fail-fast: false - matrix: - os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - toolkit: ['null'] - kiva-backend: ['image', 'celiagg'] - python-version: ['3.8', '3.11'] - runs-on: ${{ matrix.os }} - env: - ETS_TOOLKIT: ${{ matrix.toolkit }}.${{ matrix.kiva-backend }} - steps: - - name: Check out - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies for Linux - run: | - # needed for Celiagg - sudo apt-get install libfreetype-dev libharfbuzz-dev - # needed for Cairo - sudo apt-get install libcairo2-dev - if: matrix.os == 'ubuntu-latest' - - name: Install dependencies for Mac - run: | - brew install cairo - if: matrix.os == 'macos-latest' - - name: Install build dependencies + python -m pip install --upgrade pip wheel Cython + - name: Install wxdependencies for Linux run: | - python -m pip install --upgrade pip wheel - - name: Install local enable main (temporary) - run: pip install --force "enable[celiagg,cairo,layout,svg] @ git+https://github.com/enthought/enable.git" + sudo apt-get update + sudo apt-get install libgtk-3-dev + if: matrix.os == 'ubuntu-latest' && matrix.toolkit == 'wx' + - name: Install Qt dependencies on Linux + uses: ./.github/actions/install-qt-support + if: matrix.os == 'ubuntu-latest' && startsWith(matrix.toolkit, 'py') - name: Install local packages run: pip install ".[tests,${{ matrix.toolkit }}]" - name: Sanity check package version diff --git a/chaco/base_contour_plot.py b/chaco/base_contour_plot.py index 9f2adf429..9cef21fa4 100644 --- a/chaco/base_contour_plot.py +++ b/chaco/base_contour_plot.py @@ -8,7 +8,7 @@ # # Thanks for using Enthought open source! -from numpy import array, isscalar, issubsctype, linspace, number +from numpy import array, isscalar, issubdtype, linspace, number # Enthought library imports from enable.api import ColorTrait @@ -135,7 +135,7 @@ def _update_colors(self, numcolors=None): # be converted via self._color_map_trait. else: if len(colors) in (3, 4) and ( - isscalar(colors[0]) and issubsctype(type(colors[0]), number) + isscalar(colors[0]) and issubdtype(type(colors[0]), number) ): self._color_map_trait = colors self._colors = [self._color_map_trait_] * numcolors diff --git a/chaco/color_mapper.py b/chaco/color_mapper.py index a75db75a6..a62c73745 100644 --- a/chaco/color_mapper.py +++ b/chaco/color_mapper.py @@ -12,6 +12,7 @@ """ # Major library imports +import numpy as np from numpy import ( arange, array, @@ -24,7 +25,6 @@ isnan, ones, searchsorted, - sometrue, sort, take, uint8, @@ -413,7 +413,7 @@ def _make_mapping_array(self, n, data): raise ValueError( "data mapping points must start with x=0. and end with x=1" ) - if sometrue(sort(x) - x): + if np.any(sort(x) - x): raise ValueError( "data mapping points must have x in increasing order" ) diff --git a/chaco/downsample/lttb.py b/chaco/downsample/lttb.py index 7b8370c1f..bbd84052a 100644 --- a/chaco/downsample/lttb.py +++ b/chaco/downsample/lttb.py @@ -7,8 +7,8 @@ # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! - import logging +import platform logger = logging.getLogger(__name__) diff --git a/chaco/downsample/tests/test_lttb.py b/chaco/downsample/tests/test_lttb.py index 627dec9f8..fe66649b7 100644 --- a/chaco/downsample/tests/test_lttb.py +++ b/chaco/downsample/tests/test_lttb.py @@ -10,11 +10,12 @@ import unittest import timeit +import platform import numpy as np from numpy.testing import assert_array_equal, assert_almost_equal -from ..lttb import largest_triangle_three_buckets +from ..lttb import largest_triangle_three_buckets, _lttb TIMING_SETUP = """ @@ -28,6 +29,7 @@ """ +@unittest.skipIf(_lttb is None, "extension is not compiled") class TestLargestTriangleThreeBuckets(unittest.TestCase): def test_timing(self): statement = "largest_triangle_three_buckets(a, n_buckets)" @@ -44,6 +46,9 @@ def test_timing(self): # 0.0112847280502 2016/10/18, 2.8 GHz 16 GB mid-2014 MacBook Pro self.assertLess(t, 0.1) + @unittest.skipIf( + platform.system() == 'Darwin', + 'Test fails on macOS; https://github.com/enthought/chaco/issues/918') def test_linear(self): a = np.empty(shape=(101, 2)) a[:, 0] = np.linspace(0.0, 10.0, 101) diff --git a/chaco/log_mapper.py b/chaco/log_mapper.py index 7059706ff..18b0f512a 100644 --- a/chaco/log_mapper.py +++ b/chaco/log_mapper.py @@ -18,7 +18,6 @@ log10, exp, zeros, - sometrue, floor, ceil, ndarray, @@ -79,7 +78,7 @@ def map_screen(self, data_array): try: with np.errstate(invalid="ignore"): mask = (data_array <= LOG_MINIMUM) | isnan(data_array) - if sometrue(mask): + if np.any(mask): data_array = array(data_array, copy=True, ndmin=1) data_array[mask] = self.fill_value intermediate = ( diff --git a/chaco/plots/contour/cntr.c b/chaco/plots/contour/cntr.c index 21d052432..b0c55397d 100644 --- a/chaco/plots/contour/cntr.c +++ b/chaco/plots/contour/cntr.c @@ -32,8 +32,7 @@ #ifdef NUMPY #include "numpy/arrayobject.h" # ifndef PyArray_SBYTE -# include "numpy/oldnumeric.h" -# include "numpy/old_defines.h" +# define PyArray_SBYTE NPY_INT8 # endif #else # include "Numeric/arrayobject.h" @@ -1717,7 +1716,7 @@ static PyMethodDef module_methods[] = { MOD_INIT(contour) { PyObject* m = NULL; - + static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "contour", /* m_name */ @@ -1744,4 +1743,3 @@ MOD_INIT(contour) PyModule_AddObject(m, "Cntr", (PyObject *)&CntrType); RETURN_MODINIT; } - diff --git a/chaco/plots/tests/test_barplot.py b/chaco/plots/tests/test_barplot.py index d92554bd8..fdfbf2b6a 100644 --- a/chaco/plots/tests/test_barplot.py +++ b/chaco/plots/tests/test_barplot.py @@ -10,7 +10,8 @@ import unittest -from numpy import alltrue, arange, nan +import numpy as np +from numpy import arange, nan from traits.testing.api import UnittestTools @@ -71,7 +72,7 @@ def test_barplot(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.barplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_barplot_horizontal(self): self.barplot.orientation = 'v' @@ -95,4 +96,4 @@ def test_barplot_horizontal(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.barplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) diff --git a/chaco/plots/tests/test_colormapped_scatterplot.py b/chaco/plots/tests/test_colormapped_scatterplot.py index a34f8fcc8..865507322 100644 --- a/chaco/plots/tests/test_colormapped_scatterplot.py +++ b/chaco/plots/tests/test_colormapped_scatterplot.py @@ -10,7 +10,8 @@ import unittest -from numpy import alltrue, arange +import numpy as np +from numpy import arange from enable.compiled_path import CompiledPath # Chaco imports @@ -59,7 +60,7 @@ def test_scatter_render(self): """ Coverage test to check basic case works """ self.gc.render_component(self.scatterplot) actual = self.gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_circle(self): """ Coverage test to check circles work """ @@ -67,7 +68,7 @@ def test_scatter_circle(self): self.gc.render_component(self.scatterplot) actual = self.gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_custom(self): """Coverage test to check custom markers work. @@ -87,7 +88,7 @@ def test_scatter_custom(self): self.gc.render_component(self.scatterplot) actual = self.gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_colormap_updated(self): """ If colormapper updated then we need to redraw """ @@ -100,4 +101,4 @@ def test_non_kiva_marker(self): self.gc.render_component(self.scatterplot) actual = self.gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) diff --git a/chaco/plots/tests/test_errorbarplot.py b/chaco/plots/tests/test_errorbarplot.py index 74f497d7f..8ff1eaf36 100644 --- a/chaco/plots/tests/test_errorbarplot.py +++ b/chaco/plots/tests/test_errorbarplot.py @@ -11,7 +11,6 @@ import unittest import numpy as np -from numpy import alltrue # Chaco imports from chaco.api import ( @@ -46,4 +45,4 @@ def test_errorbarplot(self): gc = PlotGraphicsContext(size) gc.render_component(errorbar_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) diff --git a/chaco/plots/tests/test_image_plot.py b/chaco/plots/tests/test_image_plot.py index afed30367..8da0b4f79 100644 --- a/chaco/plots/tests/test_image_plot.py +++ b/chaco/plots/tests/test_image_plot.py @@ -9,10 +9,9 @@ # Thanks for using Enthought open source! import os - +import platform import tempfile from contextlib import contextmanager - import unittest import numpy as np @@ -207,6 +206,9 @@ def test_map_screen(self): # regression test for enthought/chaco#528 @unittest.skipIf(is_null, "Skip on 'null' toolkit") + @unittest.skipIf( + ETSConfig.toolkit == "wx" and platform.system() == 'Darwin', + "Test does not work correctly on wx; https://github.com/enthought/chaco/issues/919") def test_resize_to_zero(self): class TestResize(HasTraits): plot = Instance(Component) diff --git a/chaco/plots/tests/test_jitterplot.py b/chaco/plots/tests/test_jitterplot.py index 2b04fb116..f0f452336 100644 --- a/chaco/plots/tests/test_jitterplot.py +++ b/chaco/plots/tests/test_jitterplot.py @@ -10,7 +10,8 @@ import unittest -from numpy import alltrue, arange, array +import numpy as np +from numpy import arange, array from numpy.testing import assert_almost_equal from enable.compiled_path import CompiledPath @@ -48,7 +49,7 @@ def test_scatter_1d(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_1d_horizontal(self): self.scatterplot.orientation = "h" @@ -62,7 +63,7 @@ def test_scatter_1d_horizontal(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_1d_flipped(self): self.scatterplot.direction = "flipped" @@ -76,7 +77,7 @@ def test_scatter_1d_flipped(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_1d_horizontal_flipped(self): self.scatterplot.direction = "flipped" @@ -91,14 +92,14 @@ def test_scatter_1d_horizontal_flipped(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_1d_circle(self): self.scatterplot.marker = "circle" gc = PlotGraphicsContext(self.size) gc.render_component(self.scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_1d_custom(self): path = CompiledPath() @@ -113,7 +114,7 @@ def test_scatter_1d_custom(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_1d_map_data(self): points = array([[0, 124.5], [124.5, 0]]) diff --git a/chaco/plots/tests/test_line_scatterplot.py b/chaco/plots/tests/test_line_scatterplot.py index 7c86cccf5..1bf2a23a3 100644 --- a/chaco/plots/tests/test_line_scatterplot.py +++ b/chaco/plots/tests/test_line_scatterplot.py @@ -10,7 +10,8 @@ import unittest -from numpy import alltrue, arange, array +import numpy as np +from numpy import arange, array from numpy.testing import assert_almost_equal from traits.testing.api import UnittestTools @@ -53,7 +54,7 @@ def test_linescatter_1d(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.linescatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_linescatter_1d_horizontal(self): self.linescatterplot.orientation = "h" @@ -67,7 +68,7 @@ def test_linescatter_1d_horizontal(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.linescatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_linescatter_1d_flipped(self): self.linescatterplot.direction = "flipped" @@ -81,7 +82,7 @@ def test_linescatter_1d_flipped(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.linescatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_linescatter_1d_horizontal_flipped(self): self.linescatterplot.direction = "flipped" @@ -96,28 +97,28 @@ def test_linescatter_1d_horizontal_flipped(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.linescatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_linescatter_1d_thicker(self): self.linescatterplot.line_width = 2.0 gc = PlotGraphicsContext(self.size) gc.render_component(self.linescatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_linescatter_1d_color(self): self.linescatterplot.color = "orange" gc = PlotGraphicsContext(self.size) gc.render_component(self.linescatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_linescatter_1d_line_style(self): self.linescatterplot.line_style = "dash" gc = PlotGraphicsContext(self.size) gc.render_component(self.linescatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_linescatter_1d_map_data(self): points = array([[0, 124.5], [124.5, 0]]) @@ -155,7 +156,7 @@ def test_linescatter_1d_selection(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.linescatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_linescatter_1d_selection_mask_name(self): # select with a mask @@ -167,7 +168,7 @@ def test_linescatter_1d_selection_mask_name(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.linescatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_linescatter_1d_selection_alpha(self): # test with different alpha @@ -179,7 +180,7 @@ def test_linescatter_1d_selection_alpha(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.linescatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_linescatter_1d_set_index_range(self): new_range = DataRange1D(low=0.42, high=1.42) diff --git a/chaco/plots/tests/test_scatterplot_1d.py b/chaco/plots/tests/test_scatterplot_1d.py index a6ac97a8b..1b12a7e26 100644 --- a/chaco/plots/tests/test_scatterplot_1d.py +++ b/chaco/plots/tests/test_scatterplot_1d.py @@ -10,7 +10,8 @@ import unittest -from numpy import alltrue, arange, array +import numpy as np +from numpy import arange, array from numpy.testing import assert_almost_equal from enable.compiled_path import CompiledPath @@ -53,7 +54,7 @@ def test_scatter_1d(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_1d_horizontal(self): self.scatterplot.orientation = "h" @@ -67,7 +68,7 @@ def test_scatter_1d_horizontal(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_1d_flipped(self): self.scatterplot.direction = "flipped" @@ -81,7 +82,7 @@ def test_scatter_1d_flipped(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_1d_horizontal_flipped(self): self.scatterplot.direction = "flipped" @@ -96,14 +97,14 @@ def test_scatter_1d_horizontal_flipped(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_1d_circle(self): self.scatterplot.marker = "circle" gc = PlotGraphicsContext(self.size) gc.render_component(self.scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_1d_custom(self): path = CompiledPath() @@ -118,7 +119,7 @@ def test_scatter_1d_custom(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_1d_map_data(self): points = array([[0, 124.5], [124.5, 0]]) @@ -153,7 +154,7 @@ def test_scatter_1d_selection(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_1d_selection_mask_name(self): # select with a mask @@ -165,7 +166,7 @@ def test_scatter_1d_selection_mask_name(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_1d_selection_alpha(self): # test with different alpha @@ -177,7 +178,7 @@ def test_scatter_1d_selection_alpha(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_1d_set_index_range(self): new_range = DataRange1D(low=0.42, high=1.42) diff --git a/chaco/plots/tests/test_scatterplot_renderers.py b/chaco/plots/tests/test_scatterplot_renderers.py index 54bcee37b..a931c133e 100644 --- a/chaco/plots/tests/test_scatterplot_renderers.py +++ b/chaco/plots/tests/test_scatterplot_renderers.py @@ -10,7 +10,7 @@ import unittest -from numpy import alltrue +import numpy as np from enable.compiled_path import CompiledPath # Chaco imports @@ -29,7 +29,7 @@ def test_scatter_fast(self): gc = PlotGraphicsContext(size) gc.render_component(scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_circle(self): """ Coverage test to check circles work """ @@ -43,7 +43,7 @@ def test_scatter_circle(self): gc = PlotGraphicsContext(size) gc.render_component(scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_custom(self): """ Coverage test to check custom markers work """ @@ -66,7 +66,7 @@ def test_scatter_custom(self): gc = PlotGraphicsContext(size) gc.render_component(scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_scatter_slow(self): """ Coverage test to check multiple marker size works """ @@ -81,4 +81,4 @@ def test_scatter_slow(self): gc = PlotGraphicsContext(size) gc.render_component(scatterplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) diff --git a/chaco/plots/tests/test_segment_plot.py b/chaco/plots/tests/test_segment_plot.py index 8cc6ddae3..439152e0c 100644 --- a/chaco/plots/tests/test_segment_plot.py +++ b/chaco/plots/tests/test_segment_plot.py @@ -10,7 +10,8 @@ import unittest -from numpy import alltrue, arange, array +import numpy as np +from numpy import arange, array from numpy.testing import assert_array_equal # Chaco imports @@ -79,7 +80,7 @@ def test_segment(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_orthogonal(self): self.segment_plot.render_style = "orthogonal" @@ -95,7 +96,7 @@ def test_segment_orthogonal(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_quad(self): self.segment_plot.render_style = "quad" @@ -111,7 +112,7 @@ def test_segment_quad(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_cubic(self): self.segment_plot.render_style = "cubic" @@ -127,7 +128,7 @@ def test_segment_cubic(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_color(self): self.set_color_data() @@ -135,7 +136,7 @@ def test_segment_color(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_color_orthogonal(self): self.segment_plot.render_style = "orthogonal" @@ -144,7 +145,7 @@ def test_segment_color_orthogonal(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_color_quad(self): self.segment_plot.render_style = "quad" @@ -153,7 +154,7 @@ def test_segment_color_quad(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_color_cubic(self): self.segment_plot.render_style = "cubic" @@ -162,7 +163,7 @@ def test_segment_color_cubic(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_width(self): self.set_width_data() @@ -170,7 +171,7 @@ def test_segment_width(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_width_orthogonal(self): self.segment_plot.render_style = "orthogonal" @@ -179,7 +180,7 @@ def test_segment_width_orthogonal(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_width_quad(self): self.segment_plot.render_style = "quad" @@ -188,7 +189,7 @@ def test_segment_width_quad(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_width_cubic(self): self.segment_plot.render_style = "cubic" @@ -197,7 +198,7 @@ def test_segment_width_cubic(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_width_color(self): self.set_width_data() @@ -206,7 +207,7 @@ def test_segment_width_color(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_width_orthogonal_color(self): self.segment_plot.render_style = "orthogonal" @@ -216,7 +217,7 @@ def test_segment_width_orthogonal_color(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_width_quad_color(self): self.segment_plot.render_style = "quad" @@ -226,7 +227,7 @@ def test_segment_width_quad_color(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_width_cubic_color(self): self.segment_plot.render_style = "cubic" @@ -236,7 +237,7 @@ def test_segment_width_cubic_color(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_alpha(self): self.segment_plot.alpha = 0.5 @@ -244,7 +245,7 @@ def test_segment_alpha(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_orthogonal_alpha(self): self.segment_plot.render_style = "orthogonal" @@ -253,7 +254,7 @@ def test_segment_orthogonal_alpha(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_quad_alpha(self): self.segment_plot.render_style = "quad" @@ -262,7 +263,7 @@ def test_segment_quad_alpha(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_cubic_alpha(self): self.segment_plot.render_style = "cubic" @@ -271,7 +272,7 @@ def test_segment_cubic_alpha(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_selection(self): mask = array([True, True, False, False, True]) @@ -290,7 +291,7 @@ def test_segment_selection(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_selection_color(self): mask = array([True, True, False, False, True]) @@ -309,4 +310,4 @@ def test_segment_selection_color(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.segment_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) diff --git a/chaco/plots/tests/test_text_plot.py b/chaco/plots/tests/test_text_plot.py index 19d59ad09..c4eb21300 100644 --- a/chaco/plots/tests/test_text_plot.py +++ b/chaco/plots/tests/test_text_plot.py @@ -10,7 +10,8 @@ import unittest -from numpy import alltrue, arange, array +import numpy as np +from numpy import arange, array # Chaco imports from chaco.api import ( @@ -63,4 +64,4 @@ def test_text(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.text_plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) diff --git a/chaco/plots/tests/test_text_plot_1d.py b/chaco/plots/tests/test_text_plot_1d.py index 9ae76fae9..417176b59 100644 --- a/chaco/plots/tests/test_text_plot_1d.py +++ b/chaco/plots/tests/test_text_plot_1d.py @@ -10,7 +10,8 @@ import unittest -from numpy import alltrue, arange, array +import numpy as np +from numpy import arange, array from numpy.testing import assert_almost_equal from traits.testing.api import UnittestTools @@ -65,7 +66,7 @@ def test_text_1d(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.textplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_text_1d_horizontal(self): self.textplot.orientation = "h" @@ -77,7 +78,7 @@ def test_text_1d_horizontal(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.textplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_text_1d_flipped(self): self.textplot.direction = "flipped" @@ -89,7 +90,7 @@ def test_text_1d_flipped(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.textplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_text_1d_horizontal_flipped(self): self.textplot.direction = "flipped" @@ -102,14 +103,14 @@ def test_text_1d_horizontal_flipped(self): gc = PlotGraphicsContext(self.size) gc.render_component(self.textplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_text_1d_rotated(self): self.textplot.text_rotate_angle = 45 gc = PlotGraphicsContext(self.size) gc.render_component(self.textplot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_text_1d_map_data(self): points = array([[0, 124.5], [124.5, 0]]) diff --git a/chaco/tests/test_border.py b/chaco/tests/test_border.py index 0d22f0fc3..98d22fb56 100644 --- a/chaco/tests/test_border.py +++ b/chaco/tests/test_border.py @@ -17,7 +17,8 @@ import unittest -from numpy import array, alltrue, ravel +import numpy as np +from numpy import array, ravel # Chaco imports from chaco.api import Plot, PlotGraphicsContext @@ -26,7 +27,7 @@ class DrawBorderTestCase(unittest.TestCase): def assertRavelEqual(self, x, y): self.assertTrue( - alltrue(ravel(x) == ravel(y)), "\n%s\n !=\n%s" % (x, y) + np.all(ravel(x) == ravel(y)), "\n%s\n !=\n%s" % (x, y) ) def test_draw_border_simple(self): diff --git a/chaco/tests/test_datarange_2d.py b/chaco/tests/test_datarange_2d.py index 761878424..692cb07f0 100644 --- a/chaco/tests/test_datarange_2d.py +++ b/chaco/tests/test_datarange_2d.py @@ -11,7 +11,8 @@ import unittest import warnings -from numpy import alltrue, arange, array, ravel, transpose, zeros, inf, isinf +import numpy as np +from numpy import arange, array, ravel, transpose, zeros, inf, isinf from numpy.testing import assert_equal, assert_ from chaco.api import DataRange2D, GridDataSource, PointDataSource @@ -249,7 +250,7 @@ def assert_close_(desired, actual): diff = abs(ravel(actual) - ravel(desired)) for d in diff: if not isinf(d): - assert_(alltrue(d <= diff_allowed)) + assert_(np.all(d <= diff_allowed)) return diff --git a/chaco/tests/test_plot.py b/chaco/tests/test_plot.py index 9e458d5da..66cb1f5de 100644 --- a/chaco/tests/test_plot.py +++ b/chaco/tests/test_plot.py @@ -9,9 +9,10 @@ # Thanks for using Enthought open source! import unittest +import platform import numpy as np -from numpy import alltrue, arange, array +from numpy import arange, array from enable.api import ComponentEditor from enable.testing import EnableTestAssistant @@ -26,6 +27,7 @@ class PlotTestCase(unittest.TestCase): + def test_plot_from_unsupported_array_shape(self): arr = arange(8).reshape(2, 2, 2) data = ArrayPlotData(x=arr, y=arr) @@ -63,7 +65,7 @@ def test_segment_plot(self): gc = PlotGraphicsContext((250, 250)) gc.render_component(plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_plot_color(self): x = arange(10) @@ -77,7 +79,7 @@ def test_segment_plot_color(self): gc = PlotGraphicsContext((250, 250)) gc.render_component(plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_plot_color_width(self): x = arange(10) @@ -94,7 +96,7 @@ def test_segment_plot_color_width(self): gc = PlotGraphicsContext((250, 250)) gc.render_component(plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def test_segment_plot_map_screen(self): x = arange(10) @@ -120,7 +122,7 @@ def test_text_plot(self): gc = PlotGraphicsContext((250, 250)) gc.render_component(plot) actual = gc.bmp_array[:, :, :] - self.assertFalse(alltrue(actual == 255)) + self.assertFalse(np.all(actual == 255)) def check_map_screen(self, renderer): arr = arange(10) @@ -170,6 +172,10 @@ def _plot_default(self): @unittest.skipIf(ETSConfig.toolkit == "null", "Skip on 'null' toolkit") class TestEmptyPlot(unittest.TestCase, EnableTestAssistant): + + @unittest.skipIf( + ETSConfig.toolkit == "wx" and platform.system() == 'Darwin', + "Test does not work correctly on wx; https://github.com/enthought/chaco/issues/919") def test_dont_crash_on_click(self): from traitsui.testing.api import UITester tester = UITester() diff --git a/chaco/tests/test_speedups.py b/chaco/tests/test_speedups.py index aa57bdf9b..39de90144 100644 --- a/chaco/tests/test_speedups.py +++ b/chaco/tests/test_speedups.py @@ -10,7 +10,8 @@ import unittest -from numpy import alltrue, array, ravel, zeros, isinf, linspace +import numpy as np +from numpy import array, ravel, zeros, isinf, linspace def assert_close(desired, actual): @@ -18,7 +19,7 @@ def assert_close(desired, actual): diff = abs(ravel(actual) - ravel(desired)) for d in diff: if not isinf(d): - assert alltrue(d <= diff_allowed) + assert np.all(d <= diff_allowed) return diff --git a/chaco/tools/lasso_selection.py b/chaco/tools/lasso_selection.py index fa446189d..685afd4c0 100644 --- a/chaco/tools/lasso_selection.py +++ b/chaco/tools/lasso_selection.py @@ -12,7 +12,7 @@ """ # Major library imports import numpy -from numpy import array, column_stack, empty, sometrue, vstack, zeros +from numpy import array, column_stack, empty, vstack, zeros # Enthought library imports from traits.api import ( @@ -306,7 +306,7 @@ def _update_selection(self): else: selected_mask |= active_selection - if sometrue( + if numpy.any( selected_mask != self.selection_datasource.metadata[self.metadata_name] ): diff --git a/chaco/tools/tests/test_cursor_tool.py b/chaco/tools/tests/test_cursor_tool.py index 7f7a443da..6d1e23305 100644 --- a/chaco/tools/tests/test_cursor_tool.py +++ b/chaco/tools/tests/test_cursor_tool.py @@ -8,6 +8,7 @@ # # Thanks for using Enthought open source! import unittest +import platform import numpy as np @@ -26,6 +27,9 @@ class TestCursorTool(unittest.TestCase, EnableTestAssistant): # regression test for enthought/chaco#289 @unittest.skipIf(ETSConfig.toolkit == "null", "Skip on 'null' toolkit") + @unittest.skipIf( + ETSConfig.toolkit == "wx" and platform.system() == 'Darwin', + "Test does not work correctly on wx; https://github.com/enthought/chaco/issues/919") def test_use_with_log_mappers(self): class TestCursor(HasTraits): plot = Instance(Plot) @@ -62,6 +66,9 @@ def _plot_default(self): ) @unittest.skipIf(ETSConfig.toolkit == "null", "Skip on 'null' toolkit") + @unittest.skipIf( + ETSConfig.toolkit == "wx" and platform.system() == 'Darwin', + "Test does not work correctly on wx; https://github.com/enthought/chaco/issues/919") def test_use_with_linear_mappers(self): class TestCursor(HasTraits): plot = Instance(Plot) diff --git a/ci/edm.yaml b/ci/edm.yaml new file mode 100644 index 000000000..9773a5cba --- /dev/null +++ b/ci/edm.yaml @@ -0,0 +1,4 @@ +store_url: https://packages.enthought.com +repositories: + - enthought/free + - enthought/lgpl diff --git a/ci/edmtool.py b/ci/edmtool.py index dbd8ddb1f..b9c0c59c4 100644 --- a/ci/edmtool.py +++ b/ci/edmtool.py @@ -77,8 +77,7 @@ import click supported_combinations = { - '3.6': {'pyside2', 'pyqt5', 'null'}, - '3.8': {'pyside6', 'null'}, + '3.11': {'pyside6', 'pyqt6', 'wx', 'null'}, } dependencies = { @@ -92,8 +91,6 @@ "traitsui", "cython", "enable", - # Needed to install enable from source - "swig", } pypi_dependencies = {} @@ -111,10 +108,9 @@ github_url_fmt = "git+http://github.com/enthought/{0}.git#egg={0}" extra_dependencies = { - 'pyside2': {'pyside2'}, + 'pyqt6': {'pyqt6'}, 'pyside6': {'pyside6'}, - 'pyqt': {'pyqt'}, - 'pyqt5': {'pyqt5'}, + "wx": {'wxPython'}, 'null': set() } @@ -163,10 +159,9 @@ } environment_vars = { - 'pyside2': {'ETS_TOOLKIT': 'qt4', 'QT_API': 'pyside2'}, - 'pyside6': {'ETS_TOOLKIT': 'qt4', 'QT_API': 'pyside6'}, - 'pyqt': {'ETS_TOOLKIT': 'qt4', 'QT_API': 'pyqt'}, - 'pyqt5': {'ETS_TOOLKIT': 'qt4', 'QT_API': 'pyqt5'}, + 'pyside6': {'ETS_TOOLKIT': 'qt', 'QT_API': 'pyside6'}, + 'pyqt6': {'ETS_TOOLKIT': 'qt', 'QT_API': 'pyqt6'}, + 'wx': {'ETS_TOOLKIT': 'wx'}, 'null': {'ETS_TOOLKIT': 'null.image'}, } @@ -185,7 +180,7 @@ def cli(): @cli.command() -@click.option('--runtime', default='3.6') +@click.option('--runtime', default='3.11') @click.option('--toolkit', default='null') @click.option('--environment', default=None) @click.option( @@ -208,15 +203,10 @@ def install(runtime, toolkit, environment, editable, source): | ci_dependencies ) - if toolkit.startswith("pyside"): - addn_repositories = "--add-repository enthought/lgpl" - else: - addn_repositories = "" - # edm commands to setup the development environment commands = [ "edm environments create {environment} --force --version={runtime}", - "edm install -y -e {environment} {packages} " + addn_repositories, + "edm install -y -e {environment} {packages}", ("edm run -e {environment} -- pip install -r ci/requirements.txt" " --no-dependencies"), ] @@ -237,6 +227,7 @@ def install(runtime, toolkit, environment, editable, source): "--environment {environment} --force " ) commands = [cmd_fmt + source_pkg for source_pkg in source_dependencies] + commands.append(f'edm install -e --environment {environment} swig') execute(commands, parameters) source_pkgs = [ github_url_fmt.format(pkg) for pkg in source_dependencies @@ -267,7 +258,7 @@ def install(runtime, toolkit, environment, editable, source): @cli.command() -@click.option('--runtime', default='3.6') +@click.option('--runtime', default='3.11') @click.option('--toolkit', default='null') @click.option('--environment', default=None) def test(runtime, toolkit, environment): @@ -295,7 +286,7 @@ def test(runtime, toolkit, environment): @cli.command() -@click.option('--runtime', default='3.6') +@click.option('--runtime', default='3.11') @click.option('--toolkit', default='null') @click.option('--environment', default=None) def cleanup(runtime, toolkit, environment): @@ -312,7 +303,7 @@ def cleanup(runtime, toolkit, environment): @cli.command() -@click.option('--runtime', default='3.6') +@click.option('--runtime', default='3.11') @click.option('--toolkit', default='null') def test_clean(runtime, toolkit): """ Run tests in a clean environment, cleaning up afterwards @@ -342,7 +333,7 @@ def update(runtime, toolkit, environment): @cli.command() -@click.option("--runtime", default="3.6", help="Python version to use") +@click.option("--runtime", default="3.11", help="Python version to use") @click.option("--toolkit", default="null", help="Toolkit and API to use") @click.option("--environment", default=None, help="EDM environment to use") def docs(runtime, toolkit, environment): @@ -417,7 +408,7 @@ def test_all(): @cli.command() -@click.option("--runtime", default="3.6", help="Python version to use") +@click.option("--runtime", default="3.11", help="Python version to use") @click.option("--toolkit", default="null", help="Toolkit and API to use") @click.option("--environment", default=None, help="EDM environment to use") def flake8(runtime, toolkit, environment): diff --git a/pyproject.toml b/pyproject.toml index b1256a319..46901ad2a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["cython", "oldest-supported-numpy", "setuptools", "wheel"] +requires = ["cython", "numpy>=2", "setuptools", "wheel"] build-backend = "setuptools.build_meta" [tool.cibuildwheel] diff --git a/setup.py b/setup.py index ed97584ab..1fc909309 100644 --- a/setup.py +++ b/setup.py @@ -367,4 +367,5 @@ def resolve_version(): packages=find_packages(), platforms=["Windows", "Linux", "Mac OS-X", "Unix", "Solaris"], zip_safe=False, + python_requires=">=3.9", )