<a id="skfolio-utils-tools-input-to-array"></a>

# skfolio.utils.tools.input_to_array

<a id="skfolio.utils.tools.input_to_array"></a>

### skfolio.utils.tools.input_to_array(items, n_assets, fill_value, dim, assets_names, name, investable_mask=None)

Convert a collection of items (array-like or dictionary) into
a numpy array and verify its shape.

When `investable_mask` is provided, dictionary inputs are resolved against
the full `assets_names` and then subsetted, while array inputs sized to the
full universe are sliced down to the investable assets.  This allows callers
to pass user-facing parameters (keyed by asset name or sized for the full
universe) and transparently obtain arrays sized for the investable subset.

* **Parameters:**
  **items** *FloatArray | dict | list*
  : Items to verify and convert to array.

  **n_assets** *int*
  : Expected number of assets in the **output** array (i.e. the investable
    count when `investable_mask` is provided).

  **fill_value** *Any*
  : When `items` is a dictionary, elements that are not in `asset_names` are filled
    with `fill_value` in the converted array.

  **dim** *int*
  : Dimension of the final array.
    Possible values are `1` or `2`.

  **assets_names** *ndarray, optional*
  : Asset names used when `items` is a dictionary.  When `investable_mask`
    is provided, this must contain the **full-universe** names.

  **name** *str*
  : Name of the items used for error messages.

  **investable_mask** *ndarray of shape (n_full_assets,), optional*
  : Boolean mask selecting investable assets from the full universe.
    When provided, dictionary inputs are first resolved against the full
    universe then sliced, and array-like inputs sized to the full universe
    are sliced along the last axis.
* **Returns:**
  **values** *ndarray of shape (n_assets) for dim=1 or (n_groups, n_assets) for dim=2*
  : Converted array.

