pytc.test.test_cache_stateΒΆ

Tests for pytc.utils.cache_state.

Covers:
  • cache_has_mf_state detects the presence of cached orbital state.

  • save_orbital_state_to_cache + sync_mf_from_cache round-trip arrays bit-exactly.

  • ISDFXTC.from_xtc auto-saves mo_coeff / mo_occ on the first build.

  • sync_mf_from_cache is a no-op when the cache does not yet exist.

  • check_mo_coeff_matches_cache returns True for identical values and False (with a warning) for a different gauge.

  • sync_mf_from_cache refuses to sync when the cached mo_coeff has a different AO size than the current mol.

Classes

TestCacheHasMfStateRequiresMoOcc

cache_has_mf_state must require both mo_coeff AND mo_occ so that prepare_mf never skips SCF based on a partial cache.

TestCacheStateRoundTrip

TestCheckMoCoeffAtolTightens

check_mo_coeff_matches_cache must use rtol=0 so the advertised atol is the real tolerance (np.allclose default rtol=1e-5 would mask noticeably different mo_coeff).

TestCheckMoCoeffMatches

TestFingerprint

TestFromXtcFailsOnMismatchedMoCoeff

from_xtc must raise (not warn) when the cache mo_coeff doesn't match.

TestISDFXTCAutoSavesMoCoeff

ISDFXTC.from_xtc should persist mo_coeff to the cache on the first build.

TestLegacyCacheNotOverwritten

ISDFXTC.from_xtc must refuse to auto-save mo_coeff when the cache already contains ISDF kernels but no cached mo_coeff (i.e. was written by an older pytc that didn't know to pin the gauge).

TestPrepareMf

prepare_mf runs SCF when no cache, adopts cached state when present.

TestPrepareMfFallsBackOnRejectedSync

If sync_mf_from_cache refuses to sync (basis mismatch), prepare_mf must fall back to running mf.kernel() rather than returning an unsolved mf.

TestSyncRejectsWrongBasis

Functions