Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python graph attributes: add implicit conversion from int to float #1221

Open
bernlu opened this issue May 16, 2024 · 0 comments
Open

Python graph attributes: add implicit conversion from int to float #1221

bernlu opened this issue May 16, 2024 · 0 comments

Comments

@bernlu
Copy link
Contributor

bernlu commented May 16, 2024

Python currently does not implicitly convert integer literals to float when using float graph attributes:

g = nk.Graph(1)
attr = g.attachNodeAttribute('test', float)
attr[0] = 0
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
Cell In[4], [line 3](vscode-notebook-cell:?execution_count=4&line=3)
      [1](vscode-notebook-cell:?execution_count=4&line=1) g = nk.Graph(1)
      [2](vscode-notebook-cell:?execution_count=4&line=2) attr = g.attachNodeAttribute('test', float)
----> [3](vscode-notebook-cell:?execution_count=4&line=3) attr[0] = 0

File .venv/lib/python3.10/site-packages/networkit/graph.pyx:1372, in networkit.graph.NodeAttribute.__setitem__()

Exception: Wrong Attribute type

running the same code with attr[0] = 0. works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant