From 56e7e83b7beec8dde72cf65bff2441dac0c499c5 Mon Sep 17 00:00:00 2001 From: yucongalicechen Date: Thu, 26 Dec 2024 16:24:07 -0500 Subject: [PATCH 1/6] improve comment --- tests/test_diffraction_objects.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/test_diffraction_objects.py b/tests/test_diffraction_objects.py index 9dee757d..f3091561 100644 --- a/tests/test_diffraction_objects.py +++ b/tests/test_diffraction_objects.py @@ -191,7 +191,7 @@ def test_init_invalid_xtype(): "org_do_args, target_do_args, scale_inputs, expected", [ # Test whether scale_to() scales to the expected values - ( # C1: Same x-array and y-array with 2.1 offset, expect yarray shifted by 2.1 offset + ( # C1: Same x-array and y-array with 2.1 offset, expect y-array to shift up by 2.1 { "xarray": np.array([10, 15, 25, 30, 60, 140]), "yarray": np.array([2, 3, 4, 5, 6, 7]), @@ -212,7 +212,7 @@ def test_init_invalid_xtype(): }, {"xtype": "tth", "yarray": np.array([4.1, 5.1, 6.1, 7.1, 8.1, 9.1])}, ), - ( # C2: Same length x-arrays with exact x-value match + ( # C2: Same x-arrays, x-value matches at tth=60, expect y-array to divide by 10 { "xarray": np.array([10, 15, 25, 30, 60, 140]), "yarray": np.array([10, 20, 25, 30, 60, 100]), @@ -233,7 +233,10 @@ def test_init_invalid_xtype(): }, {"xtype": "tth", "yarray": np.array([1, 2, 2.5, 3, 6, 10])}, ), - ( # C3: Same length x-arrays with approximate x-value match + ( # C3: Different x-arrays with same length, + # x-value has closest match at q=0.12 (y=10) and q=0.14 (y=1) + # for original and target diffraction objects, + # expect y-array to divide by 10 { "xarray": np.array([0.12, 0.24, 0.31, 0.4]), "yarray": np.array([10, 20, 40, 60]), @@ -254,7 +257,10 @@ def test_init_invalid_xtype(): }, {"xtype": "q", "yarray": np.array([1, 2, 4, 6])}, ), - ( # C4: Different x-array lengths with approximate x-value match + ( # C4: Different x-array lengths + # x-value has closest matches at tth=61 (y=50) and tth=62 (y=5), + # for original and target diffraction objects, + # expect y-array to divide by 10 { "xarray": np.array([10, 25, 30.1, 40.2, 61, 120, 140]), "yarray": np.array([10, 20, 30, 40, 50, 60, 100]), @@ -273,7 +279,6 @@ def test_init_invalid_xtype(): "d": None, "offset": 0, }, - # C5: 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])}, ), ], From 0a3081877eaaba0ae1574e01e71f9393cb4a64a5 Mon Sep 17 00:00:00 2001 From: yucongalicechen Date: Thu, 26 Dec 2024 16:26:31 -0500 Subject: [PATCH 2/6] no news added --- news/scaleto-comments.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 news/scaleto-comments.rst diff --git a/news/scaleto-comments.rst b/news/scaleto-comments.rst new file mode 100644 index 00000000..73d0f042 --- /dev/null +++ b/news/scaleto-comments.rst @@ -0,0 +1,23 @@ +**Added:** + +* no news added - make test comments for `test_scale_to` more readable + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From a2a43a091e34b350d697531c221be59ab7a90f32 Mon Sep 17 00:00:00 2001 From: yucongalicechen Date: Thu, 26 Dec 2024 22:10:13 -0500 Subject: [PATCH 3/6] edit test comments --- tests/test_diffraction_objects.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_diffraction_objects.py b/tests/test_diffraction_objects.py index f3091561..441ae2dd 100644 --- a/tests/test_diffraction_objects.py +++ b/tests/test_diffraction_objects.py @@ -212,7 +212,10 @@ def test_init_invalid_xtype(): }, {"xtype": "tth", "yarray": np.array([4.1, 5.1, 6.1, 7.1, 8.1, 9.1])}, ), - ( # C2: Same x-arrays, x-value matches at tth=60, expect y-array to divide by 10 + ( # C2: Same x-arrays + # x-value has exact matches at tth=60 (y=60) and tth=60 (y=6), + # for original and target diffraction objects, + # expect y-array to multiply by 6/60=1/10 { "xarray": np.array([10, 15, 25, 30, 60, 140]), "yarray": np.array([10, 20, 25, 30, 60, 100]), @@ -236,7 +239,7 @@ def test_init_invalid_xtype(): ( # C3: Different x-arrays with same length, # x-value has closest match at q=0.12 (y=10) and q=0.14 (y=1) # for original and target diffraction objects, - # expect y-array to divide by 10 + # expect y-array to multiply by 1/10 { "xarray": np.array([0.12, 0.24, 0.31, 0.4]), "yarray": np.array([10, 20, 40, 60]), @@ -260,7 +263,7 @@ def test_init_invalid_xtype(): ( # C4: Different x-array lengths # x-value has closest matches at tth=61 (y=50) and tth=62 (y=5), # for original and target diffraction objects, - # expect y-array to divide by 10 + # expect y-array to multiply by 5/50=1/10 { "xarray": np.array([10, 25, 30.1, 40.2, 61, 120, 140]), "yarray": np.array([10, 20, 30, 40, 50, 60, 100]), From 5fc00b2a21878140fa0283f691f8527c682cb6cb Mon Sep 17 00:00:00 2001 From: yucongalicechen Date: Thu, 26 Dec 2024 22:11:01 -0500 Subject: [PATCH 4/6] edit test comments --- tests/test_diffraction_objects.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_diffraction_objects.py b/tests/test_diffraction_objects.py index 441ae2dd..e5c24806 100644 --- a/tests/test_diffraction_objects.py +++ b/tests/test_diffraction_objects.py @@ -215,7 +215,7 @@ def test_init_invalid_xtype(): ( # C2: Same x-arrays # x-value has exact matches at tth=60 (y=60) and tth=60 (y=6), # for original and target diffraction objects, - # expect y-array to multiply by 6/60=1/10 + # expect original y-array to multiply by 6/60=1/10 { "xarray": np.array([10, 15, 25, 30, 60, 140]), "yarray": np.array([10, 20, 25, 30, 60, 100]), @@ -239,7 +239,7 @@ def test_init_invalid_xtype(): ( # C3: Different x-arrays with same length, # x-value has closest match at q=0.12 (y=10) and q=0.14 (y=1) # for original and target diffraction objects, - # expect y-array to multiply by 1/10 + # expect original y-array to multiply by 1/10 { "xarray": np.array([0.12, 0.24, 0.31, 0.4]), "yarray": np.array([10, 20, 40, 60]), @@ -263,7 +263,7 @@ def test_init_invalid_xtype(): ( # C4: Different x-array lengths # x-value has closest matches at tth=61 (y=50) and tth=62 (y=5), # for original and target diffraction objects, - # expect y-array to multiply by 5/50=1/10 + # expect original y-array to multiply by 5/50=1/10 { "xarray": np.array([10, 25, 30.1, 40.2, 61, 120, 140]), "yarray": np.array([10, 20, 30, 40, 50, 60, 100]), From d5fd01f4e740f73d6b2ca9b0ffb3bcc1d26f7329 Mon Sep 17 00:00:00 2001 From: yucongalicechen Date: Thu, 26 Dec 2024 22:11:57 -0500 Subject: [PATCH 5/6] edit test comments --- tests/test_diffraction_objects.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_diffraction_objects.py b/tests/test_diffraction_objects.py index e5c24806..861bacbe 100644 --- a/tests/test_diffraction_objects.py +++ b/tests/test_diffraction_objects.py @@ -190,7 +190,7 @@ def test_init_invalid_xtype(): @pytest.mark.parametrize( "org_do_args, target_do_args, scale_inputs, expected", [ - # Test whether scale_to() scales to the expected values + # Test whether the original y-array is scaled as expected ( # C1: Same x-array and y-array with 2.1 offset, expect y-array to shift up by 2.1 { "xarray": np.array([10, 15, 25, 30, 60, 140]), From 07938c9aaff79e628fd4846ac9f053ad62a74781 Mon Sep 17 00:00:00 2001 From: yucongalicechen Date: Fri, 27 Dec 2024 10:01:20 -0500 Subject: [PATCH 6/6] offset test case goes to the end --- tests/test_diffraction_objects.py | 48 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/test_diffraction_objects.py b/tests/test_diffraction_objects.py index 861bacbe..d76f248a 100644 --- a/tests/test_diffraction_objects.py +++ b/tests/test_diffraction_objects.py @@ -191,28 +191,7 @@ def test_init_invalid_xtype(): "org_do_args, target_do_args, scale_inputs, expected", [ # Test whether the original y-array is scaled as expected - ( # C1: Same x-array and y-array with 2.1 offset, expect y-array to shift up by 2.1 - { - "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])}, - ), - ( # C2: Same x-arrays + ( # C1: Same x-arrays # x-value has exact matches at tth=60 (y=60) and tth=60 (y=6), # for original and target diffraction objects, # expect original y-array to multiply by 6/60=1/10 @@ -236,7 +215,7 @@ def test_init_invalid_xtype(): }, {"xtype": "tth", "yarray": np.array([1, 2, 2.5, 3, 6, 10])}, ), - ( # C3: Different x-arrays with same length, + ( # C2: Different x-arrays with same length, # x-value has closest match at q=0.12 (y=10) and q=0.14 (y=1) # for original and target diffraction objects, # expect original y-array to multiply by 1/10 @@ -260,7 +239,7 @@ def test_init_invalid_xtype(): }, {"xtype": "q", "yarray": np.array([1, 2, 4, 6])}, ), - ( # C4: Different x-array lengths + ( # C3: Different x-array lengths # x-value has closest matches at tth=61 (y=50) and tth=62 (y=5), # for original and target diffraction objects, # expect original y-array to multiply by 5/50=1/10 @@ -284,6 +263,27 @@ def test_init_invalid_xtype(): }, {"xtype": "tth", "yarray": np.array([1, 2, 3, 4, 5, 6, 10])}, ), + ( # C4: Same x-array and y-array with 2.1 offset, expect y-array to shift up by 2.1 + { + "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])}, + ), ], ) def test_scale_to(org_do_args, target_do_args, scale_inputs, expected):