Time an EMD command with the given data as arguments
557786
def time_emd(emd_type, data):
    """"""

    emd = {
        'cause': _CAUSE_EMD,
        'effect': pyphi.subsystem.effect_emd,
        'hamming': pyphi.utils.hamming_emd
    }[emd_type]

    def statement():
        for (d1, d2) in data:
            emd(d1, d2)

    results = timeit.repeat(statement, number=NUMBER, repeat=REPEAT)

    return min(results)
988585
def getChargeTimeElapsed(self):
    """"""
    command = '$GS'
    status = self.sendCommand(command)
    if int(status[1]) == 3:
      return int(status[2])
    else:
      return 0
677601
def handle(self, *args, **options):
        

        # Create a data directory
        self.data_dir = os.path.join(
            settings.BASE_DIR,
            'data')
        if not os.path.exists(self.data_dir):
            os.makedirs(self.data_dir)

        # Start the clock
        self.start_datetime = datetime.now()
515985
def parse_time_arg(s):
    
    try:
        return time.strptime(s, "%Y-%m-%d %H:%M")
    except ValueError as e:
        raise argparse.ArgumentTypeError(e)
975009
def pipe_data_received(self, fd, data):
        """"""
        if fd == 2:  # stderr fd number
            self._on_stderr(data)
        elif self._on_data:
            self._on_data(data)
        else:
            self._queued_data.append(data)
166500
function getElapsedTime(startTime) {
	const prettyHrtime = require("pretty-hrtime");
	const timeDiff = process.hrtime(startTime);
	return prettyHrtime(timeDiff);
}
1066157
def cmd(send, _, args):
    
    curr = datetime.now()
    uptime = args['handler'].uptime
    load_avg = ', '.join([str(x) for x in os.getloadavg()])
    starttime = curr - uptime['start']
    reloaded = curr - uptime['reloaded']
    send("Time since start: %s, load average: %s" % (starttime, load_avg))
    send("Time since reload: %s" % reloaded)
1036809
def ctime(message=None):
    ""
    t = time.time()
    yield
    if message:
        print message + ":\t",
    print round(time.time() - t, 4), "sec"
349731
def mtime(filename, local = false)
      str = mdtm(filename)
      ary = str.scan(MDTM_REGEXP)[0].collect {|i| i.to_i}
      return local ? Time.local(*ary) : Time.gm(*ary)
    end
1065408
def run(self, cmd):
        """"""
        print datetime.datetime.now()
        output = subprocess.Popen(cmd, shell=True)
        output = output.communicate()[0]
        print output
1370692
def rungtd1d(time: Union[datetime, str, np.ndarray],
             altkm: np.ndarray,
             glat: float, glon: float) -> xarray.Dataset:
    
    time = todt64(time)
    # %% get solar parameters for date
    f107Ap = gi.getApF107(time, smoothdays=81)
    f107a = f107Ap['f107s'].item()
    f107 = f107Ap['f107'].item()
    Ap = f107Ap['Ap'].item()
# %% dimensions
    altkm = np.atleast_1d(altkm)
    assert altkm.ndim == 1
    assert isinstance(glon, (int, float))
    assert isinstance(glat, (int, float))
    assert isinstance(time, np.datetime64) or (time.size == 1 and isinstance(
        time[0], np.datetime64)), 'if you have multiple times, for loop over them'

# don't check ap, too complicated
    assert isinstance(MASS, (float, int))
    assert len(TSELECOPS) == 25
# %%
    gtd7.tselec(TSELECOPS)  # like the msis_driver example

    iyd, utsec, stl = datetime2gtd(time, glon)
    altkm = np.atleast_1d(altkm)

    gtd7.meters(1)  # makes output in m^-3 and kg/m^-3
# %%
    if isinstance(Ap, (float, int)):
        Ap = [Ap]*7  # even if SW(9) == 1 due to f2py needs for array

    dens = np.empty((altkm.size, len(species)))
    temp = np.empty((altkm.size, len(ttypes)))
    for i, a in enumerate(altkm):
        dens[i, :], temp[i, :] = gtd7.gtd7(iyd, utsec, a, glat, glon, stl, f107a, f107, Ap, MASS)

    dsf = {k: (('time', 'alt_km', 'lat', 'lon'), v[None, :, None, None]) for (k, v) in zip(species, dens.T)}
    dsf.update({'Tn':  (('time', 'alt_km', 'lat', 'lon'), temp[:, 1][None, :, None, None]),
                'Texo': (('time', 'alt_km', 'lat', 'lon'), temp[:, 0][None, :, None, None])})

    atmos = xarray.Dataset(dsf,
                           coords={'time': time.astype(datetime), 'alt_km': altkm, 'lat': [glat], 'lon': [glon], },
                           attrs={'Ap': Ap, 'f107': f107, 'f107a': f107a,
                                  'species': species})

    return atmos
574527
function parseArgv() {
  const args = {}
  for (const arg of process.argv) {
    const elems = arg.split('=')
    const key = elems[0]
    const val = elems.length > 1 ? elems[1] : true
    args[key] = val
  }
  return args
}
447371
def do_eb(self, arg):
        
        # TODO
        # data parameter should be optional, use a child Cmd here
        pid        = self.get_process_id_from_prefix()
        token_list = self.split_tokens(arg, 2)
        address    = self.input_address(token_list[0], pid)
        data       = HexInput.hexadecimal(' '.join(token_list[1:]))
        self.write_memory(address, data, pid)
1027266
def clock(seg, seconds):
    
    interval = 0.5
    for i in range(int(seconds / interval)):
        now = datetime.now()
        seg.text = now.strftime("%H-%M-%S")

        # calculate blinking dot
        if i % 2 == 0:
            seg.text = now.strftime("%H-%M-%S")
        else:
            seg.text = now.strftime("%H %M %S")

        time.sleep(interval)
1107438
def strtime (t, func=time.localtime):
    """"""
    return time.strftime("%Y-%m-%d %H:%M:%S", func(t)) + strtimezone()
955435
def makeFMData( from_dict, locked = False):
	""""""

	class FMData(object):
		"""Datastructure where:

			- attr and dict access is equal (eg. FMData.value == FMData['value'])
			- only attributtes given during initialization are readable and writable 
			- modified attributes are tracked"""
		__modified__ = set()
		__slots__, __init_dict__, __old2new__, __new2old__ = key_dict(  from_dict )

		def __init__(self, locked = False):
			init_dict = self.__init_dict__
			for key in init_dict:
				value = init_dict[key]
				date, mo, da, ye, time, ho, mi, se = [None] * 8
				if type(value) in [str, unicode]:
					date, da, mo, ye, time, ho, mi, se = reDateTime.match( value ).groups()
					if mo and int(mo) > 12:
						mo, da = da, mo

				if type(init_dict[key]) == dict:
					setattr(self, key, makeFMData( init_dict[key], locked=False ) ) # lock all substructures??
				elif type(init_dict[key]) == list:
					l = []
					for d in init_dict[key]:
						if type(d) == dict:
							l.append( makeFMData (d )) # lock ??
						else:
							l.append( d )
					setattr(self, key, l )
				elif date and time:
					setattr(self, key, DateTime(int(ye), int(mo), int(da), int(ho), int(mi), int(se)))
				elif date:
					setattr(self, key, Date(int(ye), int(mo), int(da)))
				elif time:
					setattr(self, key, Time(int(ho), int(mi), int(se)))
				else:
					setattr(self, key, init_dict[key])
			if locked:
				self.__modified__.add('__locked__')

		def __setattr__(self, key, value):
			if '__locked__' in self.__modified__:
				raise AttributeError, "This substructure is read-only, so you cannot modify '%s' attribute." % key
			oldvalue = None
			if hasattr(self, key):
				oldvalue = getattr(self, key)
			#if oldvalue != None and type(oldvalue) != type(value):
			#	 raise TypeError, "Type of field '%s' is %s, you cannot insert %s" % (key, type(oldvalue), type(value))
			object.__setattr__(self, key, value)
			if oldvalue != None and value != oldvalue:
				self.__modified__.add(key)

		def __getitem__(self, key):
			if type(key) == str or type(key) == unicode:
				spl = key.split('.')
			else:
				print "-"*20, key, type(key)
			if len(spl) == 2:
				if self.__old2new__.has_key(spl[0]):
					spl[0] = self.__old2new__[spl[0]]
				if self.__old2new__.has_key(spl[1]):
					spl[1] = self.__old2new__[spl[1]]					
				return getattr( getattr(self, spl[0]), spl[1])
			if self.__old2new__.has_key(key):
				key = self.__old2new__[key]
			return getattr(self, key)

		def __setitem__(self, key, value):
			spl = key.split('.')
			if len(spl) == 2:
				if self.__old2new__.has_key(spl[0]):
					spl[0] = self.__old2new__[spl[0]]
				if self.__old2new__.has_key(spl[1]):
					spl[1] = self.__old2new__[spl[1]]					
				return setattr( getattr(self, spl[0]), spl[1], value)
			if self.__old2new__.has_key(key):
				key = self.__old2new__[key]
			return setattr(self, key, value)

		def __str__(self):
			return object.__repr__(self)

		def __iter__(self):
			l = []
			for key in self.__slots__:
				if hasattr( getattr(self, key), '__slots__'):
					for subkey in getattr(self, key).__slots__:
						l.append( "%s.%s" % (key, subkey))
				else:
					l.append( key )
			l.sort()
			for x in l:
				yield x

		def _modified(self):
			"""Returns tuple (key, value) for modified keys inside of FMData tree (recursive without lists)"""
			l = []
			for key in self.__slots__:
				if hasattr( getattr(self, key), '__modified__'):
					for subkey, value in getattr(self, key)._modified():
						yield ( "%s.%s" % (key, subkey), value )
				else:
					if key in self.__modified__:
						yield (key, getattr( self, key))

		def __repr__(self):
			#from pformat import pformat
			#return "<%s instance with %s records>\n%s" % (str(self.__class__), len(self.__slots__), pformat(dict([(value, getattr(self, value)) for value in self.__slots__])))
			#return pformat(dict([(value, getattr(self, value)) for value in self.__slots__]))
			l = []
			for key in self.__slots__:
				ukey = ""
				if self.__new2old__.has_key(key):
					ukey = " (%s)" % self.__new2old__[key]
				if hasattr( getattr(self, key), '__slots__'):
					for subkey in getattr(self, key).__slots__:
						value = getattr( getattr(self, key), subkey)
						if type(value) == str:
							value = value.decode('utf-8')
						l.append( "%s.%s = '%s'" % (key, subkey, value))
				elif type(getattr(self, key)) == list:
					l.append( "%s%s = <list with %s records>" % (key, ukey, len(getattr(self, key))))
				elif type(getattr(self, key)) == str:
					l.append( "%s%s = '%s'" % (key, ukey, getattr(self, key).decode('utf-8')))
				else:
					l.append( "%s%s = '%s'" % (key, ukey, getattr(self, key)))
			l.sort()
			return str(('\n'.join(l)).encode('utf-8'))

		def get(self, key, default=None):
			try:
				return self.__getitem__(key)
			except AttributeError:
				return default

	return FMData( locked )
1113331
def cmd_time(self, args):
        ''''''
        tusec = self.master.field('SYSTEM_TIME', 'time_unix_usec', 0)
        if tusec == 0:
            print("No SYSTEM_TIME time available")
            return
        print("%s (%s)\n" % (time.ctime(tusec * 1.0e-6), time.ctime()))