pyg4ometry.compare._Compare¶
Classes¶
Set of options of which tests to perform and potentially with what tolerance. |
|
A test result can be either pass, fail or not conducted. |
|
Holder for a test result. Roughly a dict[testname] = list(TestResultNamed) |
Functions¶
|
|
|
|
|
Compare two LogicalVolume instances with a set of tests. |
|
lvName is an optional parent object name to help in print out details decode where the placement is. |
|
|
|
|
|
|
|
|
|
Compare two DivisionVolume instances with a set of tests. |
|
Compare two ParameterisedVolume instances with a set of tests. |
|
Compare two materials with a set of tests. |
|
|
|
Compare any two solids with a set of tests. |
|
|
|
|
|
|
|
|
|
|
|
|
|
Module Contents¶
- class pyg4ometry.compare._Compare.Tests(*testsByNameToTurnOn)¶
Set of options of which tests to perform and potentially with what tolerance.
- Parameters:
testsByNameToTurnOn (str, list of) – optional strings of tests to turn on. If any, all will be turned off first.
>>> t = Tests() >>> t = Tests("nDaughters") # only nDaughters will be tested >>> t = Tests("nDaughters", "shapeArea") # only nDaughters and shapeArea will be tested
- _testNames = ['names', 'namesIgnorePointer', 'nDaughters', 'solidExact', 'solidExtent', 'shapeExtent',...¶
- names = True¶
- namesIgnorePointer = True¶
- nDaughters = True¶
- solidExact = True¶
- shapeExtent = True¶
- shapeVolume = True¶
- shapeArea = True¶
- placement = True¶
- scale = True¶
- copyNumber = True¶
- materials = True¶
- materialClassType = True¶
- materialCompositionType = True¶
- testDaughtersByName = True¶
- toleranceSolidParameterFraction = 0.001¶
- toleranceSolidExtentFraction = 1e-06¶
- toleranceVolumeFraction = 0.01¶
- toleranceAreaFraction = 0.01¶
- toleranceTranslationFraction = 1e-06¶
- toleranceScaleFraction = 0.001¶
- toleranceRotationFraction = 1e-06¶
- toleranceMaterialDensityFraction = 0.0001¶
- toleranceMaterialMassFraction = 0.0001¶
- setAllFalse()¶
Utility to turn off all tests at once. Then can just turn on the one we want.
- setFalse(testName)¶
Safely set a test by name to False.
- __len__()¶
- classmethod printAllTestNames()¶
Print all tests names - the exact strings that can be used to turn them off or on.
- __repr__()¶
- class pyg4ometry.compare._Compare.TestResult¶
Bases:
enum.EnumA test result can be either pass, fail or not conducted.
Use 0,1 so we can also implicitly construct this with a Boolean.
Use the bitwise or operator | and not the keyword or. This bitwise or operator returns Failed if either have failed. Only returns NotTested if both are not tested. Cannot use bitwise |= as we cannot update an Enum internally.
Use TestResult.All() for a list of all possible results - useful as an argument for printing.
- Failed = 0¶
- Passed = 1¶
- NotTested = 2¶
- __or__(other)¶
- __ior__(other)¶
- static All()¶
Utility function to get a list of all test types in one.
- class pyg4ometry.compare._Compare.TestResultNamed(nameIn, testResultIn=TestResult.Failed, detailsIn='')¶
- testResult¶
- name¶
- details¶
- __str__()¶
- class pyg4ometry.compare._Compare.ComparisonResult¶
Holder for a test result. Roughly a dict[testname] = list(TestResultNamed)
Use + and += to append to this object. Uses a default dictionary so no need to initialise any key names. Should always append a list even if only 1 item.
>>> cr = ComparisonResult() >>> cr['nDaughtersTest'] += [TestResultNamed('volume_1', TestResult.Failed, 'different number')] >>> cr.print()
print() can take a list of test result outcomes to print. e.g. TestResult.All()
- test¶
- result¶
- __getitem__(key)¶
- __setitem__(key, value)¶
- __add__(other)¶
- __iadd__(other)¶
- __len__()¶
- testNames()¶
- print(testName=None, testResultsToPrint=[TestResult.Failed, TestResult.NotTested], allTests=False)¶
- Parameters:
testName (str) – (optional) name of specific single test to print - see testNames()
testResultsToPrint (list(TestResult)) – (optional) list of result outcomes to print
allTests (bool) – (optional) print all tests irrespective of the result
Print failed tests and ones relevant but not implemented yet by default. Control level of print out with optional argument of list of test outcomes to print, or allTests=True.
>>> cr.print() >>> cr.print('solidName') >>> cr.print(testResultsToPrint=TestResult.All()) >>> cr.print(allTests=True)
- pyg4ometry.compare._Compare.gdmlFiles(referenceFile, otherFile, tests=Tests(), includeAllTestResults=False)¶
- Parameters:
referenceFile (str.) – GDML file to use as a reference.
otherFile (str.) – GDML file to compare.
tests (pyg4ometry.compare._Compare.Tests.) – Tests instance to use.
includeAllTestResults (bool.) – document all tests attempted in result.
- pyg4ometry.compare._Compare.geometry(referenceLV, otherLV, tests=Tests(), includeAllTestResults=False)¶
- Parameters:
referenceLV (LogicalVolume) – LogicalVolume instance to compare against.
otherLV (LogicalVolume) – LogicalVolume instance to compare with referenceLV.
tests (pyg4ometry.compare._Compare.Tests.) – Tests instance to use.
includeAllTestResults (bool.) – document all tests attempted in result.
- pyg4ometry.compare._Compare.logicalVolumes(referenceLV, otherLV, tests, recursive=False, includeAllTestResults=False, testsAlreadyDone=[])¶
Compare two LogicalVolume instances with a set of tests.
testsAlreadyDone should be purposively given as an empty list if using more than once. This is an artefact of the only way we can nicely pass by reference a set of tests while we use these functions recursively. However, this is defined on import and must be updated if reused.
- pyg4ometry.compare._Compare.physicalVolumes(referencePV, otherPV, tests, recursive=False, lvName='', includeAllTestResults=False, testsAlreadyDone=[])¶
lvName is an optional parent object name to help in print out details decode where the placement is.
- pyg4ometry.compare._Compare.assemblyVolumes(referenceAV, otherAV, tests, recursive=False, includeAllTestResults=False, testsAlreadyDone=[])¶
- pyg4ometry.compare._Compare._checkPVLikeDaughters(referencePVLikeObject, otherPVLikeObject, tests, parentName, testName, result, recursive=True, includeAllTestResults=True, testsAlreadyDone=[])¶
- pyg4ometry.compare._Compare._testDaughterNameSets(referenceDaughterNameSet, otherDaughterNameSet, result, testName, includeAllTestResults)¶
- pyg4ometry.compare._Compare.replicaVolumes(referenceRV, otherRV, tests, recursive=True, includeAllTestResults=False, testsAlreadyDone=[])¶
- pyg4ometry.compare._Compare.divisionVolumes(referenceRV, otherRV, tests, includeAllTestResults=False, testsAlreadyDone=[])¶
Compare two DivisionVolume instances with a set of tests.
- pyg4ometry.compare._Compare.parameterisedVolumes(referenceRV, otherRV, tests, includeAllTestResults=False, testsAlreadyDone=[])¶
Compare two ParameterisedVolume instances with a set of tests.
- pyg4ometry.compare._Compare.materials(referenceMaterial, otherMaterial, tests, lvName='', includeAllTestResults=False, testsAlreadyDone=[])¶
Compare two materials with a set of tests.
This tests assumes both referenceMaterial and otherMaterial are derived from the type pyg4ometry.geant4._Material.Material.
Compares, name, classname, density, n components
- pyg4ometry.compare._Compare._elements(referenceElement, otherElement, tests, lvName='', includeAllTestResults=False)¶
- pyg4ometry.compare._Compare.solids(referenceSolid, otherSolid, tests, lvName='', includeAllTestResults=False)¶
Compare any two solids with a set of tests.
- pyg4ometry.compare._Compare._names(testName, str1, str2, parentName='', includeAllTestResults=False)¶
- pyg4ometry.compare._Compare._namesIgnorePointer(testName, str1, str2, parentName='', includeAllTestResults=False)¶
- pyg4ometry.compare._Compare._vector(vectortype, r1, r2, tests, parentName='', includeAllTestResults=False)¶
- pyg4ometry.compare._Compare._copyNumber(pvname, c1, c2, tests, includeAllTestResults=False)¶
- pyg4ometry.compare._Compare._getBoundingBox(obj)¶
- pyg4ometry.compare._Compare._getRawMesh(obj)¶
- pyg4ometry.compare._Compare._meshes(lvname, referenceMesh, otherMesh, tests, includeAllTestResults=False)¶