def get_multiple_streams(sub_sample=2,
                         include_strs=None,
                         n_reps=100) -> List[List[float]]:
    """  """
    if include_strs is None:
        include_strs = [
            'hospital', 'electricity', 'airport', 'volume', 'emoji',
            'three_body', 'helicopter', 'noaa'
        ]
    mr = MicroReader()
    streams = mr.get_stream_names()
    acceptable = [
        s for s in streams
        if any([incl in s for incl in include_strs]) and not '~' in s
    ]
    ys = list()
    for nm in acceptable:
        try:
            lagged_values, lagged_times = mr.get_lagged_values_and_times(
                name=nm, count=2000)
            y, t = list(reversed(lagged_values)), list(reversed(lagged_times))
            if 'hospital' in nm:
                y_sub = y[::sub_sample]
            else:
                y_sub = y
            # Create new stream where

            if len(y_sub) >= 750:
                for _ in range(n_reps):
                    rho = np.random.rand() * 0.075 + 0.025
                    y_scaled = deform(y_sub, rho=rho)
                    ys.append(y_scaled)
            else:
                print(nm + ' too short')
        except:
            print(nm + ' exception')
    print(len(ys))
    return ys
def test_troublesome_devapi():
    mr = MicroReader(base_url='https://devapi.microprediction.org')
    pdf = mr.get_discrete_pdf_lagged(name='die.json', delay=mr.DELAYS[1])
def test_get_cdf_cop():
    for base_url in BASE_URLS:
        mr = MicroReader(base_url=base_url)
        res = mr.get_cdf_lagged(name='die.json', delay=mr.DELAYS[0], num=15)
        if not len(res['x']) > 3:
            assert False
def test_die_cdf():
    for base_url in BASE_URLS:
        mr = MicroReader(base_url=base_url)
        pdf = mr.get_discrete_pdf_lagged(name='die.json', delay=mr.DELAYS[0])
def test_troublesome():
    mr = MicroReader()
    pdf = mr.get_discrete_pdf_lagged(name='die.json', delay=mr.DELAYS[0])
Example #6
0
def test_get_cdf():
    mr = MicroReader()
    y, x = mr.get_cdf(name='cop.json')