def test_log_np_histogram(self):
    assert (os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is False)
    assert (os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is False)
    (values, counts) = np.histogram(np.random.randint(255, size=(1000,)))
    with patch('polyaxon.tracking.run.Run._log_has_events') as log_np_histogram:
        self.run.log_np_histogram(name='histo', values=values, counts=counts, step=1)
    assert (log_np_histogram.call_count == 1)
    self.event_logger.flush()
    assert (os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is False)
    assert (os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is True)
    events_file = get_event_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM, name='histo')
    assert (os.path.exists(events_file) is True)
    results = V1Events.read(kind='histogram', name='histo', data=events_file)
    assert (len(results.df.values) == 1)
def test_log_np_histogram(self):
    assert (os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is False)
    assert (os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is False)
    (values, counts) = np.histogram(np.random.randint(255, size=(1000,)))
    with patch('polyaxon.tracking.run.Run._log_has_events') as log_np_histogram:
        self.run.log_np_histogram(name='histo', values=values, counts=counts, step=1)
    assert (log_np_histogram.call_count == 1)
    self.event_logger.flush()
    assert (os.path.exists(get_asset_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is False)
    assert (os.path.exists(get_event_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM)) is True)
    events_file = get_event_path(self.run_path, kind=V1ArtifactKind.HISTOGRAM, name='histo')
    assert (os.path.exists(events_file) is True)
    results = V1Events.read(kind='histogram', name='histo', data=events_file)
    assert (len(results.df.values) == 1)