|
4 | 4 | """ |
5 | 5 |
|
6 | 6 |
|
7 | | -import os |
8 | 7 | import unittest |
9 | 8 | import cPickle |
| 9 | +import numpy |
10 | 10 |
|
11 | 11 | from diffpy.srreal.scatteringfactortable import ScatteringFactorTable |
12 | 12 |
|
@@ -132,6 +132,23 @@ def test_derived_clone(self): |
132 | 132 | self.assertEqual(set(['Xy']), lsft2.getCustomSymbols()) |
133 | 133 | return |
134 | 134 |
|
| 135 | + def test_lookup(self): |
| 136 | + """Check ScatteringFactorTable.lookup handling of array arguments. |
| 137 | + """ |
| 138 | + qa = numpy.linspace(0, 50) |
| 139 | + sftx = self.sftx |
| 140 | + fmn0 = numpy.array([sftx.lookup('Mn', x) for x in qa]) |
| 141 | + fmn1 = sftx.lookup('Mn', qa) |
| 142 | + self.assertTrue(numpy.array_equal(fmn0, fmn1)) |
| 143 | + self.assertTrue(numpy.array_equal( |
| 144 | + fmn0.reshape(5, 10), sftx.lookup('Mn', qa.reshape(5, 10)))) |
| 145 | + self.assertTrue(numpy.array_equal( |
| 146 | + fmn0.reshape(5, 2, 5), sftx.lookup('Mn', qa.reshape(5, 2, 5)))) |
| 147 | + self.assertTrue(numpy.array_equal(fmn0, sftx.lookup('Mn', list(qa)))) |
| 148 | + self.assertRaises(TypeError, sftx.lookup, 'Na', 'asdf') |
| 149 | + self.assertRaises(TypeError, sftx.lookup, 'Na', {}) |
| 150 | + return |
| 151 | + |
135 | 152 | # End of class TestScatteringFactorTable |
136 | 153 |
|
137 | 154 | if __name__ == '__main__': |
|
0 commit comments