Inquiry About How to Disable Print Function in Pypower

4 views
Skip to first unread message

Talihati, Baligen

unread,
Oct 22, 2025, 1:18:00 PMOct 22
to pyp...@googlegroups.com

Dear Pypower Team,

Hello!

First of all, I would like to express my sincere gratitude for developing Pypower. I used it in a previous project, and I am very grateful for that. I have cited the paper by R. D. Zimmerman et al. as required on your GitHub page (please let me know if I need to cite any other works).

However, there is one feature of Pypower that has been troubling me. Due to the urgent nature of my previous work, I did not reach out to you at that time. But since I am about to use Pypower again for another project, I would like to seek your assistance. The issue is that Pypower prints power flow information for each node every time it is called. I have tried various methods to disable this feature without success. I will be using AI methods that may involve a very large number of training iterations, and having this information printed every time is quite frustrating and also consumes a significant amount of memory. Since I will be using Pypower again soon, I would like to ask if there is any way to freely disable this print function. It is very useful when debugging algorithms, but it drives me crazy when running the entire loop.

I would greatly appreciate it if you could reply and provide some suggestions. Looking forward to your response.

Have a good day!!

Best, Baligen

 

David Chassin

unread,
Oct 22, 2025, 1:44:00 PMOct 22
to pyp...@googlegroups.com
Hi Baligen,

I ran into this problem when running solvers in Marimo as part of an attempt to create an API for pypower. The issue is how some modules in pypower import sys. When a module uses import sys, the import is local and changing sys.stdout in your module to something else doesn’t affect the copy in the pypower modules you import. You basically have to set each module’s sys.stdout separately to sys.devnull (or a file handle if you prefer). This can be tedious and is probably not how it should be done anyway—but at least it’s a possible workaround. 

If you search the pypower repository you can find all the offending "sys.std{out,err}.write" statements to find which modules you need to update “sys.stdout" after you import it. If I remember correctly there are about a dozen such modules.  A quick search for "sys.std(out|err).write" yields the following files in which you would have to modify “sys.stdout" and “sys.stderr" through the module you’re importing—not a trivial task.

cps_callbacks.py
e2i_data.py
ext2int.py
fpdf.py
gausspf.py
i2e_data.py
int2ext.py
loadcase.py
modcost.py
newtonpf.py
polycost.py
qps_pypower.py

I started trying to fix this some months ago but I haven’t finished it and made a PR for it yet.  If I do that, would you be willing to review it before it’s merged?

Thanks,
Dave
_____________________________
David P. Chassin, PhD

PastedGraphic-4.png
7443 87th Dr NE
Marysville, WA 98270 (USA)
www.eudoxys.com
1+425-474-9298





-- 
You received this message because you are subscribed to the Google Groups "pypower" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pypower+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pypower/DM6PR02MB5420F2F0BD8F4E2F6A1B7911EDF3A%40DM6PR02MB5420.namprd02.prod.outlook.com.

Richard Lincoln

unread,
Oct 22, 2025, 3:35:52 PMOct 22
to pyp...@googlegroups.com
opt = ppoption(OUT_ALL=0, VERBOSE=0)

should prevent most (all?) messages from being printed.

--

David Chassin

unread,
Oct 22, 2025, 5:05:03 PMOct 22
to pyp...@googlegroups.com
When I encountered the problem Baligen describes, I found that not all output is suppressed by the options.  

Reply all
Reply to author
Forward
0 new messages