30
30
import tensorflow as tf
31
31
from sklearn .metrics import r2_score , mean_squared_error , mean_absolute_error
32
32
from sklearn .base import BaseEstimator
33
- from qml . aglaia .symm_funct import generate_parkhill_acsf
34
- from qml . aglaia .utils import InputError , ceil , is_positive_or_zero , is_positive_integer , is_positive , \
35
- is_bool , is_positive_integer_or_zero , is_string , is_positive_integer_array , is_array_like , is_none , \
33
+ from .symm_funct import generate_parkhill_acsf
34
+ from . .utils import InputError , ceil , is_positive_or_zero , is_positive_integer , is_positive , \
35
+ is_bool , is_positive_integer_or_zero , is_string , is_positive_integer_array , is_array_like , \
36
36
check_global_representation , check_y , check_sizes , check_dy , check_classes , is_numeric_array , is_non_zero_integer , \
37
37
is_positive_integer_or_zero_array , check_local_representation
38
38
39
- from qml . aglaia .tf_utils import TensorBoardLogger
39
+ from .tf_utils import TensorBoardLogger
40
40
41
41
try :
42
42
from qml .data import Compound
@@ -580,7 +580,7 @@ def _set_slatm_parameters(self, params):
580
580
self .slatm_parameters = {'slatm_sigma1' : 0.05 , 'slatm_sigma2' : 0.05 , 'slatm_dgrid1' : 0.03 , 'slatm_dgrid2' : 0.03 ,
581
581
'slatm_rcut' : 4.8 , 'slatm_rpower' : 6 , 'slatm_alchemy' : False }
582
582
583
- if not is_none ( params ) :
583
+ if params is not None :
584
584
for key , value in params .items ():
585
585
if key in self .slatm_parameters :
586
586
self .slatm_parameters [key ] = value
@@ -597,7 +597,7 @@ def _set_acsf_parameters(self, params):
597
597
self .acsf_parameters = {'radial_cutoff' : 10.0 , 'angular_cutoff' : 10.0 , 'radial_rs' : (0.0 , 0.1 , 0.2 ),
598
598
'angular_rs' : (0.0 , 0.1 , 0.2 ), 'theta_s' : (3.0 , 2.0 ), 'zeta' : 3.0 , 'eta' : 2.0 }
599
599
600
- if not is_none ( params ) :
600
+ if params is not None :
601
601
for key , value in params .items ():
602
602
if key in self .acsf_parameters :
603
603
self .acsf_parameters [key ] = value
@@ -658,7 +658,7 @@ def generate_compounds(self, filenames):
658
658
"""
659
659
660
660
# Check that the number of properties match the number of compounds if the properties have already been set
661
- if is_none ( self .properties ) :
661
+ if self .properties is None :
662
662
pass
663
663
else :
664
664
if self .properties .size == len (filenames ):
@@ -683,18 +683,18 @@ def generate_representation(self, xyz=None, classes=None):
683
683
:return: None
684
684
"""
685
685
686
- if is_none ( self .compounds ) and is_none ( xyz ) and is_none ( classes ) :
686
+ if self .compounds is None and xyz is None and classes is None :
687
687
raise InputError ("QML compounds need to be created in advance or Cartesian coordinates need to be passed in "
688
688
"order to generate the representation." )
689
689
690
- if not is_none ( self .representation ) :
690
+ if self .representation is not None :
691
691
raise InputError ("The representations have already been set!" )
692
692
693
- if is_none ( self .compounds ) :
693
+ if self .compounds is None :
694
694
695
695
self .representation , self .classes = self ._generate_representations_from_data (xyz , classes )
696
696
697
- elif is_none ( xyz ) :
697
+ elif xyz is None :
698
698
# Make representations from compounds
699
699
700
700
self .representation , self .classes = self ._generate_representations_from_compounds ()
@@ -708,7 +708,7 @@ def set_properties(self, properties):
708
708
:param y: array of properties of size (nsamples,)
709
709
:type y: array
710
710
"""
711
- if is_none ( properties ) :
711
+ if properties is None :
712
712
raise InputError ("Properties cannot be set to none." )
713
713
else :
714
714
if is_numeric_array (properties ) and np .asarray (properties ).ndim == 1 :
@@ -725,10 +725,10 @@ def set_representations(self, representations):
725
725
:type representations: numpy array of shape (n_samples, n_features) or (n_samples, n_atoms, n_features)
726
726
"""
727
727
728
- if not is_none ( self .representation ) :
728
+ if self .representation is not None :
729
729
raise InputError ("The representations have already been set!" )
730
730
731
- if is_none ( representations ) :
731
+ if representations is None :
732
732
raise InputError ("Descriptor cannot be set to none." )
733
733
else :
734
734
if is_numeric_array (representations ):
@@ -745,7 +745,7 @@ def set_gradients(self, gradients):
745
745
:return: None
746
746
"""
747
747
748
- if is_none ( gradients ) :
748
+ if gradients is None :
749
749
raise InputError ("Gradients cannot be set to none." )
750
750
else :
751
751
if is_numeric_array (gradients ):
@@ -762,7 +762,7 @@ def set_classes(self, classes):
762
762
:type classes: numpy array of shape (n_samples, n_atoms) of ints
763
763
:return: None
764
764
"""
765
- if is_none ( classes ) :
765
+ if classes is None :
766
766
raise InputError ("Classes cannot be set to none." )
767
767
else :
768
768
if is_positive_integer_array (classes ):
@@ -1050,7 +1050,7 @@ def _initialise_representation(self, representation, parameters):
1050
1050
raise InputError ("Unknown representation %s" % representation )
1051
1051
self .representation_name = representation .lower ()
1052
1052
1053
- if not is_none ( parameters ) :
1053
+ if parameters is not None :
1054
1054
if not type (parameters ) is dict :
1055
1055
raise InputError ("The representation parameters passed should be either None or a dictionary." )
1056
1056
@@ -1060,7 +1060,7 @@ def _initialise_representation(self, representation, parameters):
1060
1060
1061
1061
else :
1062
1062
1063
- if not is_none ( parameters ) :
1063
+ if parameters is not None :
1064
1064
raise InputError ("The representation %s does not take any additional parameters." % (self .representation_name ))
1065
1065
1066
1066
def _set_representation (self , representation ):
@@ -1098,7 +1098,7 @@ def _generate_representations_from_compounds(self):
1098
1098
:rtype: numpy array of shape (n_samples, n_features) and None
1099
1099
"""
1100
1100
1101
- if is_none ( self .compounds ) :
1101
+ if self .compounds is None :
1102
1102
raise InputError ("This should never happen." )
1103
1103
1104
1104
n_samples = len (self .compounds )
@@ -1368,18 +1368,18 @@ def _check_inputs(self, x, y, dy, classes):
1368
1368
if not is_array_like (x ):
1369
1369
raise InputError ("x should be an array either containing indices or data." )
1370
1370
1371
- if not is_none ( dy ) and not is_none ( classes ) :
1371
+ if dy is not None and classes is not None :
1372
1372
raise InputError ("MRMP estimator cannot predict gradients and do atomic decomposition." )
1373
1373
1374
1374
# Check if x is made up of indices or data
1375
1375
if is_positive_integer_or_zero_array (x ):
1376
1376
1377
- if is_none ( self .representation ) :
1378
- if is_none ( self .compounds ) :
1377
+ if self .representation is None :
1378
+ if self .compounds is None :
1379
1379
raise InputError ("No representations or QML compounds have been set yet." )
1380
1380
else :
1381
1381
self .representation , _ = self ._generate_representations_from_compounds ()
1382
- if is_none ( self .properties ) :
1382
+ if self .properties is None :
1383
1383
raise InputError ("The properties need to be set in advance." )
1384
1384
1385
1385
approved_x = self .representation [x ]
@@ -1391,7 +1391,7 @@ def _check_inputs(self, x, y, dy, classes):
1391
1391
1392
1392
else :
1393
1393
1394
- if is_none ( y ) :
1394
+ if y is None :
1395
1395
raise InputError ("y cannot be of None type." )
1396
1396
1397
1397
approved_x = check_global_representation (x )
@@ -1420,18 +1420,18 @@ def _check_predict_input(self, x, classes):
1420
1420
if not is_array_like (x ):
1421
1421
raise InputError ("x should be an array either containing indices or data." )
1422
1422
1423
- if not is_none ( classes ) :
1423
+ if classes is not None :
1424
1424
raise InputError ("MRMP estimator cannot do atomic decomposition." )
1425
1425
1426
1426
# Check if x is made up of indices or data
1427
1427
if is_positive_integer_or_zero_array (x ):
1428
1428
1429
- if is_none ( self .representation ) :
1430
- if is_none ( self .compounds ) :
1429
+ if self .representation is None :
1430
+ if self .compounds is None :
1431
1431
raise InputError ("No representations or QML compounds have been set yet." )
1432
1432
else :
1433
1433
self .representation , _ = self ._generate_representations_from_compounds ()
1434
- if is_none ( self .properties ) :
1434
+ if self .properties is None :
1435
1435
raise InputError ("The properties need to be set in advance." )
1436
1436
1437
1437
approved_x = self .representation [x ]
@@ -1586,7 +1586,7 @@ def _initialise_representation(self, representation, parameters):
1586
1586
raise InputError ("Unknown representation %s" % representation )
1587
1587
self .representation_name = representation .lower ()
1588
1588
1589
- if not is_none ( parameters ) :
1589
+ if parameters is not None :
1590
1590
if not type (parameters ) is dict :
1591
1591
raise InputError ("The representation parameters passed should be either None or a dictionary." )
1592
1592
self ._check_representation_parameters (parameters )
@@ -1601,7 +1601,7 @@ def _initialise_representation(self, representation, parameters):
1601
1601
1602
1602
else :
1603
1603
1604
- if not is_none ( parameters ) :
1604
+ if parameters is not None :
1605
1605
raise InputError ("The representation %s does not take any additional parameters." % (self .representation_name ))
1606
1606
1607
1607
def _set_representation (self , representation ):
@@ -1624,7 +1624,7 @@ def _generate_representations_from_data(self, xyz, classes):
1624
1624
:rtype: numpy arrays of shape (n_samples, n_atoms, n_features) and (n_samples, n_atoms)
1625
1625
"""
1626
1626
1627
- if is_none ( classes ) :
1627
+ if classes is None :
1628
1628
raise InputError ("The classes need to be provided for the ARMP estimator." )
1629
1629
else :
1630
1630
if len (classes .shape ) > 2 or np .all (xyz .shape [:2 ] != classes .shape ):
@@ -1743,7 +1743,7 @@ def _generate_representations_from_compounds(self):
1743
1743
:rtype: numpy array of shape (n_samples, n_atoms, n_features) and (n_samples, n_atoms)
1744
1744
"""
1745
1745
1746
- if is_none ( self .compounds ) :
1746
+ if self .compounds is None :
1747
1747
raise InputError ("QML compounds needs to be created in advance" )
1748
1748
1749
1749
if self .representation_name == 'slatm' :
@@ -2028,22 +2028,22 @@ def _check_inputs(self, x, y, dy, classes):
2028
2028
if not is_array_like (x ):
2029
2029
raise InputError ("x should be an array either containing indices or data." )
2030
2030
2031
- if not is_none ( dy ) :
2031
+ if dy is not None :
2032
2032
raise InputError ("ARMP estimator cannot be used to predict gradients. Use ARMP_G estimator." )
2033
2033
2034
2034
# Check if x is made up of indices or data
2035
2035
if is_positive_integer_or_zero_array (x ):
2036
2036
2037
- if is_none ( self .representation ) :
2037
+ if self .representation is None :
2038
2038
2039
- if is_none ( self .compounds ) :
2039
+ if self .compounds is None :
2040
2040
raise InputError ("No representations or QML compounds have been set yet." )
2041
2041
else :
2042
2042
self .representation , self .classes = self ._generate_representations_from_compounds ()
2043
2043
2044
- if is_none ( self .properties ) :
2044
+ if self .properties is None :
2045
2045
raise InputError ("The properties need to be set in advance." )
2046
- if is_none ( self .classes ) :
2046
+ if self .classes is None :
2047
2047
raise InputError ("The classes need to be set in advance." )
2048
2048
2049
2049
approved_x = self .representation [x ]
@@ -2055,9 +2055,9 @@ def _check_inputs(self, x, y, dy, classes):
2055
2055
2056
2056
else :
2057
2057
2058
- if is_none ( y ) :
2058
+ if y is None :
2059
2059
raise InputError ("y cannot be of None type." )
2060
- if is_none ( classes ) :
2060
+ if classes is None :
2061
2061
raise InputError ("ARMP estimator needs the classes to do atomic decomposition." )
2062
2062
2063
2063
approved_x = check_local_representation (x )
@@ -2089,12 +2089,12 @@ def _check_predict_input(self, x, classes):
2089
2089
# Check if x is made up of indices or data
2090
2090
if is_positive_integer_or_zero_array (x ):
2091
2091
2092
- if is_none ( self .representation ) :
2093
- if is_none ( self .compounds ) :
2092
+ if self .representation is None :
2093
+ if self .compounds is None :
2094
2094
raise InputError ("No representations or QML compounds have been set yet." )
2095
2095
else :
2096
2096
self .representation , self .classes = self ._generate_representations_from_compounds ()
2097
- if is_none ( self .properties ) :
2097
+ if self .properties is None :
2098
2098
raise InputError ("The properties need to be set in advance." )
2099
2099
2100
2100
approved_x = self .representation [x ]
@@ -2104,7 +2104,7 @@ def _check_predict_input(self, x, classes):
2104
2104
2105
2105
else :
2106
2106
2107
- if is_none ( classes ) :
2107
+ if classes is None :
2108
2108
raise InputError ("ARMP estimator needs the classes to do atomic decomposition." )
2109
2109
2110
2110
approved_x = check_local_representation (x )
0 commit comments