forked from goodboy/tractor
1
0
Fork 0

Updates from latest `piker.data._sharedmem` changes

asyncio_debugger_support
Tyler Goodlet 2023-06-22 17:16:17 -04:00
parent fc56971a2d
commit ac695a05bf
1 changed files with 19 additions and 14 deletions

View File

@ -287,9 +287,9 @@ class ShmArray:
self, self,
fields: Optional[list[str]] = None, fields: Optional[list[str]] = None,
# type that all field values will be cast to in the returned # type that all field values will be cast to
# view. # in the returned view.
common_dtype: np.dtype = np.float64, # type: ignore common_dtype: np.dtype = float,
) -> np.ndarray: ) -> np.ndarray:
@ -344,7 +344,7 @@ class ShmArray:
field_map: Optional[dict[str, str]] = None, field_map: Optional[dict[str, str]] = None,
prepend: bool = False, prepend: bool = False,
update_first: bool = True, update_first: bool = True,
start: Optional[int] = None, start: int | None = None,
) -> int: ) -> int:
''' '''
@ -386,7 +386,11 @@ class ShmArray:
# tries to access ``.array`` (which due to the index # tries to access ``.array`` (which due to the index
# overlap will be empty). Pretty sure we've fixed it now # overlap will be empty). Pretty sure we've fixed it now
# but leaving this here as a reminder. # but leaving this here as a reminder.
if prepend and update_first and length: if (
prepend
and update_first
and length
):
assert index < self._first.value assert index < self._first.value
if ( if (
@ -460,10 +464,10 @@ class ShmArray:
def open_shm_ndarray( def open_shm_ndarray(
key: Optional[str] = None, size: int,
size: int = int(2 ** 10), key: str | None = None,
dtype: np.dtype | None = None, dtype: np.dtype | None = None,
append_start_index: int = 0, append_start_index: int | None = None,
readonly: bool = False, readonly: bool = False,
) -> ShmArray: ) -> ShmArray:
@ -529,9 +533,12 @@ def open_shm_ndarray(
# ``ShmArray._start.value: int = 0`` and the yet-to-be written # ``ShmArray._start.value: int = 0`` and the yet-to-be written
# real-time section will start at ``ShmArray.index: int``. # real-time section will start at ``ShmArray.index: int``.
# this sets the index to 3/4 of the length of the buffer # this sets the index to nearly 2/3rds into the the length of
# leaving a "days worth of second samples" for the real-time # the buffer leaving at least a "days worth of second samples"
# section. # for the real-time section.
if append_start_index is None:
append_start_index = round(size * 0.616)
last.value = first.value = append_start_index last.value = first.value = append_start_index
shmarr = ShmArray( shmarr = ShmArray(
@ -640,9 +647,7 @@ def attach_shm_ndarray(
def maybe_open_shm_ndarray( def maybe_open_shm_ndarray(
key: str, # unique identifier for segment key: str, # unique identifier for segment
size: int,
# from ``open_shm_array()``
size: int = int(2 ** 10), # array length in index terms
dtype: np.dtype | None = None, dtype: np.dtype | None = None,
append_start_index: int = 0, append_start_index: int = 0,
readonly: bool = True, readonly: bool = True,