manoharan-lab / holopy

Hologram processing and light scattering in python
GNU General Public License v3.0
131 stars 50 forks source link

Fix output suppression from multisphere and DDA codes #433

Closed vnmanoharan closed 7 months ago

vnmanoharan commented 7 months ago

The SuppressOutput context manager was wreaking havoc with pytest. The problem, as noted in #403, is that the context manager closes stdout, which pytest (and ipython) expect to remain open. We originally did this because the multisphere code keeps outputting to stdout even when python attempts to redirect stdout to /dev/null. This is a general problem when wrapping fortran codes in python. This PR fixes this issue by removing the context manager and modifying the amncalc subroutine in scsmfo_min to not print anything unless it is told otherwise. The other place that the SuppressOutput context manager was used was in the code that interfaces with DDA. Since we call ADDA in a subprocess, the output can be suppressed by using the capture_output kwarg of subprocess.run().

Fixes #403. With these changes, pytest now runs, though there is some additional work to do to fully integrate it.

pep8speaks commented 7 months ago

Hello @vnmanoharan! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers:

Comment last updated at 2024-01-06 02:43:51 UTC