Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Here is a snippet: <|code_start|> fid = open(fname, 'r') fcntl.flock(fid, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError: fid.close() msg = '%s already converting in another process\n' % fname sys.stderr.write(msg) sys.stderr.flush() ...
store(run)
Here is a snippet: <|code_start|> @property def game(self): return self.game_release.game @property def game_release(self): try: gr = GameRelease.objects.get(name=self.gametype) return gr except ObjectDoesNotExist: # new game release ...
send_mail([x[1] for x in settings.ADMINS], "SRS: ambiguous game name", msg)
Given the following code snippet before the placeholder: <|code_start|># This file is part of the "spring relay site / srs" program. It is published # under the GPLv3. # # Copyright (C) 2018 Daniel Troeder (daniel #at# admin-box #dot# com) # # You should have received a copy of the GNU General Public License # along wi...
timer = SrsTiming()
Predict the next line after this snippet: <|code_start|># This file is part of the "spring relay site / srs" program. It is published # under the GPLv3. # # Copyright (C) 2018 Daniel Troeder (daniel #at# admin-box #dot# com) # # You should have received a copy of the GNU General Public License # along with this program...
for ts_attr, label in TeamStats.graphid2label.items():
Given the code snippet: <|code_start|> image.thumbnail(size, Image.ANTIALIAS) self.thumb = "{}_home.jpg".format(self.map_name) image.save(path_join(settings.MAPS_PATH, self.thumb), "JPEG") return self.thumb def create_map_with_boxes(self, replay): """ create a map pic...
allyteams = Allyteam.objects.filter(
Predict the next line after this snippet: <|code_start|> ( int(at.startrectright * full_img_x) - int(at.startrectleft * full_img_x), int(at.startrectbottom * full_img_y) - int(at.startrecttop * full_img_y), ), (25...
players = Player.objects.filter(
Predict the next line for this snippet: <|code_start|> except Exception as exc: logger.error("FIXME: to broad exception handling.") logger.exception("Exception parsing packet '%s': %s", packet, exc) # raise e if DEBUG: kop.close() ...
match_stats_generation = MatchStatsGeneration(filename)
Based on the snippet: <|code_start|>#!/usr/bin/env python # This file is part of the "spring relay site / srs" program. It is published # under the GPLv3. # # Copyright (C) 2020 Daniel Troeder (daniel #at# admin-box #dot# com) # # You should have received a copy of the GNU General Public License # along with this prog...
maps = Map.objects.filter(metadata2=None).order_by("pk")
Given snippet: <|code_start|> ) # search for unused username counter = 0 while User.objects.filter(username="{}_{}".format(username, counter)).exists(): counter += 1 username = "{}_{}".format(usern...
userprofile, up_created = UserProfile.objects.get_or_create(
Here is a snippet: <|code_start|> widget=forms.TextInput(attrs={"size": "53"}), label="Tags (comma separated)", required=False, ) class SLDBPrivacyForm(forms.Form): MODE_CHOICES = ( ( 0, "<p><b>Privacy disabled</b>:<br>Your exact trueskill rating is shown...
game_choices = list(Game.objects.all().order_by("name").values_list("id", "name"))
Predict the next line for this snippet: <|code_start|># This file is part of the "infolog-upload" program. It is published # under the GPLv3. # # Copyright (C) 2016-2020 Daniel Troeder (daniel #at# admin-box #dot# com) # # You should have received a copy of the GNU General Public License # along with this program. If ...
admin.site.register(UserProfile, UserProfileAdmin)
Next line prediction: <|code_start|> @receiver(post_save, sender=apps.get_model(settings.AUTH_USER_MODEL)) def create_user_profile(sender, instance, created, **kwargs): if not created: return token = ''.join(choice(digits) for i in range(6)) token = instance.email + ':' + token <|code_end|> . U...
profile = UserProfile.objects.create(user=instance, token=token)
Given the following code snippet before the placeholder: <|code_start|> class IP(Timestampable): address = models.URLField(max_length=255) vhost = models.CharField(blank=True, max_length=255, default='default') <|code_end|> , predict the next line using imports from the current file: from django.core.exceptio...
user_profile = models.ForeignKey(UserProfile)
Given snippet: <|code_start|> # Create your views here. class LoginView(BaseView, TemplateView): """docstring for LoginView""" template_name = 'home/login.html' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) info = { 'info': { ...
class HomeView(BaseView, LoginRequiredMixin, TemplateView):
Using the snippet: <|code_start|> class UtilsIP(object): def get_list_ip(self, vhost): obj_vhost = {} obj_vhost['default'] = [] if not vhost: <|code_end|> , determine the next line of code. You have imports: from .models import IP and context (class names, function names, or code) availa...
list_ip = IP.objects.values_list('vhost', 'address').distinct()
Predict the next line after this snippet: <|code_start|> class IPAPIList(BaseView): def get(self, request, *args, **kwargs): util_ip = UtilsIP() result = util_ip.get_list_ip('') return HttpResponse(json.dumps(result)) class APIIPCreateView(BaseView): def post(self, request, *args, **...
model = IP
Predict the next line after this snippet: <|code_start|> class IPAPIList(BaseView): def get(self, request, *args, **kwargs): util_ip = UtilsIP() result = util_ip.get_list_ip('') return HttpResponse(json.dumps(result)) class APIIPCreateView(BaseView): def post(self, request, *args, **...
class IPListView(BaseView, LoginRequiredMixin, ListView):
Predict the next line for this snippet: <|code_start|> class TransactionStatusAPI(BaseView): @method_decorator(csrf_exempt) def dispatch(self, request, *args, **kwargs): return super().dispatch(request, *args, **kwargs) def get(self, *args, **kwargs): result = { "data": [ ...
your_ip = IP.objects.values_list('address', flat=True).filter(user_profile=self.request.user.profile)
Given snippet: <|code_start|> class TransactionStatusAPI(BaseView): @method_decorator(csrf_exempt) def dispatch(self, request, *args, **kwargs): return super().dispatch(request, *args, **kwargs) def get(self, *args, **kwargs): result = { "data": [ ] } ...
your_id_transaction = Transaction.objects.filter(address__in=set(your_ip)).values('address').annotate(id=Max('id')).values_list("id", flat=True)
Using the snippet: <|code_start|> struct.pack(b'>L', enum) + rec0[ebase + 12:ebase_idx + 4] + \ struct.pack(b'>L', len(exth_bytes) + 8) + exth_bytes + \ rec0[ebase_idx + getint(rec0, ebase_idx + 4):] enum_idx = enum_idx - 1 ebase_idx = ebase_idx + ...
with open(pathof(infile), 'rb') as f:
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- def save_html(string): if string: return html.escape(string, quote=False) else: return '' class EpubProc: def __init__(self, opffile, config): self.buff = [] self.book_title = '' # Название книги se...
self.hyphenator = MyHyphen(self.book_lang)
Given the code snippet: <|code_start|> # note: re requites the pattern to be the exact same type as the data to be searched in python3 # but u"" is not allowed for the pattern itself only b"" _TABLE = [('m', 1000), ('cm', 900), ('d', 500), ('cd', 400), ('c', 100), ('xc', 90), ('l', 50), ('xl', 40), ('x', 10), ('ix', ...
data = unicode_str(data)
Given the code snippet: <|code_start|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- count_files = 0 count_located = 0 count_processed = 0 def process_file(infile, kindle_dir, width, height, stretch, verbose): global count_files, count_located, count_processed count_files += 1 if not os.path.exists(...
reader = mobi_read(infile, width, height, stretch)
Using the snippet: <|code_start|> self.current_profile = {} self.mhl = False self.recursive = False self.send_to_kindle = {} self.send_to_kindle['send'] = False self.send_to_kindle['deleteSendedBook'] = True self.send_to_kindle['smtpServer'] = 'smtp.gmail.com' ...
default_cover_path = os.path.join(get_executable_path(), 'default_cover.jpg')
Next line prediction: <|code_start|> self.profiles['default']['seriesPositions'] = 2 self.profiles['default']['openBookFromCover'] = False self.profiles['default']['scaleImages'] = 0.0 self.profiles['default']['coverDefault'] = 'default_cover.jpg' self.profiles['default']['coverSt...
make_dir(default_css_path)
Using the snippet: <|code_start|> self.mhl = False self.recursive = False self.send_to_kindle = {} self.send_to_kindle['send'] = False self.send_to_kindle['deleteSendedBook'] = True self.send_to_kindle['smtpServer'] = 'smtp.gmail.com' self.send_to_kindle['smtpPort...
copy_file(default_cover_path, os.path.abspath(os.path.join(os.path.dirname(self.config_file), 'default_cover.jpg')))
Given the following code snippet before the placeholder: <|code_start|> if s is None: return None if isinstance(s, text_type): return s if isinstance(s, binary_type): try: return s.decode(enc) except: pass return s def exists(s): return os.path...
if PY2:
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- # borrowed from https://github.com/kevinhendricks/KindleUnpack and modified from __future__ import unicode_literals, division, absolute_import, print_function # utility routines to convert all paths to be full unicode # Under Python 2, if...
if isinstance(s, text_type):
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- # borrowed from https://github.com/kevinhendricks/KindleUnpack and modified from __future__ import unicode_literals, division, absolute_import, print_function # utility routines to convert all paths to be full unicode # U...
if isinstance(s, binary_type):
Based on the snippet: <|code_start|> try: decorators = settings.CARROT.get('monitor_authentication', []) except AttributeError: decorators = [] def _(v: Any, **kwargs) -> Any: """ Decorates a class based view with a custom auth decorator specified in the settings module """ return decorate_cla...
url(r'^$', _(MessageList), name='carrot-monitor'),
Given snippet: <|code_start|> try: decorators = settings.CARROT.get('monitor_authentication', []) except AttributeError: decorators = [] def _(v: Any, **kwargs) -> Any: """ Decorates a class based view with a custom auth decorator specified in the settings module """ <|code_end|> , continue by pre...
return decorate_class_view(v, decorators).as_view(**kwargs)
Here is a snippet: <|code_start|> try: decorators = settings.CARROT.get('monitor_authentication', []) except AttributeError: decorators = [] def _(v: Any, **kwargs) -> Any: """ Decorates a class based view with a custom auth decorator specified in the settings module """ return decorate_class_...
return decorate_function_view(v, decorators)
Given snippet: <|code_start|> try: decorators = settings.CARROT.get('monitor_authentication', []) except AttributeError: decorators = [] def _(v: Any, **kwargs) -> Any: """ Decorates a class based view with a custom auth decorator specified in the settings module """ return decorate_class_view...
url(r'^api/message-logs/published/$', _f(published_message_log_viewset), name='published-messagelog'),
Given snippet: <|code_start|> try: decorators = settings.CARROT.get('monitor_authentication', []) except AttributeError: decorators = [] def _(v: Any, **kwargs) -> Any: """ Decorates a class based view with a custom auth decorator specified in the settings module """ return decorate_class_view...
url(r'^api/message-logs/failed/$', _f(failed_message_log_viewset)),
Using the snippet: <|code_start|> try: decorators = settings.CARROT.get('monitor_authentication', []) except AttributeError: decorators = [] def _(v: Any, **kwargs) -> Any: """ Decorates a class based view with a custom auth decorator specified in the settings module """ return decorate_class_...
url(r'^api/message-logs/completed/$', _f(completed_message_log_viewset)),
Next line prediction: <|code_start|> try: decorators = settings.CARROT.get('monitor_authentication', []) except AttributeError: decorators = [] def _(v: Any, **kwargs) -> Any: """ Decorates a class based view with a custom auth decorator specified in the settings module """ return decorate_cla...
url(r'^api/scheduled-tasks/$', _f(scheduled_task_viewset)),
Based on the snippet: <|code_start|> try: decorators = settings.CARROT.get('monitor_authentication', []) except AttributeError: decorators = [] def _(v: Any, **kwargs) -> Any: """ Decorates a class based view with a custom auth decorator specified in the settings module """ return decorate_cla...
url(r'^api/message-logs/(?P<pk>[0-9]+)/$', _f(detail_message_log_viewset)),
Continue the code snippet: <|code_start|> decorators = settings.CARROT.get('monitor_authentication', []) except AttributeError: decorators = [] def _(v: Any, **kwargs) -> Any: """ Decorates a class based view with a custom auth decorator specified in the settings module """ return decorate_clas...
url(r'^api/scheduled-tasks/(?P<pk>[0-9]+)/$', _f(scheduled_task_detail)),
Given the code snippet: <|code_start|>except AttributeError: decorators = [] def _(v: Any, **kwargs) -> Any: """ Decorates a class based view with a custom auth decorator specified in the settings module """ return decorate_class_view(v, decorators).as_view(**kwargs) def _f(v: MessageLogViewset)...
url(r'^api/scheduled-tasks/(?P<pk>[0-9]+)/run/$', _f(run_scheduled_task)),
Given the following code snippet before the placeholder: <|code_start|> try: decorators = settings.CARROT.get('monitor_authentication', []) except AttributeError: decorators = [] def _(v: Any, **kwargs) -> Any: """ Decorates a class based view with a custom auth decorator specified in the settings mod...
url(r'^api/scheduled-tasks/task-choices/$', _f(task_list)),
Given the code snippet: <|code_start|>try: decorators = settings.CARROT.get('monitor_authentication', []) except AttributeError: decorators = [] def _(v: Any, **kwargs) -> Any: """ Decorates a class based view with a custom auth decorator specified in the settings module """ return decorate_cl...
url(r'^api/scheduled-tasks/validate-args/$', _f(validate_args)),
Next line prediction: <|code_start|> try: decorators = settings.CARROT.get('monitor_authentication', []) except AttributeError: decorators = [] def _(v: Any, **kwargs) -> Any: """ Decorates a class based view with a custom auth decorator specified in the settings module """ return decorate_cla...
url(r'^api/message-logs/purge/$', _f(purge_messages)),
Continue the code snippet: <|code_start|> try: decorators = settings.CARROT.get('monitor_authentication', []) except AttributeError: decorators = [] def _(v: Any, **kwargs) -> Any: """ Decorates a class based view with a custom auth decorator specified in the settings module """ return decorat...
def _f(v: MessageLogViewset) -> Any:
Predict the next line for this snippet: <|code_start|> try: decorators = settings.CARROT.get('monitor_authentication', []) except AttributeError: decorators = [] def _(v: Any, **kwargs) -> Any: """ Decorates a class based view with a custom auth decorator specified in the settings module """ r...
url(r'^api/message-logs/requeue/$', _f(requeue_pending)),
Predict the next line for this snippet: <|code_start|> ('IN_PROGRESS', 'In progress'), ('FAILED', 'Failed'), ('COMPLETED', 'Completed'), ) #: status = models.CharField(max_length=11, choices=STATUS_CHOICES, default='PUBLISHED') exchange = models.CharField(max_length=200, blank=True, ...
except CarrotConfigException:
Given snippet: <|code_start|> class ScheduledTaskThread(threading.Thread): """ A thread that handles a single :class:`carrot.models.ScheduledTask` object. When started, it waits for the interval to pass before publishing the task to the required queue While waiting for the task to be due for publica...
scheduled_task: ScheduledTask,
Given the following code snippet before the placeholder: <|code_start|> def runner(options): BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(BASE_DIR) vhost = { 'host': options.host, 'port': options.port, 'name': options.name, 'usernam...
_vhost = VirtualHost(**vhost)
Predict the next line for this snippet: <|code_start|> class Command(BaseCommand): help = 'Queues a job for execution' def add_arguments(self, parser: CommandParser) -> None: parser.add_argument('job_name', type=str) parser.add_argument('job_args', type=str, nargs='+') def handle(self, *a...
publish_message(job_name, *job_args)
Here is a snippet: <|code_start|> VAR_IN: mem.get(VAR_IN, UndefValue()), VAR_OUT: mem.get(VAR_OUT, UndefValue()), } if len(fnc.params) != len(args): raise RuntimeErr("Wrong number of args: expected %s, got %s" % ( len(fnc.params), len(args) ...
raise UnknownLanguage("No interpreter for language: '%s'" % (lang,))
Continue the code snippet: <|code_start|> def __repr__(self): return '<undef>' def isundef(x): return isinstance(x, UndefValue) class Interpreter(object): DEFAULT_RETURN = UndefValue() def __init__(self, timeout=5, entryfnc='main'): self.timeout = timeout self.starttime ...
if not isinstance(prog, Program):
Continue the code snippet: <|code_start|> self.prog = None def getfnc(self, name): return self.prog.getfnc(name) def run(self, prog, mem=None, ins=None, args=None, entryfnc=None): if not isinstance(prog, Program): raise Exception("Expected Program, for '%s'" % (prog,)) ...
mem[VAR_IN] = list(ins)
Next line prediction: <|code_start|> def getfnc(self, name): return self.prog.getfnc(name) def run(self, prog, mem=None, ins=None, args=None, entryfnc=None): if not isinstance(prog, Program): raise Exception("Expected Program, for '%s'" % (prog,)) self.prog = prog ...
if VAR_OUT not in mem:
Here is a snippet: <|code_start|> return self.prog.getfnc(name) def run(self, prog, mem=None, ins=None, args=None, entryfnc=None): if not isinstance(prog, Program): raise Exception("Expected Program, for '%s'" % (prog,)) self.prog = prog # Get function entryfnc...
mem[VAR_RET] = UndefValue()
Given the code snippet: <|code_start|> # Check for timeout if self.timeout and self.starttime \ and (time.time() - self.starttime > self.timeout): raise RuntimeErr( 'Timeout (%.3f)' % (round(time.time() - self.starttime, 3),)) # Get name of the obj...
if var == VAR_COND:
Continue the code snippet: <|code_start|> and (time.time() - self.starttime > self.timeout): raise RuntimeErr( 'Timeout (%.3f)' % (round(time.time() - self.starttime, 3),)) # Get name of the object to be executed name = obj.__class__.__name__ meth =...
varp = prime(var)
Predict the next line after this snippet: <|code_start|> if var == VAR_RET and not isundef(val): break # Save memory (newmem, mem) = self.procmem(mem) self.trace.append((self.fnc, self.loc, mem)) mem = newmem # Check return...
var = unprime(var)
Based on the snippet: <|code_start|> if var == VAR_RET and not isundef(val): break # Save memory (newmem, mem) = self.procmem(mem) self.trace.append((self.fnc, self.loc, mem)) mem = newmem # Check return if not...
if isprimed(var):
Predict the next line for this snippet: <|code_start|> self.R[ri] = (loc1, var1, var2, cost, order, idx) if len(RV) and var1 != '-': # sum ri >= 1 # At least one ri for (loc1,var) should be chosen self.C.append((RV, EQ, 1)) ...
debug('setting scaling=%d', scalings[scaling])
Using the snippet: <|code_start|> self.R1 = {} # Map from ints -> V1 for var1 in self.V1: self.M1[var1] = len(self.M1) self.R1[self.M1[var1]] = var1 self.M2 = {} # Map from V2 -> ints self.R2 = {} # Map from ints -> V2 for var2 in self.V2: s...
if (var1 in SPECIAL_VARS) or (var2 in SPECIAL_VARS):
Given the code snippet: <|code_start|> # Init model self.LP = LpModel(cols=self.N) if not self.verbose: self.LP.setverbose(1) # Bound variables for i in range(1, self.N + 1): self.LP.setint(i, 1) self.LP.setupbo(i, 1.0) # Set objective...
raise Timeout()
Using the snippet: <|code_start|>""" These MathApp-based digital logic classes are experimental. """ # decorator for _getvalue or any value handler that may experience recursion def _recursiontrap(handler): def trapmagic(self): """ An attempt to catch recursion (doesn't work). """ ...
class _BoolDevice(_MathDynamic, metaclass=ABCMeta):
Given the following code snippet before the placeholder: <|code_start|> super().select() self.togglestate += 1 if self.togglestate == len(self.statelist): self.togglestate = 0 self.setImage(self.togglestate) self.unselect() def __call__(self): return self....
kwargs.setdefault("frame", Frame(0, 0, 110, 150))
Given snippet: <|code_start|> log = CPLog(__name__) class movieSearcher(): sources = [] limit = 8 def __init__(self, config): self.config = config # Config TheMovieDB self.theMovieDb = theMovieDb(self.config) self.sources.append(self.theMovieDb) # Config imdbWra...
movies = Db.query(Movie).order_by(Movie.name).filter(or_(Movie.status == u'want', Movie.status == u'waiting')).all()
Given the code snippet: <|code_start|> etaQueue = Queue.Queue() log = CPLog(__name__) class etaCron(rss, cronBase): apiUrl = 'http://couchpotatoapp.com/api/eta/%s/' def conf(self, option): return self.config.get('RottenTomatoes', option) def run(self): log.info('ETA thread is running.') ...
movie = Db.query(Movie).filter_by(id = queue.get('id')).first()
Based on the snippet: <|code_start|> except TypeError: return None return None def determineMovie(self, movie): result = False movieName = self.cleanName(movie['folder']) movieYear = self.findYear(movie['folder']) #check to see if the downloaded movie n...
queue = Db.query(MovieQueue).filter_by(name = movie['folder']).first()
Based on the snippet: <|code_start|> log = CPLog(__name__) class subtitleBase(rss): def alreadyDownloaded(self, movie, file, key): key = self.getKey(key) movieId = 0 if not movie else movie.id file = latinToAscii(file) <|code_end|> , predict the immediate next line with the help of import...
results = Db.query(SubtitleHistory).filter(and_(SubtitleHistory.subtitle == key, SubtitleHistory.movie == movieId, SubtitleHistory.file == file)).all()
Given the code snippet: <|code_start|> log = CPLog(__name__) class FeedController(BaseController): """ Search for new and cool movies and other stuff """ @cherrypy.expose @cherrypy.tools.mako(filename = "feed/index.html") def index(self): # Releases <|code_end|> , generate the next line using...
theater = Db.query(MovieETA) \
Using the snippet: <|code_start|> def validate(self): ''' Checks that the target is valid. ''' if self.channel == '-1': raise Exception('Ignoring target with Negative-One (-1) channel') # Filter broadcast/multicast BSSIDs, see https://github.com/derv82/wifite2/issues/32 b...
essid = Color.s('{C}%s' % essid)
Using the snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- class Arguments(object): ''' Holds arguments used by the Wifite ''' def __init__(self, configuration): # Hack: Check for -v before parsing args; so we know which commands to display. self.verbose = '-v' in sys.arg...
return Color.s(msg)
Given the code snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- try: except (ValueError, ImportError) as e: raise Exception('You may need to run wifite from the root directory (which includes README.md)', e) class Wifite(object): def __init__(self): ''' Initializes Wifi...
Color.pl('{!} {R}error: {O}wifite{R} must be run as {O}root{W}')
Continue the code snippet: <|code_start|> vbm = bs.get_vbm()['energy'] - evac edges = {'up_cbm': cbm, 'up_vbm': vbm, 'dn_cbm': cbm, 'dn_vbm': vbm, 'efermi': efermi} return edges def plot_band_alignments(directories, run_type='PBE', fmt='pdf'): """ Plot CBM's and VBM's of a...
if is_converged(sub_dir):
Next line prediction: <|code_start|>""" tests for mpinterfaces.transformations """ from __future__ import unicode_literals __author__ = "Seve G. Monahan" __copyright__ = "Copyright 2017, Henniggroup" __maintainer__ = "Joshua J. Gabriel" __email__ = "joshgabriel92@gmail.com" __status__ = "Production" __date__ = "Mar...
self.assertEqual([1, 1], get_uv([1, 1], [[1, 0], [0, 1]]))
Using the snippet: <|code_start|>""" tests for mpinterfaces.transformations """ from __future__ import unicode_literals __author__ = "Seve G. Monahan" __copyright__ = "Copyright 2017, Henniggroup" __maintainer__ = "Joshua J. Gabriel" __email__ = "joshgabriel92@gmail.com" __status__ = "Production" __date__ = "March 3...
generated_list = list(get_trans_matrices(number))
Next line prediction: <|code_start|> 'requested surface coverage exceeds the max possible coverage. exiting.') sys.exit() else: for scell in range(1, self.scell_nmax): for nlig in range(1, scell * n_top_atoms + 1): surface_area = scell *...
uv_list, _ = reduced_supercell_vectors(ab, scell)
Predict the next line after this snippet: <|code_start|> to_unit_cell: Pymatgen Slab routine to find unit cell coords_are_cartesian: Whether the input coordinates are in cartesian from_ase: Whether to create Slab using python-ase for producing slabs...
strt = get_ase_slab(strt,
Given snippet: <|code_start|># coding: utf-8 # Copyright (c) Henniggroup. # Distributed under the terms of the MIT License. from __future__ import division, print_function, unicode_literals, \ absolute_import """ Defines the Interface(extends class Slab) and Ligand(extends class Molecule) classes """ __auth...
logger = get_default_logger(__name__)
Using the snippet: <|code_start|> from __future__ import division, unicode_literals, print_function """ Utility script to find if endpoint slabs are matching with substrate Usage: Provide inputs <path to poscar substrate>, <path to poscar 2D> and match constraints using for the search python get_matchi...
iface, n_sub, z_ub = lma.run_lat_match(sub, twod, match_constraints)
Next line prediction: <|code_start|> from __future__ import division, unicode_literals, print_function """ Utility script to find if endpoint slabs are matching with substrate Usage: Provide inputs <path to poscar substrate>, <path to poscar 2D> and match constraints using for the search python get_mat...
iface, n_sub, z_ub = transformations.run_lat_match(sub, twod, match_constraints)
Using the snippet: <|code_start|> Returns: capacity (float): Maximum capacity """ # Calculated with the relax() function in # mat2d.stability.startup. If you are using other input # parameters, you need to recalculate these values! ion_ev_fu = {'Li': -1.838, 'Mg': 0.620, 'Al': -3.291} ...
if is_converged(directory):
Predict the next line after this snippet: <|code_start|> class MPINTVaspJob(MPINTJob): """ defines a vasp job i.e setup the required input files and launch the job Args: job_cmd: a list, the command to be issued in each job_dir eg: ['qsub', 'submit_job'] job_dir: the dir...
vasprun = MPINTVasprun(vasprun_file_path,
Using the snippet: <|code_start|># Copyright (c) Henniggroup. # Distributed under the terms of the MIT License. from __future__ import division, print_function, unicode_literals, \ absolute_import """ The instrument module: defines the inputset and the job """ # uncomment for python2.7 pymatgen versions compati...
logger = get_default_logger(__name__)
Predict the next line after this snippet: <|code_start|># coding: utf-8 # Copyright (c) Henniggroup. # Distributed under the terms of the MIT License. from __future__ import division, print_function, unicode_literals, \ absolute_import """ process vasprun.xml file by walking through the enitre directory tree in t...
logger = get_default_logger(__name__)
Continue the code snippet: <|code_start|>""" tests for mpinterfaces.transformations """ from __future__ import unicode_literals __author__ = "Seve G. Monahan" __copyright__ = "Copyright 2017, Henniggroup" __maintainer__ = "Joshua J. Gabriel" __email__ = "joshgabriel92@gmail.com" __status__ = "Production" __date__ = ...
self.assertEqual([[1, 1]], get_r_list(1, 0.98, 2))
Given snippet: <|code_start|>""" tests for mpinterfaces """ from __future__ import unicode_literals __author__ = "Seve G. Monahan" __copyright__ = "Copyright 2017, Henniggroup" __maintainer__ = "Joshua J. Gabriel" __email__ = "joshgabriel92@gmail.com" __status__ = "Production" __date__ = "March 3, 2017" class Te...
self.logger = get_default_logger("Example_Module_name", self.mystdout)
Predict the next line after this snippet: <|code_start|> raise ImportError("You must install `scipy` to use this function") def get_most_abundant_isotope(element): """Given a `periodictable` element, return the most abundant isotope. """ most_abundant_isotope = element.isotopes[0] abundance...
class Nuclear(Method):
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- # # Copyright (c) 2020, the cclib development team # # This file is part of cclib (http://cclib.github.io) and is distributed under # the terms of the BSD 3-Clause License. class PyscfTest(unittest.TestCase): def setUp(self): ...
self.data, self.logfile = getdatafile(
Using the snippet: <|code_start|> ref_file = "data/GAMESS/basicGAMESS-US2017/dvb_sp.out" programs = { 'ORCA': "data/ORCA/basicORCA4.2/dvb_sp.out", 'NWChem': "data/NWChem/basicNWChem6.5/dvb_sp_hf.out", 'Psi4': "data/Psi4/basicPsi4-1.3.1/dvb_sp_rhf.out", 'GAM...
float_section = _section('Test Section', 123.456)
Given snippet: <|code_start|> for name in programs: fpath_prog = os.path.join(__datadir__, programs[name]) data_prog = cclib.io.ccread(fpath_prog) wfx_prog = cclib.io.wfxwriter.WFXWriter(data_prog) norm_mat_prog = wfx_prog._norm_mat()[0] mos_prog = wfx...
odd_list = _list_format([1, 2, 3], 2, '%8.1E')
Next line prediction: <|code_start|># -*- coding: utf-8 -*- # # Copyright (c) 2020, the cclib development team # # This file is part of cclib (http://cclib.github.io) and is distributed under # the terms of the BSD 3-Clause License. class PyquanteTest(unittest.TestCase): """Tests for the cclib2pyquante bridge...
self.data, self.logfile = getdatafile("Gaussian", "basicGaussian16", ["water_ccsd.log"])
Using the snippet: <|code_start|> if atom_num <= charge_ceil: density_ceil = numpy.array([0]) else: keystring_ceil = "Z={}_Q={:+d}".format(atom_num, charge_ceil) density_ceil = numpy.asanyarray(list(proatomdb[keystring_ceil]["rh...
self.charge_density = electrondensity_spin(
Predict the next line after this snippet: <|code_start|> class Population(Method): """An abstract base class for population-type methods.""" # All of these are typically required for population analyses. required_attrs = ('homos', 'mocoeffs', 'nbasis') # At least one of these are typically ...
raise MissingAttributeError(
Continue the code snippet: <|code_start|> - For PES or IRCs, return all geometries for which optstatus matches OPT_UNKNOWN - The input geometry for simple optimisations or single points """ if hasattr(self, 'optstatus'): unknown_indexes = [x for x, y in enumerate(s...
return orbitals.Orbitals(self).closed_shell()
Given the code snippet: <|code_start|># # Copyright (c) 2020, the cclib development team # # This file is part of cclib (http://cclib.github.io) and is distributed under # the terms of the BSD 3-Clause License. """Calculation of Bader's QTAIM charges based on data parsed by cclib.""" # Distance between two adjacent ...
class Bader(Method):
Given the following code snippet before the placeholder: <|code_start|> if numpy.sum(self.data.coreelectrons) != 0: # Pseudopotentials can cause Bader spaces to be inaccurate, as suggested by the # original paper. self.logger.info( "It looks like pseudopotenti...
self.chgdensity = electrondensity_spin(
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- # # Copyright (c) 2018, the cclib development team # # This file is part of cclib (http://cclib.github.io) and is distributed under # the terms of the BSD 3-Clause License. """Calculation of overlap population analysis based on cclib data.""" ...
class OPA(Population):
Given snippet: <|code_start|> # # Model serializers # Typical relationships applications # class AccountSerializer(serializers.ModelSerializer): class Meta: model = Account fields = ('id', 'email') class ReporterSerializer(serializers.ModelSerializer): account = AccountSerializer() ...
model = Reporter
Next line prediction: <|code_start|> # # Model serializers # Typical relationships applications # class AccountSerializer(serializers.ModelSerializer): class Meta: model = Account fields = ('id', 'email') class ReporterSerializer(serializers.ModelSerializer): account = AccountSerializer...
model = Article
Based on the snippet: <|code_start|> # # Model serializers # Typical relationships applications # class AccountSerializer(serializers.ModelSerializer): class Meta: model = Account fields = ('id', 'email') class ReporterSerializer(serializers.ModelSerializer): account = AccountSerializer(...
model = Tag
Here is a snippet: <|code_start|> self.assertEqual(accounts.count(), 1) self.assertEqual(accounts[0].id, 2) self.assertEqual(accounts[0].email, 'paul@example.com') # # Relationships # Typical relationships applications # # One to One reporter = Re...
article = Article.objects.get(id=1)
Using the snippet: <|code_start|> self.assertEqual(reporter.account.email, 'john@example.com') # One to one reversed: # TODO: doesn't work # account = Account.objects.get(id=1) # self.assertEqual(account.reporter.id, 1) # self.assertEqual(account.reporter.first_name, "Joh...
tag = Tag.objects.get(id=1)