Skip to content

Commit d9cab02

Browse files
committed
TST: check failures from np.broadcast side effects
Because of numpy.broadcast `structure.xyz = 0` results in linked `xyz` coordinates at each atom site.
1 parent 708a754 commit d9cab02

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/diffpy/structure/tests/teststructure.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ def test_element(self):
464464
return
465465

466466

467+
@unittest.expectedFailure
467468
def test_xyz(self):
468469
"""check Structure.xyz
469470
"""
@@ -473,6 +474,10 @@ def test_xyz(self):
473474
stru.xyz += 0.1
474475
self.assertTrue(numpy.array_equal([0.1, 0.1, 0.1], stru[0].xyz))
475476
self.assertTrue(numpy.array_equal([1.1, 1.1, 1.1], stru[1].xyz))
477+
stru.xyz = 0
478+
stru[1].xyz[:] = 1
479+
self.assertTrue(numpy.array_equal([0, 0, 0], stru[0].xyz))
480+
self.assertTrue(numpy.array_equal([1, 1, 1], stru[0].xyz))
476481
return
477482

478483

@@ -527,13 +532,16 @@ def test_label(self):
527532
return
528533

529534

535+
@unittest.expectedFailure
530536
def test_occupancy(self):
531537
"""check Structure.occupancy
532538
"""
533539
cdse = self.cdse
534540
self.assertTrue(numpy.array_equal(numpy.ones(4), cdse.occupancy))
535541
self.stru.occupancy *= 0.5
536542
self.assertEqual(1.0, sum([a.occupancy for a in self.stru]))
543+
cdse.occupancy = 1
544+
self.assertTrue(all(isinstance(a.occupancy, int) for a in cdse))
537545
return
538546

539547

@@ -588,6 +596,9 @@ def test_U(self):
588596
stru.U = 0
589597
self.assertTrue(numpy.all(stru.anisotropy))
590598
self.assertFalse(numpy.any(stru.U != 0.0))
599+
stru[1].U[:] = 1
600+
self.assertTrue(numpy.all(stru[0].U == 0.0))
601+
self.assertTrue(numpy.all(stru[1].U == 1.0))
591602
return
592603

593604

0 commit comments

Comments
 (0)