Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .github/workflows/bleeding-edge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,33 @@ jobs:
test-ets:
strategy:
matrix:
os: [ubuntu-20.04]
toolkit: ['pyside6', 'pyside2', 'wx']
os: [ubuntu-latest]
toolkit: ['pyside6', 'pyside2']
python-version: [3.8]
runs-on: ${{ matrix.os }}
steps:
- name: Check out
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install PySide2 (from PyPI) dependencies for Linux
run: |
sudo apt-get update
sudo apt-get install qt5-default
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
sudo apt-get install libxcb-image0
sudo apt-get install libxcb-keysyms1
sudo apt-get install libxcb-randr0
sudo apt-get install libxcb-render-util0
sudo apt-get install libxcb-xinerama0
sudo apt-get install libxcb-shape0
if: matrix.toolkit != 'wx'
- name: Install Wx dependencies for Linux
run: |
Expand Down Expand Up @@ -62,19 +67,14 @@ jobs:
- name: Run enable test suite
env:
PYTHONFAULTHANDLER: 1
uses: GabrielBB/xvfb-action@v1
with:
# kiva agg requires at least 15-bit color depth.
# The --server-args assumes xvfb-run is called, hence Linux only.
run: --server-args="-screen 0 1024x768x24" python -m unittest discover -v enable
working-directory: ${{ runner.temp }}
# kiva agg requires at least 15-bit color depth.
run: xvfb-run --server-args="-screen 0 1024x768x24" python -m unittest discover -v enable
working-directory: ${{ runner.temp }}
- name: Run kiva test suite
env:
PYTHONFAULTHANDLER: 1
uses: GabrielBB/xvfb-action@v1
with:
run: python -m unittest discover -v kiva
working-directory: ${{ runner.temp }}
run: xvfb-run python -m unittest discover -v kiva
working-directory: ${{ runner.temp }}

notify-on-failure:
needs: test-ets
Expand Down
29 changes: 19 additions & 10 deletions .github/workflows/test-with-edm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,38 @@ name: Test with EDM
on: pull_request

env:
INSTALL_EDM_VERSION: 3.2.1
INSTALL_EDM_VERSION: 3.5.0

jobs:

# Test against EDM packages on Linux
test-edm-linux:
strategy:
matrix:
toolkit: ['null', 'pyqt5', 'pyside2', 'wx']
toolkit: ['null', 'pyqt5', 'pyside2']
runtime: ['3.6']
include:
- toolkit: 'pyside6'
runtime: '3.8'
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install Qt dependencies for 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
sudo apt-get install libxcb-image0
sudo apt-get install libxcb-keysyms1
sudo apt-get install libxcb-randr0
sudo apt-get install libxcb-render-util0
sudo apt-get install libxcb-xinerama0
sudo apt-get install libxcb-shape0
if: matrix.toolkit != 'wx'
- name: Install Wx dependencies for Linux
run: |
Expand All @@ -41,19 +53,16 @@ jobs:
path: ~/.cache
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@v2
with:
edm-version: ${{ env.INSTALL_EDM_VERSION }}
- name: Install click to the default EDM environment
run: edm --config ci/.edm.yaml install -y wheel click coverage
- name: Install test environment
run: edm run -- python ci/edmtool.py install --toolkit=${{ matrix.toolkit }} --runtime=${{ matrix.runtime }}
- name: Run tests
uses: GabrielBB/xvfb-action@v1
with:
# kiva agg requires at least 15-bit color depth.
# The --server-args assumes xvfb-run is called, hence Linux only.
run: --server-args="-screen 0 1024x768x24" edm run -- python ci/edmtool.py test --toolkit=${{ matrix.toolkit }} --runtime=${{ matrix.runtime }}
# kiva agg requires at least 15-bit color depth.
run: xvfb-run --server-args="-screen 0 1024x768x24" edm run -- python ci/edmtool.py test --toolkit=${{ matrix.toolkit }} --runtime=${{ matrix.runtime }}

# Test against EDM packages on Windows and OSX
test-with-edm:
Expand Down
1 change: 1 addition & 0 deletions ci/.edm.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
store_url: https://packages.enthought.com
repositories:
- enthought/free
- enthought/lgpl
2 changes: 1 addition & 1 deletion ci/edmtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def install(runtime, toolkit, environment, source):
elif sys.platform == "linux":
# XXX this is mainly for TravisCI workers; need a generic solution
commands.append(
"edm run -e {environment} -- pip install -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04/ wxPython<4.1" # noqa: E501
"edm run -e {environment} -- pip install -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-22.04/ wxPython" # noqa: E501
)
else:
commands.append(
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements_3.6.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pygarrayimage
pyglet
pyglet<2.0
4 changes: 2 additions & 2 deletions ci/requirements_3.8.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pygarrayimage
pyglet
pypdf2
pyglet<2.0
pypdf2<3.0
reportlab
4 changes: 2 additions & 2 deletions enable/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Dependencies for running enable/kiva's examples
"examples": ["chaco", "mayavi", "scipy", "kiwisolver", "pyglet"],
# Dependencies for GL backend support
"gl": ["pygarrayimage", "pyglet"],
"gl": ["pygarrayimage", "pyglet<2.0"],
# Dependencies for constrained layout
"layout": ["kiwisolver"],
# Dependencies for PDF backend
Expand All @@ -34,7 +34,7 @@
"svg": ["pyparsing"],
# Dependencies purely for running tests.
"test": [
"PyPDF2", # for pdf drawing tests in kiva.
"PyPDF2<3.0", # for pdf drawing tests in kiva.
"setuptools",
],
}
9 changes: 6 additions & 3 deletions enable/savage/svg/tests/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
#
# Thanks for using Enthought open source!

from io import StringIO
from io import BytesIO, StringIO
import unittest
from unittest.mock import patch
import xml.etree.cElementTree as etree

import enable.savage.svg.document as document
Expand Down Expand Up @@ -62,8 +63,10 @@ def testOpacityClampLow(self):
self.document.state["fill-opacity"] = -100
self.assertEqual(self.document.getBrushFromState().color[-1], 0)

def testURLFallback(self):
self.document.state["fill"] = "url(http://google.com) red"
@patch('urllib.request.urlopen')
def testURLFallback(self, mock_urlopen):
mock_urlopen.return_value = BytesIO(b"<!doctype html><html></html>")
self.document.state["fill"] = "url(http://example.com) red"
self.assertEqual(
self.document.getBrushFromState().color, (255, 0, 0, 255)
)
Expand Down
14 changes: 7 additions & 7 deletions kiva/agg/tests/test_affine_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from math import pi
import unittest

from numpy import array, allclose, ones, alltrue
from numpy import array, allclose, ones, all

from kiva import agg

Expand All @@ -24,7 +24,7 @@ def test_init_from_array(self):
m = agg.AffineMatrix(a)
desired = ones(6, "d")
result = m.asarray()
assert alltrue(result == desired)
assert all(result == desired)

def test_init_from_array1(self):
a = ones(6, "D")
Expand Down Expand Up @@ -53,19 +53,19 @@ def test_imul(self):
a *= a
actual = a
desired = agg.AffineMatrix((4.0, 0, 0, 4.0, 0, 0))
assert alltrue(desired == actual)
assert all(desired == actual)

def test_asarray(self):
m = agg.AffineMatrix()
result = m.asarray()
desired = array((1.0, 0.0, 0.0, 1.0, 0.0, 0.0))
assert alltrue(result == desired)
assert all(result == desired)

def _test_zero_arg_transform(self, method, orig, desired):
m = agg.AffineMatrix(orig)
method(m)
result = m.asarray()
assert alltrue(result == desired)
assert all(result == desired)

def test_flip_x(self):
method = agg.AffineMatrix.flip_x
Expand All @@ -92,14 +92,14 @@ def test_multiply(self):
other = agg.AffineMatrix(orig)
m.multiply(other)
result = m.asarray()
assert alltrue(result == desired)
assert all(result == desired)

def test_determinant(self):
orig = array((1.0, 2.0, 3.0, 1.0, 4.0, 5.0))
desired = -5.0
m = agg.AffineMatrix(orig)
result = m.determinant()
assert alltrue(result == desired)
assert all(result == desired)

def test_invert(self):
orig = agg.AffineMatrix((1.0, 2.0, 3.0, 1.0, 4.0, 5.0))
Expand Down
4 changes: 2 additions & 2 deletions kiva/agg/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
# is also available online at http://www.enthought.com/licenses/BSD.txt
#
# Thanks for using Enthought open source!
from numpy import alltrue, ravel
from numpy import all, ravel


class Utils(object):
def assertRavelEqual(self, x, y):
self.assertTrue(
alltrue(ravel(x) == ravel(y)), "\n%s\n !=\n%s" % (x, y)
all(ravel(x) == ravel(y)), "\n%s\n !=\n%s" % (x, y)
)
6 changes: 3 additions & 3 deletions kiva/basecore2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

"""
import numpy as np
from numpy import alltrue, array, asarray, float64, pi
from numpy import all, array, asarray, float64, pi

from .constants import (
CAP_BUTT, CAP_ROUND, CAP_SQUARE, CLOSE, CONCAT_CTM, EOF_FILL_STROKE,
Expand Down Expand Up @@ -73,7 +73,7 @@ def is_fully_transparent(color):

def fill_equal(fill1, fill2):
""" Compares the two fill colors. """
return alltrue(fill1 == fill2)
return all(fill1 == fill2)


class GraphicsContextBase(AbstractGraphicsContext):
Expand Down Expand Up @@ -353,7 +353,7 @@ def set_line_dash(self, pattern, phase=0):
to start. phase defaults to 0.

"""
if not alltrue(pattern):
if not all(pattern):
self.state.line_state.line_dash = NO_DASH
return
pattern = asarray(pattern)
Comment on lines +356 to 359
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This whole section could be re-written to be much clearer in intent

Suggested change
if not all(pattern):
self.state.line_state.line_dash = NO_DASH
return
pattern = asarray(pattern)
pattern = asarray(pattern)
if (pattern == 0).any():
self.state.line_state.line_dash = NO_DASH
return

Expand Down
4 changes: 2 additions & 2 deletions kiva/line_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
state (eg. Wx, SVG and PDF backends, but not Agg or QPainter).
"""

from numpy import alltrue, array, asarray, shape, sometrue
from numpy import all, array, asarray, shape, sometrue

from .constants import NO_DASH


def exactly_equal(arr1, arr2):
return shape(arr1) == shape(arr2) and alltrue(arr1 == arr2)
return shape(arr1) == shape(arr2) and all(arr1 == arr2)


def is_dashed(dash):
Expand Down
6 changes: 3 additions & 3 deletions kiva/tests/agg/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import unittest

from numpy import (
alltrue, array, concatenate, dtype, frombuffer, newaxis, ones, pi, ravel,
all, array, concatenate, dtype, frombuffer, newaxis, ones, pi, ravel,
zeros,
)
from PIL import Image
Expand Down Expand Up @@ -76,7 +76,7 @@ def alpha_blend(src1, src2, alpha=1.0, ambient_alpha=1.0):
def assert_equal(desired, actual):
""" Only use for small arrays. """
try:
assert alltrue(ravel(actual) == ravel(desired))
assert all(ravel(actual) == ravel(desired))
except AssertionError:
size = sum(array(desired.shape))
if size < 10:
Expand All @@ -97,7 +97,7 @@ def assert_close(desired, actual, diff_allowed=2):
try:
# cast up so math doesn't underflow
diff = abs(ravel(actual.astype(Int32)) - ravel(desired.astype(Int32)))
assert alltrue(diff <= diff_allowed)
assert all(diff <= diff_allowed)
except AssertionError:
size = sum(array(desired.shape))
if size < 10:
Expand Down
Loading