Skip to content

Commit 4ac1076

Browse files
committed
fix test_basis_set.py
1 parent 80c8b64 commit 4ac1076

File tree

1 file changed

+57
-45
lines changed

1 file changed

+57
-45
lines changed

tests/test_basis_set.py

Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -422,86 +422,97 @@ def test_quick_step() -> None:
422422

423423

424424
@pytest.mark.parametrize(
425-
'basis_set_name, basis_type, role',
425+
'basis_set_name, basis_type, role, expected_name, expected_type, expected_role',
426426
[
427-
('cc-pVTZ', 'GTO', 'orbital'),
428-
('def2-TZVP', 'GTO', 'auxiliary_scf'),
429-
('aug-cc-pVDZ', 'STO', 'auxiliary_post_hf'),
430-
('custom_basis', None, None), # Undefined type and role
427+
('cc-pVTZ', 'GTO', 'orbital', 'cc-pVTZ', 'GTO', 'orbital'),
428+
('def2-TZVP', 'GTO', 'auxiliary_scf', 'def2-TZVP', 'GTO', 'auxiliary_scf'),
429+
('aug-cc-pVDZ', 'STO', 'auxiliary_post_hf', 'aug-cc-pVDZ', 'STO', 'auxiliary_post_hf'),
430+
('custom_basis', None, None, 'custom_basis', None, None), # Undefined type and role
431431
],
432432
)
433-
def test_atom_centered_basis_set_init(basis_set_name, basis_type, role) -> None:
433+
def test_atom_centered_basis_set_init(
434+
basis_set_name, basis_type, role, expected_name, expected_type, expected_role
435+
):
434436
"""Test initialization of AtomCenteredBasisSet."""
435437
bs = AtomCenteredBasisSet(basis_set=basis_set_name, type=basis_type, role=role)
436-
assert bs.basis_set == basis_set_name
437-
assert bs.type == basis_type
438-
assert bs.role == role
438+
assert bs.basis_set == expected_name
439+
assert bs.type == expected_type
440+
assert bs.role == expected_role
439441

440442

441443
@pytest.mark.parametrize(
442-
'functions',
444+
'functions, expected_count',
443445
[
444-
[
445-
AtomCenteredFunction(
446-
basis_type='spherical',
447-
function_type='s',
448-
n_primitive=3,
449-
exponents=[1.0, 2.0, 3.0],
450-
contraction_coefficients=[0.5, 0.3, 0.2],
451-
),
452-
],
453-
[
454-
AtomCenteredFunction(
455-
basis_type='cartesian',
456-
function_type='p',
457-
n_primitive=1,
458-
exponents=[0.5],
459-
contraction_coefficients=[1.0],
460-
),
461-
AtomCenteredFunction(
462-
basis_type='spherical',
463-
function_type='d',
464-
n_primitive=2,
465-
exponents=[1.0, 2.0],
466-
contraction_coefficients=[0.4, 0.6],
467-
),
468-
],
446+
(
447+
[
448+
AtomCenteredFunction(
449+
harmonic_type='spherical',
450+
function_type='s',
451+
n_primitive=3,
452+
exponents=[1.0, 2.0, 3.0],
453+
contraction_coefficients=[0.5, 0.3, 0.2],
454+
),
455+
],
456+
1,
457+
),
458+
(
459+
[
460+
AtomCenteredFunction(
461+
harmonic_type='cartesian',
462+
function_type='p',
463+
n_primitive=1,
464+
exponents=[0.5],
465+
contraction_coefficients=[1.0],
466+
),
467+
AtomCenteredFunction(
468+
harmonic_type='spherical',
469+
function_type='d',
470+
n_primitive=2,
471+
exponents=[1.0, 2.0],
472+
contraction_coefficients=[0.4, 0.6],
473+
),
474+
],
475+
2,
476+
),
469477
],
470478
)
471-
def test_atom_centered_basis_set_functional_composition(functions) -> None:
479+
def test_atom_centered_basis_set_functional_composition(functions, expected_count):
472480
"""Test functional composition within AtomCenteredBasisSet."""
473481
bs = AtomCenteredBasisSet(functional_composition=functions)
474-
assert len(bs.functional_composition) == len(functions)
482+
assert len(bs.functional_composition) == expected_count
475483
for f, ref_f in zip(bs.functional_composition, functions):
476-
assert f.basis_type == ref_f.basis_type
484+
assert f.harmonic_type == ref_f.harmonic_type
477485
assert f.function_type == ref_f.function_type
478486
assert f.n_primitive == ref_f.n_primitive
479487
assert np.allclose(f.exponents, ref_f.exponents)
480488
assert np.allclose(f.contraction_coefficients, ref_f.contraction_coefficients)
481489

482490

483-
def test_atom_centered_basis_set_normalize() -> None:
491+
def test_atom_centered_basis_set_normalize():
484492
"""Test normalization of AtomCenteredBasisSet."""
485493
bs = AtomCenteredBasisSet(
486494
basis_set='cc-pVTZ',
487495
type='GTO',
488496
role='orbital',
489497
functional_composition=[
490498
AtomCenteredFunction(
491-
basis_type='spherical',
499+
harmonic_type='spherical',
492500
function_type='s',
493501
n_primitive=2,
494502
exponents=[1.0, 2.0],
495503
contraction_coefficients=[0.5, 0.5],
496504
)
497505
],
498506
)
499-
bs.normalize(None, logger)
500-
# Add checks for normalized behavior, if any
507+
bs.normalize(None, None)
508+
# Add assertions for normalized attributes if needed
501509
assert bs.basis_set == 'cc-pVTZ'
510+
assert bs.type == 'GTO'
511+
assert bs.role == 'orbital'
512+
assert len(bs.functional_composition) == 1
502513

503514

504-
def test_atom_centered_basis_set_invalid_data() -> None:
515+
def test_atom_centered_basis_set_invalid_data():
505516
"""Test behavior with missing or invalid data."""
506517
bs = AtomCenteredBasisSet(
507518
basis_set='invalid_basis',
@@ -514,7 +525,7 @@ def test_atom_centered_basis_set_invalid_data() -> None:
514525

515526
# Test functional composition with invalid data
516527
invalid_function = AtomCenteredFunction(
517-
basis_type='spherical',
528+
harmonic_type='spherical',
518529
function_type='s',
519530
n_primitive=2,
520531
exponents=[1.0], # Mismatched length
@@ -524,4 +535,5 @@ def test_atom_centered_basis_set_invalid_data() -> None:
524535

525536
# Call normalize to trigger validation
526537
with pytest.raises(ValueError, match='Mismatch in number of exponents'):
527-
invalid_function.normalize(None, logger)
538+
invalid_function.normalize(None, None)
539+

0 commit comments

Comments
 (0)