UnifiedRead#
- class gwpy.io.registry.UnifiedRead(instance: object, cls: type[~gwpy.io.registry.T], registry: ~gwpy.io.registry.UnifiedIORegistry = <gwpy.io.registry.UnifiedIORegistry object>)[source]#
Bases:
UnifiedReadWrite,ABC,Generic[T]Base
Class.read()implementation that handles parallel reads.Each parallel read must return an instance of the same type as the input class, and the results are merged by the provided
merge_functionwhich should have the following signature:def merge_function(self: Type, instances: list[Type], **kwargs) -> Type
i.e take in the type object and a list of instances, and return a single instance of the same type.
Methods Summary
__call__(source, *args[, format, cache, ...])Execute
cls.read().merge(items, **kwargs)Merge a sequence of items into a single item.
Methods Documentation
- __call__(
- source: NamedReadable | list[NamedReadable],
- *args,
- format: str | None = None,
- cache: bool | None = None,
- parallel: int = 1,
- verbose: str | bool = False,
- merge_function: MergeProtocol | None = None,
- **kwargs,
Execute
cls.read().This method generalises parallel reading of lists of files for any input class.
This method also generalises downloading files from remote URLs over HTTP or via
fsspec.
- abstractmethod merge(items: Sequence[T], **kwargs) T[source]#
Merge a sequence of items into a single item.
- Parameters:
- items
Sequence[T] The sequence of items to merge.
- **kwargs
Additional keyword arguments specific to the merge operation. Subclasses may override this method with specific named parameters; use
# type: ignore[override]to suppress mypy warnings about signature compatibility.
- items
- Returns:
TThe merged item.
Notes
The base class automatically extracts merge-specific kwargs from the
__call__method by inspecting the merge method signature, so subclasses with specific named parameters will receive them correctly.