Hi,
I'm trying to use Sfepy in a Doctest example. It would be nice to turn off Sfepy output to reduce the noise in the Docs. The code I'm using is here,
https://github.com/wd15/pymks/blob/993e4b43beed9db4ed0402b846b66d7723d8e361/...
I've managed to turn off most of the output using
goptions['verbose'] = False
and
gen_block_mesh((Lx, Ly), shape, center, verbose=False)
Unfortunately, the following still remains
sfepy: matrix shape: (199, 199)
sfepy: assembling matrix graph...
sfepy: ...done in 0.00 s
sfepy: matrix structural nonzeros: 5631 (1.42e-01% fill)
I can't figure out how to turn off the above four lines. Any ideas?
Thanks
-- Daniel Wheeler
Hi!
Three things interact here in an undesired way:
- output() can take a "verbose" bool argument, that has precedence over goptions['verbose'] (that is good)
- Equations.create_matrix_graph() has also a verbose argument, with True as default
- Problem.time_update() has no verbose argument and calls Equations.create_matrix_graph() with the True default.
So this needs to be fixed. I am not sure yet how - in past many functions got verbose arguments (with differing default values and differing call values). Possibilities are, for example:
a) Add verbose to all top level functions (Problem methods etc.) that lack it now, and make all the defaults None so that goptions['verbose'] is not overrided if the argument is not set explicitly by the user. b) Remove all verbose arguments, and use only goptions['verbose'].
Historically, goptions['verbose'] was added as a poor man's solution for silencing output of functions without verbose argument.
I am more in favour of a), what do you think?
Btw. you can monkey-patch the code for the time being by using
self.mtx_a = self.equations.create_matrix_graph(verbose=False)
instead of
self.mtx_a = self.equations.create_matrix_graph()
in Problem.update_equations().
r.
On 05/27/2014 06:51 PM, Daniel Wheeler wrote:
Hi,
I'm trying to use Sfepy in a Doctest example. It would be nice to turn off Sfepy output to reduce the noise in the Docs. The code I'm using is here,
https://github.com/wd15/pymks/blob/993e4b43beed9db4ed0402b846b66d7723d8e361/...
I've managed to turn off most of the output using
goptions['verbose'] = False
and
gen_block_mesh((Lx, Ly), shape, center, verbose=False)
Unfortunately, the following still remains
sfepy: matrix shape: (199, 199) sfepy: assembling matrix graph... sfepy: ...done in 0.00 s sfepy: matrix structural nonzeros: 5631 (1.42e-01% fill)
I can't figure out how to turn off the above four lines. Any ideas?
Thanks
On Tue, May 27, 2014 at 5:15 PM, Robert Cimrman <cimr...@ntc.zcu.cz> wrote:
Hi!
Three things interact here in an undesired way:
- output() can take a "verbose" bool argument, that has precedence over goptions['verbose'] (that is good)
- Equations.create_matrix_graph() has also a verbose argument, with True as default
- Problem.time_update() has no verbose argument and calls Equations.create_matrix_graph() with the True default.
So this needs to be fixed. I am not sure yet how - in past many functions got verbose arguments (with differing default values and differing call values). Possibilities are, for example:
a) Add verbose to all top level functions (Problem methods etc.) that lack it now, and make all the defaults None so that goptions['verbose'] is not overrided if the argument is not set explicitly by the user. b) Remove all verbose arguments, and use only goptions['verbose'].
Historically, goptions['verbose'] was added as a poor man's solution for silencing output of functions without verbose argument.
I am more in favour of a), what do you think?
Not in agreement with you on that. I don't think that passing a verbose argument to every function is a good idea. I think the idea expressed here is the way to go
http://stackoverflow.com/questions/5980042/how-to-implement-the-verbose-or-v-option-into-a-script
Define a function in one place for printing, but which is defined differently based on the verbose flag. My feeling is that the verbose flag should be managed in one location. I'm in favour of setting environment variables and passing command line arguments to change the verbosity. I'm not really sold on the global options either, I think I prefer command line options or environment variables for defining global options. Not sure why, but it seems like what they were designed for.
Btw. you can monkey-patch the code for the time being by using
self.mtx_a = self.equations.create_matrix_graph(verbose=False)
instead of
self.mtx_a = self.equations.create_matrix_graph()
in Problem.update_equations().
Thanks. Shall I submit a pull request for that?
-- Daniel Wheeler
On 05/28/2014 05:49 PM, Daniel Wheeler wrote:
On Tue, May 27, 2014 at 5:15 PM, Robert Cimrman <cimr...@ntc.zcu.cz> wrote:
Hi!
Three things interact here in an undesired way:
- output() can take a "verbose" bool argument, that has precedence over goptions['verbose'] (that is good)
- Equations.create_matrix_graph() has also a verbose argument, with True as default
- Problem.time_update() has no verbose argument and calls Equations.create_matrix_graph() with the True default.
So this needs to be fixed. I am not sure yet how - in past many functions got verbose arguments (with differing default values and differing call values). Possibilities are, for example:
a) Add verbose to all top level functions (Problem methods etc.) that lack it now, and make all the defaults None so that goptions['verbose'] is not overrided if the argument is not set explicitly by the user. b) Remove all verbose arguments, and use only goptions['verbose'].
Historically, goptions['verbose'] was added as a poor man's solution for silencing output of functions without verbose argument.
I am more in favour of a), what do you think?
Not in agreement with you on that. I don't think that passing a verbose argument to every function is a good idea. I think the idea expressed here is the way to go
http://stackoverflow.com/questions/5980042/how-to-implement-the-verbose-or-v-option-into-a-script
Define a function in one place for printing, but which is defined differently based on the verbose flag. My feeling is that the verbose flag should be managed in one location. I'm in favour of setting environment variables and passing command line arguments to change the verbosity. I'm not really sold on the global options either, I think I prefer command line options or environment variables for defining global options. Not sure why, but it seems like what they were designed for.
Actually, this is already possible - all prints are done using the output() object (from sfepy.base.base). You can silence it (and also redirect to a file) by calling output.set_output():
from sfepy.base.base import output
output.set_output(quiet=True)
etc.
Adding a verbose (or quiet or print-mode to allow also file output?) argument to simple.py and other scripts is a good idea and could be easily implemented using the above.
Btw. you can monkey-patch the code for the time being by using
self.mtx_a = self.equations.create_matrix_graph(verbose=False)
instead of
self.mtx_a = self.equations.create_matrix_graph()
in Problem.update_equations().
Thanks. Shall I submit a pull request for that?
It would need adding the verbose argument to time_update() and update_equations(). I still consider the option a) as well, as sometimes I did need to see output of some functions while silencing other functions. Contributions are welcome, of course :)
r.
participants (2)
-
Daniel Wheeler
-
Robert Cimrman