From 62dc5ddabda9d3b7c9abb2a29e8e5cee51f6ca7b Mon Sep 17 00:00:00 2001 From: Toon Verstraelen Date: Thu, 11 Jul 2024 11:52:42 +0200 Subject: [PATCH] AI-inspired changes --- iodata/prepare.py | 4 ++-- iodata/test/test_convert.py | 8 ++++++++ iodata/test/test_molden.py | 11 +++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/iodata/prepare.py b/iodata/prepare.py index eafc2d5d..52abcd8c 100644 --- a/iodata/prepare.py +++ b/iodata/prepare.py @@ -55,7 +55,7 @@ def prepare_unrestricted_aminusb(data: IOData, allow_changes: bool, filename: st ------- data The given data object if no conversion took place, - or a shallow copy with some new attriubtes. + or a shallow copy with some new attributes. Raises ------ @@ -113,7 +113,7 @@ def prepare_segmented(data: IOData, keep_sp: bool, allow_changes: bool, filename ------- data The given data object if no conversion took place, - or a shallow copy with some new attriubtes. + or a shallow copy with some new attributes. Raises ------ diff --git a/iodata/test/test_convert.py b/iodata/test/test_convert.py index 2afa2d17..d9b35a86 100644 --- a/iodata/test/test_convert.py +++ b/iodata/test/test_convert.py @@ -355,3 +355,11 @@ def test_convert_to_segmented_sp(): assert_equal(shell3.kinds, ["p"]) assert_equal(shell3.exponents, obasis0.shells[1].exponents) assert_equal(shell3.coeffs, obasis0.shells[1].coeffs[:, 1:]) + + +def test_convert_to_segmented_empty(): + obasis0 = MolecularBasis([], HORTON2_CONVENTIONS, "L2") + obasis1 = convert_to_segmented(obasis0, keep_sp=False) + assert len(obasis1.shells) == 0 + obasis2 = convert_to_segmented(obasis0, keep_sp=True) + assert len(obasis2.shells) == 0 diff --git a/iodata/test/test_molden.py b/iodata/test/test_molden.py index 69803710..55a8606e 100644 --- a/iodata/test/test_molden.py +++ b/iodata/test/test_molden.py @@ -590,12 +590,11 @@ def test_load_molden_f(): ], ) def test_load_dump_consistency(tmpdir, fn, match, allow_changes): - with as_file(files("iodata.test.data").joinpath(fn)) as file_name: - if match is None: - mol1 = load_one(str(file_name)) - else: - with pytest.warns(LoadWarning, match=match): - mol1 = load_one(str(file_name)) + with ExitStack() as stack: + file_name = stack.enter_context(as_file(files("iodata.test.data").joinpath(fn))) + if match is not None: + stack.enter_context(pytest.warns(LoadWarning, match=match)) + mol1 = load_one(file_name) fn_tmp = os.path.join(tmpdir, "foo.bar") if allow_changes: with pytest.warns(PrepareDumpWarning):