def test_construct_timeseries_cds(report_with_raw): report = report_with_raw raw_report = report.raw_report timeseries_cds, metadata_cds = figures.construct_timeseries_cds(report) ts_pair_index = timeseries_cds.data['pair_index'] assert np.all(ts_pair_index == np.arange( len(report.report_parameters.object_pairs)).repeat([ len(fxob.forecast_values) for fxob in raw_report.processed_forecasts_observations ])) observation_values = timeseries_cds.data['observation_values'] forecast_values = timeseries_cds.data['forecast_values'] assert len(observation_values) == len(ts_pair_index) assert len(forecast_values) == len(ts_pair_index) # just testing for non-mangling behavior here assert np.all(observation_values == 100) assert np.all(forecast_values == 100) assert 'pair_index' in metadata_cds.data assert 'observation_name' in metadata_cds.data assert 'forecast_name' in metadata_cds.data assert 'interval_label' in metadata_cds.data assert 'observation_hash' in metadata_cds.data assert 'forecast_hash' in metadata_cds.data assert 'observation_color' in metadata_cds.data
def test_timeseries(report_with_raw): timeseries_cds, metadata_cds = figures.construct_timeseries_cds( report_with_raw) report_params = report_with_raw.report_parameters fig = figures.timeseries(timeseries_cds, metadata_cds, report_params.start, report_params.end, report_params.object_pairs[0].forecast.units) assert fig is not None
def test_scatter(report_with_raw): timeseries_cds, metadata_cds = figures.construct_timeseries_cds( report_with_raw) fig = figures.scatter( timeseries_cds, metadata_cds, report_with_raw.report_parameters.object_pairs[0].forecast.units, ) assert fig is not None
def test_extract_metadata_from_cds(report_with_raw, hash_key): timeseries_cds, metadata_cds = figures.construct_timeseries_cds( report_with_raw) for the_hash in metadata_cds.data[hash_key]: metadata = figures._extract_metadata_from_cds(metadata_cds, the_hash, hash_key) assert 'pair_index' in metadata assert 'observation_name' in metadata assert 'interval_label' in metadata assert 'observation_color' in metadata
def test_construct_timeseries_cds_no_data(set_report_pfxobs_values, value): report = set_report_pfxobs_values(value) with pytest.raises(ValueError): timeseires_cds, metadata_cds = figures.construct_timeseries_cds(report)