We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Originally posted by @sbillinge in #255 (comment)
The majority of code has been listing "cases", but we can further scale our tests by grouping them:
From:
@pytest.mark.parametrize( "org_do_args, target_do_args, scale_inputs, expected", [ # Case 1: same x-array and y-array, check offset ( { "xarray": np.array([10, 15, 25, 30, 60, 140]), "yarray": np.array([2, 3, 4, 5, 6, 7]), "xtype": "tth", "wavelength": 2 * np.pi, }, { "xarray": np.array([10, 15, 25, 30, 60, 140]), "yarray": np.array([2, 3, 4, 5, 6, 7]), "xtype": "tth", "wavelength": 2 * np.pi, }, { "q": None, "tth": 60, "d": None, "offset": 2.1, }, {"xtype": "tth", "yarray": np.array([4.1, 5.1, 6.1, 7.1, 8.1, 9.1])}, ), # Case 2: same length x-arrays with exact x-value match ( { "xarray": np.array([10, 15, 25, 30, 60, 140]), "yarray": np.array([10, 20, 25, 30, 60, 100]), "xtype": "tth", "wavelength": 2 * np.pi, }, { "xarray": np.array([10, 20, 25, 30, 60, 140]), "yarray": np.array([2, 3, 4, 5, 6, 7]), "xtype": "tth", "wavelength": 2 * np.pi, }, { "q": None, "tth": 60, "d": None, "offset": 0, }, {"xtype": "tth", "yarray": np.array([1, 2, 2.5, 3, 6, 10])}, ), # Case 3: same length x-arrays with approximate x-value match ( { "xarray": np.array([0.12, 0.24, 0.31, 0.4]), "yarray": np.array([10, 20, 40, 60]), "xtype": "q", "wavelength": 2 * np.pi, }, { "xarray": np.array([0.14, 0.24, 0.31, 0.4]), "yarray": np.array([1, 3, 4, 5]), "xtype": "q", "wavelength": 2 * np.pi, }, { "q": 0.1, "tth": None, "d": None, "offset": 0, }, {"xtype": "q", "yarray": np.array([1, 2, 4, 6])}, ), # Case 4: different x-array lengths with approximate x-value match ( { "xarray": np.array([10, 25, 30.1, 40.2, 61, 120, 140]), "yarray": np.array([10, 20, 30, 40, 50, 60, 100]), "xtype": "tth", "wavelength": 2 * np.pi, }, { "xarray": np.array([20, 25.5, 32, 45, 50, 62, 100, 125, 140]), "yarray": np.array([1.1, 2, 3, 3.5, 4, 5, 10, 12, 13]), "xtype": "tth", "wavelength": 2 * np.pi, }, { "q": None, "tth": 60, "d": None, "offset": 0, }, # Case 5 Scaling factor is calculated at index = 4 (tth=61) for self and index = 5 for target (tth=62) {"xtype": "tth", "yarray": np.array([1, 2, 3, 4, 5, 6, 10])}, ), ], ) ...
To:
@pytest.mark.parametrize( "wavelength, q, expected_tth", [ # Case 1: Allow empty arrays for q # 1. Empty q values, no wavelength, return empty arrays (None, np.empty((0)), np.empty((0))), # 2. Empty q values, wavelength specified, return empty arrays (4 * np.pi, np.empty((0)), np.empty(0)), # Case 2: Allow wavelength to be missing. # Valid q values, no wavelength, return index array ( None, np.array([0, 0.2, 0.4, 0.6, 0.8, 1]), np.array([0, 1, 2, 3, 4, 5]), ), # Case 3: Correctly specified q and wavelength # Expected tth values are 2*arcsin(q) in degrees (4 * np.pi, np.array([0, 1 / np.sqrt(2), 1.0]), np.array([0, 90.0, 180.0])), ], )
For all test functions diffpy.utils, review each test function and group test cases.
The text was updated successfully, but these errors were encountered:
I think we could close this issue once #273 for test_diffraction_objects.py and #275 for test_transform.py are merged?
@sbillinge
Sorry, something went wrong.
bobleesj
No branches or pull requests
Problem
Originally posted by @sbillinge in #255 (comment)
The majority of code has been listing "cases", but we can further scale our tests by grouping them:
From:
To:
Proposed solution
For all test functions diffpy.utils, review each test function and group test cases.
The text was updated successfully, but these errors were encountered: