print vs assign output in QuantLib-SWIG

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

print vs assign output in QuantLib-SWIG

Tawanda Gwena
I am working on quantlib-swig and porting it to Lua.

I have been working with the interest rate curves. They mostly work except at the output stage. I successfully created the PiecewiseFlatForward object "ff". When I issue the command

      print(ff:zeroRate(zDate,daycount,Annual)

I get the output

    0.443772 % Actual/360 Annual compounding

Unfortunately I get the same string when I assign, which is generally not easy to work with.


I would like to know how the other languages deal with it (Python for instance) and pointers to where I may be able to fix it.

Thanks
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: print vs assign output in QuantLib-SWIG

Luigi Ballabio
Hi Tawanda,
    I'm not sure what you mean by "I get the same string when I assign".
Do you mean that if you write "x = ff:zeroRate(zDate,daycount,Annual)"
(or whatever the syntax for assignment is in Lua) then x holds the
string instead of an InterestRate instance?  If so, it looks like an
issue of the Lua wrappers to me...

Luigi

On Sun, Aug 26, 2012 at 1:08 AM, Tawanda Gwena <[hidden email]> wrote:

> I am working on quantlib-swig and porting it to Lua.
>
> I have been working with the interest rate curves. They mostly work except at the output stage. I successfully created the PiecewiseFlatForward object "ff". When I issue the command
>
>       print(ff:zeroRate(zDate,daycount,Annual)
>
> I get the output
>
>     0.443772 % Actual/360 Annual compounding
>
> Unfortunately I get the same string when I assign, which is generally not easy to work with.
>
>
> I would like to know how the other languages deal with it (Python for instance) and pointers to where I may be able to fix it.
>
> Thanks
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> QuantLib-dev mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: print vs assign output in QuantLib-SWIG

Tawanda Gwena

I've solved it.

I needed to say  

    ff:zeroRate(zDate,daycount,Annual):rate()

I had not realized there was an InterestRate wrapper in interestrate.i.



On Aug 27, 2012, at 10:55 AM, Luigi Ballabio <[hidden email]> wrote:

> Hi Tawanda,
>    I'm not sure what you mean by "I get the same string when I assign".
> Do you mean that if you write "x = ff:zeroRate(zDate,daycount,Annual)"
> (or whatever the syntax for assignment is in Lua) then x holds the
> string instead of an InterestRate instance?  If so, it looks like an
> issue of the Lua wrappers to me...
>
> Luigi
>
> On Sun, Aug 26, 2012 at 1:08 AM, Tawanda Gwena <[hidden email]> wrote:
>> I am working on quantlib-swig and porting it to Lua.
>>
>> I have been working with the interest rate curves. They mostly work except at the output stage. I successfully created the PiecewiseFlatForward object "ff". When I issue the command
>>
>>      print(ff:zeroRate(zDate,daycount,Annual)
>>
>> I get the output
>>
>>    0.443772 % Actual/360 Annual compounding
>>
>> Unfortunately I get the same string when I assign, which is generally not easy to work with.
>>
>>
>> I would like to know how the other languages deal with it (Python for instance) and pointers to where I may be able to fix it.
>>
>> Thanks
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> QuantLib-dev mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-dev


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Trying to extend functions into Lua

Tawanda Gwena
In reply to this post by Tawanda Gwena
Hi again (Luigi)

I am trying to emulate the way you built the UnaryFunction class in functions.i.

My question is how did you know or arranged for the UnaryFunction constructor to accept the PyObject* object (or the Scheme_Object* and function_ in scheme). I am trying to figure out what Lua sends. I guess this is more about understanding SWIG.

Thanks



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Trying to extend functions into Lua

Luigi Ballabio
Hi Tawanda,
    sorry it took so long.  The default typemaps provided by SWIG let
native objects for a few languages (such as PyObject* for Python) pass
through unmodified.  I don't think the support is there for Lua,
though.  You should extend the typemaps to do this, but I think you'd
have more luck asking on the SWIG mailing list; I guess they would be
interested in adding your patches to their repository.

Later,
    Luigi

On Tue, Aug 28, 2012 at 3:03 AM, Tawanda Gwena <[hidden email]> wrote:
> Hi again (Luigi)
>
> I am trying to emulate the way you built the UnaryFunction class in functions.i.
>
> My question is how did you know or arranged for the UnaryFunction constructor to accept the PyObject* object (or the Scheme_Object* and function_ in scheme). I am trying to figure out what Lua sends. I guess this is more about understanding SWIG.
>
> Thanks
>
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev