Source code for skfolio.descriptor._passthrough
"""Passthrough descriptor exposing a raw :class:`~skfolio.containers.AssetPanel` field."""
# Copyright (c) 2023-2026
# Author: Hugo Delatte <hugo.delatte@skfoliolabs.com>
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
from skfolio.containers import AssetPanel
from skfolio.descriptor._base import BaseDescriptor
from skfolio.typing import FloatArray, IntArray
from skfolio.utils.validation import validate_asset_panel
[docs]
class Passthrough(BaseDescriptor, stateless=True):
"""Passthrough descriptor for an :class:`~skfolio.containers.AssetPanel` field.
Returns the selected panel field without numerical transformation. This is
useful for raw vendor fields or for values computed upstream that should
enter a factor exposure model unchanged.
Parameters
----------
field : str
Name of the field to read from the input
:class:`~skfolio.containers.AssetPanel`.
Attributes
----------
n_assets_ : int
Number of assets seen during fitting.
asset_names_ : ndarray of shape (n_assets,)
Asset names seen during fitting.
Examples
--------
>>> from skfolio.datasets import make_synthetic_characteristics
>>> from skfolio.descriptor import Passthrough
>>>
>>> X = make_synthetic_characteristics()
>>>
>>> descriptor = Passthrough("eps_ntm")
>>> eps_ntm = descriptor.fit_transform(X)
"""
def __init__(self, field: str) -> None:
self.field = field