[python-affine] 01/05: Imported Upstream version 1.2.0
Sebastiaan Couwenberg
sebastic at moszumanska.debian.org
Fri Jun 5 00:12:56 UTC 2015
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch master
in repository python-affine.
commit bb28a1ee4977f947d1ecf8f9bbb85ac52cbb6b89
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Fri Jun 5 02:01:54 2015 +0200
Imported Upstream version 1.2.0
---
.coveragerc | 2 ++
.travis.yml | 4 ++--
AUTHORS.txt | 1 +
CHANGES.txt | 7 ++++++-
README.rst | 4 ++--
affine/__init__.py | 21 ++++++++++++++-------
affine/tests/test_pickle.py | 30 ++++++++++++++++++++++++++++++
affine/tests/test_transform.py | 18 +++++++++---------
setup.py | 10 ++++------
9 files changed, 70 insertions(+), 27 deletions(-)
diff --git a/.coveragerc b/.coveragerc
new file mode 100644
index 0000000..793a509
--- /dev/null
+++ b/.coveragerc
@@ -0,0 +1,2 @@
+[run]
+omit = affine/tests/*
diff --git a/.travis.yml b/.travis.yml
index f30a897..a8481aa 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,10 +5,10 @@ python:
- "3.3"
- "3.4"
install:
- - "pip install pytest"
+ - "pip install pytest pytest-cov nose"
- "pip install coveralls"
- "pip install -e ."
script:
- - coverage run --source=affine --omit='*.pxd,*.pyx,*/tests/*,*/docs/*,*/examples/*,*/benchmarks/*' -m py.test
+ - py.test --cov affine --cov-report term-missing
after_success:
- coveralls
diff --git a/AUTHORS.txt b/AUTHORS.txt
index 91ba223..34c7ba2 100644
--- a/AUTHORS.txt
+++ b/AUTHORS.txt
@@ -5,3 +5,4 @@ Authors
- Sean Gillies <sean at mapbox.com> (same as ^^)
- Steven Ring <smr at southsky.com.au>
- Mike Toews <mwtoews at gmail.com>
+- Kevin Wurster <wursterk at gmail.com>
diff --git a/CHANGES.txt b/CHANGES.txt
index 15d1bc2..ec950e4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,9 +1,14 @@
CHANGES
=======
+1.2.0 (2015-06-01)
+------------------
+- Enable pickling of Affine objects (#14).
+- Sort out the mixed up shearing parameters (#12).
+
1.1.0 (2014-11-13)
------------------
-- add loadsw/dumpsw world file utilities (#6).
+- Add loadsw/dumpsw world file utilities (#6).
- Travis-CI and Coveralls config and web hooks added (#10).
1.0.1 (2014-10-20)
diff --git a/README.rst b/README.rst
index 9e8ee0b..73fcc11 100644
--- a/README.rst
+++ b/README.rst
@@ -1,12 +1,12 @@
Affine
======
-Matrices describing affine transformation of the plane
+Matrices describing affine transformation of the plane.
.. image:: https://travis-ci.org/sgillies/affine.svg?branch=master
:target: https://travis-ci.org/sgillies/affine
-.. image:: https://coveralls.io/repos/sgillies/affine/badge.png
+.. image:: https://coveralls.io/repos/sgillies/affine/badge.svg
:target: https://coveralls.io/r/sgillies/affine
The Affine package is derived from Casey Duncan's Planar package. Please see
diff --git a/affine/__init__.py b/affine/__init__.py
index f7d8af9..dc2dac9 100644
--- a/affine/__init__.py
+++ b/affine/__init__.py
@@ -47,7 +47,7 @@ import math
__all__ = ['Affine']
__author__ = "Sean Gillies"
-__version__ = "1.1.0"
+__version__ = "1.2.0"
EPSILON = 1e-5
EPSILON2 = EPSILON ** 2
@@ -208,17 +208,17 @@ class Affine(
def shear(cls, x_angle=0, y_angle=0):
"""Create a shear transform along one or both axes.
- :param x_angle: Angle in degrees to shear along the x-axis.
+ :param x_angle: Shear angle in degrees parallel to the x-axis.
:type x_angle: float
- :param y_angle: Angle in degrees to shear along the y-axis.
+ :param y_angle: Shear angle in degrees parallel to the y-axis.
:type y_angle: float
:rtype: Affine
"""
- sx = math.tan(math.radians(x_angle))
- sy = math.tan(math.radians(y_angle))
+ mx = math.tan(math.radians(x_angle))
+ my = math.tan(math.radians(y_angle))
return tuple.__new__(cls,
- (1.0, sy, 0.0,
- sx, 1.0, 0.0,
+ (1.0, mx, 0.0,
+ my, 1.0, 0.0,
0.0, 0.0, 1.0))
@classmethod
@@ -434,6 +434,13 @@ 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.
+ return self.a, self.b, self.c, self.d, self.e, self.f
+
identity = Affine(1, 0, 0, 0, 1, 0)
"""The identity transform"""
diff --git a/affine/tests/test_pickle.py b/affine/tests/test_pickle.py
new file mode 100644
index 0000000..7911a73
--- /dev/null
+++ b/affine/tests/test_pickle.py
@@ -0,0 +1,30 @@
+"""
+Validate that instances of `affine.Affine()` can be pickled and unpickled.
+"""
+
+
+import pickle
+from multiprocessing import Pool
+
+import affine
+
+
+def test_pickle():
+ a = affine.Affine(1, 2, 3, 4, 5, 6)
+ assert pickle.loads(pickle.dumps(a)) == a
+
+
+def _mp_proc(x):
+ # A helper function - needed for test_with_multiprocessing()
+ # Can't be defined inside the test because multiprocessing needs
+ # everything to be in __main__
+ assert isinstance(x, affine.Affine)
+ return x
+
+
+def test_with_multiprocessing():
+ a1 = affine.Affine(1, 2, 3, 4, 5, 6)
+ a2 = affine.Affine(6, 5, 4, 3, 2, 1)
+ results = Pool(2).map(_mp_proc, [a1, a2])
+ for expected, actual in zip([a1, a2], results):
+ assert expected == actual
diff --git a/affine/tests/test_transform.py b/affine/tests/test_transform.py
index d456cba..d5c5806 100644
--- a/affine/tests/test_transform.py
+++ b/affine/tests/test_transform.py
@@ -146,25 +146,25 @@ class PyAffineTestCase(unittest.TestCase):
def test_shear_constructor(self):
shear = Affine.shear(30)
assert isinstance(shear, Affine)
- sx = math.tan(math.radians(30))
+ mx = math.tan(math.radians(30))
seq_almost_equal(
tuple(shear),
- (1, 0, 0,
- sx, 1, 0,
+ (1, mx, 0,
+ 0, 1, 0,
0, 0, 1))
shear = Affine.shear(-15, 60)
- sx = math.tan(math.radians(-15))
- sy = math.tan(math.radians(60))
+ mx = math.tan(math.radians(-15))
+ my = math.tan(math.radians(60))
seq_almost_equal(
tuple(shear),
- (1, sy, 0,
- sx, 1, 0,
+ (1, mx, 0,
+ my, 1, 0,
0, 0, 1))
shear = Affine.shear(y_angle=45)
seq_almost_equal(
tuple(shear),
- (1, 1, 0,
- 0, 1, 0,
+ (1, 0, 0,
+ 1, 1, 0,
0, 0, 1))
def test_rotation_constructor(self):
diff --git a/setup.py b/setup.py
index ae9c86b..cc704b1 100755
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,5 @@
-#!/usr/bin/env python
-
-from setuptools import setup
+from codecs import open as codecs_open
+from setuptools import setup, find_packages
# Parse the version from the affine module.
@@ -11,7 +10,7 @@ with open('affine/__init__.py') as f:
version = version.strip('"').strip("'")
break
-with open('README.rst') as f:
+with codecs_open('README.rst', encoding='utf-8') as f:
readme = f.read()
@@ -25,8 +24,7 @@ setup(name='affine',
author_email='sean at mapbox.com',
url='https://github.com/sgillies/affine',
license='BSD',
- package_dir={'': '.'},
- packages=['affine'],
+ packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
include_package_data=True,
zip_safe=False,
extras_require = {'test': ['pytest']}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/python-affine.git
More information about the Pkg-grass-devel
mailing list