Skip to content

Commit

Permalink
Better docstrings in _can_save_etcetera
Browse files Browse the repository at this point in the history
  • Loading branch information
matteobachetti committed Oct 11, 2023
1 parent d707496 commit bd7f552
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion stingray/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit bd7f552

Please sign in to comment.