Pass `str` dtype for `use_str` case

shm_apis
Tyler Goodlet 2022-10-20 16:08:28 -04:00
parent f9a84f0732
commit 4f442efbd7
2 changed files with 10 additions and 6 deletions
tractor

View File

@ -70,7 +70,10 @@ async def child_read_shm_list(
) -> None: ) -> None:
# attach in child # attach in child
shml = attach_shm_list(key=shm_key) shml = attach_shm_list(
key=shm_key,
# dtype=str if use_str else float,
)
await ctx.started(shml.key) await ctx.started(shml.key)
async with ctx.open_stream() as stream: async with ctx.open_stream() as stream:
@ -92,7 +95,9 @@ async def child_read_shm_list(
@pytest.mark.parametrize( @pytest.mark.parametrize(
'use_str', [False, True], 'use_str',
[False, True],
ids=lambda i: f'use_str_values={i}',
) )
@pytest.mark.parametrize( @pytest.mark.parametrize(
'frame_size', 'frame_size',
@ -106,7 +111,7 @@ def test_parent_writer_child_reader(
async def main(): async def main():
async with tractor.open_nursery( async with tractor.open_nursery(
debug_mode=True, # debug_mode=True,
) as an: ) as an:
portal = await an.start_actor( portal = await an.start_actor(
@ -121,6 +126,7 @@ def test_parent_writer_child_reader(
shml = open_shm_list( shml = open_shm_list(
key=key, key=key,
size=seq_size, size=seq_size,
dtype=str if use_str else float,
readonly=False, readonly=False,
) )
@ -143,7 +149,7 @@ def test_parent_writer_child_reader(
if use_str: if use_str:
val = str(val) val = str(val)
print(f'(parent): writing {val}') # print(f'(parent): writing {val}')
shml[i] = val shml[i] = val
# only on frame fills do we # only on frame fills do we

View File

@ -460,7 +460,6 @@ class ShmArray:
def open_shm_ndarray( def open_shm_ndarray(
key: Optional[str] = None, key: Optional[str] = None,
size: int = int(2 ** 10), size: int = int(2 ** 10),
dtype: np.dtype | None = None, dtype: np.dtype | None = None,
@ -799,7 +798,6 @@ def open_shm_list(
None: None, None: None,
}[dtype] }[dtype]
sequence = [default] * size sequence = [default] * size
# sequence = [0.] * size
shml = ShmList( shml = ShmList(
sequence=sequence, sequence=sequence,