Skip to content

Feat/week5 density tests#235

Closed
kir943 wants to merge 10 commits intotheochem:masterfrom
kir943:feat/week5-density-tests
Closed

Feat/week5 density tests#235
kir943 wants to merge 10 commits intotheochem:masterfrom
kir943:feat/week5-density-tests

Conversation

@kir943
Copy link

@kir943 kir943 commented Feb 28, 2026

Week-5: Add tests, benchmarks, and real-basis validation for density API

This PR completes the Week-5 milestone of the density (intracule and extracule) API by adding comprehensive tests and performance validation.

Summary of additions

This PR introduces five new test modules to validate correctness, robustness, and performance of the compute_intracule and compute_extracule APIs implemented in Week-4.


Test coverage details

1. Unit tests for intracule (tests/test_intracule.py)

These tests verify the basic correctness and expected behavior of compute_intracule.

They validate:

  • Shape correctness
    Ensures the returned matrix has shape (n, n) where n is the number of shells.

  • Empty input handling
    Confirms the function correctly returns an empty (0, 0) matrix when given no shells.

  • Symmetry property

    The intracule and extracule matrices are expected to be symmetric because they are based on overlap integrals between pairs
    of shells.
    This means the interaction between shell i and shell j must be the same as the interaction between shell j and shell i.
    The test verifies this by checking that the matrix is equal to its transpose:
    result[i, j] == result[j, i]
    This confirms the matrix is constructed correctly and consistently.


2. Unit tests for extracule (tests/test_extracule.py)

These tests perform the same structural and correctness validation for compute_extracule, ensuring:

  • correct matrix shape
  • valid output structure
  • consistent behavior with the density API design

This confirms both density APIs behave consistently.


3. Performance benchmark (tests/test_performance.py)

This test evaluates execution time of the intracule computation on a moderate number of shells.

It verifies that:

  • The function executes within a reasonable time limit.
  • No performance regressions are introduced.

This ensures the implementation remains efficient and suitable for practical use.


4. Real basis validation for intracule (tests/test_intracule_real.py)

This test validates the intracule implementation using an actual Gaussian basis set (data_631g.gbs) included in the repository.

The test:

  • Parses real basis set data
  • Converts it into GeneralizedContractionShell objects
  • Computes the intracule matrix

It then verifies:

  • correct shape
  • symmetry
  • physically valid diagonal values (non-negative)

This confirms the API works correctly with real scientific input.


5. Real basis validation for extracule (tests/test_extracule_real.py)

This performs the same real-data validation for compute_extracule, ensuring:

  • compatibility with real GBasis shell objects
  • correct output structure
  • physical validity

Overall validation achieved

These tests collectively verify:

  • API correctness
  • Edge case handling
  • Numerical validity
  • Integration with GBasis shell objects
  • Performance behavior

All existing and new tests pass successfully.


This PR builds directly on the Week-4 density API implementation.

@marco-2023
Copy link
Contributor

Superseeded by #236

@marco-2023 marco-2023 closed this Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants