Skip to content

Commit

Permalink
Make ion_cyclotron_source dummy i/o test a classmethod.
Browse files Browse the repository at this point in the history
dummy_input and dummy_output are class attributes. The test should thus be a classmethod. Noticed due to linter complaints.

PiperOrigin-RevId: 709072778
  • Loading branch information
jcitrin authored and Torax team committed Dec 23, 2024
1 parent 2af8b67 commit a287db8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions torax/sources/tests/ion_cyclotron_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,23 +182,24 @@ def test_icrh_output_matches_total_power(
total_power,
)

def test_toric_nn_loads_and_predicts_with_dummy_model(self):
@classmethod
def test_toric_nn_loads_and_predicts_with_dummy_model(cls):
"""Test that the ToricNNWrapper loads and predicts consistently."""
# Load the model and verify the prediction are consistent with the output
# of the dummy network.
toric_wrapper = ion_cyclotron_source.ToricNNWrapper(path=_DUMMY_MODEL_PATH)
wrapper_output = toric_wrapper.predict(self.dummy_input)
wrapper_output = toric_wrapper.predict(cls.dummy_input)
np.testing.assert_array_equal(
wrapper_output.power_deposition_He3,
self.dummy_output,
cls.dummy_output,
)
np.testing.assert_array_equal(
wrapper_output.power_deposition_2T,
self.dummy_output,
cls.dummy_output,
)
np.testing.assert_array_equal(
wrapper_output.power_deposition_e,
self.dummy_output,
cls.dummy_output,
)
# pylint: enable=protected-access

Expand Down

0 comments on commit a287db8

Please sign in to comment.