IP 1.0 Beta 2 float to int conversion

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

IP 1.0 Beta 2 float to int conversion

J. de  Hooge

Hi,

 

 

Thanks for the new release and all the work invested!

I’ve just stepped up from IP 0.9.5 to IP 1.0 Beta 2, and I noticed the following:

 

 

 

In 0.9.5 the following runs fine, where self.widget is a Forms.SplitContainer (type: Int32 property) and the r.h.s. is a float, e.g. 100.0:

 

self.widget.SplitterDistance = self.state * self.getMaxSplitterDistance ()

 

 

 

In 1.0 Beta it will stall with the following message:

 

No conversion from 100 to System.Int32

 

 

 

Stricktly taken, the IP 1.0 is correct, but I found the auto-conversion convenient.

Has the conversion behaviour been tightened deliberately?

 

Kind regards

 

Jacques de Hooge

[hidden email]

 


_______________________________________________
users mailing list
[hidden email]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Reply | Threaded
Open this post in threaded view
|

Re: IP 1.0 Beta 2 float to int conversion

Dino Viehland-3

We have made some changes in this space but I just haven’t found the change that would have affected this yet…

 

One thing I’m curious about – is getMaxSpliiterDistance C# code or Python code?  The reason I ask if I’m wondering if it’s returning a float or a double (we represent Python float’s w/ doubles, so if it came from a literal it’ll be a double).

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of J. de Hooge
Sent: Thursday, January 26, 2006 8:10 AM
To: [hidden email]
Subject: [IronPython] IP 1.0 Beta 2 float to int conversion

 

Hi,

 

 

Thanks for the new release and all the work invested!

I’ve just stepped up from IP 0.9.5 to IP 1.0 Beta 2, and I noticed the following:

 

 

 

In 0.9.5 the following runs fine, where self.widget is a Forms.SplitContainer (type: Int32 property) and the r.h.s. is a float, e.g. 100.0:

 

self.widget.SplitterDistance = self.state * self.getMaxSplitterDistance ()

 

 

 

In 1.0 Beta it will stall with the following message:

 

No conversion from 100 to System.Int32

 

 

 

Stricktly taken, the IP 1.0 is correct, but I found the auto-conversion convenient.

Has the conversion behaviour been tightened deliberately?

 

Kind regards

 

Jacques de Hooge

[hidden email]

 


_______________________________________________
users mailing list
[hidden email]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Reply | Threaded
Open this post in threaded view
|

Re: IP 1.0 Beta 2 float to int conversion

J. de  Hooge

Dino,

 

Function getMaxSplitterDistance is a Python function, defined in two derived classes.

It returns an integer. See code below.

Variable state is a float between 0 and 1.

 

But the same thing happens in the following simpler situation:

 

If I code literally:

 

       self.widget.SplitterDistance = 100.0

 

It’s ok on IP 0.9.5 but not on IP 1.0 Beta 2, whereas

 

self.widget.SplitterDistance = 100

 

is ok on both.

 

Jacques

 

 

--- Minimum (nonsense) code for reproduction of this behaviour:

 

from sys import *

LoadAssemblyByName("System.Windows.Forms")

from System.Windows import Forms

 

splitContainer = Forms.SplitContainer ()

 

print 1

splitContainer.SplitterDistance = 100

print 2

splitContainer.SplitterDistance = 100.0

print 3

 

 

--- Output on IP 0.9.5:

 

1

2

3

 

 

--- Output on IP 1.0 Beta 2:

 

1

2

Traceback (most recent call last):

  File C:\activ_dell\prog\fun\src\funTry.py, line 10, in Initialize

TypeError: No conversion from 100 to System.Int32

 

 

--- Original code that revealed the change:

 

class SplitViewBase:

 

       # … Other members

 

       def createWidget (self):

              self.widget = Forms.SplitContainer ()

              self.widget.Dock = Forms.DockStyle.Fill

             

              def setState (sender, arguments):

                     self.state = (1.0 * self.widget.SplitterDistance) / self.getMaxSplitterDistance ()

 

              def getStateAndAllowSetState (sender, arguments):

                     if self.widget.Visible:

                           if hasattr (self, 'state'):

                                  try:

                                         self.widget.SplitterDistance = int (self.state * self.getMaxSplitterDistance ())

                                  except:

                                         pass

                                 

                           self.widget.SplitterMoved += setState

             

              self.widget.VisibleChanged += getStateAndAllowSetState

             

              self.widget.Panel1.Controls.Add (self.childView1 .createWidget ())        

              self.widget.Panel2.Controls.Add (self.childView2 .createWidget ())

             

              return self.widget

      

class HSplitView (SplitViewBase):

       # … Other members

       def getMaxSplitterDistance (self):

              return self.widget.Width

       # … Other members

             

class VSplitView (SplitViewBase):

       # … Other members

       def getMaxSplitterDistance (self):

              return self.widget.Height

       # … Other members

 

 

-----Oorspronkelijk bericht-----
Van: [hidden email] [mailto:[hidden email]] Namens Dino Viehland
Verzonden: Thursday, January 26, 2006 6:55 PM
Aan: Discussion of IronPython
Onderwerp: Re: [IronPython] IP 1.0 Beta 2 float to int conversion

 

We have made some changes in this space but I just haven’t found the change that would have affected this yet…

 

One thing I’m curious about – is getMaxSpliiterDistance C# code or Python code?  The reason I ask if I’m wondering if it’s returning a float or a double (we represent Python float’s w/ doubles, so if it came from a literal it’ll be a double).

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of J. de Hooge
Sent:
Thursday, January 26, 2006 8:10 AM
To: [hidden email]
Subject: [IronPython] IP 1.0 Beta 2 float to int conversion

 

Hi,

 

 

Thanks for the new release and all the work invested!

I’ve just stepped up from IP 0.9.5 to IP 1.0 Beta 2, and I noticed the following:

 

 

 

In 0.9.5 the following runs fine, where self.widget is a Forms.SplitContainer (type: Int32 property) and the r.h.s. is a float, e.g. 100.0:

 

self.widget.SplitterDistance = self.state * self.getMaxSplitterDistance ()

 

 

 

In 1.0 Beta it will stall with the following message:

 

No conversion from 100 to System.Int32

 

 

 

Stricktly taken, the IP 1.0 is correct, but I found the auto-conversion convenient.

Has the conversion behaviour been tightened deliberately?

 

Kind regards

 

Jacques de Hooge

[hidden email]

 


_______________________________________________
users mailing list
[hidden email]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com