Skip to content
Commits on Source (4)
sudo: false
dist: xenial
language: python
cache: pip
python:
- 2.7
- 3.6
- 3.7
install:
- pip install -r requirements.txt
- pip install .[test]
......@@ -17,4 +18,4 @@ deploy:
tags: true
provider: pypi
distributions: "sdist bdist_wheel"
user: seang
user: __token__
......@@ -3,7 +3,7 @@ Authors
- Sean Gillies <sean@mapbox.com>
- Steven Ring <smr@southsky.com.au>
- Mike Toews <mwtoews@gmail.com>
- Mike Taves <mwtoews@gmail.com>
- Kevin Wurster <wursterk@gmail.com>
- Todd Small <todd_small@icloud.com>
- Juan Luis Cano Rodríguez <juanlu@satellogic.com>
......
CHANGES
=======
2.3.0 (2019-09-04)
------------------
Deprecations:
- Right multiplication like vector * matrix is deprecated and will raise
AffineError in version 3.0.0.
Bug fixes:
- Change signature of Affine constructor to help users of PyCharm (#45).
- The Affine class docstring has been improved.
2.2.2 (2018-12-20)
------------------
- Affine.itransform computed the wrong results for arrays with rotation or
......
"""Affine transformation matrices
The 3x3 augmented affine transformation matrix for transformations in two
dimensions is illustrated below.
| x' | | a b c | | x |
| y' | = | d e f | | y |
| 1 | | 0 0 1 | | 1 |
The Affine package is derived from Casey Duncan's Planar package. See the
copyright statement below.
"""
......@@ -43,11 +36,12 @@ from __future__ import division
from collections import namedtuple
import math
import warnings
__all__ = ['Affine']
__author__ = "Sean Gillies"
__version__ = "2.2.2"
__version__ = "2.3.0"
EPSILON = 1e-5
......@@ -123,10 +117,36 @@ class Affine(
namedtuple('Affine', ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'))):
"""Two dimensional affine transform for 2D linear mapping.
Parallel lines are preserved by these transforms. Affine transforms
can perform any combination of translations, scales/flips, shears,
and rotations. Class methods are provided to conveniently compose
transforms from these operations.
Parameters
----------
a, b, c, d, e, f : float
Coefficients of an augmented affine transformation matrix
| x' | | a b c | | x |
| y' | = | d e f | | y |
| 1 | | 0 0 1 | | 1 |
`a`, `b`, and `c` are the elements of the first row of the
matrix. `d`, `e`, and `f` are the elements of the second row.
Attributes
----------
a, b, c, d, e, f, g, h, i : float
The coefficients of the 3x3 augumented affine transformation
matrix
| x' | | a b c | | x |
| y' | = | d e f | | y |
| 1 | | g h i | | 1 |
`g`, `h`, and `i` are always 0, 0, and 1.
The Affine package is derived from Casey Duncan's Planar package.
See the copyright statement below. Parallel lines are preserved by
these transforms. Affine transforms can perform any combination of
translations, scales/flips, shears, and rotations. Class methods
are provided to conveniently compose transforms from these
operations.
Internally the transform is stored as a 3x3 transformation matrix.
The transform may be constructed directly by specifying the first
......@@ -140,25 +160,19 @@ class Affine(
matrices and vectors in general, but provides a convenience for
users of this class.
:param members: 6 floats for the first two matrix rows.
:type members: float
"""
precision = EPSILON
def __new__(cls, *members):
def __new__(cls, a, b, c, d, e, f):
"""Create a new object
Parameters
----------
members : list of float
Affine matrix members a, b, c, d, e, f
a, b, c, d, e, f : float
Elements of an augmented affine transformation matrix.
"""
if len(members) == 6:
mat3x3 = [x * 1.0 for x in members] + [0.0, 0.0, 1.0]
mat3x3 = [x * 1.0 for x in [a, b, c, d, e, f]] + [0.0, 0.0, 1.0]
return tuple.__new__(cls, mat3x3)
else:
raise TypeError(
"Expected 6 coefficients, found %d" % len(members))
@classmethod
def from_gdal(cls, c, a, b, f, d, e):
......@@ -265,7 +279,10 @@ class Affine(
@classmethod
def permutation(cls, *scaling):
"""Create the permutation transform. For 2x2 matrices, there is only one permutation matrix that is not the identity.
"""Create the permutation transform
For 2x2 matrices, there is only one permutation matrix that is
not the identity.
:rtype: Affine
"""
......@@ -491,12 +508,17 @@ class Affine(
def __rmul__(self, other):
"""Right hand multiplication
.. deprecated:: 2.3.0
Right multiplication will be prohibited in version 3.0. This method
will raise AffineError.
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.
"""
warnings.warn("Right multiplication will be prohibited in version 3.0", DeprecationWarning, stacklevel=2)
assert not isinstance(other, Affine)
return self.__mul__(other)
......
......@@ -499,6 +499,7 @@ def test_mul_tuple():
def test_rmul_tuple():
with pytest.warns(DeprecationWarning):
t = Affine(1, 2, 3, 4, 5, 6)
(2.0, 2.0) * t
......
python-affine (2.3.0-1) unstable; urgency=medium
* New upstream release.
-- Bas Couwenberg <sebastic@debian.org> Thu, 05 Sep 2019 06:19:35 +0200
python-affine (2.2.2-2) unstable; urgency=medium
* Bump Standards-Version to 4.4.0, no changes.
......
[tox]
envlist =
py27,py36
py27,py36,py37
[testenv]
usedevelop = true
......