webknossos-libs
webknossos-libs copied to clipboard
docs imprecise: temporary_volume_layer_copy doesn't return an iterable
the documentation says it should return an iterable https://docs.webknossos.org/api/webknossos/annotation/annotation.html#Annotation.temporary_volume_layer_copy
print(hasattr(a.temporary_volume_layer_copy('Volume'),'__iter__'))
-> False
Well it's returning a Generator from within a with context. So the correct type might be a GeneratorContextManager.
In any case, the preferred way of using this roughly:
annotation = wk.Annotation.load(
<some_path>
)
volume_names = sorted(annotation.get_volume_layer_names())
with annotation.temporary_volume_layer_copy(
volume_layer_name=volume_names[0]
) as layer:
voxels = layer.get_finest_mag().read(
...
)
Reading further in this the recommended annotation for generators are Iterator or Generator. See mypy docs: https://mypy.readthedocs.io/en/stable/kinds_of_types.html#generators
Perhaps, the fact that the function is wrapped in a @contextmanager annotation/wrapper might no be properly be picked up by the documentation tool.