Skip to content

Commit

Permalink
added test for spahm-b (water)
Browse files Browse the repository at this point in the history
  • Loading branch information
YAY-C committed Apr 12, 2024
1 parent 01798cf commit 77860d1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Binary file added tests/data/H2O_spahm_b.npy_alpha_beta.npy
Binary file not shown.
22 changes: 22 additions & 0 deletions tests/test_spahm_b.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
import numpy as np
from qstack.spahm.rho import bond, utils
from qstack import compound

def test_water():
path = os.path.dirname(os.path.realpath(__file__))
xyz_in = path+'/data/H2O.xyz'
mols = utils.load_mols([xyz_in], [0], [0], 'minao')
dms = utils.mols_guess(mols, [xyz_in], 'LB', spin=[0])
X = bond.bond(mols, dms, spin=[0])
X = np.hstack(X) # merging alpha-beta components for spin unrestricted representation #TODO: should be included into function not in main
true_file = path+'/data/H2O_spahm_b.npy_alpha_beta.npy'
X_true = np.load(true_file)
assert(X_true.shape == X.shape)
for Xa, Xa_true in zip(X, X_true):
assert(np.linalg.norm(Xa-Xa_true) < 1e-8) # evaluating representation diff as norm (threshold = 1e-8)


if __name__ == '__main__':
test_water()

0 comments on commit 77860d1

Please sign in to comment.