credit.preblock.nan
===================

.. py:module:: credit.preblock.nan


Classes
-------

.. autoapisummary::

   credit.preblock.nan.FillNan


Module Contents
---------------

.. py:class:: FillNan(variables: list[str] = None, data_types: list[str] = None, fill_value: float = 0.0)

   Bases: :py:obj:`credit.preblock.base.BasePreblock`


   Replace NaN values with a constant fill value for selected variables.

   Walks a nested batch dict of the form ``batch[data_type][source][var_key]``
   and replaces any NaN entries with ``fill_value`` for the selected variables.
   Only NaNs are touched; ``+/-inf`` and finite values are left unchanged.

   ``variables`` may contain full or partial names (e.g. ``"era5/prognostic/3d"``
   expands to every variable beneath it) and is expanded against the first batch
   via :func:`credit.preblock._utils._parse_variable_selection`. An empty or
   omitted ``variables`` list means "every variable". Specifying a subset lets
   several ``FillNan`` preblocks coexist, each filling different variables with a
   different value.

   Config example::

       type: "fill_nan"
       args:
           variables:                  # optional, defaults to all variables
               - "era5/prognostic/3d/Q"
           data_types:                 # optional, defaults to ['input', 'target']
               - "input"
               - "target"
           fill_value: 0.0             # optional, default 0.0


   .. py:attribute:: variables
      :value: []



   .. py:attribute:: variables_expanded
      :value: False



   .. py:attribute:: data_types
      :value: ['input', 'target']



   .. py:attribute:: fill_value
      :value: 0.0



   .. py:method:: forward(batch: dict) -> dict


