Fix handling of Infinity/NaN in line chart domain

Test Plan:
  - Use the script listed below to generate data that has enough
    infinities for these values to not be treated as outliers.
  - Load the data into TensorBoard (`--logdir /tmp/infbug`) and look at
    the scalars plot; also look at the console.
  - Before this change, the chart is completely blank, and there is a
    console warning: "QuantitativeScales cannot take NaN or Infinity as
    a domain value. Ignoring."
  - After this change, there is no console output, and the chart appears
    as intended: a reasonable domain is shown, and the infinities just
    shoot off the chart.

Generating script:
```py
import tensorflow as tf

LOGDIR = '/tmp/infbug'
STEPS = 134

def main():
  x = tf.Variable(3.1415)
  y = x.assign_add(x)
  tf.summary.scalar('y', y)
  summ = tf.summary.merge_all()

  sess = tf.Session()
  writer = tf.summary.FileWriter(LOGDIR)
  writer.add_graph(sess.graph)
  sess.run(tf.global_variables_initializer())
  for step in xrange(STEPS):
    writer.add_summary(sess.run(summ), step)
  writer.close()

if __name__ == '__main__':
  main()
```

PiperOrigin-RevId: 157472340
This commit is contained in:
A. Unique TensorFlower 2017-05-30 09:24:43 -07:00 committed by TensorFlower Gardener
parent 49476a62cb
commit 4788ca2be1

View File

@ -77,6 +77,9 @@ export function multiscaleFormatter(digits: number): ((v: number) => string) {
* sort the data. * sort the data.
*/ */
export function computeDomain(values: number[], ignoreOutliers: boolean) { export function computeDomain(values: number[], ignoreOutliers: boolean) {
// Don't include infinities and NaNs in the domain computation.
values = values.filter(z => isFinite(z));
if (values.length === 0) { if (values.length === 0) {
return [-0.1, 1.1]; return [-0.1, 1.1];
} }