-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
23 additions
and
27 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ | |
__contact__ = "[email protected]" | ||
__license__ = "MIT" | ||
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" | ||
__date__ = "15/04/2024" | ||
__date__ = "20/12/2024" | ||
|
||
import os | ||
import json | ||
|
@@ -50,31 +50,31 @@ def test_poni(self): | |
config = {"poni": utilstest.UtilsTest.getimage("Pilatus1M.poni"), | ||
"wavelength": 50} | ||
config = integration_config.normalize(config) | ||
self.assertNotIn("poni", config) | ||
# self.assertNotIn("poni", config) | ||
# From PONI file | ||
self.assertEqual(config["dist"], 1.58323111834) | ||
self.assertEqual(config["poni"]["dist"], 1.58323111834) | ||
# From dict | ||
self.assertEqual(config["wavelength"], 50) | ||
self.assertEqual(config["poni"]["wavelength"], 50) | ||
|
||
def test_single_flatdark(self): | ||
config = {"dark_current": "abc", | ||
"flat_field": "abd"} | ||
config = integration_config.normalize(config) | ||
self.assertEqual(config["dark_current"], "abc") | ||
self.assertEqual(config["flat_field"], "abd") | ||
self.assertEqual(config["dark_current_image"], "abc") | ||
self.assertEqual(config["flat_field_image"], "abd") | ||
|
||
def test_coma_flatdark(self): | ||
config = {"dark_current": "a,b,c", | ||
"flat_field": "a,b,d"} | ||
config = integration_config.normalize(config) | ||
self.assertEqual(config["dark_current"], ["a", "b", "c"]) | ||
self.assertEqual(config["flat_field"], ["a", "b", "d"]) | ||
self.assertEqual(config["dark_current_image"], ["a", "b", "c"]) | ||
self.assertEqual(config["flat_field_image"], ["a", "b", "d"]) | ||
|
||
def test_pilatus(self): | ||
config = {"detector": "pilatus2m"} | ||
config = integration_config.normalize(config) | ||
self.assertEqual(config["detector"], "Pilatus2M") | ||
self.assertIsInstance(config["detector_config"], dict) | ||
self.assertEqual(config["poni"]["detector"], "Pilatus2M") | ||
self.assertIsInstance(config["poni"]["detector_config"], dict) | ||
|
||
def test_detector(self): | ||
config = {"detector": "detector", | ||
|
@@ -83,18 +83,18 @@ def test_detector(self): | |
config = integration_config.normalize(config) | ||
self.assertNotIn("pixel1", config) | ||
self.assertNotIn("pixel2", config) | ||
self.assertEqual(config["detector"], "Detector") | ||
self.assertEqual(config["detector_config"]["pixel1"], 1.0) | ||
self.assertEqual(config["detector_config"]["pixel2"], 1.0) | ||
self.assertEqual(config["poni"]["detector"], "Detector") | ||
self.assertEqual(config["poni"]["detector_config"]["pixel1"], 1.0) | ||
self.assertEqual(config["poni"]["detector_config"]["pixel2"], 1.0) | ||
|
||
def test_frelon(self): | ||
spline_file = utilstest.UtilsTest.getimage("frelon.spline") | ||
config = {"detector": "frelon", | ||
"splineFile": spline_file} | ||
config = integration_config.normalize(config) | ||
self.assertNotIn("splineFile", config) | ||
self.assertEqual(config["detector"], "FReLoN") | ||
self.assertEqual(config["detector_config"]["splineFile"], spline_file) | ||
self.assertEqual(config["poni"]["detector"], "FReLoN") | ||
self.assertEqual(config["poni"]["detector_config"]["splineFile"], spline_file) | ||
|
||
def test_opencl(self): | ||
config = {"do_OpenCL": True} | ||
|
@@ -151,6 +151,14 @@ def test_2132(self): | |
expected = expected_with_gpu if ocl else expected_without_gpu | ||
self.assertEqual(parsed_config["ai"]["method"], expected, "method match with -g option") | ||
|
||
def test_dataclass(self): | ||
test_files = "0.14_verson0.json id11_v0.json id13_v0.json id15_1_v0.json id15_v0.json id16_v3.json id21_v0.json version0.json version3.json version4.json" | ||
for fn in test_files.split(): | ||
js = utilstest.UtilsTest.getimage(fn) | ||
with utilstest.TestLogging(logger='pyFAI.io.integrarion_config', warning=0): | ||
# with self.assertLogs('pyFAI.io.integrarion_config', level='WARNING') as cm: | ||
wc = integration_config.WorkerConfig.load(js) | ||
self.assertEqual(wc, integration_config.WorkerConfig.from_dict(wc.as_dict()), f"Idempotent {fn}") | ||
|
||
|
||
def suite(): | ||
|
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