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(va...
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 = at...
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])) se...
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,...
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())) ...
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: ...
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.__f...
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) ...
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(...
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']: ...
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() ...
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...
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 = %...
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( ...
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....
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:...
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,(...
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_facto...
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 pro...
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: ...
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(s...
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: ...
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 ]