
    AVh                     ,   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 dd	lm
Z
 dd
lmZ ddlmZ  ed      ej                  dej                   dfd              Z ed      ej                  dej                   dfd              Zy)zHistograms.
    )dtypes)ops)	array_ops)clip_ops)control_flow_assert)control_flow_ops)gen_math_ops)math_ops)dispatch)	tf_exporthistogram_fixed_width_binsd   Nc           	      R   t        j                  |d| ||g      5  t        j                  | d      } t        j                  |       }t        j
                  | dg      } t        j                  |d      }t        j                  |t        j                  d      }t        j                  t        j                  |d      d	|z  g      }t        j                  |g|      }t        j                  || j                        }t        j                   | |d   z
  |d
   |d   z
  d      }t        j"                  ||z  d      }	t        j                  t%        j&                  |	d|d
z
        t        j                        }	t        j
                  |	|      cddd       S # 1 sw Y   yxY w)a  Bins the given values for use in a histogram.

  Given the tensor `values`, this operation returns a rank 1 `Tensor`
  representing the indices of a histogram into which each element
  of `values` would be binned. The bins are equal width and
  determined by the arguments `value_range` and `nbins`.

  Args:
    values:  Numeric `Tensor`.
    value_range:  Shape [2] `Tensor` of same `dtype` as `values`.
      values <= value_range[0] will be mapped to hist[0],
      values >= value_range[1] will be mapped to hist[-1].
    nbins:  Scalar `int32 Tensor`.  Number of histogram bins.
    dtype:  dtype for returned histogram.
    name:  A name for this operation (defaults to 'histogram_fixed_width').

  Returns:
    A `Tensor` holding the indices of the binned values whose shape matches
    `values`.

  Raises:
    TypeError: If any unsupported dtype is provided.
    tf.errors.InvalidArgumentError: If value_range does not
        satisfy value_range[0] < value_range[1].

  Examples:

  >>> # Bins will be:  (-inf, 1), [1, 2), [2, 3), [3, 4), [4, inf)
  ...
  >>> nbins = 5
  >>> value_range = [0.0, 5.0]
  >>> new_values = [-1.0, 0.0, 1.5, 2.0, 5.0, 15]
  >>> indices = tf.histogram_fixed_width_bins(new_values, value_range, nbins=5)
  >>> indices.numpy()
  array([0, 0, 1, 2, 4, 4], dtype=int32)
  r   values)namevalue_rangenbinsdtyper   r   znbins %s must > 0   scaled_valuesindicesN)r   
name_scopeconvert_to_tensorr   shapereshaper   int32r   Assertr
   greaterr   with_dependenciescastr   truedivfloorr   clip_by_value)
r   r   r   r   r   r   checknbins_floatr   r   s
             S/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/histogram_ops.pyr   r      sl   V ~~d8{E24 -""69FOOF#Evt,F''-HK!!%v||'JE&&"%85%@$ACE..w>E--v||4K $$QAQ'M nn[=8yIG mmw;?;V\\KGWe,5- - -s   E8FF&histogram_fixed_widthc                     t        j                  |d| ||g      5 }t        j                  | ||||      cddd       S # 1 sw Y   yxY w)a  Return histogram of values.

  Given the tensor `values`, this operation returns a rank 1 histogram counting
  the number of entries in `values` that fell into every bin.  The bins are
  equal width and determined by the arguments `value_range` and `nbins`.

  Args:
    values:  Numeric `Tensor`.
    value_range:  Shape [2] `Tensor` of same `dtype` as `values`.
      values <= value_range[0] will be mapped to hist[0],
      values >= value_range[1] will be mapped to hist[-1].
    nbins:  Scalar `int32 Tensor`.  Number of histogram bins.
    dtype:  dtype for returned histogram.
    name:  A name for this operation (defaults to 'histogram_fixed_width').

  Returns:
    A 1-D `Tensor` holding histogram of values.

  Raises:
    TypeError: If any unsupported dtype is provided.
    tf.errors.InvalidArgumentError: If value_range does not
        satisfy value_range[0] < value_range[1].

  Examples:

  >>> # Bins will be:  (-inf, 1), [1, 2), [2, 3), [3, 4), [4, inf)
  ...
  >>> nbins = 5
  >>> value_range = [0.0, 5.0]
  >>> new_values = [-1.0, 0.0, 1.5, 2.0, 5.0, 15]
  >>> hist = tf.histogram_fixed_width(new_values, value_range, nbins=5)
  >>> hist.numpy()
  array([2, 1, 1, 0, 2], dtype=int32)
  r)   r   N)r   r   r	   _histogram_fixed_width)r   r   r   r   r   s        r(   r)   r)   g   sQ    R ~~d3{E24 <7;..U%d<< < <s	   ?A)__doc__tensorflow.python.frameworkr   r   tensorflow.python.opsr   r   r   r   r	   r
   tensorflow.python.utilr    tensorflow.python.util.tf_exportr   add_dispatch_supportr   r   r)        r(   <module>r4      s     / + + * 5 2 . * + 6 '(	 &)%+\\$(	C-  )C-L "#	 !$ &#	+<  $+<r3   