Skip to content

Commit a74b6b7

Browse files
committed
DOC: Add Bento object docs and refine descriptions
1 parent 0e53768 commit a74b6b7

File tree

1 file changed

+18
-27
lines changed

1 file changed

+18
-27
lines changed

databento/common/bento.py

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def reader(self, decompress: bool = False) -> BinaryIO:
113113

114114
def writer(self) -> BinaryIO:
115115
"""
116-
Return a raw I/O writer for the data.
116+
Return an I/O writer for the data.
117117
118118
Returns
119119
-------
@@ -124,6 +124,14 @@ def writer(self) -> BinaryIO:
124124

125125
@property
126126
def nbytes(self) -> int:
127+
"""
128+
Return the size of the data in bytes.
129+
130+
Returns
131+
-------
132+
int
133+
134+
"""
127135
raise NotImplementedError() # pragma: no cover
128136

129137
@property
@@ -181,7 +189,7 @@ def metadata(self) -> Dict[str, Any]:
181189
@property
182190
def dataset(self) -> str:
183191
"""
184-
Return the dataset name.
192+
Return the dataset code.
185193
186194
Returns
187195
-------
@@ -317,7 +325,7 @@ def limit(self) -> Optional[int]:
317325
@property
318326
def encoding(self) -> Encoding:
319327
"""
320-
Return the encoding for the data.
328+
Return the data encoding.
321329
322330
Returns
323331
-------
@@ -333,7 +341,7 @@ def encoding(self) -> Encoding:
333341
@property
334342
def compression(self) -> Compression:
335343
"""
336-
Return the compression mode for the data.
344+
Return the data compression mode.
337345
338346
Returns
339347
-------
@@ -441,11 +449,11 @@ def to_df(self, pretty_ts: bool = False, pretty_px: bool = False) -> pd.DataFram
441449
Parameters
442450
----------
443451
pretty_ts : bool, default False
444-
If the type of any timestamp columns should be converted from UNIX
445-
nanosecond `int` to `pd.Timestamp` (UTC).
452+
If all timestamp columns should be converted from UNIX nanosecond
453+
`int` to `pd.Timestamp` tz-aware (UTC).
446454
pretty_px : bool, default False
447-
If the type of any price columns should be converted from `int` to
448-
`float` at the correct scale (using the fixed precision scalar 1e-9).
455+
If all price columns should be converted from `int` to `float` at
456+
the correct scale (using the fixed precision scalar 1e-9).
449457
450458
Returns
451459
-------
@@ -598,7 +606,7 @@ def to_json(self, path: str) -> None:
598606

599607
class MemoryBento(Bento):
600608
"""
601-
Provides a data container backed by in-memory buffer streaming I/O.
609+
Provides data streaming I/O operations backed by an in-memory buffer.
602610
603611
Parameters
604612
----------
@@ -613,15 +621,6 @@ def __init__(self, initial_bytes: Optional[bytes] = None):
613621

614622
@property
615623
def nbytes(self) -> int:
616-
"""
617-
Return the amount of space in bytes that the data array would use in a
618-
contiguous representation.
619-
620-
Returns
621-
-------
622-
int
623-
624-
"""
625624
return self._buffer.getbuffer().nbytes
626625

627626
@property
@@ -641,7 +640,7 @@ def writer(self) -> BinaryIO:
641640

642641
class FileBento(Bento):
643642
"""
644-
Provides a data container backed by file streaming I/O.
643+
Provides data streaming I/O operations backed by a file on disk.
645644
646645
Parameters
647646
----------
@@ -668,14 +667,6 @@ def path(self) -> str:
668667

669668
@property
670669
def nbytes(self) -> int:
671-
"""
672-
Return the amount of space occupied by the data.
673-
674-
Returns
675-
-------
676-
int
677-
678-
"""
679670
return os.path.getsize(self._path)
680671

681672
@property

0 commit comments

Comments
 (0)