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

magic command reset is not working #13087

Open
dmytroxshevchuk opened this issue Aug 9, 2021 · 1 comment
Open

magic command reset is not working #13087

dmytroxshevchuk opened this issue Aug 9, 2021 · 1 comment

Comments

@dmytroxshevchuk
Copy link

I found that %reset -f command not working. I see in docs and in namespace.py file instruction how to use reset command and expected result, its looks like:

In [9]: %reset -f
In [1]: 

So I expect that after %reset -f command, number in [9] must be reset and will be [1].
In my case its looks like:

In [35]: %reset -f
In [36]:

So, this number is not reset after magic command. Arguments like --aggressive and -s is not help.

Also in docs I found that must be created new session:

By default (without this option), we do a ‘hard’ reset, giving you a new session and removing all references to objects from the current session.

But I go through the code and found that by default we send new_session = False:

if 's' in opts: # Soft reset
user_ns = self.shell.user_ns
for i in self.who_ls():
del(user_ns[i])
elif len(args) == 0: # Hard reset
self.shell.reset(new_session=False, aggressive=("aggressive" in opts))

How can I restart session, reset [n] value or fully clear caches/modules without restart main application?

@MrMino
Copy link
Member

MrMino commented Aug 31, 2021

Judging by %reset docstring, this is a regression. And, wow, it's an old one.

  • The new_session=False goes back to b24bd65 (10 years back). It's the first commit which breaks the magic.
  • It works on the previous commit, a6a440b.

I'm not sure what's the context of the b24bd65 change. In any case, I think that given the docstring and the fact that, intuitively, a reset should get the console back to its initial state, I can safely mark this as a bug.

Currently new_session=True would also have a small quirk, where it resets to [2] instead of [1]. Something to look into if we ever get the True back. In Jupyter Notebook, the cell with %reset gets [1], which leads me to believe that simply, the new session starts before the counter is incremented, and the magic should prevent that somehow.

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

No branches or pull requests

2 participants