Beispiel #1
0
    def __init__(self):
        config = Config()
        self.question_table = QuestionTable()
        self.solution_table = SolutionTable()
        self.msg = tools.read_from_file(MD_TEMPLATE_PATH)
        assert isinstance(self.msg, str)

        leetcode_account = config.leetcode_account
        github_account = config.github_account

        ranking = '1/1'

        total_solved_num = self.solution_table.total_solved_num
        locked_num = self.question_table.locked_num
        total_num = self.question_table.total_question_num

        hard = self.solution_table.get_solved_num_by_difficulty('Hard')
        medium = self.solution_table.get_solved_num_by_difficulty('Medium')
        easy = self.solution_table.get_solved_num_by_difficulty('Easy')

        lang = str(LANG_SETTING.keys())

        t = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())

        png_url = "https://github.com/{}/leetcode-algorithms/raw/master/config/site-logo.png".format(
            github_account)

        self.msg = self.msg.format(png_url, leetcode_account, ranking,
                                   total_solved_num, total_num, locked_num,
                                   hard, medium, easy, lang, t)
Beispiel #2
0
def run():
    '''Wrapper function.'''
    # parse command line arguments
    arg_parser = build_arg_parse()
    args = arg_parser.parse_args()
    # get output file path
    output_loc = args.output
    # read in compound noun list
    comp_nouns = tools.read_from_file(args.input)
    if comp_nouns:
        # show process bar
        if args.verbose:
            print 'Segmented Compound Noun Parser Version 1.0'
            bar = Bar('Parse nouns\t', max=len(comp_nouns))
        (results, bar) = parallel_parse_helper(comp_nouns, args.max_workers,
                                               bar, args.verbose)
        if args.verbose:
            bar.finish()
        # write results to file
        if args.verbose:
            print 'Writing parse results to {}'.format(output_loc)
        if results:
            tools.write_results(results, output_loc)
            # write dot file
            if args.dot:
                dot_write.write(results, args.dot_dir, args.verbose)
Beispiel #3
0
                result = get_U(self.cutoff, self.parameter[0][depth][0],
                               self.parameter[0][depth][1], tuple(shrink))
            else:
                result = get_U(self.cutoff, self.parameter[1][depth][0],
                               self.parameter[1][depth][1], tuple(shrink))
        return result

    def energy(self):
        if self._energy:
            return self._energy
        e1 = get_energy(self.length, self.depth + 1, self, get_H(),
                        self.length // 2 - 1, self.cut1, self.cut2)
        e2 = get_energy(self.length, self.depth + 1, self, get_H(),
                        self.length // 2, self.cut1, self.cut2)
        self._energy = (e1 + e2) / 2

        self._energy += loss_sign(abs(self.projector_1) - 1)
        self._energy += loss_sign(abs(self.projector_2) - 1)
        for l in self.parameter:
            for r, omega in l:
                self._energy += loss_sign(abs(r) - 2)

        return self._energy


handle = read_from_file(IMPS, sys.argv[1])

import opt_tools

getattr(opt_tools, sys.argv[2])(handle, sys.argv[1], sys.argv[3:])
Beispiel #4
0
#!/usr/bin/python3

__author__ = "Mateusz Kowalski"
__email__ = "*****@*****.**"
__status__ = "Development"

import tools

tools.read_from_file('/etc/hosts')

tools.read_from_file('/afs/cern.ch/user/m/mlisowsk/public/.forward')
tools.write_to_file(
    '/afs/cern.ch/user/m/mlisowsk/public/htcondor_playground/launcher4.txt')

tools.run_application(app="/bin/env")

tools.do_nothing(time=60)
tools.do_heavy_computation(time=60)

tools.do_nothing(time=60 * 5)
tools.do_heavy_computation(time=60 * 5)

tools.do_nothing(time=60 * 60)
tools.do_heavy_computation(time=60 * 60)
#!/usr/bin/python3

__author__ = "Mateusz Kowalski"
__email__ = "*****@*****.**"
__status__ = "Development"

import tools

if __name__ == "__main__":
    tools.do_heavy_computation(time=1)
    tools.do_nothing(time=1)
    tools.read_from_file('/etc/hosts')
    tools.do_heavy_computation(time=3)
    tools.do_nothing(time=3)
    tools.run_application("echo", "test 123")