Dear Group,
I would like to understand the workings of SymPy a little better, and to
that end, I thought it would be instructive to create a trivial 'special
function' that had some or all of the properties of the SymPy in-built
functions. The following link was helpful:
https://github.com/Shekharrajak/sympy/wiki/About-implementing-special-functions
However, I could not tell from that whether I could have the new
function stored separately from the directory tree holding the SymPy
software. I'd much prefer it if I could experiment without disturbing
the SymPy software at all.
I decided to call the function bailey, so following the recipe in the
above link, I created a file bailey.py in a directory outside the SymPy
tree, and to test it my calling Python from that directory, as follows:
from sympy.core.function import Function
class bailey(Function):
"""
The experimental function
"""
nargs=1
@classmethod
def eval(cls, arg):
# This body does nothing useful at all
z=arg[0]
if z is S.Zero:
return S.Zero
else: return 1
Now I tried to use this module:
>>> import sympy
>>> import bailey
>>> bailey(a+3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'module' object is not callable
Alternatively I tried:
>>> (a+3).bailey(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Add' object has no attribute 'bailey'
I admit to being fairly confused at this level! What I would like to
know is:
1) Can I experiment in this way without actually adding files to
SymPy itself or modifying anything there already?
2) I would expect to get back a function call: bailey(a+3) or
perhaps the answer 1.
3) Is there a place where this is described more completely?
Thanks,
David
--
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 sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/04eaf831-b1a1-6f1c-68b7-2ae9a7d60c2e%40dbailey.co.uk.