These are chat archives for spyder-ide/public

14th
May 2019
Rohan
@RohanVB
May 14 00:40
That's some great info. Thanks!
CAM Gerlach
@CAM-Gerlach
May 14 00:49
Best of luck!
Massimo Pinto
@massimopinto
May 14 07:48
Hi community, how do I make real time code analysis be aware of the variables that I have imported from a .spydata file? I have a lot of 'undefined name' warnings which are not helpful since the name is there among all other variables. Running spyder 3.3.4, cheers.
seabirdman
@seabirdman
May 14 14:12
I am interested in implementing several image analysis filters and visualizations to color images. I am not a programmer per se but a fast learner. Ideally, I could run an environment that lets me load images and quickly build come custom filters by editing or replacing some existing filters with my code. Am I even in the right place to do this?
CAM Gerlach
@CAM-Gerlach
May 14 16:09

@massimopinto This is by design; a static analyzer can only see what's actually present in your code, rather than any "magic" steps you may do manually (like importing variables from a .spydata file), i.e. the exact sort of things you want to avoid if you want to have stable, reproducible and reusable code. While its fine to save and load your session to same computation time when running your code dynamically, you still want your actual code to work reproducible independent of having to load a particular saved session in a particular IDE.

For example, what I often do in situations where repeated recomputation is expensive when testing my code is have "checkpoints" in my high-level script after each major expensive processing stage (typically organized into Spyder code cells) where I save the primary data structure(s) (e.g. my main dataframe(s)) and reload it at the beginning of the next stage/code cell, e.g. using joblib.dump/joblib.load or pickle.dump/pickle.load). This not only keeps pyflakes happy (and ensures you easily see other errors), but avoids the manual labor of saving and reloading and allows me to easily perform my processing/data analysis in self-contained stages.

Alternatively, you could execute the Spydata import directly in the code and access the result as a dictionary or namespace (possibly assigning items to local variable names as desired). The functions to call are in spyder_kernels.utils.iofuncsand are load_dict and save_dict (you might need to coerce your namespace to a dict). However, it is much cleaner, more efficient, safer and easier over the long term to implement something like the former.

Hope this is helpful at resolving this!

Massimo Pinto
@massimopinto
May 14 16:27
@CAM-Gerlach that is very nicely put, thank you. I will opt for your first set of advice so that I can also adopt a makefile approach.
CAM Gerlach
@CAM-Gerlach
May 14 17:27
@seabirdman I'm not really sure. Spyder isn't really a dedicated raster processing system like e.g. QGIS , but there are many common packages in Python that are dedicated to image processing, like pillow (which Spyder has integration with), scikit-image, and others. However, of course, you're going to need to know at least some programming to do what you want, that's just a fact of life unless you use expensive, less flexible pre-made tools.