Ejemplo n.º 1
0
    def test_text_init(self):
        "Test the Diagnostic object creation from text"

        # 1. Create Diagnostic object from text
        myobj = diagnostic.Diagnostic(text=aoc_03.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 12)

        # 3. Check methods
        self.assertEqual(myobj.get_bits(), 22)
        self.assertEqual(myobj.get_bits(False), 9)

        self.assertEqual(myobj.most(myobj.text, 0), '1')
        self.assertEqual(myobj.most(myobj.text, 1), '0')
        self.assertEqual(myobj.most(myobj.text, 2), '1')
        self.assertEqual(myobj.most(myobj.text, 3), '1')
        self.assertEqual(myobj.most(myobj.text, 4), '0')

        self.assertEqual(myobj.handle_ties('0', '1'), '0')
        self.assertEqual(myobj.handle_ties('=', '1'), '1')
        self.assertEqual(myobj.handle_ties('1', '1'), '1')

        self.assertEqual(len(myobj.keep(myobj.text, '1', 0)), 7)
        self.assertEqual(len(myobj.keep(myobj.text, '0', 0)), 5)

        self.assertEqual(myobj.keep_one(), 23)
        self.assertEqual(myobj.keep_one(False), 10)
Ejemplo n.º 2
0
    def diagnose(self, interval):
        """Perform the diagnostic and return it"""
        v_resident_mean = self.mm.get_reduced_metric('memory', 'resident',
                                                     ('mean', ), interval)
        v_committed_mean = self.mm.get_reduced_metric('memory', 'committed',
                                                      ('mean', ), interval)

        diag = diagnostic.Diagnostic(diagnoser='pfitscher_memory',
                                     resource='memory')

        if v_resident_mean is None or v_committed_mean is None:
            diag.diagnostic = None
        elif v_resident_mean < self.t_resident_low\
                and v_committed_mean < self.t_committed_relevant:
            diag.diagnostic = diagnostic.OVER
        elif (v_resident_mean >= self.t_resident_low
                and v_committed_mean >= self.t_committed_relevant)\
                or (v_resident_mean >= self.t_resident_high
                and v_committed_mean < self.t_committed_relevant):
            diag.diagnostic = diagnostic.UNDER
        else:
            diag.diagnostic = diagnostic.CORRECT

        if diag.diagnostic is not None:
            diag.info = self.make_info(v_resident_mean, v_committed_mean)
        return diag
Ejemplo n.º 3
0
    def diagnose(self, interval):
        """Perform the diagnostic and return it"""
        v_queue_mean = self.mm.get_reduced_metric('network', 'queue',
                                                  ('mean', ), interval)
        v_tr_stdev = self.mm.get_reduced_metric('network', 'transmission_rate',
                                                ('stdev', ), interval)
        v_tr_mean = self.mm.get_reduced_metric('network', 'transmission_rate',
                                               ('mean', ), interval)
        if v_tr_stdev is not None and v_tr_mean is not None:
            if v_tr_mean != 0.0:
                v_tr_cv = v_tr_stdev / v_tr_mean
            else:
                v_tr_cv = float('inf')
        else:
            v_tr_cv = None

        diag = diagnostic.Diagnostic(diagnoser='pfitscher_network',
                                     resource='network')

        if v_queue_mean is None or v_tr_cv is None:
            diag.diagnostic = None
        elif v_queue_mean > self.t_queue_high:
            diag.diagnostic = diagnostic.UNDER
        elif v_tr_cv > self.t_tr_high:
            diag.diagnostic = diagnostic.OVER
        else:
            diag.diagnostic = diagnostic.CORRECT

        if diag.diagnostic is not None:
            diag.info = self.make_info(v_queue_mean, v_tr_cv)
        return diag
Ejemplo n.º 4
0
    def diagnose(self, interval):
        """Perform the diagnostic and return it"""
        v_inuse_mean = self.mm.get_reduced_metric('cpu',
                                                        'inuse',
                                                        ('mean', ),
                                                        interval)
        v_inuse_over = self.mm.get_reduced_metric('cpu',
                                                        'inuse',
                                                        ('over',95.0),
                                                        interval)
        v_steal_mean = self.mm.get_reduced_metric('cpu',
                                                        'steal',
                                                        ('mean', ),
                                                        interval)

        diag = diagnostic.Diagnostic(diagnoser='pfitscher_cpu',
                                     resource='cpu')

        if v_inuse_mean is None or v_steal_mean is None:
            diag.diagnostic = None
        elif v_steal_mean >= self.t_steal_high \
                or v_inuse_mean >= self.t_inuse_high:
            diag.diagnostic = diagnostic.UNDER
        elif v_inuse_mean < self.t_inuse_low \
                and v_inuse_over <= self.t_inuse_saturated:
            diag.diagnostic = diagnostic.OVER
        else:
            diag.diagnostic = diagnostic.CORRECT

        if diag.diagnostic is not None:
            diag.info = self.make_info(v_inuse_mean, v_inuse_over, v_steal_mean)
        return diag
Ejemplo n.º 5
0
    def test_part_one(self):
        "Test part one example of Diagnostic object"

        # 1. Create Diagnostic object from text
        myobj = diagnostic.Diagnostic(text=aoc_03.from_text(PART_ONE_TEXT))

        # 2. Check the part one result
        self.assertEqual(myobj.part_one(verbose=False), PART_ONE_RESULT)
Ejemplo n.º 6
0
    def test_empty_init(self):
        "Test the default Diagnostic creation"

        # 1. Create default Diagnostic object
        myobj = diagnostic.Diagnostic()

        # 2. Make sure it has the default values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(myobj.text, None)
Ejemplo n.º 7
0
    def test_part_two(self):
        "Test part two example of Diagnostic object"

        # 1. Create Diagnostic object from text
        myobj = diagnostic.Diagnostic(part2=True,
                                      text=aoc_03.from_text(PART_TWO_TEXT))

        # 2. Check the part two result
        self.assertEqual(myobj.part_two(verbose=False), PART_TWO_RESULT)
Ejemplo n.º 8
0
def part_two(args, input_lines):
    "Process part two of the puzzle"

    # 1. Create the puzzle solver
    solver = diagnostic.Diagnostic(part2=True, text=input_lines)

    # 2. Determine the solution for part two
    solution = solver.part_two(verbose=args.verbose, limit=args.limit)
    if solution is None:
        print("There is no solution")
    else:
        print("The solution for part two is %s" % (solution))

    # 3. Return result
    return solution is not None
Ejemplo n.º 9
0
  os.chdir(os.path.dirname(wd_dir))

choice=input('Use DeCoSTAR (y/N)? ')

if choice=='y':                           
  print(path + "/DeCoSTAR parameter.file="+parameter_file)  
  f= path + "/DeCoSTAR parameter.file="+parameter_file  
  subprocess.call(f, shell=True)


####################################################
#####

print("Diagnostic in process ...")

diag=diagnostic.Diagnostic(parameter_file)
diag.build_ancestral()

print(diag.anc)

output=input(' Output cycles (y/N)? ').strip()

if output=="y":
  diag.output_cycles()

## Zip

ziprep=input('Zip families (y/N)? ').strip()

if ziprep=="y":
  fix=fix_bubbles.Fix_bubbles(diag)