function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def save():
global s
s = area.saveState() | robertsj/poropy | [
6,
12,
6,
3,
1324137820
] |
def load():
global s
area.restoreState(s) | robertsj/poropy | [
6,
12,
6,
3,
1324137820
] |
def start_requests(self):
for url in self.start_urls:
yield Request(url, cookies={'loginEmail': "@.com"}, dont_filter=True) | firmadyne/scraper | [
98,
69,
98,
3,
1453272653
] |
def minimizePOSCAR(self):
m = self.m
if m.engine == "lammps":
m.dump2POSCAR(m.home + '/minimize/range', rotate=True)
elif m.engine == "vasp":
cp(m.home + '/minimize/CONTCAR', 'POSCAR') | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def energyForce(self):
self.getVaspRun_vasp()
forces = parseVasprun('forces')
stress = parseVasprun('stress')
c = shell_exec("grep TOTEN OUTCAR|tail -1")
energy = sscanf(c, "free energy TOTEN = %f eV")[0]
return forces, stress, energy | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def check1(self, filename='FORCE_CONSTANTS'):
ref = io.read('SPOSCAR')
fc2 = readfc2(filename)
np.set_printoptions(precision=2, suppress=True)
files = ['dir_POSCAR-001']
vasprunxml = "dir_SPOSCAR/vasprun.xml"
if exists(vasprunxml):
vasprun = etree.iterparse(vasprunxml, tag='varray')
forces0 = parseVasprun(vasprun, 'forces')
print(forces0.max())
else:
forces0 = 0.0
for file in files:
print(file)
POSCAR = 'dirs/%s/POSCAR' % file
vasprunxml = "dirs/%s/vasprun.xml" % file
atoms = io.read(POSCAR)
u = atoms.positions - ref.positions
f = -np.einsum('ijkl,jl', fc2, u)
vasprun = etree.iterparse(vasprunxml, tag='varray')
forces = parseVasprun(vasprun, 'forces') - forces0
print(np.abs(f).max(), "\n")
print(np.abs(forces - f).max())
print(np.allclose(f, forces, atol=1e-2)) | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def stub(self):
files = shell_exec("ls dirs").split('\n')
files = map(lambda x: x.replace('dir_', ''), files)
fc2 = readfc2('fc2')
for file in files:
ref = io.read('SPOSCAR')
a = 'dirs/dir_' + str(file)
atoms = io.read(a + "/POSCAR")
u = atoms.positions - ref.positions
f = -np.einsum('ijkl,jl', fc2, u)
forces = ""
for force in f:
forces += "<v> %f %f %f </v>\n" % tuple(force)
vasprun = '<root><calculation><varray name="forces" >\n'
vasprun += forces
vasprun += '</varray></calculation></root>\n'
write(vasprun, a + "/vasprun.xml") | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def fc2(self):
files = shell_exec("ls dirs").split('\n')
files = map(lambda x: x.replace('dir_', ''), files)
# when the number of files >1000, the order is wrong ,POSCAR-001,
# POSCAR-1500 ,POSCAR-159
files.sort(lambda x, y: int(x.split('-')[1]) - int(y.split('-')[1]))
self.force_constant(files) | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def generate_vconf(self):
# generate v.conf
m = self.m
mesh = """DIM = %s
ATOM_NAME = %s
MP = %s
FORCE_CONSTANTS = READ
MESH_SYMMETRY = .FALSE.
GROUP_VELOCITY=.TRUE.
PRIMITIVE_AXIS = %s
""" % (m.dim, ' '.join(m.elements), ' '.join(map(str, m.kpoints)),
toString(m.premitive.flatten()))
mesh = mesh.replace(r'^\s+', '')
write(mesh, 'v.conf') | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def generate_vqconf(self, q):
# generate q.conf
m = self.m
mesh = """DIM = %s
ATOM_NAME = %s
FORCE_CONSTANTS = READ
GROUP_VELOCITY=.TRUE.
QPOINTS=.TRUE.
PRIMITIVE_AXIS = %s
""" % (m.dim, ' '.join(m.elements), toString(m.premitive.flatten()))
mesh = mesh.replace(r'^\s+', '')
write(mesh, 'q.conf')
s = "%s\n" % len(q)
for qq in q:
s += "%s\n" % toString(qq)
write(s, 'QPOINTS') | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def writeINCAR(self):
m = self.m
npar = 1
for i in range(1, int(np.sqrt(m.cores)) + 1):
if m.cores % i == 0:
npar = i
if m.ispin:
ispin = "ISPIN=2"
else:
ispin = ""
if m.soc:
soc = "LSORBIT=T"
else:
soc = ""
if m.isym:
sym = "ISYM = 1"
else:
sym = "ISYM = 0"
s = """SYSTEM=calculate energy
PREC = High
IBRION = -1
ENCUT = %f
EDIFF = 1.0e-8
ISMEAR = %d; SIGMA = 0.01
IALGO = 38
LREAL = .FALSE.
ADDGRID = .TRUE.
LWAVE = .FALSE.
LCHARG = .FALSE.
NPAR = %d
%s
%s
%s
""" % (self.m.ecut, m.ismear, npar, sym, ispin, soc)
if m.vdw:
s += """\nIVDW = 1
VDW_RADIUS = 50
VDW_S6 = 0.75
VDW_SR = 1.00
VDW_SCALING = 0.75
VDW_D = 20.0
VDW_C6 = 63.540 31.50
VDW_R0 = 1.898 1.892
"""
s = s.replace(r'^\s+', '')
write(s, 'INCAR') | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def getVaspRun_lammps(self):
m = self.m
if 'jm' in self.__dict__:
path = pwd()
pb = pbs(
queue=m.queue,
nodes=1,
procs=4,
disp=m.pbsname,
path=path,
content=config.python + vasprun.__file__ + ' >log.out')
self.jm.reg(pb)
else:
shell_exec(config.python + vasprun.__file__ + ' >log.out') | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def getvasprun(self, files):
m = self.m
maindir = pwd()
if m.engine == "vasp":
calculator = self.getVaspRun_vasp
elif m.engine == "lammps":
calculator = self.getVaspRun_lammps
self.jm = jobManager()
for file in files:
print(file)
dir = "dirs/dir_" + file
mkdir(dir)
mv(file, dir + '/POSCAR')
cd(dir)
calculator()
cd(maindir)
self.jm.run()
if m.th:
mkdir(m.pbsname)
self.thcode(files, m.pbsname)
cp("dirs", m.pbsname)
passthru("tar zcf %s.tar.gz %s" % (m.pbsname, m.pbsname))
print('start check')
self.jm.check()
if m.engine == "lammps1":
from multiprocessing.dummy import Pool
pool = Pool()
pool.map_async(lammpsvasprun, files)
pool.close()
pool.join() | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def checkMinimize(self):
import yaml
data = yaml.load(open('disp.yaml').read())
disps = [map(float, a['direction']) for a in data['displacements']]
maindir = pwd()
dirs = ls('dirs/dir_*')
ii = 0
L = np.linalg.norm
# d,p,d1,p1=self.m.rot
out = open('ccos.txt', 'w')
for dir in dirs:
cd(dir)
f = open('dump.force')
for i in range(9):
f.next()
for b in range(ii):
f.next()
line = f.next()
line = line.split()
force = np.array(map(float, line[1:4]))
# force=RotateVector(force,d1,-p1)
# force=RotateVector(force,d,-p)
d = disps[i]
ccos = force.dot(d) / L(force) / L(d)
ii += 1
print >> out, "%d\t%f" % (ii, ccos)
cd(maindir) | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def generate(self):
self.minimizePOSCAR()
self.run() | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def postp(self):
m = self.m
if m.gamma_only:
self.getDos()
return
self.getband()
self.getDos()
self.getbanddos()
self.drawpr()
self.getV() | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def getvqpoints(self, q):
self.generate_vqconf(q)
passthru(config.phonopy + "--tolerance=1e-4 q.conf")
data = parseyaml('qpoints.yaml')
file = open("v.txt", 'w')
for phonon in data['phonon']:
qp = phonon['q-position']
for band in phonon['band']:
frequency = band['frequency']
v = np.array(band['group_velocity'])
v = np.linalg.norm(v)
print >> file, "%s\t%f\t%f" % ('\t'.join(map(str, qp)),
frequency, v)
file.close()
v = np.loadtxt('v.txt')
plot(
(v[:, 3], 'Frequency (THz)'), (v[:, 4],
'Group Velocity (Angstrom/ps)'),
'v_freq.png',
grid=True,
scatter=True) | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def getV(self):
if not exists('groupv'):
mkdir('groupv')
cd('groupv')
cp('../FORCE_CONSTANTS', '.')
cp('../POSCAR', '.')
cp('../disp.yaml', '.')
self.generate_vconf()
passthru(config.phonopy + "--tolerance=1e-4 v.conf")
self.drawV()
cd('..') | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def getband(self):
self.generate_bandconf()
passthru(config.phonopy + "--tolerance=1e-4 -s band.conf")
plotband(labels=' '.join(self.m.bandpath)) | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def modulation(self):
m = self.m
conf = """
DIM = %s
MODULATION = 1 1 1, 0 0 0 0 1 0
ATOM_NAME = %s
FORCE_CONSTANTS = READ
""" % (m.dim, ' '.join(m.elements))
write(conf, 'modulation.conf')
passthru(config.phonopy + "--tolerance=1e-4 modulation.conf") | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def generate_bandconf(self):
# generate mesh.conf
m = self.m
bp = m.bandpoints
bpath = ' '.join([toString(bp[x]) for x in m.bandpath])
band = """DIM = %s
ATOM_NAME = %s
BAND = %s
BAND_POINTS = 101
FORCE_CONSTANTS = READ
PRIMITIVE_AXIS = %s
""" % (m.dim, ' '.join(m.elements),
bpath, toString(m.premitive.flatten()))
band = band.replace(r'^\s+', '')
write(band, 'band.conf') | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def drawDos(self):
freq, pdos = self.getpdos()
datas = [(freq, p, '') for p in pdos.T]
series(
'Frequency (THz)',
'Partial Density of States',
datas=datas,
filename='partial_dos.png',
legend=False,
grid=True)
plot(
(freq, 'Frequency (THz)'), (np.sum(pdos, axis=1),
'Density of States'),
filename='total_dos.png')
# calculate paticipation ratio | vanceeasleaf/aces | [
19,
9,
19,
4,
1428476265
] |
def __init__(self):
self.Chat_Message_Event = events.ChatMessageEventHandler()
self.Player_Join_Event = events.PlayerJoinEventHandler()
self.Player_Leave_Event = events.PlayerLeaveEventHandler()
self.Player_Move_Event = events.PlayerMoveEventHandler()
self.Command_Event = events.CommandEventHandler()
self.Packet_Recv_Event = events.PacketRecvEventHandler() | benbaptist/pymine2 | [
8,
2,
8,
3,
1378884958
] |
def __init__(self, server):
self.plugins = {}
self.server = server | benbaptist/pymine2 | [
8,
2,
8,
3,
1378884958
] |
def CreateVXPExpansionFromColor(name,author,outfile,shortname,color,uniqueid,progress):
created_files=[]
try:
if name=='':
raise SaveError('No name')
if author=='':
raise SaveError('No author')
if shortname=='':
raise SaveError('No shortname')
try:
r,g,b=color
if r<0 or r>255:
raise SaveError('R channel out of bounds!')
if g<0 or g>255:
raise SaveError('G channel out of bounds!')
if b<0 or b>255:
raise SaveError('B channel out of bounds!')
except ValueError:
raise SaveError('Bad color')
if outfile=='':
raise SaveError('No outfile')
def SaveCFG(outzip):
cfg='Name=%s\nAuthor=%s\nOriginal Author=%s\nType=Portable\nContent=Backgrounds\nDate=%i\nGenerator=rgb2vxp %s\n' % (name,author,author,int(time()),version)
outzip.writestr(shortname+'.cfg',cfg)
progress()
def Save3CN(outzip):
bkgd=lib3dmm.Quad('BKGD',uniqueid,2)
bkgd.setData('\x01\x00\x03\x03\x0A\x5C\xF8\x77')
bkgd.setString(name)
bds=lib3dmm.Quad('BDS ',uniqueid)
bds.setData('\x01\x00\x03\x03\x00\x00\x01\x00\x01\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x44\x4E\x53\x4D\xFF\x4F\x00\x00')
cam=lib3dmm.Quad('CAM ',uniqueid)
cam.setData('\x01\x00\x03\x03\x00\x00\x01\x00\x00\x00\x88\x13\xbd\x16\x5f\x4e\x4a\xb7\x5a\x00\x00\x00\x00\x00\x23\x13\x11\x00\x27\x18\x00\x00\x00\x00\x00\x00\x2c\x01\xff\xff\x94\xfd\xff\xff\xf4\xff\x00\x00\xc5\xff\xff\xff\xcc\xfe\x00\x00\x6e\x02\x00\x00\x27\x18\x00\x00\x6c\x28\xa9\x00\xcf\xda\x15\x00\x94\xa8\x17\x00\xc8\xa0\x38\x00\x00\x00\x00\x00\xfb\xdb\x1f\x00')
mbmp=lib3dmm.Quad('MBMP',uniqueid)
mbmp.setDataFromFile('code/templates/rgbtemplate.MBMP')
zbmp=lib3dmm.Quad('ZBMP',uniqueid,4) # compressed
zbmp.setDataFromFile('code/templates/rgbtemplate.ZBMP')
gllt=lib3dmm.Quad('GLLT',uniqueid)
gllt.setData('\x01\x00\x03\x03\x38\x00\x00\x00\x02\x00\x00\x00\x24\xce\x00\x00\x00\x00\x00\x00\xbd\x97\x00\x00\xc9\x44\x00\x00\x26\xe4\x00\x00\x8c\xa2\xff\xff\xc3\x78\xff\xff\x0e\x74\x00\x00\xba\xb7\x00\x00\x1a\xa2\x38\x00\x33\xf2\x9a\x00\x06\x34\x5a\x00\x00\x00\x01\x00\x01\x00\x00\x00\xdb\x11\xff\xff\x00\x00\x00\x00\x27\xa2\xff\xff\x3a\xe0\xff\xff\xda\xf0\x00\x00\xa0\x50\x00\x00\x4d\x58\x00\x00\xac\x56\x00\x00\xef\x1f\xff\xff\x19\x21\x65\x02\xf2\x30\x71\x01\x44\x8b\xaa\xfb\x00\x00\x01\x00\x01\x00\x00\x00')
glcr=lib3dmm.Quad('GLCR',uniqueid)
glcrdata=str(open('code/templates/rgb_template.GLCR','rb').read())
glcrdata=glcrdata[0:772]+pack('<3B',b,g,r)+glcrdata[772+3:]
glcr.setData(glcrdata) | foone/7gen | [
5,
1,
5,
2,
1422166989
] |
def CreateMBMP():
surf=pygame.Surface((128,72),SWSURFACE,palette_surf)
surf.fill(30)
surf.set_palette(palette_surf.get_palette())
font=sockgui.Font('code/font.png')
font.draw(surf,(2,2),'Custom color')
font.draw(surf,(2,2+8), 'Red: %i (%2.0f%%)' % (r,(r/255.0)*100))
font.draw(surf,(2,2+16),'Green: %i (%2.0f%%)' % (g,(g/255.0)*100))
font.draw(surf,(2,2+24),'Blue: %i (%2.0f%%)' % (b,(b/255.0)*100))
#stuff here.
return surf | foone/7gen | [
5,
1,
5,
2,
1422166989
] |
def NullProgress():
pass | foone/7gen | [
5,
1,
5,
2,
1422166989
] |
def setUp(self):
super(TopologyLayer2TestCase, self).setUp()
self.model_id = 1
self.nav_graph = nx.MultiDiGraph()
self.a = a = self._netbox_factory('a')
self.b = b = self._netbox_factory('b')
self.c = c = self._netbox_factory('c')
self.d = d = self._netbox_factory('d')
self.a1 = a1 = self._interface_factory('a1', a)
self.a2 = a2 = self._interface_factory('a2', a)
self.a3 = a3 = self._interface_factory('a3', a)
self.b1 = b1 = self._interface_factory('b1', b)
self.b2 = b2 = self._interface_factory('b2', b)
self.c3 = c3 = self._interface_factory('c3', c)
self.c4 = c4 = self._interface_factory('c4', c)
self.d4 = d4 = self._interface_factory('d4', d)
self._add_edge(self.nav_graph, a1.netbox, a1, b1.netbox, b1)
self._add_edge(self.nav_graph, b1.netbox, b1, a1.netbox, a1)
self._add_edge(self.nav_graph, a2.netbox, a2, b2.netbox, b2)
self._add_edge(self.nav_graph, b2.netbox, b2, a2.netbox, a2)
self._add_edge(self.nav_graph, a3.netbox, a3, c3.netbox, c3)
self._add_edge(self.nav_graph, d4.netbox, d4, c4.netbox, c4)
self.vlan__a1_b1 = a_vlan_between_a1_and_b1 = SwPortVlan(
id=self._next_id(), interface=self.a1, vlan=Vlan(id=201, vlan=2))
self.vlans = patch.object(topology, '_get_vlans_map_layer2',
return_value=(
{
self.a1: [a_vlan_between_a1_and_b1],
self.b1: [a_vlan_between_a1_and_b1],
self.a2: [],
self.b2: [],
self.a3: [],
self.c3: []
},
{
self.a: {201: a_vlan_between_a1_and_b1},
self.b: {201: a_vlan_between_a1_and_b1},
self.c: {}
}))
self.vlans.start()
self.build_l2 = patch.object(vlan, 'build_layer2_graph', return_value=self.nav_graph)
self.build_l2.start()
bar = vlan.build_layer2_graph()
#foo = topology._get_vlans_map_layer2(bar)
vlan_by_interfaces, vlan_by_netbox = topology._get_vlans_map_layer2(self.nav_graph)
self.netmap_graph = topology.build_netmap_layer2_graph(
vlan.build_layer2_graph(),
vlan_by_interfaces,
vlan_by_netbox,
None) | UNINETT/nav | [
131,
35,
131,
187,
1484647509
] |
def test_noop_layer2_testcase_setup(self):
self.assertTrue(True) | UNINETT/nav | [
131,
35,
131,
187,
1484647509
] |
def angle_symbol(angle, round_to=1.0):
"""
Return a string representing an angle, rounded and with a degree symbol. | bosscha/alma-calibrator | [
1,
1,
1,
1,
1447869513
] |
def __init__(self,
projection='hammer',
lat_0=0., lon_0=0.,
suppress_ticks=True,
boundinglat=None,
fix_aspect=True,
anchor=str('C'),
ax=None):
if projection != 'hammer' and projection !='moll':
raise ValueError('Only hammer and moll projections supported!')
# Use Basemap's init, enforcing the values of many parameters that
# aren't used or whose Basemap defaults would not be altered for all-sky
# celestial maps.
Basemap.__init__(self, llcrnrlon=None, llcrnrlat=None,
urcrnrlon=None, urcrnrlat=None,
llcrnrx=None, llcrnry=None,
urcrnrx=None, urcrnry=None,
width=None, height=None,
projection=projection, resolution=None,
area_thresh=None, rsphere=1.,
lat_ts=None,
lat_1=None, lat_2=None,
lat_0=lat_0, lon_0=lon_0,
suppress_ticks=suppress_ticks,
satellite_height=1.,
boundinglat=None,
fix_aspect=True,
anchor=anchor,
celestial=True,
ax=ax)
# Keep a local ref to lon_0 for hemisphere checking.
self._lon_0 = self.projparams['lon_0']
self._limb = None | bosscha/alma-calibrator | [
1,
1,
1,
1,
1447869513
] |
def label_meridians(self, lons, fontsize=10, valign='bottom', vnudge=0,
halign='center', hnudge=0, color='black'):
"""
Label meridians with their longitude values in degrees. | bosscha/alma-calibrator | [
1,
1,
1,
1,
1447869513
] |
def east_hem(self, lon):
"""
Return True if lon is in the eastern hemisphere of the map wrt lon_0.
"""
if (lon-self._lon_0) % 360. <= self.east_lon:
return True
else:
return False | bosscha/alma-calibrator | [
1,
1,
1,
1,
1447869513
] |
def tissot(self,lon_0,lat_0,radius_deg,npts,ax=None,**kwargs):
"""
Draw a polygon centered at ``lon_0,lat_0``. The polygon
approximates a circle on the surface of the earth with radius
``radius_deg`` degrees latitude along longitude ``lon_0``,
made up of ``npts`` vertices. | bosscha/alma-calibrator | [
1,
1,
1,
1,
1447869513
] |
def setLanguage( language ):
"""
@summary : sets specified language as the
language used for translations
throughout the entire class.
""" | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def addMonthsToIsoDate( isodate, monthstoAdd ):
""" | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getCurrentTimeInIsoformat():
"""
@summary : Returns current system time in iso format. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def isValidIsoDate( isoDate ):
"""
@summary : Verifies whether or not the received
date is a valid iso format date. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getYearMonthDayInStrfTime( timeInEpochFormat ):
"""
@summary : Return the year month day in strftime
based on an epoch date. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getDayOfTheWeek( timeInEpochFormat ):
"""
@summary : Return the year month day in strftime
based on an epoch date. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getStartEndFromPreviousDay( currentTime, nbDays = 1 ):
"""
Returns the start and end time of
the day prior to the currentTime. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getStartEndFromPreviousWeek( currentTime, nbWeeks = 1 ):
"""
Returns the start and end time of
the week prior to the currentTime. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getStartEndFromPreviousMonth( currentTime ):
"""
Returns the start and end time of
the month prior to the currentTime. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getStartEndFromPreviousYear( currentTime ):
"""
Returns the start and end time of
the day prior to the currentTime. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getStartEndFromCurrentDay( currentTime ):
"""
Returns the start and end time of
the current day. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getStartEndFromCurrentWeek( currentTime ):
"""
Returns the start and end time of
the currentweek. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getStartEndFromCurrentMonth( currentTime ):
"""
Returns the start and end time of
the currentDay. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getStartEndFromCurrentYear( currentTime ):
"""
Returns the start and end time of
the currentDay. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getHoursFromIso( iso = '2005-08-30 20:06:59' ):
"""
Returns the hours field from a iso format date. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getMinutesFromIso( iso = '2005-08-30 20:06:59' ):
"""
Returns the minute field from a iso format date. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def rewindXDays( date = '2005-08-30 20:06:59' , x = 0 ):
"""
Takes an iso format date and substract the number
of days specified by x. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getNumberOfDaysBetween( date1 = '2005-08-30 20:06:59', date2 = '2005-08-30 20:06:59' ):
""" | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def areDifferentDays( date1 = '2005-08-30 20:06:59', date2 = '2005-08-30 20:06:59' ):
""" | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getSecondsSinceEpoch(date='2005-08-30 20:06:59', format='%Y-%m-%d %H:%M:%S'): | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getIsoLastMinuteOfDay( iso = '2005-08-30 20:06:59' ):
"""
Takes an iso format date like 2005-08-30 20:06:59.
Replaces hour, minutes and seconds by last minute of day.
Returns 2005-08-30 23:59:59. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getIsoTodaysMidnight( iso ):
"""
Takes an iso format date like 2005-08-30 20:06:59.
Replaces hour, minutes and seconds by 00.
Returns 2005-08-30 00:00:00. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getIsoWithRoundedHours( iso ):
"""
Takes an iso format date like 2005-08-30 20:06:59.
Replaces minutes and seconds by 00.
Returns 2005-08-30 20:00:00. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getIsoWithRoundedSeconds( iso ):
"""
Takes a numbers of seconds since epoch and tranforms it in iso format
2005-08-30 20:06:59. Replaces minutes and seconds by 00 thus returning
2005-08-30 20:00:00. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getSeconds(string):
# Should be used with string of following format: hh:mm:ss
hours, minutes, seconds = string.split(':')
return int(hours) * HOUR + int(minutes) * MINUTE + int(seconds) | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getHoursSinceStartOfDay( date='2005-08-30 20:06:59' ):
"""
This method takes an iso style date and returns the number
of hours that have passed since 00:00:00 of the same day. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def isoDateDashed( date = "20060613162653" ):
"""
This method takes in parameter a non dashed iso date and
returns the date dashed and the time with : as seperator. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getMinutesSinceStartOfDay( date='2005-08-30 20:06:59' ):
"""
This method receives an iso date as parameter and returns the number of minutes
wich have passed since the start of that day. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getSecondsSinceStartOfDay( date='2005-08-30 20:06:59' ):
"""
This method receives an iso date as parameter and returns the number of seconds
wich have passed since the start of that day. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getNumericMonthFromString( month ) :
"""
This method takes a month in the string format and returns the month.
Returns 00 if month is unknown. | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getIsoFromEpoch( seconds ):
"""
Take a number of seconds built with getSecondsSinceEpoch
and returns a date in the format of '2005-08-30 20:06:59'
Thu May 18 13:00:00 2006 | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getOriginalHour( seconds ):
"""
Take a number of seconds built with getSecondsSinceEpoch
and returns a date in the format of '2005-08-30 20:06:59'
Thu May 18 13:00:00 2006 | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getSeparators( width=DAY, interval = 20*MINUTE ): | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getSeparatorsWithStartTime( startTime = "2006-06-06 00:00:00", width=DAY, interval=60*MINUTE ):
"""
This method works exactly like getSeparators but it uses a start time to set
the separators | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def getStartEndInIsoFormat( timeOfTheCall, span, spanType = "", fixedCurrent = False, fixedPrevious = False ):
""" | khosrow/metpx | [
1,
1,
1,
1,
1446661693
] |
def __init__(self, url):
super(Mitele, self).__init__(url)
self.session.http.headers.update({
"User-Agent": useragents.FIREFOX,
"Referer": self.url
}) | repotvsupertuga/tvsupertuga.repository | [
1,
8,
1,
4,
1493763534
] |
def can_handle_url(cls, url):
return cls._url_re.match(url) is not None | repotvsupertuga/tvsupertuga.repository | [
1,
8,
1,
4,
1493763534
] |
def setUp(self):
unittest.TestCase.setUp(self) | acutesoftware/worldbuild | [
5,
1,
5,
1,
1440234758
] |
def test_01_recipe(self):
res = mod_craft.Recipe('1', 'new recipe','20','mix')
#print(res)
self.assertEqual(str(res),'new recipe') | acutesoftware/worldbuild | [
5,
1,
5,
1,
1440234758
] |
def __init__(self, whex):
QScrollBar.__init__(self)
self.init(whex)
self.initCallBacks() | elthariel/dff | [
8,
5,
8,
1,
1268260249
] |
def init(self, whex):
self.whex = whex
self.heditor = self.whex.heditor
self.filesize = self.heditor.filesize
self.min = 0
self.single = 1
#Initialized in Whex with LFMOD
self.page = self.heditor.pageSize
self.max = 0
#Long File Mode | elthariel/dff | [
8,
5,
8,
1,
1268260249
] |
def initCallBacks(self):
self.connect(self, SIGNAL("sliderMoved(int)"), self.moved)
self.connect(self, SIGNAL("actionTriggered(int)"), self.triggered) | elthariel/dff | [
8,
5,
8,
1,
1268260249
] |
def triggered(self, action):
if action == QAbstractSlider.SliderSingleStepAdd:
self.whex.view.move(self.singleStep(), 1)
elif action == QAbstractSlider.SliderSingleStepSub:
self.whex.view.move(self.singleStep(), 0)
elif action == QAbstractSlider.SliderPageStepSub:
self.whex.view.move(self.pageStep(), 0)
elif action == QAbstractSlider.SliderPageStepAdd:
self.whex.view.move(self.pageStep(), 1) | elthariel/dff | [
8,
5,
8,
1,
1268260249
] |
def debug (message, level=10):
if timestamp: ts= '%s:'%time.time()
else: ts = ''
if level <= debug_level:
stack = traceback.extract_stack()
if len(stack) >= 2:
caller=stack[-2]
finame=caller[0]
line = caller[1]
else:
finame = " ".join(stack)
line = ""
if args.debug_file:
if debug_file.search(finame):
print("DEBUG: ",ts,"%s: %s"%(finame,line),message)
else:
print("DEBUG: ",ts,"%s: %s"%(finame,line),message) | kirienko/gourmet | [
27,
17,
27,
25,
1396286677
] |
def __init__ (self, name, level=10):
self.level = level
if level <= debug_level:
self.name = name
self.start = time.time() | kirienko/gourmet | [
27,
17,
27,
25,
1396286677
] |
def print_timer_info ():
for n,times in list(timers.items()):
print("%s:"%n, end=' ')
for t in times: print("%.02e"%t,",", end=' ')
print("") | kirienko/gourmet | [
27,
17,
27,
25,
1396286677
] |
def _set_container(self, item):
if hasattr( item, "container" ) and item.container not in (None,self): | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def _unset_container(self, item):
if item.container is not self:
raise ContainerError("Item %s was removed from container %s but was not in it" % (item, self))
item.container = None | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def _unset_container_multi(self, items):
"""Remove items from the container in an all-or-nothing way"""
r = []
try:
for i in items:
self._unset_container(i)
r.append(i)
r = None
finally:
if r is not None:
for i in r:
try:
self._set_container(i)
except ContainerError:
pass | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def __init__(self, items=[], owner=None):
list.__init__(self, items)
self._set_container_multi(items)
self.owner = owner | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def append(self, item):
self._set_container(item)
list.append(self,item) | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def insert(self, i, item):
self._set_container(item)
list.insert(self,i,item) | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def pop(self, i=-1):
self._unset_container(self[i])
return list.pop(self,i) | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def __add__(self, other):
raise NotImplementedError | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def __imul__(self,other):
raise NotImplementedError | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def __rmul__(self,other):
raise NotImplementedError | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def __iadd__(self, other):
self.extend(other)
return self | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def __delitem__(self, key):
# FIXME: check slices work okay
if isinstance(key, slice):
self._unset_container_multi(self[key])
else:
self._unset_container(self[key])
list.__delitem__(self,key) | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def __delslice__(self,i,j):
del self[slice(i,j,None)] | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def __init__(self, contents=None, **kwargs):
if contents is None:
dict.__init__(self, **kwargs)
else:
dict.__init__(self, contents, **kwargs)
self._set_container_multi(list(self.values())) | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def __setitem__(self, key, value):
if key in self:
self._unset_container(self[key])
try:
self._set_container(value)
except ContainerError:
if key in self:
self._set_container(self[key])
raise
dict.__setitem__(self,key,value) | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def pop(self, key):
if key in self:
self._unset_container(self[key])
return dict.pop(self,key) | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def setdefault(self, key, default=None):
if key not in self:
self._set_container(default)
dict.setdefault(self, key, default) | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def __init__(self, name, container=None):
self.name = name
self.container = container | jwvhewitt/dmeternal | [
54,
12,
54,
15,
1381198371
] |
def __init__(self, msg):
self.msg = msg
self.logger.warning(msg) | ComputerNetworks-UFRGS/AuroraSDN | [
5,
1,
5,
1,
1434721607
] |
def event(self, state, data=None):
pass | kadamski/func | [
9,
2,
9,
1,
1211919894
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.