WIP: Issue 1323 optest#1334
Conversation
|
Bump. Would be nice to get some feedback. |
| # Copyright 2014-2017 The ODL contributors | ||
| # coding: utf-8 | ||
|
|
||
| # Copyright 2014-2017 The ODL contributors |
| """Print message if ``self.verbose == True``.""" | ||
| if self.verbose: | ||
| print(message) | ||
| VERBOSITY_LEVELS = {'DEBUG': 0, 'INFO': 1, 'CHECK': 2, 'WARNING': 3, |
There was a problem hiding this comment.
These are not exported. Is that on purpose? Also, shouldn't these be the same for all the things in diagnostics? Move to a unified file.
| """Estimate the operator norm of the operator. | ||
|
|
||
| The norm is estimated by calculating | ||
| #TODO: add `logfile` parameter |
| logger=self.log) as counter: | ||
| log('', level='SECTION') | ||
| log('Linearity', level='SECTION') | ||
| log('=' * log_linewidth, level='SECTION') |
There was a problem hiding this comment.
Stuff like this has to be solvable in a much nicer way. Perhaps create a log object with some standard calls (e.g. log.new_section('Linearity'), that would make this so much more readable
|
|
||
| # --- Basic properties --- # | ||
|
|
||
| num_failed += _check_cond( |
There was a problem hiding this comment.
Perhaps we could have a utility class for this that contains all executed tests, e.g.
test_history = TestHistory()
test_history.append(_check_cond(...))
print(test_history.num_failed) # 1
|
|
||
| log('', level='SECTION') | ||
| log('Basic properties', level='SECTION') | ||
| log('=' * log_linewidth, level='SECTION') |
There was a problem hiding this comment.
These 3 line logs should be replacable by something standardized to save lots of space and copy-paste code
| kwargs={'verbosity': verbosity, 'deriv_arg': deriv_arg}, | ||
| verbosity=verbosity) | ||
|
|
||
| log('## Getting operator properties...', level='DEBUG') |
There was a problem hiding this comment.
How about using a format like "with (something)" that indents the strings inside it? E.g.
## Getting operator properties...
Got derivative
## Done
| level=failed_level) | ||
|
|
||
| return dict(num_failed=num_failed, | ||
| deriv=deriv, inverse=inverse, adjoint=adjoint) |
|
|
||
| denom = opnorm * (x.norm() + y.norm()) | ||
| if denom == 0: | ||
| denom = 1.0 |
| Wikipedia article on `Adjoint | ||
| <https://en.wikipedia.org/wiki/Adjoint>`_. | ||
| """ | ||
| opnorm = op.norm(estimate=False) |
There was a problem hiding this comment.
There is a utility that does this (in this file)
This is an attempt at improving our
diagnosticsmodule. It's work in progress, and I'm curious what others think about the output and the workflow.Here's what I think is better:
OpTestclass is gone, instead everything is implemented with plain functions.norm()being executed before, and it would also fail for nonlinear operators.'DEBUG'which prints A LOT, to'QUIET', which only prints the number of failures.Here's an example:
Output is here
TODO:
{'num_failed': <number of failed tests>}. Maybe some more details would be nice, like number of tests run, elapsed time, or even a list of checks, each with timing and result.Input on this is appreciated!
Updated TODO: try all of the above and see how it goes
examplesin all spaces where definedFrom review:
Loggerclass (or functions) for verbosity level specific logging, to make the code cleanerTestHistoryfor convenient storage (and output) of test results_get_...)Ping @adler-j @aringh @sbanert
Related issues: #1323, #526, #717, #340, #339