Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #10135. Added python unit tests
Since it appears to be impossible to export shared_ptr<const T> to python, the pointer from the factory has to be const-casted before it's returned.
- Loading branch information
Michael Wedel
committed
Sep 11, 2014
1 parent
1ba49c6
commit bdb8289
Showing
4 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
Code/Mantid/Framework/PythonInterface/test/python/mantid/geometry/PointGroupTest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import unittest | ||
from mantid.geometry import PointGroup, PointGroupFactoryImpl | ||
from mantid.kernel import V3D | ||
|
||
class PointGroupTest(unittest.TestCase): | ||
|
||
def test_creation(self): | ||
self.assertRaises(RuntimeError, PointGroupFactoryImpl.Instance().createPointGroup, "none") | ||
|
||
PointGroupFactoryImpl.Instance().createPointGroup("m-3m") | ||
|
||
def test_getInfo(self): | ||
pg = PointGroupFactoryImpl.Instance().createPointGroup("m-3m") | ||
self.assertEquals(pg.getName(), "m-3m (Cubic)") | ||
self.assertEquals(pg.getSymbol(), "m-3m") | ||
self.assertEquals(pg.crystalSystem(), PointGroup.CrystalSystem.Cubic) | ||
|
||
def test_isEquivalent(self): | ||
hkl1 = V3D(1, 1, 1) | ||
hkl2 = V3D(-1, -1, -1) | ||
hkl3 = V3D(-1, -1, 2) | ||
|
||
pg = PointGroupFactoryImpl.Instance().createPointGroup("m-3m") | ||
self.assertTrue(pg.isEquivalent(hkl1, hkl2)) | ||
self.assertFalse(pg.isEquivalent(hkl1, hkl3)) | ||
|
||
def test_getEquivalents(self): | ||
hkl1 = V3D(1, 0, 0) | ||
hkl2 = V3D(-1, 0, 0) | ||
|
||
pg = PointGroupFactoryImpl.Instance().createPointGroup("-1") | ||
equivalents = pg.getEquivalents(hkl1) | ||
|
||
self.assertTrue(hkl1 in equivalents) | ||
self.assertTrue(hkl2 in equivalents) | ||
|
||
self.assertEquals(len(equivalents), 2) | ||
|
||
def test_getReflectionFamily(self): | ||
hkl1 = V3D(0, 0, 1) | ||
hkl2 = V3D(-1, 0, 0) | ||
|
||
pg = PointGroupFactoryImpl.Instance().createPointGroup("m-3m") | ||
self.assertEquals(pg.getReflectionFamily(hkl1), pg.getReflectionFamily(hkl2)) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
28 changes: 28 additions & 0 deletions
28
Code/Mantid/Framework/PythonInterface/test/python/mantid/geometry/SymmetryOperationTest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import unittest | ||
from mantid.geometry import SymmetryOperation, SymmetryOperationFactoryImpl | ||
from mantid.kernel import V3D | ||
|
||
class SymmetryOperationTest(unittest.TestCase): | ||
|
||
def test_creation(self): | ||
self.assertRaises(RuntimeError, SymmetryOperationFactoryImpl.Instance().createSymOp, "none") | ||
|
||
SymmetryOperationFactoryImpl.Instance().createSymOp("m [001]") | ||
|
||
def test_getInfo(self): | ||
symOp = SymmetryOperationFactoryImpl.Instance().createSymOp("m [001]") | ||
self.assertEquals(symOp.order(), 2) | ||
self.assertEquals(symOp.identifier(), "m [001]") | ||
|
||
def test_apply(self): | ||
symOp = SymmetryOperationFactoryImpl.Instance().createSymOp("m [001]") | ||
|
||
hkl1 = V3D(1, 1, 1) | ||
hkl2 = symOp.apply(hkl1) | ||
|
||
self.assertEquals(hkl2, V3D(1, 1, -1)) | ||
self.assertEquals(symOp.apply(hkl2), hkl1) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |