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

Escape { to support dictionary in params #32

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

hishamhijjawi
Copy link

@hishamhijjawi hishamhijjawi commented Mar 2, 2024

Problem

Right now, if the function which we are visualizing the recursion for has a dictionary or defaultdict in it's param list, I get this error on my mac:

Error: bad label format fib(d={}, n=1)

How to repro:

With the default example provided in the readme, pass in a dictionary to fibonnaci:

# Add decorator
# Decorator accepts optional arguments: ignore_args , show_argument_name, show_return_value and node_properties_kwargs
@vs(node_properties_kwargs={"shape":"record", "color":"#f57542", "style":"filled", "fillcolor":"grey"})
def fib(n,d={}):
    if n <= 1:
        return n
    return fib(n=n - 1, d={}) + fib(n=n - 2, d={'1':'2'})

Solution

If I escape { and }, the error goes away for dictionary and set. For default dict, I also need to escape < and > Not sure if there are any other special chars that need to be escaped because the pydot spec isn't particularly clear, but since dictionary and set both use { and } and those are both used often I figured I'd push this for now. Fix tested locally with the fibonacci example by adding a dictionary filled with arbitrary values to the param list of the fibonacci function.

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

Successfully merging this pull request may close these issues.

1 participant