On Fri, Oct 24, 2008 at 2:58 PM, tomanizer <[EMAIL PROTECTED]> wrote: > > Hi All, > > I have successfully compiled the new > quantlib_swig-0.9.6 > quantlib-0.9.6 > packages from Sage 3.0.1. > > A number of functions work fine form the Sage notebook. > Unfortunately the important quantlib Date() function is causing > problems. > > I am trying to run > > from QuantLib import * > calendar = TARGET() > todaysDate = Date(6,October,2001) > > and I get the error: > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "/root/.sage/sage_notebook/worksheets/tomanizer/18/code/3.py", > line 7, in <module> > todaysDate = Date(Integer(6),October,Integer(2001)) > File "/filesrv/Sage/sage-3.0.2-debian32-intelx86-i686-Linux/local/ > lib/python2.5/site-packages/sympy/plotting/", line 1, in <module> > > File "/filesrv/Sage/sage-3.0.2-debian32-intelx86-i686-Linux/local/ > lib/python2.5/site-packages/QuantLib/QuantLib.py", line 203, in > __init__ > this = _QuantLib.new_Date(*args) > NotImplementedError: Wrong number of arguments for overloaded function > 'new_Date'. > Possible C/C++ prototypes are: > Date() > Date(Day,Month,Year) > Date(BigInteger) > Date(std::string const &,std::string const &) > > which is an error thrown by SWIG if the wrong parameters are passed to > the functions. > However, this example is from the Quantlib SWIG help file. So I assume > it should work from quantlib SWIG. > > My suspicion is that the error is related to the Sage's handling of > unicode. > > Does anone wlse have this problem? > Is there a workaround?
The problem is the Sage preparser turning integer literals into Sage integers, which the Swig/Quantlib interface doesn't understand. Here are some workarounds: Use "r" after the number to make it raw (not preparsed): sage: todaysDate = Date(6r,October,2001r) Explicitly cast to int: sage: todaysDate = Date(int(6),October,int(2001)) Turn of numerical literal preparsing: sage: Integer=int; RealNumber=float sage: todaysDate = Date(6,October,2001) --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---