def _transformExpression(self, expr, instance): if expr.polynomial_degree() > 2: raise ValueError("Cannot transform polynomial terms with degree > 2") if expr.polynomial_degree() < 2: return expr # expr = self._replace_bilinear(expr, instance) return expr
def evaluate(expr, seconds): gc.collect() _clear_expression_pool() start = time.time() # expr_ = expr.clone() # stop = time.time() seconds['clone'] = stop - start gc.collect() _clear_expression_pool() start = time.time() # d_ = expr.polynomial_degree() # stop = time.time() seconds['polynomial_degree'] = stop - start if False: gc.collect() _clear_expression_pool() start = time.time() # s_ = expr.to_string() # stop = time.time() seconds['to_string'] = stop - start gc.collect() _clear_expression_pool() start = time.time() # s_ = expr.is_constant() # stop = time.time() seconds['is_constant'] = stop - start gc.collect() _clear_expression_pool() start = time.time() # s_ = expr.is_fixed() # stop = time.time() seconds['is_fixed'] = stop - start try: gc.collect() _clear_expression_pool() start = time.time() # r_ = generate_canonical_repn(expr) # stop = time.time() seconds['generate_canonical'] = stop - start except: seconds['generate_canonical'] = -1 return seconds