Replace print(hist) with hist.numpy() to avoid print call, also avoid pylint too long (80) error

Remove extra "```" as doctest use ">>>" and "..." instead, and fix pylint issue by shorten the output

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang 2020-04-30 19:47:08 +00:00
parent 58a378f9f6
commit c7ae49c070

View File

@ -62,15 +62,14 @@ def histogram_fixed_width_bins(values,
Examples: Examples:
```python
>>> # Bins will be: (-inf, 1), [1, 2), [2, 3), [3, 4), [4, inf) >>> # Bins will be: (-inf, 1), [1, 2), [2, 3), [3, 4), [4, inf)
... ...
>>> nbins = 5 >>> nbins = 5
>>> value_range = [0.0, 5.0] >>> value_range = [0.0, 5.0]
>>> new_values = [-1.0, 0.0, 1.5, 2.0, 5.0, 15] >>> new_values = [-1.0, 0.0, 1.5, 2.0, 5.0, 15]
>>> tf.histogram_fixed_width_bins(new_values, value_range, nbins=5) >>> indices = tf.histogram_fixed_width_bins(new_values, value_range, nbins=5)
<tf.Tensor: shape=(6,), dtype=int32, numpy=array([0, 0, 1, 2, 4, 4], dtype=int32)> >>> indices.numpy()
``` array([0, 0, 1, 2, 4, 4], dtype=int32)
""" """
with ops.name_scope(name, 'histogram_fixed_width_bins', with ops.name_scope(name, 'histogram_fixed_width_bins',
[values, value_range, nbins]): [values, value_range, nbins]):
@ -129,15 +128,14 @@ def histogram_fixed_width(values,
Examples: Examples:
```python
>>> # Bins will be: (-inf, 1), [1, 2), [2, 3), [3, 4), [4, inf) >>> # Bins will be: (-inf, 1), [1, 2), [2, 3), [3, 4), [4, inf)
... ...
>>> nbins = 5 >>> nbins = 5
>>> value_range = [0.0, 5.0] >>> value_range = [0.0, 5.0]
>>> new_values = [-1.0, 0.0, 1.5, 2.0, 5.0, 15] >>> new_values = [-1.0, 0.0, 1.5, 2.0, 5.0, 15]
>>> tf.histogram_fixed_width(new_values, value_range, nbins=5) >>> hist = tf.histogram_fixed_width(new_values, value_range, nbins=5)
<tf.Tensor: shape=(5,), dtype=int32, numpy=array([2, 1, 1, 0, 2], dtype=int32)> >>> hist.numpy()
``` array([2, 1, 1, 0, 2], dtype=int32)
""" """
with ops.name_scope(name, 'histogram_fixed_width', with ops.name_scope(name, 'histogram_fixed_width',
[values, value_range, nbins]) as name: [values, value_range, nbins]) as name: