credit.postblock.square
=======================

.. py:module:: credit.postblock.square


Classes
-------

.. autoapisummary::

   credit.postblock.square.SquareTransform


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

.. py:class:: SquareTransform(variables: list[str], key: str = 'y_processed')

   Bases: :py:obj:`credit.postblock.base.BasePostblock`


   Inverse of the SqrtTransform preblock: converts sqrt-space values to physical space.

   Inverts ``y = sqrt(x)`` back to ``x = y^2``.

   Note: values may be slightly negative due to floating-point effects; squaring maps
   these to small positive numbers. Clamping to zero is intentionally avoided to
   preserve gradient flow if this postblock is ever connected to a differentiable loss.

   ``variables`` supports the same shorthand as the scaler: an empty list
   transforms every variable; partial paths (e.g. ``"era5/prognostic"``) expand
   to all variables under that hierarchy. Expansion happens lazily on the first
   forward call.

   Config example::

       type: "square_transform"
       args:
           variables:
               - "era5/prognostic/3d/Q"

       # or inverse-transform all variables:
       type: "square_transform"
       args:
           variables: []


   .. py:attribute:: variables


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



   .. py:attribute:: key
      :value: 'y_processed'



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


