From 7ccbfeac355543495d96194f5ee0a3b5d4f316e8 Mon Sep 17 00:00:00 2001 From: Jerome Kieffer Date: Thu, 23 Oct 2014 18:01:22 +0200 Subject: [PATCH] Small modifications ... * Register "Detector" (needed for GUI) * limit tests to <5s --- pyFAI-src/detectors.py | 5 +++-- test/test_calibrant.py | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/pyFAI-src/detectors.py b/pyFAI-src/detectors.py index aac01de0c..513c1df0a 100644 --- a/pyFAI-src/detectors.py +++ b/pyFAI-src/detectors.py @@ -26,7 +26,7 @@ __contact__ = "Jerome.Kieffer@ESRF.eu" __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 @@ -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: diff --git a/test/test_calibrant.py b/test/test_calibrant.py index e1a15abdd..5c1b5d430 100644 --- a/test/test_calibrant.py +++ b/test/test_calibrant.py @@ -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): @@ -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) @@ -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"))