Skip to content

Commits on Source 6

......@@ -55,3 +55,5 @@ coverage.xml
# Sphinx documentation
docs/_build/
__pycache__
*.swp
......@@ -5,12 +5,12 @@ python:
- 2.7
- 3.6
install:
- pip install wheel --upgrade
- pip install -r requirements.txt
- pip install .[test]
script:
- pytest --cov affine --cov-report term-missing
- python -m pytest --cov affine --cov-report term-missing
- python -m pydocstyle affine
after_success:
- pip install coveralls
- coveralls
deploy:
on:
......
CHANGES
=======
2.2.1 (2018-06-04)
------------------
- Docstring improvements (#37).
2.2.0 (2018-03-20)
------------------
- Addition of permutation matrix (#35).
......
......@@ -47,7 +47,7 @@ import math
__all__ = ['Affine']
__author__ = "Sean Gillies"
__version__ = "2.2.0"
__version__ = "2.2.1"
EPSILON = 1e-5
......@@ -146,6 +146,13 @@ class Affine(
precision = EPSILON
def __new__(cls, *members):
"""Create a new object
Parameters
----------
members : list of float
Affine matrix members a, b, c, d, e, f
"""
if len(members) == 6:
mat3x3 = [x * 1.0 for x in members] + [0.0, 0.0, 1.0]
return tuple.__new__(cls, mat3x3)
......@@ -375,8 +382,8 @@ class Affine(
limits, after applying the transform.
"""
a, b, c, d, e, f, g, h, i = self
return ((abs(a) < self.precision and abs(e) < self.precision)
or (abs(d) < self.precision and abs(b) < self.precision))
return ((abs(a) < self.precision and abs(e) < self.precision) or
(abs(d) < self.precision and abs(b) < self.precision))
@property
def is_conformal(self):
......@@ -400,9 +407,9 @@ class Affine(
always results in a congruent shape.
"""
a, b, c, d, e, f, g, h, i = self
return (self.is_conformal
and abs(1.0 - (a * a + d * d)) < self.precision
and abs(1.0 - (b * b + e * e)) < self.precision)
return (self.is_conformal and
abs(1.0 - (a * a + d * d)) < self.precision and
abs(1.0 - (b * b + e * e)) < self.precision)
@cached_property
def is_degenerate(self):
......@@ -455,9 +462,11 @@ class Affine(
__iadd__ = __add__
def __mul__(self, other):
"""Apply the transform using matrix multiplication, creating a
resulting object of the same type. A transform may be applied to
another transform, a vector, vector array, or shape.
"""Multiplication
Apply the transform using matrix multiplication, creating
a resulting object of the same type. A transform may be applied
to another transform, a vector, vector array, or shape.
:param other: The object to transform.
:type other: Affine, :class:`~planar.Vec2`,
......@@ -480,9 +489,14 @@ class Affine(
return (vx * sa + vy * sb + sc, vx * sd + vy * se + sf)
def __rmul__(self, other):
# We should not be called if other is an affine instance
# This is just a guarantee, since we would potentially
# return the wrong answer in that case.
"""Right hand multiplication
Notes
-----
We should not be called if other is an affine instance This is
just a guarantee, since we would potentially return the wrong
answer in that case.
"""
assert not isinstance(other, Affine)
return self.__mul__(other)
......@@ -528,10 +542,14 @@ class Affine(
__hash__ = tuple.__hash__ # hash is not inherited in Py 3
def __getnewargs__(self):
# Required for unpickling.
# Normal unpickling creates a situation where __new__ receives all 9
# elements rather than the 6 that are required for the constructor.
# This method ensures that only the 6 are provided.
"""Pickle protocol support
Notes
-----
Normal unpickling creates a situation where __new__ receives all
9 elements rather than the 6 that are required for the
constructor. This method ensures that only the 6 are provided.
"""
return self.a, self.b, self.c, self.d, self.e, self.f
......
python-affine (2.2.0-2) UNRELEASED; urgency=medium
python-affine (2.2.1-1) unstable; urgency=medium
* New upstream release.
* Update Vcs-* URLs for Salsa.
* Drop override for vcs-deprecated-in-debian-infrastructure.
* Bump Standards-Version to 4.1.4, no changes.
* Strip trailing whitespace from control file.
* Add module import tests to autopkgtest configuration.
* Use pytest instead of nose.
-- Bas Couwenberg <sebastic@debian.org> Sat, 31 Mar 2018 12:53:15 +0200
-- Bas Couwenberg <sebastic@debian.org> Tue, 05 Jun 2018 07:25:21 +0200
python-affine (2.2.0-1) unstable; urgency=medium
......
......@@ -8,8 +8,6 @@ Build-Depends: debhelper (>= 9),
dh-python,
python-all,
python3-all,
python-nose,
python3-nose,
python-pytest,
python3-pytest,
python-setuptools,
......
From: Johan Van de Wauw <johan.vandewauw@gmail.com>
Date: Mon, 3 Nov 2014 09:16:46 +0100
Subject: Add test configuration
---
setup.cfg | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 setup.cfg
--- a/setup.cfg
+++ b/setup.cfg
@@ -3,3 +3,12 @@ universal: 1
[tool:pytest]
testpaths: affine/tests
+
+[nosetests]
+tests=affine/tests
+nocapture=True
+verbosity=3
+logging-filter=affine
+logging-level=DEBUG
+with-coverage=1
+cover-package=affine
0001-Add-test-configuration.patch
#!/usr/bin/make -f
export PYBUILD_NAME=affine
%:
dh $@ --with python2,python3 --buildsystem pybuild --parallel
override_dh_auto_test:
PYBUILD_SYSTEM=custom \
PYBUILD_TEST_ARGS="nosetests {build_dir}/affine" dh_auto_test || echo "Ignoring test failures"
# Test installability
Depends: @
Test-Command: /bin/true
# Test module import (Python 2)
Depends: python-all, python-affine
Test-Command: set -e ; for py in $(pyversions -r 2>/dev/null) ; do cd "$ADTTMP" ; echo "Testing with $py:" ; $py -c "import affine; print(affine)" ; done
# Test module import (Python 3)
Depends: python3-all, python3-affine
Test-Command: set -e ; for py in $(py3versions -r 2>/dev/null) ; do cd "$ADTTMP" ; echo "Testing with $py:" ; $py -c "import affine; print(affine)" ; done
......@@ -3,3 +3,7 @@ universal: 1
[tool:pytest]
testpaths: affine/tests
[pydocstyle]
select: D1
add-ignore: D105
......@@ -5,29 +5,30 @@ from setuptools import find_packages, setup
# Parse the version from the affine module.
with codecs.open(os.path.join('affine', '__init__.py')) as f:
with codecs.open(os.path.join("affine", "__init__.py")) as f:
for line in f:
if "__version__" in line:
version = line.split("=")[1].strip()
version = version.strip('"').strip("'")
break
with codecs.open('README.rst', encoding='utf-8') as f:
with codecs.open("README.rst", encoding="utf-8") as f:
readme = f.read()
setup(name='affine',
setup(
name="affine",
version=version,
description="Matrices describing affine transformation of the plane.",
long_description=readme,
classifiers=[],
keywords='affine transformation matrix',
author='Sean Gillies',
author_email='sean@mapbox.com',
url='https://github.com/sgillies/affine',
license='BSD',
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
keywords="affine transformation matrix",
author="Sean Gillies",
author_email="sean@mapbox.com",
url="https://github.com/sgillies/affine",
license="BSD",
packages=find_packages(exclude=["ez_setup", "examples", "tests"]),
include_package_data=True,
zip_safe=True,
extras_require={'test': ['pytest>=3.0', 'pytest-cov']}
extras_require={"test": ["pytest>=3.0", "pytest-cov", "pydocstyle", "coveralls"]},
)