Skip to content

Commit a0b9f7f

Browse files
committed
TST: verify handling of large-stride np.arrays
1 parent 5e74c8a commit a0b9f7f

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/diffpy/srreal/tests/testpdfbaseline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ def test___call__(self):
5353
self.assertEqual(-7.0, self.linear(3.5))
5454
self.assertEqual(-2.0, self.linear._getDoubleAttr('slope'))
5555
x = numpy.arange(0, 10.001, 0.1)
56+
xb = numpy.array([(0.0, xi) for xi in x])[:, 1]
57+
self.assertTrue(xb.strides > x.strides)
5658
self.assertTrue(numpy.array_equal(-2 * x, self.linear(x)))
59+
self.assertTrue(numpy.array_equal(-2 * x, self.linear(xb)))
5760
return
5861

5962

src/diffpy/srreal/tests/testpdfenvelope.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ def test___call__(self):
4343
"""check PDFEnvelope.__call__()
4444
"""
4545
x = numpy.arange(0, 9.1, 0.3)
46+
xb = numpy.array([(0.0, xi) for xi in x])[:, 1]
47+
self.assertTrue(xb.strides > x.strides)
4648
# this is a virtual method in the base class
4749
self.assertRaises(RuntimeError, PDFEnvelope().__call__, 37)
4850
self.assertEqual(0.0, self.fstepcut(10))
4951
self.assertEqual(1.0, self.fstepcut(3.45))
5052
ycheck = numpy.array(17 * [1] + 14 * [0])
5153
self.assertTrue(numpy.array_equal(ycheck, self.fstepcut(x)))
54+
self.assertTrue(numpy.array_equal(ycheck, self.fstepcut(xb)))
5255
self.assertEqual(1.0, self.fscale(3.45))
5356
self.assertEqual(1.0, self.fscale(345))
5457
self.assertTrue(numpy.array_equal(numpy.ones_like(x), self.fscale(x)))

src/diffpy/srreal/tests/testscatteringfactortable.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,12 @@ def test_lookup(self):
167167
"""Check ScatteringFactorTable.lookup handling of array arguments.
168168
"""
169169
qa = numpy.linspace(0, 50)
170+
qb = numpy.array([(x, 0.0) for x in qa])[:,0]
171+
self.assertTrue(qb.strides > qa.strides)
170172
sftx = self.sftx
171173
fmn0 = numpy.array([sftx.lookup('Mn', x) for x in qa])
172-
fmn1 = sftx.lookup('Mn', qa)
173-
self.assertTrue(numpy.array_equal(fmn0, fmn1))
174+
self.assertTrue(numpy.array_equal(fmn0, sftx.lookup('Mn', qa)))
175+
self.assertTrue(numpy.array_equal(fmn0, sftx.lookup('Mn', qb)))
174176
self.assertTrue(numpy.array_equal(
175177
fmn0.reshape(5, 10), sftx.lookup('Mn', qa.reshape(5, 10))))
176178
self.assertTrue(numpy.array_equal(

0 commit comments

Comments
 (0)