Пример #1
0
 def test_runtime_3(self):
     sw = StopWatch()
     sw.start()
     time.sleep(2)
     assert round(sw.time) == 2.0
     time.sleep(2)
     assert round(sw.time) == 4.0
Пример #2
0
 def test_stop_1(self):
     sw = StopWatch()
     sw.start()
     time.sleep(1)
     sw.stop()
     assert not sw.running
     assert round(sw.time) == 1.0
Пример #3
0
 def test_reset_1(self):
     sw = StopWatch()
     sw.start()
     time.sleep(2)
     sw.stop()
     assert round(sw.time) == 2.0
     sw.reset()
     assert round(sw.time) == 0.0
Пример #4
0
 def test_lap_3(self):
     sw = StopWatch()
     sw.start()
     time.sleep(1)
     assert round(sw.lap.time) == 1.0
     time.sleep(3)
     assert round(sw.lap.time) == 3.0
     assert sw[0].nlaps == 2
Пример #5
0
 def test_context_3(self):
     with StopWatch() as sw:
         time.sleep(3)
         sw.stop()
         time.sleep(2)
         sw.start()
         time.sleep(1)
     assert round(sw.time) == 4.0
     assert [round(interval.time)
             for interval in sw.intervals] == [3.0, 1.0]
Пример #6
0
 def test_runtime_5(self):
     sw = StopWatch()
     sw.start()
     time.sleep(2)
     time.sleep(1)
     sw.stop()
     time.sleep(2)
     sw.start()
     time.sleep(1)
     sw.stop()
     assert round(sw.time) == 4.0
Пример #7
0
 def test_stop_2(self):
     sw = StopWatch()
     sw.start()
     time.sleep(1)
     sw.stop()
     assert round(sw.time) == 1.0
     time.sleep(1)
     sw.start()
     time.sleep(2)
     sw.stop()
     assert round(sw.time) == 3.0
     assert sw.nintervals == 2
Пример #8
0
def main():
    """SIMBAD database creation function"""
    p = create_db_argparse()
    args = p.parse_args()

    global logger
    log_class = simbad.command_line.LogController()
    log_class.add_console(level=args.debug_lvl)
    logger = log_class.get_logger()

    simbad.command_line.print_header()

    stopwatch = StopWatch()
    stopwatch.start()

    if args.which == "lattice":
        create_lattice_db(args.latt_db)
    elif args.which == "contaminant":
        create_contaminant_db(args.cont_db,
                              args.add_morda_domains,
                              nproc=args.nproc,
                              submit_qtype=args.submit_qtype,
                              submit_queue=args.submit_queue)
    elif args.which == "morda":
        create_morda_db(args.simbad_db,
                        nproc=args.nproc,
                        submit_qtype=args.submit_qtype,
                        submit_queue=args.submit_queue,
                        chunk_size=args.chunk_size)
    elif args.which == "ensemble":
        create_ensemble_db(args.ensemble_db,
                           pdb_db=args.pdb_db,
                           nproc=args.nproc,
                           submit_qtype=args.submit_qtype,
                           submit_queue=args.submit_queue,
                           chunk_size=args.chunk_size)
    elif args.which == "custom":
        create_db_custom(args.input_db, args.custom_db)
    elif args.which == "validate":
        if os.path.isdir(args.database):
            validate_compressed_database(args.database)
        else:
            logger.critical("Unable to validate the following database: %s",
                            args.database)

    stopwatch.stop()
    logger.info(
        "Database creation completed in %d days, %d hours, %d minutes, and %d seconds",
        *stopwatch.time_pretty)
    log_class.close()
Пример #9
0
 def test_lap_4(self):
     sw = StopWatch()
     sw.start()
     time.sleep(1)
     assert round(sw.lap.time) == 1.0
     time.sleep(3)
     assert round(sw.lap.time) == 3.0
     sw.stop()
     time.sleep(1)
     sw.start()
     time.sleep(2)
     assert round(sw.lap.time) == 2.0
     sw.stop()
     assert sw.nintervals == 2
     assert sw[0].nlaps == 2
     assert sw[1].nlaps == 1
Пример #10
0
 def test_start_1(self):
     assert StopWatch().time == 0
Пример #11
0
 def test_lap_1(self):
     assert StopWatch().lap is None
Пример #12
0
 def test_context_2(self):
     with StopWatch() as sw:
         time.sleep(3)
         sw.stop()
         time.sleep(2)
     assert round(sw.time) == 3.0
Пример #13
0
 def test_context_1(self):
     with StopWatch() as sw:
         time.sleep(3)
     assert round(sw.time) == 3.0
Пример #14
0
 def test_convert_2(self):
     sw = StopWatch()
     sw.start()
     time.sleep(5)
     sw.stop()
     assert sw.time_pretty == (0, 0, 0, 5)
Пример #15
0
 def test_start_2(self):
     sw = StopWatch()
     sw.start()
     assert sw.running
     time.sleep(1)
     assert round(sw.time) == 1.0