Inspection¶
The pyterrier_alpha.inspect
module provides a way to inspect PyTerrier pyterrier.Transformer
and pyterrier_alpha.Artifact
objects.
- pyterrier_alpha.inspect.artifact_type_format(artifact, *, strict=True)[source]¶
Returns the type and format of the specified artifact.
These values are sourced by either the
ARTIFACT_TYPE
andARTIFACT_FORMAT
constants of the artifact, or (if these are not available) by matching on the entry points.- Return type:
Optional
[Tuple
[str
,str
]]- Parameters:
artifact – The artifact to inspect.
strict – If True, raises an error if the type or format could not be determined. If False, returns None in these cases.
- Returns:
A tuple containing the artifact’s type and format.
- Raises:
InspectError – If the artifact’s type or format could not be determined and
strict==True
.
- pyterrier_alpha.inspect.transformer_outputs(transformer, input_columns, *, strict=True)[source]¶
Infers the output columns for a transformer based on the inputs.
The method first checks if the transformer provides a
transform_outputs
method. If it does, this method is called and the result is returned. If the transformer does not provide this method, the method tries to infer the outputs by calling the transformer with an empty DataFrame.- Return type:
Optional
[List
[str
]]- Parameters:
transformer – An instance of the transformer to inspect.
input_columns – A list of the columns present in the input frame.
strict – If True, raises an error if the transformer cannot be inferred or are not accepted. If False, returns None in these cases.
- Returns:
A list of the columns present in the output for
transformer
giveninput_columns
.- Raises:
InspectError – If the artifact’s type or format could not be determined and
strict==True
.
Added in version 0.11.0.