2
2
Tests the imports and exports of the Molecule object.
3
3
"""
4
4
5
+
5
6
import numpy as np
6
7
import pytest
7
8
@@ -798,6 +799,15 @@ def test_extras():
798
799
"triplet" : "7caca87a" ,
799
800
"disinglet" : "83a85546" ,
800
801
"ditriplet" : "71d6ba82" ,
802
+ # float mult
803
+ "singlet_point1" : "4e9e2587" ,
804
+ "singlet_epsilon" : "ad3f5fab" ,
805
+ "triplet_point1" : "ad35cc28" ,
806
+ "triplet_point1_minus" : "b63d6983" ,
807
+ "triplet_point00001" : "7107b7ac" ,
808
+ "disinglet_epsilon" : "fb0aaaca" ,
809
+ "ditriplet_point1" : "33d47d5f" ,
810
+ "ditriplet_point00001" : "7f0ac640" ,
801
811
}
802
812
803
813
@@ -806,14 +816,26 @@ def test_extras():
806
816
[
807
817
pytest .param (3 , 3 , False , "triplet" ),
808
818
pytest .param (3 , 3 , True , "triplet" ),
809
- # 3.1 -> 3 (validate=False) below documents the present bad behavior where a float mult
810
- # simply gets cast to int with no error. This will change soon. The validate=True throws a
811
- # nonspecific error that at least mentions type.
812
- pytest .param (3.1 , 3 , False , "triplet" ),
819
+ # before float multiplicity was allowed, 3.1 (below) was coerced into 3 with validate=False,
820
+ # and validate=True threw a type-mentioning error. Now, 2.9 is allowed for both validate=T/F
821
+ pytest .param (3.1 , 3.1 , False , "triplet_point1" ),
822
+ # validate=True counterpart fails b/c insufficient electrons in He for more than triplet
823
+ pytest .param (2.9 , 2.9 , False , "triplet_point1_minus" ),
824
+ pytest .param (2.9 , 2.9 , True , "triplet_point1_minus" ),
825
+ pytest .param (3.00001 , 3.00001 , False , "triplet_point00001" ),
826
+ # validate=True counterpart fails like 3.1 above
827
+ pytest .param (2.99999 , 2.99999 , False , "triplet_point00001" ), # hash agrees w/3.00001 above b/c <CHARGE_NOISE
828
+ pytest .param (2.99999 , 2.99999 , True , "triplet_point00001" ),
813
829
pytest .param (3.0 , 3 , False , "triplet" ),
814
830
pytest .param (3.0 , 3 , True , "triplet" ),
815
831
pytest .param (1 , 1 , False , "singlet" ),
816
832
pytest .param (1 , 1 , True , "singlet" ),
833
+ pytest .param (1.000000000000000000002 , 1 , False , "singlet" ),
834
+ pytest .param (1.000000000000000000002 , 1 , True , "singlet" ),
835
+ pytest .param (1.000000000000002 , 1.000000000000002 , False , "singlet_epsilon" ),
836
+ pytest .param (1.000000000000002 , 1.000000000000002 , True , "singlet_epsilon" ),
837
+ pytest .param (1.1 , 1.1 , False , "singlet_point1" ),
838
+ pytest .param (1.1 , 1.1 , True , "singlet_point1" ),
817
839
pytest .param (None , 1 , False , "singlet" ),
818
840
pytest .param (None , 1 , True , "singlet" ),
819
841
# fmt: off
@@ -841,6 +863,9 @@ def test_mol_multiplicity_types(mult_in, mult_store, validate, exp_hash):
841
863
[
842
864
pytest .param (- 3 , False , "Multiplicity must be positive" ),
843
865
pytest .param (- 3 , True , "Multiplicity must be positive" ),
866
+ pytest .param (0.9 , False , "Multiplicity must be positive" ),
867
+ pytest .param (0.9 , True , "Multiplicity must be positive" ),
868
+ pytest .param (3.1 , True , "Inconsistent or unspecified chg/mult" ), # insufficient electrons in He
844
869
],
845
870
)
846
871
def test_mol_multiplicity_types_errors (mult_in , validate , error ):
@@ -859,10 +884,11 @@ def test_mol_multiplicity_types_errors(mult_in, validate, error):
859
884
[
860
885
pytest .param (5 , [3 , 3 ], [3 , 3 ], False , "ditriplet" ),
861
886
pytest .param (5 , [3 , 3 ], [3 , 3 ], True , "ditriplet" ),
862
- # 3.1 -> 3 (validate=False) below documents the present bad behavior where a float mult
863
- # simply gets cast to int with no error. This will change soon. The validate=True throws a
864
- # irreconcilable error.
865
- pytest .param (5 , [3.1 , 3.4 ], [3 , 3 ], False , "ditriplet" ),
887
+ # before float multiplicity was allowed, [3.1, 3.4] (below) were coerced into [3, 3] with validate=False.
888
+ # Now, [2.9, 2.9] is allowed for both validate=T/F.
889
+ pytest .param (5 , [3.1 , 3.4 ], [3.1 , 3.4 ], False , "ditriplet_point1" ),
890
+ pytest .param (5 , [2.99999 , 3.00001 ], [2.99999 , 3.00001 ], False , "ditriplet_point00001" ),
891
+ pytest .param (5 , [2.99999 , 3.00001 ], [2.99999 , 3.00001 ], True , "ditriplet_point00001" ),
866
892
# fmt: off
867
893
pytest .param (5 , [3.0 , 3. ], [3 , 3 ], False , "ditriplet" ),
868
894
pytest .param (5 , [3.0 , 3. ], [3 , 3 ], True , "ditriplet" ),
@@ -871,6 +897,18 @@ def test_mol_multiplicity_types_errors(mult_in, validate, error):
871
897
pytest .param (1 , [1 , 1 ], [1 , 1 ], True , "disinglet" ),
872
898
# None in frag_mult not allowed for validate=False
873
899
pytest .param (1 , [None , None ], [1 , 1 ], True , "disinglet" ),
900
+ pytest .param (1 , [1.000000000000000000002 , 0.999999999999999999998 ], [1 , 1 ], False , "disinglet" ),
901
+ pytest .param (1 , [1.000000000000000000002 , 0.999999999999999999998 ], [1 , 1 ], True , "disinglet" ),
902
+ pytest .param (
903
+ 1 ,
904
+ [1.000000000000002 , 1.000000000000004 ],
905
+ [1.000000000000002 , 1.000000000000004 ],
906
+ False ,
907
+ "disinglet_epsilon" ,
908
+ ),
909
+ pytest .param (
910
+ 1 , [1.000000000000002 , 1.000000000000004 ], [1.000000000000002 , 1.000000000000004 ], True , "disinglet_epsilon"
911
+ ),
874
912
],
875
913
)
876
914
def test_frag_multiplicity_types (mol_mult_in , mult_in , mult_store , validate , exp_hash ):
@@ -902,6 +940,9 @@ def test_frag_multiplicity_types(mol_mult_in, mult_in, mult_store, validate, exp
902
940
[
903
941
pytest .param ([- 3 , 1 ], False , "Multiplicity must be positive" ),
904
942
pytest .param ([- 3 , 1 ], True , "Multiplicity must be positive" ),
943
+ pytest .param (
944
+ [3.1 , 3.4 ], True , "Inconsistent or unspecified chg/mult"
945
+ ), # insufficient e- for triplet+ on He in frag 1
905
946
],
906
947
)
907
948
def test_frag_multiplicity_types_errors (mult_in , validate , error ):
0 commit comments