octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Integrating Pytave and Nnet


From: Colin Macdonald
Subject: Re: Integrating Pytave and Nnet
Date: Wed, 19 Apr 2017 12:28:03 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0

On 19/04/17 11:31 AM, enricobertino wrote:
Regarding pytave, I had some problems with the conversion of the pyobects.
In particular I noticed that there is not a conversion of float32 and
strings from python to octave. Is this correct or am I doing something
wrong?

strings are intentional [1] but they can be cast in a reasonable way:

>> char (py.str("hi"))

[1] https://bitbucket.org/mtmiller/pytave/issues/65/do-not-automatically-convert-bytes-str


Re: single precision, it looks like scalars are treated differently than numpy arrays, which seems like a bug to me:


octave:23> a = py.numpy.float32(py.numpy.random.rand(int32(3),int32(3)))
a =

   0.430638   0.020321   0.589018
   0.604080   0.591453   0.019476
   0.423140   0.134504   0.617556

octave:24> b = py.numpy.float32(py.numpy.pi)
b = [Python object of type numpy.float32]

  3.14159

octave:25> whos
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        a           3x3                         36  single
        b           1x1                          0  pyobject

Total is 10 elements using 36 bytes


Do you want to file a pytave bug for this?



Note we can always cast like this:

>> single (py.numpy.float32(py.numpy.pi))

But I think this will first make a double intermediate, so also possibility to improve that.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]