[GSAS-II] unit test for GSASIIspc.MoveToUnitCell() function
Mark Wolf
mwolf22 at uic.edu
Sun Sep 20 12:13:38 CDT 2015
Your website encourages user contributions so hopefully I'm sending this
to the right place. I was poking at your unit tests the other day and
one of them failed, namely those for the GSASIIspc.MoveToUnitCell
function when passing a regular python list instead of a numpy array:
Traceback (most recent call last):
File "unit_tests.py", line 35, in <module>
test_GSASIIspc()
File "unit_tests.py", line 25, in test_GSASIIspc
test()
File "/home/mwolf/src/pyGSAS/GSASIIspc.py", line 3079, in test0
assert (MoveToUnitCell([1,2,3])[0] == [0,0,0]).all, msg
File "/home/mwolf/src/pyGSAS/GSASIIspc.py", line 1065, in
MoveToUnitCell
XYZ = (xyz+10.)%1.
TypeError: can only concatenate list (not "float") to list
I fixed it with some exception handling using list comprehension as a
fallback if numpy arithmetic fails. Diff can be found at
https://gist.github.com/m3wolf/b13423db18df04eb4c21
In case this is speed-sensitive, here are the profiling results using
IPython's %timeit magic:
- Original (numpy array): 2.81 us per loop
- New (numpy array): 2.98 us per loop
- New (native list): 2.46 us per loop
If the extra 15us is too much, then maybe you want to consider removing
the unit test that uses a native list (line 3079).
If you want to use my patch, I license it (and any future contributions)
for use under the license included with the pyGSAS (GSAS-II) source code.
Cheers,
Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.aps.anl.gov/pipermail/gsas-ii/attachments/20150920/7c8820d3/attachment.sig>
More information about the GSAS-II
mailing list