Skip to content

Commit

Permalink
Small modifications ...
Browse files Browse the repository at this point in the history
* Register "Detector" (needed for GUI)
* limit tests to <5s
  • Loading branch information
kif committed Oct 23, 2014
1 parent 06747e5 commit 7ccbfea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
5 changes: 3 additions & 2 deletions pyFAI-src/detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
__contact__ = "[email protected]"
__license__ = "GPLv3+"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "2014-09-18"
__date__ = "23/10/2014"
__status__ = "stable"
__doc__ = """
Module containing the description of all detectors with a factory to instanciate them
Expand Down Expand Up @@ -68,7 +68,8 @@ class DetectorMeta(type):
# to modify attributes of the class *after* they have been
# created
def __init__(cls, name, bases, dct):
if hasattr(cls, 'MAX_SHAPE'):
# "Detector" is a bit peculiar: while abstract it may be needed by the GUI, so adding it to the repository
if hasattr(cls, 'MAX_SHAPE') or name == "Detector":
cls.registry[name.lower()] = cls
if hasattr(cls, "aliases"):
for alias in cls.aliases:
Expand Down
21 changes: 13 additions & 8 deletions test/test_calibrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ def test_factory(self):

self.assert_("LaB6" in ALL_CALIBRANTS, "LaB6 is a calibrant")

#ensure each calibrant instance is uniq
# ensure each calibrant instance is unique
cal1 = ALL_CALIBRANTS["LaB6"]
cal1.wavelength = 1e-10
cal2 = ALL_CALIBRANTS["LaB6"]
self.assert_(cal2.wavelength is None, "calibrant is delivered without wavelength")

# check that it is possible to instanciate all calibrant
for k, v, in ALL_CALIBRANTS.items():
for k, v in ALL_CALIBRANTS.items():
self.assertTrue(isinstance(v, Calibrant))

def test_2th(self):
Expand Down Expand Up @@ -91,11 +91,14 @@ def test_fake(self):
detectors = set(ALL_DETECTORS.itervalues())
for idx, detector in enumerate(detectors):
det = detector()
# skip the big detecteors for now
if det.MAX_SHAPE[0] > 5000 or det.MAX_SHAPE[1] > 5000:
# Skip generic detectors
if "MAX_SHAPE" not in dir(det):
continue
ai = pyFAI.AzimuthalIntegrator(dist=0.1, poni1=0.1, poni2=0.1,
detector=detector())
# skip the big detectors for now
if max(det.MAX_SHAPE) > 2000:
continue
ai = pyFAI.AzimuthalIntegrator(dist=0.01, poni1=0, poni2=0,
detector=det)
calibrant = ALL_CALIBRANTS["LaB6"]
calibrant.set_wavelength(1e-10)
img = calibrant.fake_calibration_image(ai)
Expand All @@ -110,13 +113,15 @@ def test_fake(self):
pp.savefig()
plt.clf()
print det.name, img.min(), img.max()
#self.assert_(img.max() != 0., "Image (%s) contains some data" % (det.name,))
#self.assert_(img.min() == 0., "Image (%s) contains some data" % (det.name,))
self.assert_(img.shape == det.shape, "Image (%s) has the right size" % (det.name,))
self.assert_(img.sum() > 0, "Image (%s) contains some data" % (det.name,))
sys.stderr.write(".")

if with_plot:
pp.savefig()
pp.close()


def test_suite_all_calibrant():
testSuite = unittest.TestSuite()
testSuite.addTest(TestCalibrant("test_factory"))
Expand Down

0 comments on commit 7ccbfea

Please sign in to comment.