On 21 Sep 2018, at 14:25, CCTBX commit <[email protected]> wrote:Repository : ssh://ws133.diamond.ac.uk/cctbx
On branch : master
commit 790d9e315a2a6ae5a875ba86b461ed570c77280d
Author: Markus Gerstel <[email protected]>
Date: Thu May 24 12:16:38 2018 +0100
Python 3 syntax changes
Replace the reduce(add, ...) function by sum().
reduce() is no longer in the global namespace in python 3.
790d9e315a2a6ae5a875ba86b461ed570c77280d
scitbx/math/__init__.py | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/scitbx/math/__init__.py b/scitbx/math/__init__.py
index a13405f92..49e295eb0 100644
--- a/scitbx/math/__init__.py
+++ b/scitbx/math/__init__.py
@@ -1,11 +1,13 @@
-from __future__ import division, absolute_import
+from __future__ import absolute_import, division, print_function
+
+import math
+
from scitbx.math.ext import *
import scitbx.linalg.eigensystem
import scitbx.math.gaussian # implicit import
from scitbx import matrix
from scitbx.array_family import flex
from boost import rational # implicit import
-import math
gaussian_fit_1d_analytical.__doc__ = """
Fits a gaussian function to a list of points.
@@ -88,16 +90,14 @@ def r3_rotation_average_rotation_matrix_from_matrices(*matrices):
"""
if not matrices:
- raise TypeError, "Average of empty sequence"
+ raise TypeError("Average of empty sequence")
- import operator
import scitbx.matrix
- average = reduce(
- operator.add,
- [ scitbx.matrix.col( r3_rotation_matrix_as_unit_quaternion( e ) )
- for e in matrices ]
- )
+ average = sum(
+ scitbx.matrix.col( r3_rotation_matrix_as_unit_quaternion( e ) )
+ for e in matrices
+ )
return r3_rotation_unit_quaternion_as_matrix( average.normalize() )
@@ -111,13 +111,12 @@ def r3_rotation_average_rotation_via_lie_algebra(matrices, maxiter = 100, conver
"""
if not matrices:
- raise TypeError, "Average of empty sequence"
+ raise TypeError("Average of empty sequence")
if maxiter < 0 or convergence <= 0:
- raise ValueError, "Invalid iteration parameters"
+ raise ValueError("Invalid iteration parameters")
from scitbx.math import so3_lie_algebra
- import operator
conv_sq = convergence * convergence
norm = 1.0 / len( matrices )
@@ -125,10 +124,9 @@ def r3_rotation_average_rotation_via_lie_algebra(matrices, maxiter = 100, conver
for i in range( maxiter ):
inverse = current.inverse()
- log_diff = norm * reduce(
- operator.add,
- [ so3_lie_algebra.element.from_rotation_matrix( matrix = inverse * m )
- for m in matrices ]
+ log_diff = norm * sum(
+ so3_lie_algebra.element.from_rotation_matrix( matrix = inverse * m )
+ for m in matrices
)
if log_diff.norm_sq() < conv_sq:
@@ -136,7 +134,7 @@ def r3_rotation_average_rotation_via_lie_algebra(matrices, maxiter = 100, conver
current *= log_diff.exponential()
- raise RuntimeError, "Iteration limit exceeded"
+ raise RuntimeError("Iteration limit exceeded")
def euler_angles_as_matrix(angles, deg=False):
if (deg):
@@ -174,7 +172,7 @@ class erf_verification(object):
if (self.max_delta < delta):
self.max_delta = delta
if (delta > self.tolerance):
- print x, expected_result, result, delta
+ print(x, expected_result, result, delta)
class minimum_covering_sphere_nd(object):
To unsubscribe from the CCTBX-COMMIT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/webadmin?SUBED1=CCTBX-COMMIT&A=1