Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Making _scalar_arg_to_dict consistent #410

@nwlandry

Description

@nwlandry

The inconsistency when converting to colors (Issue #389) was fixed in #402. In the case of _color_arg_to_dict, it helps that colors are specified with tuples or strings so that if there is an iterable of scalars, it is clear that the scalars must be mapped to a color. In contrast, for the _scalar_arg_to_dict method, it's unclear whether an iterable of scalars are the desired values, or whether those values should be interpolated between preset (or user-defined) min and max allowable values. For example:

>>> import xgi
>>> H = xgi.Hypergraph([{1, 2, 3}, {1, 2}, {1, 4}])
>>> d = H.nodes.degree.asnumpy()
>>> xgi.drawing.draw._scalar_arg_to_dict(d, [1, 2, 3, 4], 10, 30)
{1: 3.0, 2: 2.0, 3: 1.0, 4: 1.0}
>>> xgi.drawing.draw._scalar_arg_to_dict(H.nodes.degree, [1, 2, 3, 4], 10, 30)
{1: 30.0, 2: 20.0, 3: 10.0, 4: 10.0}

*I ran the _scalar_arg_to_dict function by pasting into a notebook and running it directly, because there was some weirdness with the importing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions