Folks,
I expressed some surprise at this & friends however -
- this is necessary to make the bootstrap process Python 3 compatible - the timetable for which said this should have been finished 9 months ago (https://github.com/cctbx/cctbx_project/wiki/Python-3-roadmap)
- these changes were discussed and agreed (https://github.com/cctbx/cctbx_project/pull/199)
The only part of this which was not approved was reverted before the request was merged
(I felt that this annotation was helpful as the changes themselves go back ~6 months so people have possibly forgotten the context)
Best wishes Graeme
Begin forwarded message:
From: CCTBX commit mailto:[email protected]>
Subject: [git/cctbx] master: Python 3 syntax changes (790d9e315)
Date: 21 September 2018 at 14:25:29 BST
To: mailto:[email protected]>
Reply-To: mailto:[email protected]>
Repository : ssh://ws133.diamond.ac.uk/cctbx
On branch : master
________________________________
commit 790d9e315a2a6ae5a875ba86b461ed570c77280d
Author: Markus Gerstel mailto:[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
--
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom