Defined Variable's Existence not Acknowledged by Spyder - python

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.

Related

How to show variables in Python Console after running code in Pycharm?

I am having a problem in PyCharm (2022.3.1) that the variables of my code are not showing in the right-bottom area of "Variables" in Python Console in PyCharm.
This function is extremely useful when coding. You can keep track of the changes and data-type of your variables.
How to solve it?
The problem mentioned was solved and I will described, here, how to do it:
I ran a simple code with two variables. The code runs fine but the variables do not show (in the red circle area, as they should be).
Se this first first screenshot
If I add a new variables manually in the Python Console it will show in the variable area as it shows
So how did I solve this issue?
You will need to change the Debug configurations as shown here, and check the box "Run with Python Console", then Apply, Ok.
After that when you run your code, your variables will be shown in the variables tab at the bottom-right-corner, as shown here.
After that you will also be able to type new variables in the Python Console and they will immediately be shown in the variable tab.

Remove default variables from Spyder Variable Explore

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

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.

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