From bd7f552241e20e6ea19a11c0dfbe02542c8c97b0 Mon Sep 17 00:00:00 2001 From: Matteo Bachetti Date: Mon, 9 Oct 2023 16:24:33 +0200 Subject: [PATCH] Better docstrings in _can_save_etcetera --- stingray/base.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/stingray/base.py b/stingray/base.py index 713745a61..92fc14eef 100644 --- a/stingray/base.py +++ b/stingray/base.py @@ -32,7 +32,15 @@ def _can_save_longdouble(probe_file: str, fmt: str) -> bool: - """Check if a given file format can save tables with longdoubles.""" + """Check if a given file format can save tables with longdoubles. + + Try to save a table with a longdouble column, and if it doesn't work, catch the exception. + If the exception is related to longdouble, return False (otherwise just raise it, this + would mean there are larger problems that need to be solved). In this case, also warn that + probably part of the data will not be saved. + + If no exception is raised, return True. + """ if not HAS_128: # pragma: no cover # There are no known issues with saving longdoubles where numpy.float128 is not defined return True @@ -55,6 +63,14 @@ def _can_save_longdouble(probe_file: str, fmt: str) -> bool: def _can_serialize_meta(probe_file: str, fmt: str) -> bool: + """ + Try to save a table with meta to be serialized, and if it doesn't work, catch the exception. + If the exception is related to serialization, return False (otherwise just raise it, this + would mean there are larger problems that need to be solved). In this case, also warn that + probably part of the data will not be saved. + + If no exception is raised, return True. + """ try: Table({"a": [3]}).write(probe_file, overwrite=True, format=fmt, serialize_meta=True)