1010import numpy as np
1111
1212from patsy .util import (have_pandas , atleast_2d_column_default ,
13- no_pickling , assert_no_pickling )
13+ no_pickling , assert_no_pickling , safe_string_eq )
1414from patsy .state import stateful_transform
1515
1616if have_pandas :
@@ -623,7 +623,7 @@ def memorize_finish(self):
623623 constraints = args ["constraints" ]
624624 n_constraints = 0
625625 if constraints is not None :
626- if constraints == "center" :
626+ if safe_string_eq ( constraints , "center" ) :
627627 # Here we collect only number of constraints,
628628 # actual centering constraint will be computed after all_knots
629629 n_constraints = 1
@@ -651,7 +651,7 @@ def memorize_finish(self):
651651 lower_bound = args ["lower_bound" ],
652652 upper_bound = args ["upper_bound" ])
653653 if constraints is not None :
654- if constraints == "center" :
654+ if safe_string_eq ( constraints , "center" ) :
655655 # Now we can compute centering constraints
656656 constraints = _get_centering_constraint_from_dmatrix (
657657 _get_free_crs_dmatrix (x , self ._all_knots , cyclic = self ._cyclic )
@@ -895,7 +895,7 @@ def __init__(self):
895895 def memorize_chunk (self , * args , ** kwargs ):
896896 constraints = self ._tmp .setdefault ("constraints" ,
897897 kwargs .get ("constraints" ))
898- if constraints == "center" :
898+ if safe_string_eq ( constraints , "center" ) :
899899 args_2d = []
900900 for arg in args :
901901 arg = atleast_2d_column_default (arg )
@@ -919,7 +919,7 @@ def memorize_finish(self):
919919 del self ._tmp
920920
921921 if constraints is not None :
922- if constraints == "center" :
922+ if safe_string_eq ( constraints , "center" ) :
923923 constraints = np .atleast_2d (tmp ["sum" ] / tmp ["count" ])
924924 else :
925925 constraints = np .atleast_2d (constraints )
0 commit comments