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

Visualization does not handle updates to a source file properly #163

Closed
skogsbaer opened this issue Dec 2, 2024 · 8 comments
Closed

Visualization does not handle updates to a source file properly #163

skogsbaer opened this issue Dec 2, 2024 · 8 comments
Labels
bug Something isn't working visualization

Comments

@skogsbaer
Copy link
Owner

Given this program:

def incByOneInPlace(l: list[int]) -> None:
    for i in range(len(l)):
        l[i] = l[i] + 1

x = [5, 3, 2, 0]
incByOneInPlace(x[:]) # swap x and x[:]

In todays lecture, I replaced x[:] with x and back. But the visualization sometimes displays this

Bildschirmfoto 2024-12-02 um 09 38 01

even though the file contains x and it sometimes displays

Bildschirmfoto 2024-12-02 um 09 39 07

although I wrote x[:]

I could not determine a pattern for this behavior.

@skogsbaer skogsbaer added bug Something isn't working visualization labels Dec 2, 2024
@hannesbraun
Copy link
Collaborator

As far as I can tell, two lists will be displayed for x[:], one list will be displayed for x. The reason for this is that x and x[:] have different identities.

x = [1, 2, 3]
print(id(x))
print(id(x[:]))

@skogsbaer
Copy link
Owner Author

Yes, that's true. But in the lecture, I noticed that the visualization sometimes seems not to pick up the last changes to a file. Given the program

x = [1,2,3]
y = x[:]

it displayed one list with two arrows pointing to it from x and y (which is wrong).

I think this was because I had the program

x = [1,2,3]
y = x

before, and the visualization still rendered the "old" program.

Is this possible?

@hannesbraun
Copy link
Collaborator

This should only be possible if both versions of the code have the same MD5 hash and the version with y = x was executed first. Otherwise, changes are automatically saved and the trace generator re-generates the trace if none is available in the cache for the hash of the input file.

The only thing that could have also happened is that you somehow had the old visualization still open, started the new visualization and somehow landed in the old tab (for whatever reason) as it won't be closed automatically. But I'm not sure how realistic that is.

@skogsbaer
Copy link
Owner Author

Can we (should we?) close the old visualization tab automatically? So that at most one visualization tab is visible?

@hannesbraun
Copy link
Collaborator

We can close the old visualization tab. But I'm not sure if we should. Keeping the old tab open leaves you with the option to open two tabs side by side for comparing some steps in case someone wants to do this. I'd personally not close the tab automatically. But ultimately, I'm open to whatever you think is the better solution.

@skogsbaer
Copy link
Owner Author

But the old visualization tab typically refers to code that is now no longer available. When we step through the old visualization, we highlight lines in a source file that might not correspond to the visualization at all.

@hannesbraun
Copy link
Collaborator

Hmm, yes, this is true. Maybe we should close it then as soon as we open a new one...

@skogsbaer
Copy link
Owner Author

Hmm, yes, this is true. Maybe we should close it then as soon as we open a new one...

Yes, I would prefer this solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working visualization
Projects
None yet
Development

No branches or pull requests

2 participants