text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> self.assertAllEqual(tf_out_values, out_values) self.assertAllEqual(tf_out_indices, out_indices) if __name__ == "__main__": tf.test.main()<|fim_prefix|># repo: brodyh/tensorflow path: /tensorflow/python/kernel_tests/sparsemask_op_test.py from __future__ import absolute_import from __future_...
code_fim
hard
{ "lang": "python", "repo": "brodyh/tensorflow", "path": "/tensorflow/python/kernel_tests/sparsemask_op_test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> t = tf.IndexedSlices(values_tensor, indices_tensor) masked_t = tf.sparse_mask(t, mask_indices_tensor) tf_out_values, tf_out_indices = sess.run([masked_t.values, masked_t.indices]) self.assertAllEqual(tf_out_values, out_values) ...
code_fim
hard
{ "lang": "python", "repo": "brodyh/tensorflow", "path": "/tensorflow/python/kernel_tests/sparsemask_op_test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: brodyh/tensorflow path: /tensorflow/python/kernel_tests/sparsemask_op_test.py from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow.python.platform import numpy as np import tensorflow as tf class SparseMaskTest(tf.test....
code_fim
hard
{ "lang": "python", "repo": "brodyh/tensorflow", "path": "/tensorflow/python/kernel_tests/sparsemask_op_test.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def compile(self, collection): """ Do our parameterized averaging procedure and whatever else doesn't happen every frame. """ return 0 def play(self, frame): """ Step between current frame and desired one somehow. Intend...
code_fim
hard
{ "lang": "python", "repo": "mhoaglund/TheShallows", "path": "/TheShallows_DemoCV/outputstream.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mhoaglund/TheShallows path: /TheShallows_DemoCV/outputstream.py """ Reads from a queue to retrieve collections of ROIs cut from a single frame by the corresponding input class. Has two loops: #1 carries out the aforementioned queue read #2 runs in between, averaging the collections of ROIs into ...
code_fim
hard
{ "lang": "python", "repo": "mhoaglund/TheShallows", "path": "/TheShallows_DemoCV/outputstream.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>class DetPredict(xnn.Module): def __init__(self, depth, plane, num_anchors, num_classes, num_loc_params): super(DetPredict, self).__init__() self.heads_cls = nn.ModuleList() self.heads_loc = nn.ModuleList() for i in range(depth): self.heads_cls.append(Predic...
code_fim
hard
{ "lang": "python", "repo": "ming71/SLA", "path": "/model/net/utils/modules.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ming71/SLA path: /model/net/utils/modules.py import torch from torch import nn from xtorch import xnn import torch.nn.functional as F class FeaturePyramidNet(xnn.Module): def __init__(self, depth, plane): super(FeaturePyramidNet, self).__init__() self.link = nn.ModuleList(...
code_fim
hard
{ "lang": "python", "repo": "ming71/SLA", "path": "/model/net/utils/modules.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def forward(self, x): x = self.body(x) return x.permute(0, 2, 3, 1).reshape(x.size(0), -1, self.num_classes) class DetPredict(xnn.Module): def __init__(self, depth, plane, num_anchors, num_classes, num_loc_params): super(DetPredict, self).__init__() self.heads_cls...
code_fim
hard
{ "lang": "python", "repo": "ming71/SLA", "path": "/model/net/utils/modules.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_not_hidden(self, articles_kb_app, sphinx_app, valid_registration, dummy_doctree, article_env, article_resources, mocker, ): # Turn on toctree support sphinx_app.config.kaybee_settings.articles.use_toctree ...
code_fim
hard
{ "lang": "python", "repo": "pauleveritt/kaybee", "path": "/tests/unit/plugins/articles/test_articles_handlers.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: pauleveritt/kaybee path: /tests/unit/plugins/articles/test_articles_handlers.py import dectate import pytest from kaybee.plugins.articles.handlers import ( articles_into_html_context, register_template_directory, render_toctrees, resource_toctrees, stamp_excerpt, dump_set...
code_fim
hard
{ "lang": "python", "repo": "pauleveritt/kaybee", "path": "/tests/unit/plugins/articles/test_articles_handlers.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> valid_registration, dummy_doctree, article_env, article_resources, mocker, ): # By default toctree support is turned off sphinx_app.env = article_env sphinx_app.resou...
code_fim
hard
{ "lang": "python", "repo": "pauleveritt/kaybee", "path": "/tests/unit/plugins/articles/test_articles_handlers.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: kubernetes/test-infra path: /releng/generate_tests_test.py #!/usr/bin/env python3 # Copyright 2019 The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License...
code_fim
medium
{ "lang": "python", "repo": "kubernetes/test-infra", "path": "/releng/generate_tests_test.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> shutil.rmtree(self.temp_directory) def test_e2etests_testgrid_annotations_default(self): generator = E2ETest(self.temp_directory, self.job_name, self.job, self.config) _, prow_config, _ = generator.generate() dashboards = prow_config["annotations"]["testgrid-dashboards...
code_fim
hard
{ "lang": "python", "repo": "kubernetes/test-infra", "path": "/releng/generate_tests_test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: jphkun/aeroframe path: /src/lib/aeroframe/_wrappers/structure/framat.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- # ---------------------------------------------------------------------- # Copyright 2019-2020 Airinnova AB and the AeroFrame authors # # Licensed under the Apache License, Vers...
code_fim
hard
{ "lang": "python", "repo": "jphkun/aeroframe", "path": "/src/lib/aeroframe/_wrappers/structure/framat.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # Add loads to the FramAT model file free_node_loads = [] for entry in load_field: free_node_loads.append({'coord': list(entry[0:3]), 'load': list(entry[3:9])}) # Loads acting on a mirrored side if component_uid.endswith('_m'): ...
code_fim
hard
{ "lang": "python", "repo": "jphkun/aeroframe", "path": "/src/lib/aeroframe/_wrappers/structure/framat.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #%% class city(plan): def __init__(self, H=2,W=2,grid=None, D = 5,B = 0, name = "cityX"): checktype([name], [ str]) super().__init__(H,W, grid) self.name = name self.D = D self.B = B self.residences = [] self.utilities = [] self.manhatta...
code_fim
hard
{ "lang": "python", "repo": "neroksi/hashcode18", "path": "/src/urban.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: neroksi/hashcode18 path: /src/urban.py #%% import numpy as np from enum import Enum import itertools from utils import project_from_file, checktype, btype from hyperopt import fmin, tpe, hp, STATUS_OK, Trials from matplotlib import pyplot as plt #%% class plan(object): def __init__(sel...
code_fim
hard
{ "lang": "python", "repo": "neroksi/hashcode18", "path": "/src/urban.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#%% class building(plan): def __init__(self,H=2, W=2, grid=None, kind = btype.RESIDENCE, capacity= None, utype = None, name = "BuildingX"): checktype([kind, capacity, utype, name], [ btype, (type(None),int), (type(None),int), str]) super().__init__(H,W, grid) ...
code_fim
hard
{ "lang": "python", "repo": "neroksi/hashcode18", "path": "/src/urban.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def test_update_processed(self, api_key, card_payment): card_payment.update(status="voided") assert card_payment.status == "voided" def test_transactions_not_found(self, api_key, card_payment): with pytest.raises(NotFound): pl.Transaction.get("invalid")<|fim_pr...
code_fim
hard
{ "lang": "python", "repo": "payload-code/payload-python", "path": "/tests/test_transaction.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert card_payment.risk_flag == "allowed" def test_update_processed(self, api_key, card_payment): card_payment.update(status="voided") assert card_payment.status == "voided" def test_transactions_not_found(self, api_key, card_payment): with pytest.raises(NotFound...
code_fim
medium
{ "lang": "python", "repo": "payload-code/payload-python", "path": "/tests/test_transaction.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: payload-code/payload-python path: /tests/test_transaction.py import pytest import payload as pl from payload.exceptions import NotFound from .fixtures import Fixtures class TestTransaction(Fixtures): def test_transaction_ledger_empty(self, api_key, card_payment): transaction = pl....
code_fim
hard
{ "lang": "python", "repo": "payload-code/payload-python", "path": "/tests/test_transaction.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if np.isscalar(a): return a*b return np.outer(a, b) def newton(f, df, guess, max_n = 10, abstol = 0.000005): n = 0 while np.linalg.norm(f(guess))>abstol and n<max_n: guess -= solve_linear(df(guess), f(guess)) n+=1 return guess def broyden(f, df...
code_fim
medium
{ "lang": "python", "repo": "Markus28/Scientific-Computing", "path": "/analysis/solve.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Markus28/Scientific-Computing path: /analysis/solve.py import numpy as np import matplotlib.pyplot as plt from scipy.misc import derivative import scipy def solve_linear(A, w): if np.isscalar(A): return w/A return scipy.linalg.solve(A, w) def outer(a, b): if np.isscalar...
code_fim
hard
{ "lang": "python", "repo": "Markus28/Scientific-Computing", "path": "/analysis/solve.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> guess = guess.copy() n = 1 f_guess = f(guess) J_inverse = np.linalg.inv(df) s = np.matmul(J_inverse, f_guess) guess -= s f_guess = f(guess) while np.linalg.norm(f_guess)>abstol and n<max_n: w = np.matmul(J_inverse, f_guess) s_norm = np.linalg.norm(s)**2...
code_fim
hard
{ "lang": "python", "repo": "Markus28/Scientific-Computing", "path": "/analysis/solve.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: openprocurement/openprocurement.tender.openuadefense path: /openprocurement/tender/openuadefense/tests/document.py # -*- coding: utf-8 -*- import unittest from openprocurement.api.tests.base import snitch from openprocurement.tender.belowthreshold.tests.document_blanks import ( # TenderDocu...
code_fim
hard
{ "lang": "python", "repo": "openprocurement/openprocurement.tender.openuadefense", "path": "/openprocurement/tender/openuadefense/tests/document.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> docservice = True test_create_tender_document_json_invalid = snitch(create_tender_document_json_invalid) test_create_tender_document_json = snitch(create_tender_document_json) test_put_tender_document_json = snitch(put_tender_document_json) def suite(): suite = unittest.TestSuite() ...
code_fim
medium
{ "lang": "python", "repo": "openprocurement/openprocurement.tender.openuadefense", "path": "/openprocurement/tender/openuadefense/tests/document.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: MinistereSupRecherche/bso path: /app/analyzers/html_parsers/iop.py from bs4 import * import re, bs4 from doi_utils import * # doi 10.1088 def parse_iop(soup): is_french = False authors, affiliations = [], {} for elt in soup.find_all(class_='mb-05'): is_elt_ok = False ...
code_fim
hard
{ "lang": "python", "repo": "MinistereSupRecherche/bso", "path": "/app/analyzers/html_parsers/iop.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if author_elt.find('sup') is None: continue nb_sups = author_elt.find('sup').get_text().split(',') full_name = author_elt.find('span').get_text() author['full_name'] = full_name author['affiliations_info'] = [] for nb_sup in nb_sups: ...
code_fim
hard
{ "lang": "python", "repo": "MinistereSupRecherche/bso", "path": "/app/analyzers/html_parsers/iop.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if isinstance(sub_elt, bs4.element.NavigableString): full_name = sub_elt if author_elt.find('sup') is None: continue nb_sups = author_elt.find('sup').get_text().split(',') full_name = author_elt.find('span').get_text() author['full_n...
code_fim
hard
{ "lang": "python", "repo": "MinistereSupRecherche/bso", "path": "/app/analyzers/html_parsers/iop.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: xuther/nyc-taxi-data path: /code/clustering/multi-dimensional-clustering/data-preparation.py import numpy as np import json import csv import os import locale from pyspark import SparkConf, SparkContext conf = (SparkConf() .setMaster("local[*]") .setAppName("My app") .set...
code_fim
hard
{ "lang": "python", "repo": "xuther/nyc-taxi-data", "path": "/code/clustering/multi-dimensional-clustering/data-preparation.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>splitArrivals = arrivals.map(lambda x: (x[0].split("/")[-1].split(".")[0], x[1].split()[1:])) pointedArrivals = splitArrivals.map(lambda x: (x[0], labelPointsWithTractAndArriveDepart(x, 1))) combined = sc.union([pointedDepartures, pointedArrivals]) combined = combined.reduceByKey(lambda x, y: x + y) co...
code_fim
hard
{ "lang": "python", "repo": "xuther/nyc-taxi-data", "path": "/code/clustering/multi-dimensional-clustering/data-preparation.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>splitDepartures = departures.map(lambda x: (x[0].split("/")[-1].split(".")[0], x[1].split()[1:])) pointedDepartures = splitDepartures.map(lambda x: (x[0], labelPointsWithTractAndArriveDepart(x, 0))) splitArrivals = arrivals.map(lambda x: (x[0].split("/")[-1].split(".")[0], x[1].split()[1:])) pointedArriv...
code_fim
hard
{ "lang": "python", "repo": "xuther/nyc-taxi-data", "path": "/code/clustering/multi-dimensional-clustering/data-preparation.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: VRI-UFPR/ocrd-gbn path: /gbn/sbb/predict.py from gbn.lib.dl import Model, Prediction from gbn.lib.struct import Contour, Polygon from gbn.lib.util import pil_to_cv2_rgb, cv2_to_pil_gray from gbn.tool import OCRD_TOOL from ocrd import Processor from ocrd_modelfactory import page_from_file from oc...
code_fim
hard
{ "lang": "python", "repo": "VRI-UFPR/ocrd-gbn", "path": "/gbn/sbb/predict.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> lines = region.get_TextLine() for line_idx, line in enumerate(lines): line_id = "_region%04d" % line_idx # Get image from TextLine: line_image, line_xywh = self.workspace.image_from_segment( ...
code_fim
hard
{ "lang": "python", "repo": "VRI-UFPR/ocrd-gbn", "path": "/gbn/sbb/predict.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: ivis-mizuguchi/ocs-templates path: /OpenHPC-v1/scripts/group.py from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import errno import os import os.path import re import yaml import subprocess from io import StringIO, BytesIO impor...
code_fim
hard
{ "lang": "python", "repo": "ivis-mizuguchi/ocs-templates", "path": "/OpenHPC-v1/scripts/group.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> gvars = load_group_vars(target_group, dir) return gvars[name] def store_group_vars(target_group, gvars, work_dir=os.getcwd()): path = os.path.join(work_dir, GROUP_VARS_DIR, target_group + '.yml') mkdir_p(os.path.dirname(path)) with open(path, 'w') as f: yaml.dump(gvars, f, de...
code_fim
hard
{ "lang": "python", "repo": "ivis-mizuguchi/ocs-templates", "path": "/OpenHPC-v1/scripts/group.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> """ Execute a command received from the server. """ if msg.startswith('PRINT '): window.console.ori_log(msg[6:]) elif msg.startswith('EVAL '): window._ = eval(msg[5:]) window.flexx.ws.send('RET ' + window._) # send back result el...
code_fim
hard
{ "lang": "python", "repo": "cy-fir/flexx", "path": "/flexx/app/clientcore.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def initSocket(self): """ Make the connection to Python. """ # Check WebSocket support if self.nodejs: try: WebSocket = require('ws') except Exception: # Better error message raise "FAIL: y...
code_fim
hard
{ "lang": "python", "repo": "cy-fir/flexx", "path": "/flexx/app/clientcore.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: cy-fir/flexx path: /flexx/app/clientcore.py """ The client's core Flexx engine, implemented in PyScript. """ from ..pyscript import py2js, undefined, window flexx_session_id = location = require = module = typeof = None # fool PyFlakes @py2js(inline_stdlib=False) class FlexxJS: """ JavaS...
code_fim
hard
{ "lang": "python", "repo": "cy-fir/flexx", "path": "/flexx/app/clientcore.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: utsurius/django-actionable-messages path: /django_actionable_messages/elements.py from typing import Union from django_actionable_messages.mixins import CardElement <|fim_suffix|> def __init__(self, name: str, value: Union[str, int], **kwargs): self._data = { "name": name...
code_fim
easy
{ "lang": "python", "repo": "utsurius/django-actionable-messages", "path": "/django_actionable_messages/elements.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self._data = { "name": name, "value": value } super().__init__(**kwargs)<|fim_prefix|># repo: utsurius/django-actionable-messages path: /django_actionable_messages/elements.py from typing import Union from django_actionable_messages.mixins import CardEleme...
code_fim
medium
{ "lang": "python", "repo": "utsurius/django-actionable-messages", "path": "/django_actionable_messages/elements.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def compile_results(results, index): "Compile results in a dictionary." selection = dict() for filename, haikus in results: selection[filename] = index[filename] selection[filename]['haikus'] = haikus return selection ######################################################...
code_fim
hard
{ "lang": "python", "repo": "Jaspervo159/dbnl-scripts", "path": "/accidental_haiku.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Jaspervo159/dbnl-scripts path: /accidental_haiku.py import glob import json import pyphen import spacy from utils import get_text, detokenize, load_dbnl_data, chunks, store_dbnl_data from multiprocessing import Pool from itertools import repeat dic = pyphen.Pyphen(lang='nl_NL') def count_syllab...
code_fim
hard
{ "lang": "python", "repo": "Jaspervo159/dbnl-scripts", "path": "/accidental_haiku.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Checks whether is a sentence fits the (simplified) criteria for a haiku. """ first, second, third = 0, 0, 0 first_line = [] second_line = [] third_line = [] for token in sentence: syllables = count_syllables(token) if first < 5: first += syll...
code_fim
hard
{ "lang": "python", "repo": "Jaspervo159/dbnl-scripts", "path": "/accidental_haiku.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: netvigator/auctions path: /auctionbot/taskapp/tasks.py #from celery import shared_task <|fim_suffix|>#@shared_task( name = 'auctionbot.taskapp.tasks.add' ) def add( i, j ): return i + j<|fim_middle|>from .celery import app # 2021-05-24 celery not working, so giving up on it! # instead, w...
code_fim
hard
{ "lang": "python", "repo": "netvigator/auctions", "path": "/auctionbot/taskapp/tasks.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># 2021-05-24 celery not working, so giving up on it! # instead, will set nice level on cron job processes # will leave the celery structure in place, to allow retrying later if desired #@shared_task( name = 'auctionbot.taskapp.tasks.add' ) def add( i, j ): return i + j<|fim_prefix|># repo: netvigator/auc...
code_fim
easy
{ "lang": "python", "repo": "netvigator/auctions", "path": "/auctionbot/taskapp/tasks.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: albertleers/GPflowBenchmarks path: /GPU_timed_mnist.py import sys import subprocess import os import consts def runGPUExperiments(descriptor): if descriptor=="short": num_repeats = 2 elif descriptor=="full": num_repeats = 5 else: raise NotImplementedError <|fim_suffix|>if __name__ == '...
code_fim
hard
{ "lang": "python", "repo": "albertleers/GPflowBenchmarks", "path": "/GPU_timed_mnist.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> software = "GPflow" no_limit = -1 f= open(consts.GPU_results_file_name,'w') for repeat_index in range(num_repeats): text_out = subprocess.check_output(["python","timed_mnist.py",software,str(no_limit)]) comma = "," line = software+comma+str(1)+comma+text_out.decode() f.write(line) f.close() ...
code_fim
medium
{ "lang": "python", "repo": "albertleers/GPflowBenchmarks", "path": "/GPU_timed_mnist.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: KathyLau/image2text path: /test.py from pytesser import * from PIL import Image #import subprocess #impor<|fim_suffix|>exe on image fnord #print image_file_to_string('fnord.tif')# fnord ```<|fim_middle|>t util #import errors image = Image.open('fonts_test.png') # Open image object using PIL prin...
code_fim
medium
{ "lang": "python", "repo": "KathyLau/image2text", "path": "/test.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ge object using PIL print image_file_to_string(image) # Run tesseract.exe on image fnord #print image_file_to_string('fnord.tif')# fnord ```<|fim_prefix|># repo: KathyLau/image2text path: /test.py from pytesser import * from PIL import Image #import subprocess #impor<|fim_middle|>t util #import errors i...
code_fim
medium
{ "lang": "python", "repo": "KathyLau/image2text", "path": "/test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: alercebroker/APF path: /tests/consumers/test_avro_file.py from .test_core import GenericConsumerTest from apf.consumers import AVROFileConsumer import unittest import os FILE_PATH = os.path.dirname(os.path.abspath(__file__)) EXAMPLES_PATH = os.path.abspath(os.path.join(FILE_PATH, "../examples")...
code_fim
hard
{ "lang": "python", "repo": "alercebroker/APF", "path": "/tests/consumers/test_avro_file.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> class AVROFileConsumerTest(GenericConsumerTest, unittest.TestCase): params = { "DIRECTORY_PATH": os.path.join(EXAMPLES_PATH, "avro_test"), "consume.messages": 1, } component = AVROFileConsumer(params) __test__ = True def test_consume_left_messages(self): param...
code_fim
medium
{ "lang": "python", "repo": "alercebroker/APF", "path": "/tests/consumers/test_avro_file.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> params = { "DIRECTORY_PATH": os.path.join(EXAMPLES_PATH, "avro_test"), "consume.messages": 1, } component = AVROFileConsumer(params) __test__ = True def test_consume_left_messages(self): params = self.params params["consume.messages"] = 5 self.c...
code_fim
medium
{ "lang": "python", "repo": "alercebroker/APF", "path": "/tests/consumers/test_avro_file.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: uselessscat/python-practices path: /Galaxy simulation/spiral_galaxy_3.py import numpy as np import vpython as vp from vpython import vector as v from vpython import rotate as rot # gravitacion g_constant = 6.67408e-11 sagittarius_a_mass = 4e6 # 4e4 to 4e9 sun_mass = 1.989e30 distances_scale = ...
code_fim
hard
{ "lang": "python", "repo": "uselessscat/python-practices", "path": "/Galaxy simulation/spiral_galaxy_3.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> up = v(0.0, 0.0, 1.0) initialSpeed = [np.sqrt(g_constant * sagittarius_a_mass * masses[i] / (positions[i].mag)) * positions[i].cross(up).norm() for i in range(len(positions))] # add some randomness for s in initialSpeed: s.x = s.x + (np.random.rand() * 2.0 - 1....
code_fim
hard
{ "lang": "python", "repo": "uselessscat/python-practices", "path": "/Galaxy simulation/spiral_galaxy_3.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>rate = 100 delta_tiempo = 1e-13 while True: vp.rate(rate) for i in range(count): # centripetal acceleration acceleration = (g_constant * sagittarius_a_mass * masses[i] / (positions[i].mag2)) * -positions[i].norm() # update speed an position ...
code_fim
hard
{ "lang": "python", "repo": "uselessscat/python-practices", "path": "/Galaxy simulation/spiral_galaxy_3.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>tape = Computer(int_code=data) print(*tape.compute_n(niter=2, feed=(1, 5)))<|fim_prefix|># repo: krsnadatra/Contoh-Program path: /2019/day_05.py from computer import Computer <|fim_middle|>with open('input05', 'r') as data: data = list(map(int, data.read().split(',')))
code_fim
medium
{ "lang": "python", "repo": "krsnadatra/Contoh-Program", "path": "/2019/day_05.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: krsnadatra/Contoh-Program path: /2019/day_05.py from computer import Computer <|fim_suffix|>tape = Computer(int_code=data) print(*tape.compute_n(niter=2, feed=(1, 5)))<|fim_middle|>with open('input05', 'r') as data: data = list(map(int, data.read().split(',')))
code_fim
medium
{ "lang": "python", "repo": "krsnadatra/Contoh-Program", "path": "/2019/day_05.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> @overload def get_dummy(framework: str) -> Tensor: ... def get_dummy(framework: str) -> Tensor: x: Tensor if framework == "pytorch": x = modules.torch.zeros(0) assert isinstance(x, PyTorchTensor) elif framework == "pytorch-gpu": x = modules.torch.zeros(0, device=...
code_fim
hard
{ "lang": "python", "repo": "jonasrauber/eagerpy", "path": "/eagerpy/utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ... @overload def get_dummy(framework: Literal["jax"]) -> JAXTensor: ... @overload def get_dummy(framework: Literal["numpy"]) -> NumPyTensor: ... @overload def get_dummy(framework: str) -> Tensor: ... def get_dummy(framework: str) -> Tensor: x: Tensor if framework == "pytor...
code_fim
medium
{ "lang": "python", "repo": "jonasrauber/eagerpy", "path": "/eagerpy/utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jonasrauber/eagerpy path: /eagerpy/utils.py from typing import overload from typing_extensions import Literal from .tensor import Tensor from .tensor import PyTorchTensor from .tensor import TensorFlowTensor from .tensor import JAXTensor from .tensor import NumPyTensor from . import modules <...
code_fim
hard
{ "lang": "python", "repo": "jonasrauber/eagerpy", "path": "/eagerpy/utils.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: amoudgl/habitat-sim path: /tests/test_examples.py import multiprocessing import os.path as osp import shlex import subprocess import pytest import examples.new_actions import examples.stereo_agent <|fim_suffix|> # This test needs to be done in its own process as there is a potentially for ...
code_fim
hard
{ "lang": "python", "repo": "amoudgl/habitat-sim", "path": "/tests/test_examples.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @pytest.mark.gfxtest @pytest.mark.skipif( not osp.exists("data/scene_datasets/habitat-test-scenes/skokloster-castle.glb"), reason="Requires the habitat-test-scenes", ) @pytest.mark.parametrize( "args", [ "--compute_shortest_path", "--compute_shortest_path --compute_action_...
code_fim
hard
{ "lang": "python", "repo": "amoudgl/habitat-sim", "path": "/tests/test_examples.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: kivancguckiran/torcs-rl-agent path: /algorithms/common/buffer/replay_buffer.py # -*- coding: utf-8 -*- """Replay buffer for baselines.""" from collections import deque from typing import Any, Deque, List, Tuple import numpy as np import torch from algorithms.common.helper_functions import get_...
code_fim
hard
{ "lang": "python", "repo": "kivancguckiran/torcs-rl-agent", "path": "/algorithms/common/buffer/replay_buffer.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if done: if len(self.current_episode) > self.step_size: self.episodes.append(self.current_episode) if len(self.episodes) == self.episode_size: self.episodes.pop(0) self.current_episode = list() def sample(self) -> T...
code_fim
hard
{ "lang": "python", "repo": "kivancguckiran/torcs-rl-agent", "path": "/algorithms/common/buffer/replay_buffer.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># API配置 API_HOST = '127.0.0.1' API_PORT = 5555 # 开关 #测试 TESTER_ENABLED = False #获取 GETTER_ENABLED = False #API API_ENABLED = True # 最大批测试量 BATCH_TEST_SIZE = 10<|fim_prefix|># repo: G-der/ProxyPool path: /proxypool/setting.py # Redis数据库地址 REDIS_HOST = '127.0.0.1' # Redis端口 REDIS_PORT = 6379 # Redis密码...
code_fim
medium
{ "lang": "python", "repo": "G-der/ProxyPool", "path": "/proxypool/setting.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: G-der/ProxyPool path: /proxypool/setting.py # Redis数据库地址 REDIS_HOST = '127.0.0.1' # Redis端口 REDIS_PORT = 6379 # Redis密码,如无填None REDIS_PASSWORD = None REDIS_KEY = 'proxies' # 代理分数 MAX_SCORE = 5 MIN_SCORE = 1 INITIAL_SCORE = 3 VALID_STATUS_CODES = [200, 302] # 代理池数量界限 POOL_UPPER_THRESHOLD = ...
code_fim
medium
{ "lang": "python", "repo": "G-der/ProxyPool", "path": "/proxypool/setting.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: jennyknuth/landlab path: /landlab/grid/tests/test_raster_funcs/test_flux_divergence_at_nodes.py import numpy as np from numpy.testing import assert_array_equal try: from nose.tools import assert_is except ImportError: from landlab.testing.tools import assert_is from landlab import Raster...
code_fim
hard
{ "lang": "python", "repo": "jennyknuth/landlab", "path": "/landlab/grid/tests/test_raster_funcs/test_flux_divergence_at_nodes.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """Test fluxes tha move from east to west.""" rmg = RasterModelGrid(4, 5) active_link_flux = np.array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 3., 6., 0., 1., 3., 6.]) divs = rmg.calculate_flux_divergence_at_nodes(active_link_flux) assert_array_equ...
code_fim
hard
{ "lang": "python", "repo": "jennyknuth/landlab", "path": "/landlab/grid/tests/test_raster_funcs/test_flux_divergence_at_nodes.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: microsoft/onnxruntime path: /onnxruntime/test/providers/cpu/rnn/LSTM.py = ["X", "W", "R"] for i in required_inputs: assert i in params, f"Missing Required Input: {i}" X = params["X"] # noqa: N806 W = params["W"] # noqa: N806 R = params["R"] # noqa:...
code_fim
hard
{ "lang": "python", "repo": "microsoft/onnxruntime", "path": "/onnxruntime/test/providers/cpu/rnn/LSTM.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> input = ( np.array([-0.455351, -0.276391, -0.185934, -0.269585]) .reshape(seq_length, batch_size, input_size) .astype(np.float32) ) return input class ONNXRuntimeUnitTests: @staticmethod def ONNXRuntime_TestLSTMBidirectionalBasic(): #...
code_fim
hard
{ "lang": "python", "repo": "microsoft/onnxruntime", "path": "/onnxruntime/test/providers/cpu/rnn/LSTM.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> input = ONNXRuntimeTestContext.DefaultInput() W, R, B, P = ONNXRuntimeTestContext.OneDirectionWeights() # noqa: N806 lstm = LSTM_Helper(X=input, W=W, R=R, B=B, P=P, clip=0.1) Y, Y_h, Y_c = lstm.run() # noqa: N806 print_results(Y, Y_h, Y_c) @staticmethod d...
code_fim
hard
{ "lang": "python", "repo": "microsoft/onnxruntime", "path": "/onnxruntime/test/providers/cpu/rnn/LSTM.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>from . import embeddings from . import layers from . import logger from . import neighbor_funcs from . import tf_funcs from . import utility<|fim_prefix|># repo: SkafteNicki/Deep_LMNN path: /dlmnn/helper/__init__.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue May 29 08:53:33 2018 ...
code_fim
easy
{ "lang": "python", "repo": "SkafteNicki/Deep_LMNN", "path": "/dlmnn/helper/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: SkafteNicki/Deep_LMNN path: /dlmnn/helper/__init__.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue May 29 08:53:33 2018 <|fim_suffix|>from . import embeddings from . import layers from . import logger from . import neighbor_funcs from . import tf_funcs from . import utility...
code_fim
easy
{ "lang": "python", "repo": "SkafteNicki/Deep_LMNN", "path": "/dlmnn/helper/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: arseniybanayev/aiotime path: /tests/test_aiotime.py import asyncio import pytest import datetime as dt import aiotime @pytest.mark.asyncio async def test_asyncio_sleep(): loop = asyncio.get_event_loop() # Try sleeping with normal loop behavior start = dt.datetime.now() sleep_tas...
code_fim
hard
{ "lang": "python", "repo": "arseniybanayev/aiotime", "path": "/tests/test_aiotime.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # call_later() with normal loop behavior now, after context manager exits start = dt.datetime.now() event = asyncio.Event() def test(): event.set() loop.call_later(0.25, test) await asyncio.wait_for(event.wait(), 1) # timeout just in case assert dt.datetime.now() - sta...
code_fim
hard
{ "lang": "python", "repo": "arseniybanayev/aiotime", "path": "/tests/test_aiotime.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> event.set() loop.call_later(0.25, test) await asyncio.wait_for(event.wait(), 1) # timeout just in case assert dt.datetime.now() - start > dt.timedelta(seconds=0.25)<|fim_prefix|># repo: arseniybanayev/aiotime path: /tests/test_aiotime.py import asyncio import pytest import datetime a...
code_fim
medium
{ "lang": "python", "repo": "arseniybanayev/aiotime", "path": "/tests/test_aiotime.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> bbox_tensors = [] for i, fm in enumerate(feature_maps): bbox_tensor = decode(fm, i) bbox_tensors.append(bbox_tensor) self.model = tf.keras.Model(input_layer, bbox_tensors) self.model.load_weights('./yolov3') self.model.summary() def get...
code_fim
hard
{ "lang": "python", "repo": "polycart/polycart", "path": "/PolyCart/Cart/cv_detection.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: polycart/polycart path: /PolyCart/Cart/cv_detection.py import cv2 import numpy as np import core.utils as utils import tensorflow as tf from core.yolov3 import YOLOv3, decode from core.config import cfg import time from PIL import Image class Detection: ''' 使用时, 通过 Detection.get_instance() ...
code_fim
hard
{ "lang": "python", "repo": "polycart/polycart", "path": "/PolyCart/Cart/cv_detection.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for currSegment in segmentList: rowData = [ currSegment['segid'], # ID currSegment['permalink'], # PL currRoadType, # Road type "", # FWD Dir "", ...
code_fim
hard
{ "lang": "python", "repo": "TerryOtt/segmentcsv2kml", "path": "/utils/jsonToCsv/jsonToCsv.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: TerryOtt/segmentcsv2kml path: /utils/jsonToCsv/jsonToCsv.py #!/usr/bin/env python3 import argparse import sys import os import json # from pprint import pprint import csv def main(): args = parseArgs(sys.argv) parsedData = readJson(args.jsonFile) print( "Read all JSON data success...
code_fim
hard
{ "lang": "python", "repo": "TerryOtt/segmentcsv2kml", "path": "/utils/jsonToCsv/jsonToCsv.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> segmentCsvWriter.writerow(headerRow) def addSegmentsToCsv( currRoadType, segmentList, csvWriter ): for currSegment in segmentList: rowData = [ currSegment['segid'], # ID currSegment['permalink'], # PL currRoadType, ...
code_fim
hard
{ "lang": "python", "repo": "TerryOtt/segmentcsv2kml", "path": "/utils/jsonToCsv/jsonToCsv.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Team-Alua/gcdv2gnf path: /gcdv2gnf.py import os header = 0x474E4620F8000000.to_bytes(8,'big') folder = 'E:\GRR\gcd\\' output_folder = 'E:\GRR\gnf\\' files = [] # r=root, d=directories, f = files for r, d, f in os.walk(folder): for file in f: if '.gcdm' in file: ...
code_fim
hard
{ "lang": "python", "repo": "Team-Alua/gcdv2gnf", "path": "/gcdv2gnf.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while body is not None: with open(r"%s%s_%d.gnf" % (output_folder, os.path.basename(f.name).split('.')[0], count), "wb") as output: output.write(body) print("Exported #%d" % count) count += 1 hea...
code_fim
hard
{ "lang": "python", "repo": "Team-Alua/gcdv2gnf", "path": "/gcdv2gnf.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: anhnguyendepocen/unimib_masterbi_2021 path: /indiegogo_aws/aws_glue_pyspark.py ###### UNIMIB - 2021 Indiegogo ###### import sys import json import pyspark from pyspark.sql.functions import col, collect_list, array_join from awsglue.transforms import * from awsglue.utils import getResolvedOptio...
code_fim
medium
{ "lang": "python", "repo": "anhnguyendepocen/unimib_masterbi_2021", "path": "/indiegogo_aws/aws_glue_pyspark.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # CREATE THE AGGREGATE MODEL, ADD TAGS TO TEDX_DATASET img_dataset_agg = img_dataset.groupBy(col("project_id").alias("project_id_ref")).agg(collect_list("name").alias("names")) img_dataset_agg.printSchema() projects_dataset_agg = projects_dataset.join(img_dataset_agg, projects_dataset.project_id == img_...
code_fim
hard
{ "lang": "python", "repo": "anhnguyendepocen/unimib_masterbi_2021", "path": "/indiegogo_aws/aws_glue_pyspark.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if __name__ == "__main__": logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S') # path = sys.argv[1] if len(sys.argv) > 1 else '.' path = '/saber/' # Find workflows # Find jobs c...
code_fim
hard
{ "lang": "python", "repo": "aplbrain/saber", "path": "/conduit/scripts/cwl_monitor", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>if __name__ == "__main__": logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S') # path = sys.argv[1] if len(sys.argv) > 1 else '.' path = '/saber/' # Find workflows # Find jobs c ...
code_fim
hard
{ "lang": "python", "repo": "aplbrain/saber", "path": "/conduit/scripts/cwl_monitor", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: aplbrain/saber path: /conduit/scripts/cwl_monitor #! /usr/bin/python # Copyright 2019 The Johns Hopkins University Applied Physics Laboratory # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a c...
code_fim
hard
{ "lang": "python", "repo": "aplbrain/saber", "path": "/conduit/scripts/cwl_monitor", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: msduketown/PrettyQt path: /prettyqt/widgets/toolbutton.py # -*- coding: utf-8 -*- """ @author: Philipp Temminghoff """ from qtpy import QtWidgets, QtCore from prettyqt import widgets from prettyqt.utils import bidict POPUP_MODES = bidict(delayed=QtWidgets.QToolButton.DelayedPopup, ...
code_fim
hard
{ "lang": "python", "repo": "msduketown/PrettyQt", "path": "/prettyqt/widgets/toolbutton.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> possible values are "delayed", "menu_button", "instant" Returns: popup mode """ return POPUP_MODES.inv[self.popupMode()] def set_arrow_type(self, mode: str): """sets the arrow type of the toolbutton valid values are: "none", "up", "down", ...
code_fim
hard
{ "lang": "python", "repo": "msduketown/PrettyQt", "path": "/prettyqt/widgets/toolbutton.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: akxen/mpo-dev path: /project/api/serializers.py from rest_framework import serializers <|fim_suffix|> initial_weights = serializers.JSONField() estimated_returns = serializers.JSONField() parameters = serializers.JSONField()<|fim_middle|> class ModelDataSerializer(serializers.Serializ...
code_fim
easy
{ "lang": "python", "repo": "akxen/mpo-dev", "path": "/project/api/serializers.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> initial_weights = serializers.JSONField() estimated_returns = serializers.JSONField() parameters = serializers.JSONField()<|fim_prefix|># repo: akxen/mpo-dev path: /project/api/serializers.py from rest_framework import serializers <|fim_middle|>class ModelDataSerializer(serializers.Serializ...
code_fim
easy
{ "lang": "python", "repo": "akxen/mpo-dev", "path": "/project/api/serializers.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: ericgreveson/adventofcode path: /2018/day2/challenge.py from collections import Counter from aoc.challenge_base import ChallengeBase class Challenge(ChallengeBase): """ Day 2 challenges """ def challenge1(self): """ Day 2 challenge 1 """ ids_with...
code_fim
hard
{ "lang": "python", "repo": "ericgreveson/adventofcode", "path": "/2018/day2/challenge.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """ Day 2 challenge 2 """ # Remove one letter at each position from each ID and plonk them in a set match_possibilities = set() for id in self.lines: sub_ids = set() for letter_pos in range(len(id)): sub_ids.add(id[:le...
code_fim
hard
{ "lang": "python", "repo": "ericgreveson/adventofcode", "path": "/2018/day2/challenge.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # limit = 14 # days # cond1 = Q(is_stood_down=True) # cond2 = Q(end__lt=datetime.utcnow().replace(tzinfo=timezone.utc)-timedelta(days=limit)) return super().get_queryset().\ select_related('country') # exclude(cond1 & cond2) # 'event' inclusion ^ to...
code_fim
hard
{ "lang": "python", "repo": "IFRCGo/go-api", "path": "/notifications/drf_views.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> serializer_class = SubscriptionSerializer authentication_classes = (TokenAuthentication,) permission_classes = (IsAuthenticated,) search_fields = ('user__username', 'rtype') # for /docs def get_queryset(self): return Subscription.objects.filter(user=self.request.user)<|fim_pr...
code_fim
hard
{ "lang": "python", "repo": "IFRCGo/go-api", "path": "/notifications/drf_views.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: IFRCGo/go-api path: /notifications/drf_views.py from datetime import datetime, timedelta, timezone from django.db.models import Q from django_filters import rest_framework as filters from rest_framework.authentication import TokenAuthentication from rest_framework.permissions import IsAuthenticat...
code_fim
hard
{ "lang": "python", "repo": "IFRCGo/go-api", "path": "/notifications/drf_views.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jeraldlyh/HoloRPG path: /backend/api/room/models.py from django.db import models from django.db.models.signals import pre_save from django.dispatch.dispatcher import receiver from django.utils.translation import gettext as _ from ..user.models import UserProfile from .utils import generate_unique...
code_fim
hard
{ "lang": "python", "repo": "jeraldlyh/HoloRPG", "path": "/backend/api/room/models.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return self.id @property def get_profile_pictures(self) -> list: profile_pictures = [self.host.image] if self.player_two is not None: profile_pictures.append(self.player_two.image) if self.player_three is not None: profile_pictures.appen...
code_fim
hard
{ "lang": "python", "repo": "jeraldlyh/HoloRPG", "path": "/backend/api/room/models.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }