示例#1
0
def test_export():
    """Test the JSON/YAML export functions"""
    tmp_path = tempfile.gettempdir()

    reproducible.export_yaml(os.path.join(tmp_path, 'file.yaml'))
    reproducible.export_json(os.path.join(tmp_path, 'file.json'))
    json_string = reproducible.json()
    yaml_string = reproducible.yaml()
    with open(os.path.join(tmp_path, 'file.yaml'), 'r') as fd:
        assert yaml_string == fd.read()
    with open(os.path.join(tmp_path, 'file.json'), 'r') as fd:
        assert json_string == fd.read()
示例#2
0
def test_rerunnable_module():
    """Test that the main methods work"""
    # reset
    reproducible.reset()

    reproducible.add_random_state()
    reproducible.add_repo('.', allow_dirty=True)
    reproducible.add_file(os.path.join(here, 'poem.txt'),
                          category='text_input')
    reproducible.untrack_file(os.path.join(here, 'poem.txt'),
                              category='text_input',
                              notfound_ok=False)
    reproducible.untrack_file(os.path.join(here, 'poem.txt'),
                              category='text_input',
                              notfound_ok=True)
    reproducible.add_data('n', 10)

    reproducible.find_editable_repos()
    reproducible.add_editable_repos()

    reproducible.json()
    reproducible.yaml()
    reproducible.add_pip_packages()
    reproducible.add_cpu_info()

    tmp_path = tempfile.gettempdir()
    reproducible.export_json(os.path.join(tmp_path, 'provdata.json'),
                             update_timestamp=True)
    os.remove(os.path.join(tmp_path, 'provdata.json'))
    reproducible.export_yaml(os.path.join(tmp_path, 'provdata.yaml'),
                             update_timestamp=True)
    os.remove(os.path.join(tmp_path, 'provdata.yaml'))
    reproducible.export_requirements(os.path.join(tmp_path, 'reqs.txt'))
    os.remove(os.path.join(tmp_path, 'reqs.txt'))

    reproducible.git_dirty('.')
    reproducible.git_info('.', diff=True)

    reproducible.data
示例#3
0
y_ranges = [(0, 1.2), (0.5, 3), (0.9, 1.3)]
for d, y_range in zip([0.001, 0.05, 0.5], y_ranges):
    x = sorted(diversities_fixed[d].keys())
    y_fixed_mean = [np.nanmean(diversities_fixed[d][x_i]) for x_i in x]
    y_fixed_std  = [np.nanstd(diversities_fixed[d][x_i]) for x_i in x]
    y_adapt_mean = np.nanmean(diversities_adapt[d])
    y_adapt_std  = np.nanstd(diversities_adapt[d])

    fig = graphs.Figure(y_range=y_range, height=250, width=900,
                        title='d = {}'.format(d))
    # fixed
    fig.line(x, y_fixed_mean, color=color_motor)
    fig.circle(x, y_fixed_mean, color=color_motor, swap_xy=False)
    for x_i, y_mean_i, y_std_i in zip(x, y_fixed_mean, y_fixed_std):
        fig.rect([x_i-0.002, x_i+0.002], [y_mean_i - y_std_i, y_mean_i + y_std_i],
                 color=color_motor, alpha=0.25)

    # adapt
    fig.line([0, 1], [y_adapt_mean, y_adapt_mean], color=color_goal,
             line_width=1, line_dash=[3, 3], line_cap='round')
    fig.rect([0, 1], [y_adapt_mean - y_adapt_std, y_adapt_mean + y_adapt_std],
             color=color_goal, alpha=0.15)
    figs.append(fig.fig)

graphs.show(graphs.column(figs))

reproducible.add_repo('.')
reproducible.add_file('figures/figure4.html', category='output')
reproducible.export_yaml('figures/figure4.context.yaml')