Skip to content

Conversation

@bobleesj
Copy link
Contributor

@bobleesj bobleesj commented Dec 23, 2024

Some battle-tested practices being adopted:

  • Replace UC to C
  • Add higher-level test function comment before starting "C"
  • Use "x, y, z (provided), expect blah blah blah" format for consistency

cc' @yucongalicechen

@codecov
Copy link

codecov bot commented Dec 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.68%. Comparing base (8107874) to head (499a1c3).
Report is 15 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #273   +/-   ##
=======================================
  Coverage   98.68%   98.68%           
=======================================
  Files           8        8           
  Lines         379      379           
=======================================
  Hits          374      374           
  Misses          5        5           
Files with missing lines Coverage Δ
tests/test_diffraction_objects.py 100.00% <100.00%> (ø)

@bobleesj
Copy link
Contributor Author

@sbillinge ready for review.

@yucongalicechen , the part that is remaining is the test_scale_to function.

The existing comments like# C2: Same length x-arrays with exact x-value match, # C3: Same length x-arrays with approximate x-value match were abit hard for me to understand what's being tested. Would you mind improving this test comments for test_scale_to using the above format?

@bobleesj
Copy link
Contributor Author

(Just added a quick fix) pls see my comments right above

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please see my comment. I guess this may not be liked by one of our linters or something, but I think I prefer the more compact formatting. Not a huge deal though. Let's just decide which we like and adopt it in future. It is such a small point we don't need to redo things here. Let's dicsus it. But I will merge this.

(4 * np.pi, np.array([0.25, 0.5, 0.71]), np.array([1, 2, 3]), "q", "q", 0.1, [0]),
(4 * np.pi, np.array([30, 60]), np.array([1, 2]), "tth", "tth", 63, [1]),
# Test get_array_index() returns the expected index given xtype and value
# C1: Target value is in the xarray and xtype is identical, expect exact index match
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not modify this PR again, but I do wonder whether it would be more compact as

        (  # C1: Target value is in the xarray and xtype is identical, expect exact index match
            {
                "wavelength": 4 * np.pi,
                "xarray": np.array([30.005, 60]),
                "yarray": np.array([1, 2]),
                "xtype": "tth",
            },
            {
                "xtype": "tth",
                "value": 30.005,
            },
            [0],
        ),

than the current

    # C1: Target value is in the xarray and xtype is identical, expect exact index match
        (
            {
                "wavelength": 4 * np.pi,
                "xarray": np.array([30.005, 60]),
                "yarray": np.array([1, 2]),
                "xtype": "tth",
            },
            {
                "xtype": "tth",
                "value": 30.005,
            },
            [0],
        ),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-12-25 at 10 07 41 AM

@sbillinge yeah I like that! The automatic indentation also provides a good visual hierarchy!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-12-25 at 10 11 26 AM

For single-lined cases, I think we still want to maintain this format right?

@sbillinge sbillinge merged commit b73d9d8 into diffpy:main Dec 25, 2024
5 checks passed
@bobleesj bobleesj deleted the pytest-reformat branch December 25, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants