Skip to content

Commit

Permalink
Merge pull request #27 from glotzerlab/remove_py2
Browse files Browse the repository at this point in the history
Remove support for Python < 3.6, Numpy < 1.15
  • Loading branch information
vyasr committed Jun 18, 2020
2 parents 8b2afee + d224666 commit 41929d8
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 101 deletions.
7 changes: 6 additions & 1 deletion ChangeLog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ The format is based on `Keep a Changelog <http://keepachangelog.com/en/1.0.0/>`_
This project adheres to `Semantic Versioning <http://semver.org/spec/v2.0.0.html>`_.


Unreleased
v1.3.0 - xxxx-xx-xx
----------

Fixed
Expand All @@ -11,6 +11,11 @@ Fixed
* Docstring of geometry.angle was missing a factor of 2 in the comparison to intrinsic_distance.
* Docstrings of functions using support1d decorator were losing their docstring (fixed with functools.wraps).

Changed
+++++++

* Drop Python 2 support.

v1.2.2 - 2019-09-11
-------------------

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ python setup.py install --user

### Requirements

* Python = 2.7, >= 3.3
* NumPy >= 1.10
* Python = >= 3.6
* NumPy >= 1.15

## Testing

The package is currently tested for Python versions 2.7 and Python >= 3.3 on Unix-like systems.
Continuous integrated testing is performed using CircleCI on these Python versions with NumPy versions 1.10 and above.
The package is currently tested for Python >= 3.6 on Unix-like systems.
Continuous integrated testing is performed using CircleCI on these Python versions with NumPy versions 1.15 and above.

To run the packaged unit tests, execute the following line from the root of the repository:

Expand Down
10 changes: 5 additions & 5 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ Core features of rowan include (but are not limited to):
package-interpolate
package-mapping
package-random
development

.. toctree::
:maxdepth: 1
:caption: Reference:

development
license
changelog
credits
Expand All @@ -75,8 +75,8 @@ Requirements

The minimum requirements for using rowan are:

* Python = 2.7, >= 3.3
* NumPy >= 1.10
* Python >= 3.6
* NumPy >= 1.15

Installation
------------
Expand Down Expand Up @@ -133,8 +133,8 @@ For example:
Running Tests
-------------

The package is currently tested for Python versions 2.7 and Python >= 3.3 on Unix-like systems.
Continuous integrated testing is performed using CircleCI on these Python versions with NumPy versions 1.10 and above.
The package is currently tested for Python >= 3.6 on Unix-like systems.
Continuous integrated testing is performed using CircleCI on these Python versions with NumPy versions 1.15 and above.

To run the packaged unit tests, execute the following line from the root of the repository:

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
###### Requirements without Version Specifiers ######

###### Requirements with Version Specifiers ######
numpy>=1.10
numpy>=1.15
10 changes: 4 additions & 6 deletions rowan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
not match and return results according to NumPy's broadcasting rules.
"""

from __future__ import division, print_function, absolute_import

from . import calculus
from . import geometry
from . import interpolate
Expand All @@ -38,7 +36,7 @@
__all__ = ['calculus', 'geometry', 'interpolate', 'mapping', 'random',
'allclose', 'conjugate', 'divide', 'exp', 'expb', 'exp10', 'equal',
'from_axis_angle', 'from_euler', 'from_matrix', 'from_mirror_plane',
'inverse', 'isclose', 'isinf', 'isfinite', 'isnan', 'is_unit', 'log',
'logb', 'log10', 'multiply', 'norm', 'normalize', 'not_equal',
'power', 'reflect', 'rotate', 'to_axis_angle', 'to_euler',
'to_matrix', 'vector_vector_rotation']
'inverse', 'isclose', 'isinf', 'isfinite', 'isnan', 'is_unit',
'log', 'logb', 'log10', 'multiply', 'norm', 'normalize',
'not_equal', 'power', 'reflect', 'rotate', 'to_axis_angle',
'to_euler', 'to_matrix', 'vector_vector_rotation']
1 change: 0 additions & 1 deletion rowan/calculus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
R"""This subpackage provides the ability to compute the derivative and
integral of a quaternion.
"""
from __future__ import division, print_function, absolute_import

import numpy as np

Expand Down
40 changes: 0 additions & 40 deletions rowan/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,10 @@
# All rights reserved.
# This software is licensed under the BSD 3-Clause License.
R"""Submodule containing all standard functions"""
from __future__ import division, print_function, absolute_import

import numpy as np


def _support_1d(func):
R"""Decorator to raise input array shape to 2D and flatten on output.
In order to support arbitrary-dimensional arrays, rowan makes liberal use
of fancy NumPy indexing tricks, in particular the '...' indexer. However,
NumPy versions older than 1.13 fail for inputs that are 1-dimensional that
use this approach. For backwards compatibility with older NumPy versions,
this decorator manually promotes input arrays to at least 2-dimensional
arrays, then flattens them back to the input shape if needed. This function
can be removed when we officially drop support for NumPy < 1.13
Currently the decorator is only designed for functions that take a single
argument.
"""

from functools import wraps

# Wrapper function to ensure that input arrays are at least 2-dimensional.
@wraps(func)
def func_atleast_2d(q, *args, **kwargs):
q = np.asarray(q)
if len(q.shape) == 1:
flat = True
q = np.atleast_2d(q)
else:
flat = False
ret = func(q, *args, **kwargs)
if flat:
return ret.squeeze()
else:
return ret

return func_atleast_2d


@_support_1d
def exp(q):
R"""Computes the natural exponential function :math:`e^q`.
Expand Down Expand Up @@ -136,7 +99,6 @@ def exp10(q):
return expb(q, 10)


@_support_1d
def log(q):
R"""Computes the quaternion natural logarithm.
Expand Down Expand Up @@ -246,7 +208,6 @@ def log10(q):
return logb(q, 10)


@_support_1d
def power(q, n):
R"""Computes the power of a quaternion :math:`q^n`.
Expand Down Expand Up @@ -308,7 +269,6 @@ def conjugate(q):
return conjugate


@_support_1d
def inverse(q):
R"""Computes the inverse of an array of quaternions.
Expand Down
19 changes: 9 additions & 10 deletions rowan/geometry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
between rotations. An overview of distance measurements can be found in
`this paper <https://link.springer.com/article/10.1007/s10851-009-0161-2>`_.
"""
from __future__ import division, print_function, absolute_import

import numpy as np

Expand Down Expand Up @@ -85,10 +84,10 @@ def riemann_exp_map(p, v):
The nonzero quaternions form a Lie algebra :math:`\mathbb{H}^*` that
is also a Riemannian manifold. In general, given a point :math:`p` on a
Riemannian manifold :math:`\mathcal{M}` and an element of the tangent
space at :math:`p`, :math:`v \in T_p\mathcal{M}`, the Riemannian exponential
map is defined by the geodesic starting at :math:`p` and tracing out
an arc of length :math:`v` in the direction of :math:`v`. This function
computes the endpoint of that path (which is itself a quaternion).
space at :math:`p`, :math:`v \in T_p\mathcal{M}`, the Riemannian
exponential map is defined by the geodesic starting at :math:`p` and
tracing out an arc of length :math:`v` in the direction of :math:`v`. This
function computes the endpoint of that path (which is itself a quaternion).
Explicitly, we define the exponential map as
Expand Down Expand Up @@ -117,9 +116,9 @@ def riemann_log_map(p, q):
R"""Compute the log map on the Riemannian manifold :math:`\mathbb{H}^*` of
nonzero quaterions.
This function inverts :py:func:`riemann_exp_map`. See that function for more
details. In brief, given two quaternions p and q, this method returns a
third quaternion parameterizing the geodesic passing from p to q. It is
This function inverts :py:func:`riemann_exp_map`. See that function for
more details. In brief, given two quaternions p and q, this method returns
a third quaternion parameterizing the geodesic passing from p to q. It is
therefore an important measure of the distance between the two input
quaternions.
Expand All @@ -128,8 +127,8 @@ def riemann_log_map(p, q):
q ((..., 4) np.array): Endpoints (quaternions).
Returns:
Array of shape (..., 4) containing quaternions pointing from p to q with
magnitudes equal to the length of the geodesics joining these
Array of shape (..., 4) containing quaternions pointing from p to q
with magnitudes equal to the length of the geodesics joining these
quaternions.
Example::
Expand Down
1 change: 0 additions & 1 deletion rowan/interpolate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
The rowan package provides a simple interface to slerp, the standard method
of quaternion interpolation for two quaternions.
"""
from __future__ import division, print_function, absolute_import

import numpy as np

Expand Down
32 changes: 16 additions & 16 deletions rowan/mapping/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
If points in the two sets have a known correspondence, the problem is much
simpler. Various precise formulations exist that admit analytical formulations,
such as the `orthogonal Procrustes problem
<https://en.wikipedia.org/wiki/Orthogonal_Procrustes_problem>`_ searching for an
orthogonal transformation
<https://en.wikipedia.org/wiki/Orthogonal_Procrustes_problem>`_ searching for
an orthogonal transformation
.. math::
\begin{equation}
Expand All @@ -29,21 +29,21 @@
.. math::
\begin{equation}
\min_{\boldsymbol{R} \in SO(3)} \frac{1}{2} \sum_{k=1}^N a_k \lvert
\lvert \boldsymbol{w}_k - \boldsymbol{R} \boldsymbol{v}_k \rvert\rvert^2
\lvert \boldsymbol{w}_k - \boldsymbol{R}\boldsymbol{v}_k\rvert\rvert^2
\end{equation}
Numerous algorithms to solve this problem exist, particularly in the field of
aerospace engineering and robotics where this problem must be solved on embedded
systems with limited processing. Since that constraint does not apply here, this
package simply implements some of the most stable known methods irrespective of
cost. In particular, this package contains the Kabsch algorithm, which solves
Wahba's problem using an SVD in the vein of `Peter Schonemann's original
solution <https://link.springer.com/article/10.1007/BF02289451>`_ to
the orthogonal Procrustes problem. Additionally this package contains the
`Davenport q method <https://ntrs.nasa.gov/search.jsp?R=19670009376>`_, which
works directly with quaternions. The most popular algorithms for Wahba's problem
are variants of the q method that are faster at the cost of some stability; we
omit these here.
aerospace engineering and robotics where this problem must be solved on
embedded systems with limited processing. Since that constraint does not apply
here, this package simply implements some of the most stable known methods
irrespective of cost. In particular, this package contains the Kabsch
algorithm, which solves Wahba's problem using an SVD in the vein of `Peter
Schonemann's original solution
<https://link.springer.com/article/10.1007/BF02289451>`_ to the orthogonal
Procrustes problem. Additionally this package contains the `Davenport q method
<https://ntrs.nasa.gov/search.jsp?R=19670009376>`_, which works directly with
quaternions. The most popular algorithms for Wahba's problem are variants of
the q method that are faster at the cost of some stability; we omit these here.
In addition, :py:mod:`rowan.mapping` also includes some functionality for
more general point set registration. If a point cloud has a set of known
Expand All @@ -52,7 +52,6 @@
correspondence is known at all, then the iterative closest point algorithm can
be used to approximate the mapping.
"""
from __future__ import division, print_function, absolute_import

import numpy as np

Expand Down Expand Up @@ -465,7 +464,8 @@ def icp(X, Y, method='best', unique_match=True, max_iterations=20,
row_ind, indices = optimize.linear_sum_assignment(pair_distances)
distances = pair_distances[row_ind, indices]
else:
distances, indices = nn.kneighbors(cur_points, return_distance=True)
distances, indices = nn.kneighbors(
cur_points, return_distance=True)
distances = distances.ravel()
indices = indices.ravel()

Expand Down
3 changes: 1 addition & 2 deletions rowan/random/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#
# other alternatives:
# http://home.lu.lv/~sd20008/papers/essays/Random%20unitary%20[paper].pdf
from __future__ import division, print_function, absolute_import

import numpy as np

Expand All @@ -24,7 +23,7 @@


def rand(*args):
R"""Generate random rotations that are uniformly distributed on a unit sphere.
R"""Generate random rotations uniformly distributed on a unit sphere.
This is a convenience function *a la* ``np.random.rand``. If you want a
function that takes a tuple as input, use :py:func:`random_sample` instead.
Expand Down
14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
except ImportError:
readme = desc

# Supported versions are determined according to NEP 29.
# https://numpy.org/neps/nep-0029-deprecation_policy.html

setup(name='rowan',
version=version,
description=desc,
Expand All @@ -26,18 +29,15 @@
packages=find_packages(exclude=["tests"]),
zip_safe=True,
install_requires=[
'numpy>=1.10'
'numpy>=1.15'
],
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4',
python_requires='>=3.6, <4',
classifiers=[
'Development Status :: 3 - Alpha',
'Development Status :: 6 - Mature',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Scientific/Engineering :: Mathematics',
],
)
12 changes: 5 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
[tox]
envlist=py{27,34,35,36}-numpy{10,11,12,13,14}
envlist=py{36,37,38}-numpy{15,16,17,18}

[testenv]
deps=
setuptools==38.3.0
numpy10: numpy==1.10.4
numpy11: numpy==1.11.3
numpy12: numpy==1.12.1
numpy13: numpy==1.13.3
numpy14: numpy==1.14.1
numpy15: numpy==1.15.4
numpy16: numpy==1.16.6
numpy17: numpy==1.17.5
numpy18: numpy==1.18.5
scipy==1.2.1
commands=
python -m unittest discover tests

0 comments on commit 41929d8

Please sign in to comment.