Skip to content

Bug/UX issue: Variable("key") misinterprets string as input_variables #269

Description

@LucasBoTang

Description

There is a positional argument misalignment in the Variable class. Initializing a Variable with a string (e.g., Variable("x")) causes the string to be assigned to input_variables instead of key.

Because strings are iterable, make_graph iterates over the characters, treating them as constants and creating an anonymous node. This leads to:

  1. _is_input being False, making the variable unable to fetch data from a dictionary.
  2. key being assigned a random object ID (e.g., '140...) instead of the intended string.

Example of unexpected behavior

from neuromancer.constraint import Variable

# User intends to create an input variable with key "x"
v = Variable("x")

print(f"Is input: {v._is_input}")  # Returns False, expected True
print(f"Key: {v.key}")                # Returns random ID, expected "x"

Metadata

Metadata

Assignees

No one assigned

    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