Skip to content

Commit 889fac3

Browse files
committed
Capture the warning behavior
2 parents 6e2ed38 + 20751c8 commit 889fac3

File tree

5 files changed

+42
-34
lines changed

5 files changed

+42
-34
lines changed

.github/workflows/matrix-and-codecov-on-merge-to-main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ jobs:
1717
project: diffpy.utils
1818
c_extension: false
1919
headless: false
20-
secrets: inherit
20+
secrets:
21+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

CHANGELOG.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ Release Notes
44

55
.. current developments
66
7+
3.4.2
8+
=====
9+
10+
**Added:**
11+
12+
* link docs in the README
13+
14+
**Changed:**
15+
16+
* removed need to install requirements separately when pip installing.
17+
18+
**Fixed:**
19+
20+
* Updated package structure to new group standard
21+
22+
23+
724

825
3.4.0
926
=====

README.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ If you use diffpy.utils in a scientific publication, we would like you to cite t
5353

5454
diffpy.utils Package, https://github.com/diffpy/diffpy.utils
5555

56+
Documentation
57+
-------------
58+
59+
Documentation may be found at, https://diffpy.github.io/diffpy.utils
60+
5661
Installation
5762
------------
5863

@@ -76,11 +81,7 @@ Then, to fully install ``diffpy.utils`` in our active environment, run ::
7681

7782
Another option is to use ``pip`` to download and install the latest release from
7883
`Python Package Index <https://pypi.python.org>`_.
79-
To install using ``pip`` into your ``diffpy.utils_env`` environment, we will also have to install dependencies ::
80-
81-
pip install -r https://raw.githubusercontent.com/diffpy/diffpy.utils/main/requirements/run.txt
82-
83-
and then install the package ::
84+
To install using ``pip`` into your ``diffpy.utils_env`` environment type ::
8485

8586
pip install diffpy.utils
8687

news/cookie.rst

Lines changed: 0 additions & 23 deletions
This file was deleted.

tests/test_diffraction_objects.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from pathlib import Path
23

34
import numpy as np
@@ -236,21 +237,32 @@ def test_dump(tmp_path, mocker):
236237
directory = Path(tmp_path)
237238
file = directory / "testfile"
238239
test = Diffraction_object()
239-
test.wavelength = 1.01
240+
test.wavelength = 1.54
240241
test.name = "test"
241242
test.scat_quantity = "x-ray"
242-
test.insert_scattering_quantity(
243-
x, y, "q", metadata={"thing1": 1, "thing2": "thing2", "package_info": {"package2": "3.4.5"}}
244-
)
245243

244+
# Capture warnings due to invalid arcsin input value due to the wavelenght being 1.54
245+
with warnings.catch_warnings(record=True) as captured_warnings:
246+
warnings.simplefilter("always")
247+
test.insert_scattering_quantity(
248+
x, y, "q", metadata={"thing1": 1, "thing2": "thing2", "package_info": {"package2": "3.4.5"}}
249+
)
250+
251+
# Assert that a RuntimeWarning was raised
252+
assert any(
253+
isinstance(w.message, RuntimeWarning) for w in captured_warnings
254+
), "Expected a RuntimeWarning due to invalid arcsin input value from the wavelenght set to 1.54"
255+
# Expect only one warning message produced
256+
assert len(captured_warnings) == 1
246257
mocker.patch("importlib.metadata.version", return_value="3.3.0")
258+
247259
with freeze_time("2012-01-14"):
248260
test.dump(file, "q")
249261

250262
with open(file, "r") as f:
251263
actual = f.read()
252264
expected = (
253-
"[Diffraction_object]\nname = test\nwavelength = 1.01\nscat_quantity = x-ray\nthing1 = 1\n"
265+
"[Diffraction_object]\nname = test\nwavelength = 1.54\nscat_quantity = x-ray\nthing1 = 1\n"
254266
"thing2 = thing2\npackage_info = {'package2': '3.4.5', 'diffpy.utils': '3.3.0'}\n"
255267
"creation_time = 2012-01-14 00:00:00\n\n"
256268
"#### start data\n0.000000000000000000e+00 0.000000000000000000e+00\n"

0 commit comments

Comments
 (0)