
    1VhZ                     P    d Z ddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ d	dZd
dZy)zScalar summaries and TensorFlow operations to create them, V2 versions.

A scalar summary stores a single floating-point value, as a rank-0
tensor.
    N)tf2)summary_pb2)metadata)tensor_utilc                    t        j                  d|      }t        t        j                  j
                  dd      xs t        j                  j                  } || d||g      5 \  }}t        j                  j                  |       t        j                  j                  |t        j                  |t        j                        ||      cddd       S # 1 sw Y   yxY w)a  Write a scalar summary.

    See also `tf.summary.image`, `tf.summary.histogram`, `tf.summary.SummaryWriter`.

    Writes simple numeric values for later analysis in TensorBoard.  Writes go to
    the current default summary writer. Each summary point is associated with an
    integral `step` value. This enables the incremental logging of time series
    data.  A common usage of this API is to log loss during training to produce
    a loss curve.

    For example:

    ```python
    test_summary_writer = tf.summary.create_file_writer('test/logdir')
    with test_summary_writer.as_default():
        tf.summary.scalar('loss', 0.345, step=1)
        tf.summary.scalar('loss', 0.234, step=2)
        tf.summary.scalar('loss', 0.123, step=3)
    ```

    Multiple independent time series may be logged by giving each series a unique
    `name` value.

    See [Get started with TensorBoard](https://www.tensorflow.org/tensorboard/get_started)
    for more examples of effective usage of `tf.summary.scalar`.

    In general, this API expects that data points are logged with a monotonically
    increasing step value. Duplicate points for a single step or points logged out
    of order by step are not guaranteed to display as desired in TensorBoard.

    Arguments:
      name: A name for this summary. The summary tag used for TensorBoard will
        be this name prefixed by any active name scopes.
      data: A real numeric scalar value, convertible to a `float32` Tensor.
      step: Explicit `int64`-castable monotonic step value for this summary. If
        omitted, this defaults to `tf.summary.experimental.get_step()`, which must
        not be None.
      description: Optional long-form description for this summary, as a
        constant `str`. Markdown is supported. Defaults to empty.

    Returns:
      True on success, or false if no summary was written because no default
      summary writer was available.

    Raises:
      ValueError: if a default writer exists, but no step was provided and
        `tf.summary.experimental.get_step()` is None.
    Ndisplay_namedescriptionsummary_scopescalar_summary)values)tagtensorstepr   )r   create_summary_metadatagetattrtfsummaryexperimentalr   	debuggingassert_scalarwritecastfloat32)namedatar   r
   summary_metadatar   r   _s           U/home/dcms/DCMS/lib/python3.12/site-packages/tensorboard/plugins/scalar/summary_v2.pyscalarr       s    b  77{
 	

''$? 	$::##  
t-tTl	C 
xQ
""4(zz774,%	   

 
 
s   &A'CC c                    t        j                  |      }|j                  dk7  rt        d|j                  z        |j                  j
                  dvr"t        d|j                  j                  z        t        j                  |j                  t         j                              }t        j                  d|      }t        j                         }|j                  j!                  | ||       |S )a  Create a scalar summary_pb2.Summary protobuf.

    Arguments:
      tag: String tag for the summary.
      data: A 0-dimensional `np.array` or a compatible python number type.
      description: Optional long-form description for this summary, as a
        `str`. Markdown is supported. Defaults to empty.

    Raises:
      ValueError: If the type or shape of the data is unsupported.

    Returns:
      A `summary_pb2.Summary` protobuf object.
     z0Expected scalar shape for tensor, got shape: %s.)biufz!Cast %s to float is not supportedNr   )r   r   r   )nparrayshape
ValueErrordtypekindr   r   make_tensor_protoastyper   r   r   r   Summaryvalueadd)r   r   r
   arrtensor_protor   r   s          r   	scalar_pbr4   a   s     ((4.C
yyB>J
 	
 yy~~11<syy~~MNN00BJJ1GHL77{ !!#GMM#(8NN    )NN)N)__doc__numpyr'   tensorboard.compatr   r   tensorboard.compat.protor   tensorboard.plugins.scalarr   tensorboard.utilr   r    r4   r"   r5   r   <module>r<      s'     ( 0 / (@
Fr5   