def log_histogram( self, name, values, bins, max_bins=None, step=None, timestamp=None ): """Logs a histogram. ```python >>> log_histogram(name="histo", values=np.arange(np.prod((1024,)), dtype=float).reshape((1024,)), bins="auto", step=1) # noqa ``` Args: name: str, name values: np.array bins: int or str max_bins: int, optional step: int, optional timestamp: datetime, optional """ self._log_has_events() event_value = events_processors.histogram( values=values, bins=bins, max_bins=max_bins ) if event_value == UNKNOWN: return logged_event = LoggedEventSpec( name=name, kind=V1ArtifactKind.HISTOGRAM, event=V1Event.make(timestamp=timestamp, step=step, histogram=event_value), ) self._add_event(logged_event)
def test_empty_input(self): print("expect error here:") with pytest.raises(Exception): histogram("dummy", np.ndarray(0), "tensorflow")
def test_list_input(self): with pytest.raises(Exception): histogram("dummy", [1, 3, 4, 5, 6], "tensorflow")
def test_histogram_doane(self): event = histogram(tensor_np(shape=(1024, )), bins="doane", max_bins=5) assert event.values is not None assert event.counts is not None
def test_histogram_auto(self): event = histogram(values=tensor_np(shape=(1024, )), bins="auto", max_bins=5) assert event.values is not None assert event.counts is not None