Skip to content

Instantly share code, notes, and snippets.

@canismarko
Last active September 20, 2015 16:55
Show Gist options
  • Save canismarko/b13423db18df04eb4c21 to your computer and use it in GitHub Desktop.
Save canismarko/b13423db18df04eb4c21 to your computer and use it in GitHub Desktop.
pyGSAS Unit Test Fix
diff --git a/GSASIIspc.py b/GSASIIspc.py
index 8c3cda3..a95e101 100644
--- a/GSASIIspc.py
+++ b/GSASIIspc.py
@@ -1062,7 +1062,11 @@ def MoveToUnitCell(xyz):
:param xyz: a list or numpy array of fractional coordinates
:returns: XYZ - numpy array of new coordinates now 0 or greater and less than 1
'''
- XYZ = (xyz+10.)%1.
+ try:
+ XYZ = (xyz+10.)%1.
+ except TypeError:
+ # Fall-back to list comprehension
+ XYZ = np.array([(c+10)%1 for c in xyz])
cell = np.asarray(np.rint(xyz-XYZ),dtype=np.int32)
return XYZ,cell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment