Skip to content

31 pytest warnings - wavelength zero, infinite array, divide by zero #223

Closed
@bobleesj

Description

@bobleesj

Problem

Warnings are produced:

  1. Wavelength being 0
UserWarning: INFO: no wavelength has been specified. You can continue to use the DiffractionObject but some of its powerful features will not be available. To specify a wavelength, set diffraction_object.wavelength = [number], where diffraction_object is the variable name of you Diffraction Object, and number is the wavelength in angstroms.
    warnings.warn(wavelength_warning_emsg, UserWarning)
  1. Divide by zero
  /Users/macbook/Downloads/dev/diffpy.utils/src/diffpy/utils/transforms.py:141: RuntimeWarning: divide by zero encountered in divide
  1. Infinite value in array
  /Users/macbook/Downloads/dev/diffpy.utils/src/diffpy/utils/transforms.py:174: UserWarning: INFO: The largest output value in the array is infinite. This is allowed, but it will not be plotted.

Raw data:

=================================================================== warnings summary ===================================================================
tests/test_diffraction_objects.py::test_diffraction_objects_equality[inputs16-inputs26-False]
tests/test_transforms.py::test_q_to_tth[inputs0-expected0]
tests/test_transforms.py::test_q_to_tth[inputs2-expected2]
tests/test_transforms.py::test_d_to_tth[inputs0-expected0]
tests/test_transforms.py::test_d_to_tth[inputs2-expected2]
  /Users/macbook/Downloads/dev/diffpy.utils/src/diffpy/utils/transforms.py:26: UserWarning: INFO: no wavelength has been specified. You can continue to use the DiffractionObject but some of its powerful features will not be available. To specify a wavelength, set diffraction_object.wavelength = [number], where diffraction_object is the variable name of you Diffraction Object, and number is the wavelength in angstroms.
    warnings.warn(wavelength_warning_emsg, UserWarning)

tests/test_diffraction_objects.py::test_dump
tests/test_transforms.py::test_q_to_d[inputs1-expected1]
  /Users/macbook/Downloads/dev/diffpy.utils/src/diffpy/utils/transforms.py:141: RuntimeWarning: divide by zero encountered in divide
    return 2.0 * np.pi / copy(q)

tests/test_diffraction_objects.py::test_constructor[inputs2-expected2]
tests/test_diffraction_objects.py::test_all_array_getter
tests/test_diffraction_objects.py::test_copy_object
tests/test_transforms.py::test_tth_to_d[inputs3-expected3]
  /Users/macbook/Downloads/dev/diffpy.utils/src/diffpy/utils/transforms.py:174: UserWarning: INFO: The largest output value in the array is infinite. This is allowed, but it will not be plotted.
    warnings.warn(inf_output_wmsg)

tests/test_diffraction_objects.py::test_constructor[inputs2-expected2]
tests/test_diffraction_objects.py::test_all_array_getter
tests/test_diffraction_objects.py::test_copy_object
tests/test_transforms.py::test_tth_to_d[inputs3-expected3]
  /Users/macbook/Downloads/dev/diffpy.utils/src/diffpy/utils/transforms.py:175: RuntimeWarning: divide by zero encountered in divide
    return 2.0 * np.pi / copy(q)

tests/test_diffraction_objects.py::test_input_xtype_getter
tests/test_diffraction_objects.py::test_input_xtype_setter
tests/test_transforms.py::test_tth_to_q[inputs0-expected0]
tests/test_transforms.py::test_tth_to_q[inputs2-expected2]
tests/test_transforms.py::test_tth_to_d[inputs0-expected0]
tests/test_transforms.py::test_tth_to_d[inputs2-expected2]
  /Users/macbook/Downloads/dev/diffpy.utils/src/diffpy/utils/transforms.py:118: UserWarning: INFO: no wavelength has been specified. You can continue to use the DiffractionObject but some of its powerful features will not be available. To specify a wavelength, set diffraction_object.wavelength = [number], where diffraction_object is the variable name of you Diffraction Object, and number is the wavelength in angstroms.
    warnings.warn(wavelength_warning_emsg, UserWarning)

tests/test_diffraction_objects.py::test_input_xtype_getter
tests/test_diffraction_objects.py::test_input_xtype_setter
tests/test_transforms.py::test_tth_to_d[inputs0-expected0]
tests/test_transforms.py::test_tth_to_d[inputs2-expected2]
  /Users/macbook/Downloads/dev/diffpy.utils/src/diffpy/utils/transforms.py:169: UserWarning: INFO: no wavelength has been specified. You can continue to use the DiffractionObject but some of its powerful features will not be available. To specify a wavelength, set diffraction_object.wavelength = [number], where diffraction_object is the variable name of you Diffraction Object, and number is the wavelength in angstroms.
    warnings.warn(wavelength_warning_emsg, UserWarning)

tests/test_transforms.py::test_d_to_q[inputs1-expected1]
tests/test_transforms.py::test_d_to_tth[inputs2-expected2]
tests/test_transforms.py::test_d_to_tth_bad[inputs1-expected1]
  /Users/macbook/Downloads/dev/diffpy.utils/src/diffpy/utils/transforms.py:194: UserWarning: INFO: The largest output value in the array is infinite. This is allowed, but it will not be plotted.
    warnings.warn(inf_output_wmsg)

tests/test_transforms.py::test_d_to_q[inputs1-expected1]
tests/test_transforms.py::test_d_to_tth[inputs2-expected2]
tests/test_transforms.py::test_d_to_tth_bad[inputs1-expected1]
  /Users/macbook/Downloads/dev/diffpy.utils/src/diffpy/utils/transforms.py:195: RuntimeWarning: divide by zero encountered in divide
    return 2.0 * np.pi / copy(d)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================================================== 88 passed, 31 warnings in 0.34s =================================================

Proposed solution

Some warnings may need to be suppressed. May need to resort to human judgement and behavior we want to capture.

@sbillinge we want to resolve these before 3.6.0 right?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions