Skip to content
New issue

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

add tests for diffraction methods #53

Closed
sbillinge opened this issue Feb 26, 2024 · 5 comments
Closed

add tests for diffraction methods #53

sbillinge opened this issue Feb 26, 2024 · 5 comments

Comments

@sbillinge
Copy link
Contributor

No description provided.

@sbillinge sbillinge added this to the 3.5.1 release milestone Nov 15, 2024
@sbillinge
Copy link
Contributor Author

sbillinge commented Dec 2, 2024

  • init (and insert_scattering_quantity)

  • set_all_arrays (make private)

  • scale_to

  • on x_type

  • d_to_tth

  • tth_to_d

  • d_to_q

  • q_to_d

@bobleesj
Copy link
Contributor

bobleesj commented Dec 12, 2024

@sbillinge could you remove

eq
 add
 radd
 sub
 rsub
 mul
 rmul
 truediv
 rtruediv

from this issue? These are provided in this issue: #187 Also, if we could make a small distinction b/w the two issues via title, that would be great.

@sbillinge sbillinge changed the title add tests for diffraction objects add tests for diffraction methods Dec 12, 2024
@sbillinge
Copy link
Contributor Author

Done. I also removed the methods that I think we are going to kill for making arrays from ranges. I couldn't come up with a good usecase for them because I think the stay had to be set by the y-array so I couldn't think of a time I would actually use that

@bobleesj
Copy link
Contributor

@sbillinge
Shall I make a PR that removes the methods for making arrays from ranges?

@bobleesj
Copy link
Contributor

@sbillinge We have set_all_arrays (make private) left in this issue:

Does the following close this issue? This following code is implemented in the main branch by PR #196:

def test_all_array_getter():
    actual_do = DiffractionObject(
        xarray=np.array([0.0, 90.0, 180.0]),
        yarray=np.array([1.0, 2.0, 3.0]),
        xtype="tth",
        wavelength=4.0 * np.pi,
    )
    expected_all_arrays = np.array(
        [
            [1.0, 0.0, 0.0, np.float64(np.inf)],
            [2.0, 1.0 / np.sqrt(2), 90.0, np.sqrt(2) * 2 * np.pi],
            [3.0, 1.0, 180.0, 1.0 * 2 * np.pi],
        ]
    )
    assert np.allclose(actual_do.all_arrays, expected_all_arrays)


def test_all_array_setter():
    actual_do = DiffractionObject()

    # Attempt to directly modify the property
    with pytest.raises(
        AttributeError,
        match="Direct modification of attribute 'all_arrays' is not allowed. "
        "Please use 'input_data' to modify 'all_arrays'.",
    ):
        actual_do.all_arrays = np.empty((4, 4))

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

No branches or pull requests

2 participants