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

First time using this - Python #240

Open
raydzai opened this issue Feb 9, 2025 · 1 comment
Open

First time using this - Python #240

raydzai opened this issue Feb 9, 2025 · 1 comment

Comments

@raydzai
Copy link

raydzai commented Feb 9, 2025

Image
This is my first time using this extension. I'm trying to display the array y as a table, but it looks like a complete mess... Can someone guide me on how to use this?

@Klummel69
Copy link

Note: the data must be transferred to the Visualizer as a json string for languages that only support BasicSupport.
For the structure of json strings, see Visualization Playground Otherwise the Visualizer cannot display the data correctly.

The attached example uses the visualizeArray() function to create the json string. In the debugger, the call visualizeArray(y) must be specified instead of the variable y.

Image
# Demo for visualization of an array by using VS Code Debug Visualizer.
# ⚠️ Attention: the transfer to the Visualizer must be made as a json string 
# for languages that only support BasicSupport. 

import json

def visualizeArray(arr):
    """Serialize an array into a format the visualizer can understand."""
    formatted = {
        "kind": {"grid": True},
        "rows": [
            {
                "columns": [
                    {"content": str(value), "tag": str(value)} for value in arr
                ],
            }
        ],
    }
    return json.dumps(formatted)

y = [10,20,30]
y = [10,20,30,40]
y = [10,99,30,-3]
y = [0,99,30,-3, 4, 62]

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

No branches or pull requests

2 participants