예제 #1
0
파일: ui.py 프로젝트: vnitinv/artemis
 def side_by_side(self, user_range):
     records = select_experiment_records(user_range,
                                         self.exp_record_dict,
                                         flat=True)
     print side_by_side([get_record_full_string(rec) for rec in records],
                        max_linewidth=128)
     _warn_with_prompt(use_prompt=not self.close_after)
예제 #2
0
파일: ui.py 프로젝트: Kim-Seongjung/artemis
 def side_by_side(self, user_range):
     record_ids = select_experiment_records(user_range,
                                            self.exp_record_dict,
                                            flat=True)
     records = [ExperimentRecord.from_identifier(rid) for rid in record_ids]
     texts = [
         '{title}\n{sep}\n{info}\n{sep}\n{output}\n{sep}'.format(
             title=rid,
             sep='=' * len(rid),
             info=record.info.get_text(),
             output=record.get_log())
         for rid, record in zip(record_ids, records)
     ]
     print side_by_side(texts, max_linewidth=128)
     _warn_with_prompt()
예제 #3
0
def test_side_by_side():

    print 'String 1:\n{}'.format(str1)
    print 'String 2:\n{}'.format(str2)

    out = side_by_side([str1, str2])
    print 'Side by side:\n{}'.format(out)
예제 #4
0
def show_experiment_records(records, parallel_text=None, hang_notice = None, show_logs=True, truncate_logs=None, truncate_result=10000, header_width=100, show_result ='deep', hang=True):
    """
    Show the console logs, figures, and results of a collection of experiments.

    :param records:
    :param parallel_text:
    :param hang_notice:
    :return:
    """
    if isinstance(records, ExperimentRecord):
        records = [records]
    if parallel_text is None:
        parallel_text = len(records)>1
    if len(records)==0:
        print '... No records to show ...'
    else:
        strings = [get_record_full_string(rec, show_logs=show_logs, show_result=show_result, truncate_logs=truncate_logs,
                    truncate_result=truncate_result, header_width=header_width, include_bottom_border=False) for rec in records]
    has_matplotlib_figures = any(loc.endswith('.pkl') for rec in records for loc in rec.get_figure_locs())
    if has_matplotlib_figures:
        from matplotlib import pyplot as plt
        from artemis.plotting.saving_plots import interactive_matplotlib_context
        for rec in records:
            rec.show_figures(hang=False)
        if hang_notice is not None:
            print hang_notice

        with interactive_matplotlib_context(not hang):
            plt.show()

    if any(rec.get_experiment().display_function is not None for rec in records):
        from artemis.plotting.saving_plots import interactive_matplotlib_context
        with interactive_matplotlib_context():
            for i, rec in enumerate(records):
                with CaptureStdOut(print_to_console=False) as cap:
                    display_experiment_record(rec)
                if cap != '':
                    # strings[i] += '{subborder} Result Display {subborder}\n{out} \n{border}'.format(subborder='-'*20, out=cap.read(), border='='*50)
                    strings[i] += section_with_header('Result Display', cap.read(), width=header_width, bottom_char='=')

    if parallel_text:
        print side_by_side(strings, max_linewidth=128)
    else:
        for string in strings:
            print string

    return has_matplotlib_figures
예제 #5
0
def test_side_by_side():

    print('String 1:\n{}'.format(str1))
    print('String 2:\n{}'.format(str2))

    out = side_by_side([str1, str2])
    print('Side by side:\n{}'.format(out))
    assert out==desired  # Would work but pycharm automatically trims trailing spaces from the strings defined av
def compare_experiment_records(records,
                               parallel_text=None,
                               show_logs=True,
                               truncate_logs=None,
                               truncate_result=10000,
                               header_width=100,
                               max_linewidth=128,
                               show_result='deep'):
    """
    Show the console logs, figures, and results of a collection of experiments.

    :param records:
    :param parallel_text:
    :param hang_notice:
    :return:
    """
    if isinstance(records, ExperimentRecord):
        records = [records]
    if parallel_text is None:
        parallel_text = len(records) > 1
    if len(records) == 0:
        print('... No records to show ...')
        return
    else:
        records_sections = [
            get_record_full_string(rec,
                                   show_logs=show_logs,
                                   show_result=show_result,
                                   truncate_logs=truncate_logs,
                                   truncate_result=truncate_result,
                                   header_width=header_width,
                                   include_bottom_border=False,
                                   return_list=True) for rec in records
        ]

    if parallel_text:
        full_string = '\n'.join(
            side_by_side(records_section, max_linewidth=max_linewidth)
            for records_section in zip(*records_sections))
    else:
        full_string = '\n'.join('\n'.join(record_sections)
                                for record_sections in records_sections)

    print(full_string)

    has_matplotlib_figures = any(
        loc.endswith('.pkl') for rec in records
        for loc in rec.get_figure_locs())
    if has_matplotlib_figures:
        from artemis.plotting.manage_plotting import delay_show
        with delay_show():
            for rec in records:
                rec.show_figures()

    return has_matplotlib_figures
예제 #7
0
def compare_experiment_records(records, parallel_text=None, show_logs=True, truncate_logs=None,
        truncate_result=10000, header_width=100, max_linewidth=128, show_result ='deep'):
    """
    Show the console logs, figures, and results of a collection of experiments.

    :param records:
    :param parallel_text:
    :param hang_notice:
    :return:
    """
    if isinstance(records, ExperimentRecord):
        records = [records]
    if parallel_text is None:
        parallel_text = len(records)>1
    if len(records)==0:
        print('... No records to show ...')
        return
    else:
        records_sections = [get_record_full_string(rec, show_logs=show_logs, show_result=show_result, truncate_logs=truncate_logs,
                    truncate_result=truncate_result, header_width=header_width, include_bottom_border=False, return_list=True) for rec in records]

    if parallel_text:
        full_string = '\n'.join(side_by_side(records_section, max_linewidth=max_linewidth) for records_section in zip(*records_sections))
    else:
        full_string = '\n'.join('\n'.join(record_sections) for record_sections in records_sections)

    print(full_string)

    has_matplotlib_figures = any(loc.endswith('.pkl') for rec in records for loc in rec.get_figure_locs())
    if has_matplotlib_figures:
        from artemis.plotting.manage_plotting import delay_show
        with delay_show():
            for rec in records:
                rec.show_figures()

    return has_matplotlib_figures
예제 #8
0
파일: ui.py 프로젝트: QUVA-Lab/artemis
 def side_by_side(self, user_range):
     records = select_experiment_records(user_range, self.exp_record_dict, flat=True)
     print(side_by_side([get_record_full_string(rec) for rec in records], max_linewidth=128))
     _warn_with_prompt(use_prompt=False)