Skip to content

Default value of 'pl.Array' typed attribute fails in graph.node_attrs() #251

Description

@TeunHuijben

When a node attribute has the type "Array", and I add a node without providing that attribute value (with validata_keys==False). A call to graph.node_attrs() gives the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/teun.huijben/Documents/code/github/funtracks/.venv/lib/python3.12/site-packages/tracksdata/graph/_graph_view.py", line 625, in node_attrs
    return self._node_attrs_from_node_ids(attr_keys=attr_keys, unpack=unpack)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/teun.huijben/Documents/code/github/funtracks/.venv/lib/python3.12/site-packages/tracksdata/graph/_graph_view.py", line 609, in _node_attrs_from_node_ids
    node_dfs = super()._node_attrs_from_node_ids(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/teun.huijben/Documents/code/github/funtracks/.venv/lib/python3.12/site-packages/tracksdata/graph/_rustworkx_graph.py", line 1102, in _node_attrs_from_node_ids
    s = pl.Series(name=key, values=columns[key], dtype=schema.dtype)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/teun.huijben/Documents/code/github/funtracks/.venv/lib/python3.12/site-packages/polars/series/series.py", line 306, in __init__
    self._s = sequence_to_pyseries(
              ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/teun.huijben/Documents/code/github/funtracks/.venv/lib/python3.12/site-packages/polars/_utils/construction/series.py", line 272, in sequence_to_pyseries
    if all(len(v) == n_elems for v in values):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/teun.huijben/Documents/code/github/funtracks/.venv/lib/python3.12/site-packages/polars/_utils/construction/series.py", line 272, in <genexpr>
    if all(len(v) == n_elems for v in values):
           ^^^^^^
TypeError: object of type 'NoneType' has no len()

Coming from line 1102 in tracksdata/graph/_rustworkx_graph.py

        for key in attr_keys:
            schema = node_attr_schemas[key]
            s = pl.Series(name=key, values=columns[key], dtype=schema.dtype)
            s = _maybe_fill_null(s, schema)
            columns[key] = s

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions