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

Seems like assert_configuration() (and presumably also assert_reading()) are broken for numpy array types. I guess they probably were already broken before these changes, but one of the tests in dodal uses assert_configuration and I encountered this as I'm currently in the process of going through dodal and mx-bluesky to test out this PR. #618

Open
coretl opened this issue Oct 22, 2024 · 1 comment

Comments

@coretl
Copy link
Collaborator

coretl commented Oct 22, 2024

          Seems like `assert_configuration()` (and presumably also `assert_reading()`) are broken for numpy array types. I guess they probably were already broken before these changes, but one of the tests in dodal uses assert_configuration and I encountered this as I'm currently in the process of going through dodal and mx-bluesky to test out this PR.

I will keep you posted if I find any other issues.

Originally posted by @rtuck99 in #594 (comment)

I suggest that we move the assert functions into a new ophyd_async.testing package, make pytest a dependency of it, then use pytest.approx on the value

@coretl
Copy link
Collaborator Author

coretl commented Nov 22, 2024

The other alternative is to document that you should use pytest.approx in your test code when testing for arrays:

async def test_assert_reading_array(mock_signal_array: SignalRW):
    set_mock_value(mock_signal_array, [1, 2, 4.5])
    dummy_reading = {
        "mock_signal": Reading(
            {"alarm_severity": 0, "timestamp": ANY, "value": pytest.approx([1, 2, 4.5])}
        )
    }
    await assert_reading(mock_signal_array, dummy_reading)

@rtuck99 do you prefer moving ophyd_async.core.asset_* to ophyd_async.testing.assert_* and adding the pytest approx there, or writing docs that tell people to put pytest.approx in their code?

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

1 participant