From 52dff6267e327381476a04453a37908dd49a32d6 Mon Sep 17 00:00:00 2001 From: CLU Authors Date: Tue, 6 Jan 2026 09:48:34 -0800 Subject: [PATCH] avoid failures in the histogram due to ranges that are too narrow. PiperOrigin-RevId: 852820077 --- clu/metric_writers/logging_writer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clu/metric_writers/logging_writer.py b/clu/metric_writers/logging_writer.py index e608936..40b9e2e 100644 --- a/clu/metric_writers/logging_writer.py +++ b/clu/metric_writers/logging_writer.py @@ -138,7 +138,7 @@ def _compute_histogram_as_tf( range_max = np.max(array) range_min = np.min(array) - if range_max == range_min: + if np.isclose(range_max, range_min, rtol=1e-5, atol=1e-8): histo = np.asarray([array.size], dtype=np.int64) bins = np.asarray([range_max - 0.5, range_max + 0.5], dtype=np.float64) else: