I have run across an issue with some of my user functions where a value 
could be 0.0 and during the process of evaluation, Sympy converts it to 
Zero.
This in turn causes my _eval_evalf() function to not be called. Below is my 
sample function class. If the obs_symbol has a value of 0.0, _eval_evalf() 
does not get called.  If I cast a 0 value to int, then the _eval_evalf() 
does get called. If the variable is a Float and 0.0 is passed into the 
evalf(), _eval_evalf() does not get called.

if data[obs_var.name] != 0:
  mlr_symbols[obs_var] = symFloat(data[obs_var.name])
else:
  mlr_symbols[obs_var] = int(data[obs_var.name])
self.mlrResult = sym_expr.evalf(subs=mlr_symbols)


Test function:

class TEST_FUNC(Function):
  nargs = 4

  def _eval_evalf(self, nprec):
    obs_symbol, a, b, c= symbols('obs_symbol a b c')
    test_func = a + b * obs_symbol + c * obs_symbol**2
    result = test_func.evalf(subs={obs_symbol: symFloat(self.args[0]), a: 
symFloat(self.args[1]), b: symFloat(self.args[2]), c: symFloat(self.args[3])})
    return result


I suspect I am missing an element in my TEST_FUNC class that would address 
this issue, but I'm not sure what that is.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/b27649e0-80d8-4317-ad1a-b88bffa1452a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to