← Back to team overview

aesthete-team team mailing list archive

Re: Another mpmath diff

 

Chris Palmer wrote:
Hi all,

I just noticed that sec(𝛑) didn't work. Please find attached another
patch (another hack, really) which seems to fix this for me.

Regards,
Chris.


Ahem. Try this one.

Chris.
=== modified file 'aesthete/glypher/Function.py'
--- aesthete/glypher/Function.py	2011-11-01 00:18:56 +0000
+++ aesthete/glypher/Function.py	2011-11-08 04:21:33 +0000
@@ -4,6 +4,7 @@
 from BinaryExpression import *
 from Decoration import *
 from sympy.core.function import *
+from sympy import N
 
 auto_bracket_funcs = \
  [  'cos', 'sin', 'tan',
@@ -133,7 +134,13 @@
         args = self.get_sympy_args()
         try :
             if self.get_sympy_func() :
-                return self.get_sympy_func()(*args)
+                try:
+                    return self.get_sympy_func()(*args)
+                except:  # hack to get mpmath functions working
+                    new_args = []
+                    for arg in args:
+                        new_args.append(N(arg))
+                    return self.get_sympy_func()(*new_args)
             else :
                 debug_print('x')
                 f = Function(str(self.get_target('name').to_string()))


References