> ## Documentation Index
> Fetch the complete documentation index at: https://systematica.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Checks

> systematica.utils.checks

## `is_pd_object`

```python theme={null}
is_pd_object(
    obj,
    to_frame: bool = False,
)
```

Check if an object is a `pd.DataFrame` or `pd.Series`.

**Parameters**:

| Name       | Type     | Default | Description                                                                |
| ---------- | -------- | ------- | -------------------------------------------------------------------------- |
| `obj`      | `object` | `--`    | The object to check.                                                       |
| `to_frame` | `bool`   | `False` | If `True` and the object is a `pd.Series`, convert it to a `pd.DataFrame`. |

**Raises**:

| Type         | Description                                                  |
| ------------ | ------------------------------------------------------------ |
| `ValueError` | If the object is neither a `pd.DataFrame` nor a `pd.Series`. |

**Returns**:

| Type                   | Description                        |
| ---------------------- | ---------------------------------- |
| `pd.DataFrame or None` | The `pd.DataFrame` or `pd.Series`. |

## `is_pd_dataframe`

```python theme={null}
is_pd_dataframe(
    obj,
)
```

Check if an object is a `pd.DataFrame`.

**Parameters**:

| Name  | Type     | Default | Description          |
| ----- | -------- | ------- | -------------------- |
| `obj` | `object` | `--`    | The object to check. |

**Raises**:

| Type         | Description                            |
| ------------ | -------------------------------------- |
| `ValueError` | If the object is not a `pd.DataFrame`. |

## `is_valid_shape`

```python theme={null}
is_valid_shape(
    a: pandas.core.frame.DataFrame,
    b: pandas.core.frame.DataFrame,
) ‑> pandas.core.frame.DataFrame
```

Validate the shape of two objects and align them if necessary.

**Parameters**:

| Name | Type           | Default | Description           |
| ---- | -------------- | ------- | --------------------- |
| `a`  | `pd.DataFrame` | `--`    | The first DataFrame.  |
| `b`  | `pd.DataFrame` | `--`    | The second DataFrame. |

**Raises**:

| Type         | Description                       |
| ------------ | --------------------------------- |
| `ValueError` | If the shapes are not compatible. |

**Returns**:

| Type           | Description                        |
| -------------- | ---------------------------------- |
| `pd.DataFrame` | The aligned second `pd.DataFrame`. |

## `is_valid_squarred_shape`

```python theme={null}
is_valid_squarred_shape(
    cov: pandas.core.frame.DataFrame,
    weights: pandas.core.series.Series | pandas.core.frame.DataFrame,
)
```

Check if a covariance matrix is square and aligned with weights.

**Parameters**:

| Name      | Type             | Default | Description            |
| --------- | ---------------- | ------- | ---------------------- |
| `cov`     | `pd.DataFrame`   | `--`    | The covariance matrix. |
| `weights` | `tp.SeriesFrame` | `--`    | The weights vector.    |

**Raises**:

| Type         | Description                                                         |
| ------------ | ------------------------------------------------------------------- |
| `ValueError` | If the covariance matrix is not square or not aligned with weights. |

## `is_fitted`

```python theme={null}
is_fitted(
    attr_name: str,
    raise_error: bool = True,
    custom_func: Type = None,
    **custom_func_kwargs,
) ‑> Callable
```

Decorator to check if an object is fitted.

**Parameters**:

| Name                 | Type        | Default | Description                                            |
| -------------------- | ----------- | ------- | ------------------------------------------------------ |
| `attr_name`          | `str`       | `--`    | The name of the attribute to check.                    |
| `raise_error`        | `bool`      | `True`  | If True, raise an error if the object is not fitted.   |
| `custom_func`        | `callable`  | `None`  | A custom function to call if the object is not fitted. |
| `custom_func_kwargs` | `tp.Kwargs` | `--`    | Additional arguments for the custom function.          |

**Raises**:

| Type             | Description                                              |
| ---------------- | -------------------------------------------------------- |
| `NotFittedError` | If the object is not fitted and `raise_error` is `True`. |

**Returns**:

| Type          | Description           |
| ------------- | --------------------- |
| `tp.Callable` | The decorated method. |

## `is_freq_valid`

```python theme={null}
is_freq_valid(
    index: pandas.core.indexes.base.Index,
    freq: str,
)
```

Check if the frequency of a `pd.Index` is valid.

**Parameters**:

| Name    | Type       | Default | Description           |
| ------- | ---------- | ------- | --------------------- |
| `index` | `pd.Index` | `--`    | The index to check.   |
| `freq`  | `str`      | `--`    | The target frequency. |

**Raises**:

| Type         | Description                        |
| ------------ | ---------------------------------- |
| `ValueError` | If the frequency cannot be parsed. |

**Returns**:

| Type   | Description                                          |
| ------ | ---------------------------------------------------- |
| `bool` | `True` if the frequency is valid, `False` otherwise. |

## `is_int`

```python theme={null}
is_int(
    arg: Any,
) ‑> bool
```

Check if an argument is an `int` (excluding `timedelta`).

**Parameters**:

| Name  | Type     | Default | Description            |
| ----- | -------- | ------- | ---------------------- |
| `arg` | `tp.Any` | `--`    | The argument to check. |

**Returns**:

| Type   | Description                                              |
| ------ | -------------------------------------------------------- |
| `bool` | `True` if the argument is an integer, `False` otherwise. |

## `is_float`

```python theme={null}
is_float(
    arg: Any,
) ‑> bool
```

Check if an argument is a `float`.

**Parameters**:

| Name  | Type     | Default | Description            |
| ----- | -------- | ------- | ---------------------- |
| `arg` | `tp.Any` | `--`    | The argument to check. |

**Returns**:

| Type   | Description                                             |
| ------ | ------------------------------------------------------- |
| `bool` | `True` if the argument is a `float`, `False` otherwise. |

## `is_number`

```python theme={null}
is_number(
    arg: Any,
) ‑> bool
```

Check if an argument is a number.

**Parameters**:

| Name  | Type     | Default | Description            |
| ----- | -------- | ------- | ---------------------- |
| `arg` | `tp.Any` | `--`    | The argument to check. |

**Returns**:

| Type   | Description                                            |
| ------ | ------------------------------------------------------ |
| `bool` | `True` if the argument is a number, `False` otherwise. |
