plasmapy.utils.pytest_helpers.assert_can_handle_nparray(function_to_test, insert_some_nans=[], insert_all_nans=[], kwargs={})

Test for ability to handle numpy array quantities.

  • function_to_test – The function to be tested for ability to handle numpy array quantities. Arguments are automatically given a vector input based on their variable name. Current args that are interpreted as vectors are: ["T", "T_i", "T_e", "temperature"] ["n", "n_i", "n_e", "density"] ["B"] ["V", "Vperp"] ["coulomb_log"] ["characteristic_length"]

  • insert_some_nans (list) – List of argument names in which to insert some np.nan values. These must be arguments that will be tested as vectors as listed above.

  • insert_all_nans (list) – List of argument names to fill entirely with np.nan values.

  • kwargs (dict) – Arguments to pass directly to the function in under test, in the normal kwargs python dictionary format.


~ValueError – If this function cannot interpret a parameter of function_to_test,


>>> from plasmapy.physics.parameters import Alfven_speed, gyrofrequency
>>> assert_can_handle_nparray(Alfven_speed)
>>> assert_can_handle_nparray(gyrofrequency, kwargs={"signed": True})
>>> assert_can_handle_nparray(gyrofrequency, kwargs={"signed": False})