def kernel(d1, d2, r=None, weights=None):
 diff = (d1 - d2)
 if ((weights is None) or (r[0] == 0)):
  return np.all(((r * diff) == 0))
 else:
  return (weights[diff] * np.all(((r[1:] * diff[1:]) == 0)))

def kernel ( d1 , d2 , r = None , weights = None ) : diff = ( d1 - d2 ) if ( ( weights is None ) or ( r [ 0 ] == 0 ) ) : return np . all ( ( ( r * diff ) == 0 ) ) else : return ( weights [ diff ] * np . all ( ( ( r [ 1 : ] * diff [ 1 : ] ) == 0 ) ) )
general product kernel hardcoded split for the example: cat1 is continuous .