Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Impossibility to use something else than Vec3f to specfy the layout of a new in python #120

Closed
rgiot opened this issue Jun 3, 2019 · 5 comments · Fixed by #122
Closed

Comments

@rgiot
Copy link
Contributor

rgiot commented Jun 3, 2019

When trying to set the layout property of a node using a 3-sized tuple, we obtain such error

TypeError: LayoutProperty.__setitem__(): arguments did not match any overloaded call:
  overload 1: argument 2 has unexpected type 'tuple'
  overload 2: argument 1 has unexpected type 'node'

As it is very common in python to use tuples instead of Vec3f, tuple of 3 elements should be allowed. The same comment apply for lists

Issue #16 let suggest that I should not have this error. Maybe it is not activated in the pip version of python ?

@bpinaud
Copy link
Contributor

bpinaud commented Jun 3, 2019

Why not simply using Tulip datatype:

c = tlp.Coord(3,4,1)

@tulipdev
Copy link
Contributor

tulipdev commented Jun 4, 2019 via email

@fqueyroi
Copy link
Contributor

fqueyroi commented Jun 4, 2019

Maybe you get this error because you use a tuple of integers instead of floats as input. You should try

viewLayout[n] = (0.,0.,0.) or viewLayout[n] = (0.0,0.0,0.0)

Since, according to the description of this change in Tulip-Python 5.1:

Warning

In order to successfully set a property values using a tuple, the types of the elements it contains and its length are constrained according to the the property type:

  • for tlp.ColorProperty: the tuple must contain 3 or 4 integers between 0 and 255
  • for tlp.LayoutProperty and tlp.SizeProperty: the tuple must contain 2 or 3 float (meaning the value will fail to be set if the tuple contains integers)

@anlambert
Copy link
Contributor

As explained by @fqueyroi , the issue you observed is due to the fact you are using int litterals instead of float ones in your tuple.

I will try to see if I can improve this behavior but I remember that I had no choice to proceed like this at the time I implemented this (in order to be able to create graph properties on the fly from Python using type inference).

@rgiot
Copy link
Contributor Author

rgiot commented Jun 4, 2019

@fqueyroi Thanks for pointing that, I have never thought about that. I'll pay more attention to the doc next time ...
@anlambert ok, so feel free to close the issue if it is not doable

@p-mary p-mary closed this as completed Jun 4, 2019
anlambert added a commit to anlambert/talipot that referenced this issue Jun 5, 2019
…ulip-Dev#120)

Remove type restrictions when one wants to set a node/edge value for an existing
layout or size property using a tuple filled with integers instead of floats.

Nevertheless, the type restrictions is still active when one wants to create
a new graph property on the fly by type inference.

Unit tests have been updated accordingly.
anlambert added a commit to anlambert/talipot that referenced this issue Jun 5, 2019
…ulip-Dev#120)

Remove type restrictions when one wants to set a node/edge value for an existing
layout or size property using a tuple filled with integers instead of floats.

Nevertheless, the type restrictions is still active when one wants to create
a new graph property on the fly by type inference.

Unit tests have been updated accordingly.
anlambert added a commit to anlambert/talipot that referenced this issue Jun 5, 2019
…ulip-Dev#120)

Remove type restrictions when one wants to set a node/edge value for an existing
layout or size property using a tuple filled with integers instead of floats.

Nevertheless, the type restrictions is still active when one wants to create
a new graph property on the fly by type inference.

Unit tests have been updated accordingly.
anlambert added a commit to anlambert/talipot that referenced this issue Jun 6, 2019
…ulip-Dev#120)

Remove type restrictions when one wants to set a node/edge value for an existing
layout or size property using a tuple filled with integers instead of floats.

Nevertheless, the type restrictions is still active when one wants to create
a new graph property on the fly by type inference.

Unit tests have been updated accordingly.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants