Remove default variables from Spyder Variable Explore - python

Is there a specific code or a setting on Spyder that can remove the default variables from the variables explorer?
I have changed the settings so that all variables are cleared each time I click run but the variable explore shows some default values (e.g values such pi, e, euler_gamma, cast, ScalarType and many more).
I have tried to play around with the settings and search on google but can't find any solution.
See screenshot (all the default variables have been highlighted)

I found the answer, you need to untick the following box in SpyderIDE preferences:
Tools > Preferences > IPython console > Graphics > Automatically load Pylab and NumPy modules

Related

Defined Variable's Existence not Acknowledged by Spyder

I am simply attempting to define a variable in Python. I am using Spyder and in the variable explorer, the defined variable "V0Z" does not show up at all. There is no error message that appears and I double checked my math by plugging in the definition into Wolfram Alpha and it gives me a real number (1.5E+7). Why is Python refusing to acknowledge it?
Code:
import numpy as np
MirrorAngle = 30
V0X = 1E7
MirrorAngleRad = MirrorAngle*(np.pi/180)
V0Z = (np.abs(V0X)/np.abs(np.sin(MirrorAngleRad)))*(1 - np.sin(MirrorAngleRad)**2)
Screenshot of what I see:
Spyder's Variable Explorer doesn't show all-uppercase variables by default. You can change this in the hamburger menu on the pane, just uncheck the box to hide those variables:
The likely reason all-caps variables are hidden by default is that many style guides recommend all-caps for constants, so they'll never change during the lifetime of a program. That would make monitoring them in the variable explorer pretty pointless.

How to find the variables I created in Pycharm variable explorer?

I am trying to use the variable explorer in PyCharm.
I click on python console and I have a window for the variables.
However, the variables that I created in my code do not appear, only built in variables appear. (Under special variables, there is: builtins and sys)
Where can I find the variables that appear in my code?
The specific variable I'm looking for is a dictionary called "data_model".
It is created within the program and filled during runtime.
You can run the code in python console and then you will be able to see all the variables (along side builtin variables). By default it will only show builtin and sys variables and as you run the code in python console, it will show the variables.
The dictionary view is not great I think but in pandas dataframe you will be able to right click on variable and click on 'view as a dataframe' which puts the dataframe in a new window.

How to see value of the constant hovering on it somewhere in the code? [Pycharm IDE]

I've declared variable as a constant in the module beginning and some hundreds lines below I want to see it's value.
I know that it's possible to use ctrl and LMB to jump directly to declaration, but it's so distracting!
When I move mouse over variable's occurence with ctrl btn pressed I get only name and inferred type. I believe there is some way to see the value too.
I've found keyboard combination suitable for my needs.
Click on the variable somewhere in the code and use ctrl+shift+i to see constant's definition with all its values included. Especially useful if this const was imported from other module so you don't have to jump to the declaration source.
On Mac OS it is ⌥ + Space.
While you run your code in debugging mode use inline debugging functionality. This should lets you view the value of variables used in your source code right next to their usage, without having to switch to the Variables pane of the Debug tool window.
Enabling inline debugging
To enable it in Debug tool window toolbar click the Settings icon -> select the Show Values Inline option from the popup menu.
And then go to Data Views page in Setting/Preferences dialog select check box Show values inline.

Plotly + iPython Notebook - Plots Disappear on Reopen

When I create a notebook with plotly plots, save and reopen the notebook, the plots fail to render upon reopening - there are just blank blocks where the plots should be. Is this expected behavior? If not, is there a known fix?
Check to make sure your notebook is marked as "trusted", either in the top-right corner of the notebook, or in the File menu.
My notebooks are trusted by default, but I managed to reproduce your observed behaviour by temporarily removing my ~/Library/Jupyter/nbsignatures.db file, which forces Jupyter to run the notebook as untrusted. Clicking the tile in the top-right corner to trust the notebook fixed the issue for me.
This page in the jupyter docs, Security in notebook documents explains further:
The security problem we need to solve is that no code should execute just because a user has opened a notebook that they did not write. Like any other program, once a user decides to execute code in a notebook, it is considered trusted, and should be allowed to do anything.
I also meet this annoying issue. I find no way to reveal them on the notebook, but I find a compromise way to display them on an html page that is File -> Print Preview.
The reason as documented here:
Note: Default renderers persist for the duration of a single session,
but they do not persist across sessions. If you are working in an
IPython kernel, this means that default renderers will persist for the
life of the kernel, but they will not persist across kernel restarts.
As indicated in the troubleshooting documentation, "JupyterLab Problems" section, You have two options to solve the problem:
calling fig.show("notebook") instead of just fig.show().
If this problem is recurrent, you can use this:
import plotly.io as pio
pio.renderers.default='notebook'
Credits for here

Can't find TF_MIN_GPU_MULTIPROCESSOR_COUNT

I get a message that says my GPU Device is ignored because its multiprocessor count is lower than the minimum set. However, it gives me the environment variable TF_MIN_GPU_MULTIPROCESSOR_COUNT but it doesn't seem to exist because I keep getting command not found. When I look at the environment variables using set or printenv and grep for the variable name, it doesn't exist. Does anyone know where I can find it or how I can change its set value?
Do something like this before running your main script
export TF_MIN_GPU_MULTIPROCESSOR_COUNT=4
Note though that the default is set for a reason -- if you enable slower GPU by changing that variable, your program may run slower than it would without any GPU available, because TensorFlow will try to put run everything on that GPU
In windows, create a new environmental variable with this name and assign its value.
You can do that by right clicking on the This PC in File Explorer, select Properties at bottom, then select Advanced system settings on left. That will get you to the System Properties dialog. Also you can type "environmental properties" in Cortana Search.
From there you click the Environmental Variables button. Once in the Environmental Variables dialog, select new to create the variable and assign the value, then back out. You may have to restart your IDE or open a new DOS window for that environmental variable to be visible.

Categories

Resources