gudhi-devel icon indicating copy to clipboard operation
gudhi-devel copied to clipboard

[python] warnings

Open mglisse opened this issue 4 years ago • 3 comments

I just discovered (yes, I should learn python properly...) https://docs.python.org/3/library/warnings.html . That seems like a good fit for print("Warning: computing barycenter of empty diag set. Returns None") in barycenter.py.

mglisse avatar Apr 29 '20 10:04 mglisse

Noticed. I will do a PR incorporating soon.

tlacombe avatar May 07 '20 17:05 tlacombe

List of warnings candidates:

  • [X] https://github.com/GUDHI/gudhi-devel/blob/6b5b1c0f5d4a1652e668f3ee076ec7fb1b220096/src/python/gudhi/wasserstein/barycenter.py#L59
  • [ ] https://github.com/GUDHI/gudhi-devel/blob/6b5b1c0f5d4a1652e668f3ee076ec7fb1b220096/src/python/example/rips_complex_diagram_persistence_from_correlation_matrix_file_example.py#L46-L49
  • [ ] https://github.com/GUDHI/gudhi-devel/blob/6b5b1c0f5d4a1652e668f3ee076ec7fb1b220096/src/python/gudhi/representations/metrics.py#L172-L174
  • [ ] https://github.com/GUDHI/gudhi-devel/blob/6b5b1c0f5d4a1652e668f3ee076ec7fb1b220096/src/python/gudhi/representations/metrics.py#L179-L181
  • [ ] https://github.com/GUDHI/gudhi-devel/blob/6b5b1c0f5d4a1652e668f3ee076ec7fb1b220096/src/python/gudhi/representations/metrics.py#L297-L299
  • [ ] https://github.com/GUDHI/gudhi-devel/blob/6b5b1c0f5d4a1652e668f3ee076ec7fb1b220096/src/python/gudhi/representations/metrics.py#L420-L422
  • [ ] https://github.com/GUDHI/gudhi-devel/blob/6b5b1c0f5d4a1652e668f3ee076ec7fb1b220096/src/python/gudhi/wasserstein/wasserstein.py#L14-L17
  • [ ] https://github.com/GUDHI/gudhi-devel/blob/6b5b1c0f5d4a1652e668f3ee076ec7fb1b220096/src/python/test/test_simplex_tree.py#L548-L553 (TBD if there is some added value to warn in a unitary test)

VincentRouvreau avatar Aug 16 '23 09:08 VincentRouvreau

As discussed in #1096:

  • if we stick to print, it makes sense to at least print to file=sys.stderr.
  • in addition to the warnings module, there is also https://docs.python.org/3/library/logging.html , which may be more appropriate for some of the messages (not necessarily all)

mglisse avatar Jul 25 '24 17:07 mglisse