Skip to content

Commit

Permalink
add doc strings, MemoryDisplay to public namespace, DOCUMENTED_COMPON…
Browse files Browse the repository at this point in the history
…ENTS
  • Loading branch information
flexatone committed Oct 3, 2022
1 parent 800f92b commit f345e61
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def get_defined() -> tp.Set[str]:
sf.IndexAutoConstructorFactory,
sf.NPZ,
sf.NPY,
sf.MemoryDisplay,
sf.Platform,
)

Expand Down
1 change: 1 addition & 0 deletions static_frame/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
from static_frame.core.index_hierarchy import IndexHierarchy as IndexHierarchy
from static_frame.core.index_hierarchy import IndexHierarchyGO as IndexHierarchyGO
from static_frame.core.interface_meta import InterfaceMeta as InterfaceMeta
from static_frame.core.memory_measure import MemoryDisplay as MemoryDisplay
from static_frame.core.node_dt import InterfaceBatchDatetime
from static_frame.core.node_dt import InterfaceDatetime
from static_frame.core.node_fill_value import InterfaceFillValue
Expand Down
2 changes: 1 addition & 1 deletion static_frame/core/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _memory_label_component_pairs(self,

@property
def memory(self) -> MemoryDisplay:
'''Return size in memory of this object. For compound containers, component sizes will also be provioded. Size can be interpreted through six combinations of three configurations:
'''Return a :obj:`MemoryDisplay`, providing the size in memory of this object. For compound containers, component sizes will also be provided. Size can be interpreted through six combinations of three configurations:
L: Local: memory ignoring referenced array data provided via views.
LM: Local Materialized: memory where arrays that are locally owned report their byte payload
Expand Down
9 changes: 9 additions & 0 deletions static_frame/core/memory_measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ def gen() -> tp.Iterator[int]:
return sum(gen())

class MemoryDisplay:
'''A simple container of capturing memory usage in bytes for StaticFrame container.
'''

__slots__ = (
'_frame',
Expand All @@ -211,6 +213,9 @@ def from_any(cls,
obj: tp.Any,
label_component_pairs: tp.Iterable[tp.Tuple[str, tp.Any]],
) -> 'MemoryDisplay':
'''Given any slotted object, return a ``MemoryDisplay`` instance.
'''
from static_frame.core.frame import Frame

parts = chain(label_component_pairs, (('Total', obj),))
Expand All @@ -236,6 +241,8 @@ def gen() -> tp.Iterator[tp.Tuple[tp.Tuple[str, ...], tp.List[int]]]:
return cls(f)

def __init__(self, frame: 'Frame'):
'''Initialize an instance with a ``Frame`` of byte counts.
'''
self._frame = frame

dc = DisplayConfig(type_show=False)
Expand All @@ -248,5 +255,7 @@ def __repr__(self) -> str:
return self._repr

def to_frame(self) -> 'Frame':
'''A return a Frame of bytes counts.
'''
return self._frame

0 comments on commit f345e61

Please sign in to comment.