Skip to content

Commit

Permalink
Add docs to helper functions [docs only]
Browse files Browse the repository at this point in the history
  • Loading branch information
matteobachetti committed Oct 11, 2023
1 parent bd7f552 commit 59ec903
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions stingray/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,12 @@ def to_pandas(self) -> DataFrame:
Array attributes (e.g. ``time``, ``pi``, ``energy``, etc. for
``EventList``) are converted into columns, while meta attributes
(``mjdref``, ``gti``, etc.) are saved into the ``ds.attrs`` dictionary.
Since pandas does not support n-D data, multi-dimensional arrays are
converted into columns before the conversion, with names ``<colname>_dimN_M_K`` etc.
See documentation of `make_nd_into_arrays` for details.
"""
from pandas import DataFrame
from .utils import make_nd_into_arrays
Expand Down Expand Up @@ -423,6 +429,11 @@ def from_pandas(cls: Type[Tso], ts: DataFrame) -> Tso:
using the standard attributes of the wanted StingrayObject (e.g.
``time``, ``pi``, etc. for ``EventList``)
Since pandas does not support n-D data, multi-dimensional arrays can be
specified as ``<colname>_dimN_M_K`` etc.
See documentation of `make_1d_arrays_into_nd` for details.
"""
import re
from .utils import make_1d_arrays_into_nd
Expand Down
4 changes: 4 additions & 0 deletions stingray/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ def any_complex_in_array(array):
def make_nd_into_arrays(array: np.ndarray, label: str) -> dict:
"""If an array is n-dimensional, make it into many 1-dimensional arrays.
Call additional dimensions, e.g. ``_dimN_M``. See examples below.
Parameters
----------
array : `np.ndarray`
Expand Down Expand Up @@ -237,6 +239,8 @@ def get_dimensions_from_list_of_column_labels(labels: list, label: str) -> list:
def make_1d_arrays_into_nd(data: dict, label: str) -> np.ndarray:
"""Literally the opposite of make_nd_into_arrays.
Call additional dimensions, e.g. ``_dimN_M``
Parameters
----------
data : dict
Expand Down

0 comments on commit 59ec903

Please sign in to comment.