def test_get_scalars_with_actual_inf_and_nan(self):
    'Test for get_scalars() call that involve inf and nan in user data.'
    mock_api_client = mock.Mock()

    def stream_experiment_data(request, **kwargs):
        self.assertEqual(request.experiment_id, '789')
        self.assertEqual(kwargs['metadata'], grpc_util.version_metadata())
        response = export_service_pb2.StreamExperimentDataResponse()
        response.run_name = 'train'
        response.tag_name = 'batch_loss'
        response.points.steps.append(0)
        response.points.values.append(np.nan)
        response.points.wall_times.add(seconds=0, nanos=0)
        response.points.steps.append(1)
        response.points.values.append(np.inf)
        response.points.wall_times.add(seconds=10, nanos=0)
        (yield response)
    mock_api_client.StreamExperimentData = mock.Mock(wraps=stream_experiment_data)
    with mock.patch.object(experiment_from_dev, 'get_api_client', (lambda api_endpoint: mock_api_client)):
        experiment = experiment_from_dev.ExperimentFromDev('789')
        dataframe = experiment.get_scalars(pivot=True)
    expected = pandas.DataFrame({'run': (['train'] * 2), 'step': [0, 1], 'batch_loss': [np.nan, np.inf]})
    pandas.testing.assert_frame_equal(dataframe, expected, check_names=True)
Test for get_scalars() call that involve inf and nan in user data.
def test_get_scalars_with_actual_inf_and_nan(self):
    
    mock_api_client = mock.Mock()

    def stream_experiment_data(request, **kwargs):
        self.assertEqual(request.experiment_id, '789')
        self.assertEqual(kwargs['metadata'], grpc_util.version_metadata())
        response = export_service_pb2.StreamExperimentDataResponse()
        response.run_name = 'train'
        response.tag_name = 'batch_loss'
        response.points.steps.append(0)
        response.points.values.append(np.nan)
        response.points.wall_times.add(seconds=0, nanos=0)
        response.points.steps.append(1)
        response.points.values.append(np.inf)
        response.points.wall_times.add(seconds=10, nanos=0)
        (yield response)
    mock_api_client.StreamExperimentData = mock.Mock(wraps=stream_experiment_data)
    with mock.patch.object(experiment_from_dev, 'get_api_client', (lambda api_endpoint: mock_api_client)):
        experiment = experiment_from_dev.ExperimentFromDev('789')
        dataframe = experiment.get_scalars(pivot=True)
    expected = pandas.DataFrame({'run': (['train'] * 2), 'step': [0, 1], 'batch_loss': [np.nan, np.inf]})
    pandas.testing.assert_frame_equal(dataframe, expected, check_names=True)