text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: JC-ut0/social-distance-detector path: /data_preprocess_module/filter_image.py
import os
fileNumToDelete = []
for filename in os.listdir('labels/train2014'):
if filename.endswith(".txt") or filename.endswith(".py"):
thisPath = os.path.join('labels/train2014', filename)
img_n... | code_fim | medium | {
"lang": "python",
"repo": "JC-ut0/social-distance-detector",
"path": "/data_preprocess_module/filter_image.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fileToEdit.close()
fileToCheck = open(thisPath, "r")
# print(len(fileToCheck.readlines()), img_num)
if len(fileToCheck.readlines()) == 0:
fileNumToDelete.append(img_num)
# print(fileNumToDelete)
for item in fileNumToDelete:
tx... | code_fim | hard | {
"lang": "python",
"repo": "JC-ut0/social-distance-detector",
"path": "/data_preprocess_module/filter_image.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@app.route('/predict', methods=['POST'])
def predict_query():
if not (request.args.get('domain') or request.args.get('userUtterance')):
log_util.log_errormsg("[APP] missing parameters")
abort(404)
if request.args.get('locale'):
locale = request.args.get('locale')
else:
... | code_fim | hard | {
"lang": "python",
"repo": "hmi-digital/bot_platform",
"path": "/NLPEngine/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hmi-digital/bot_platform path: /NLPEngine/app.py
# -*- coding: utf-8 -*-
import json
import os
import re
import sys, getopt
import threading
from warnings import simplefilter
import flask
from flask import request, abort, make_response, jsonify
from utils import nlp_config
from utils import log_... | code_fim | hard | {
"lang": "python",
"repo": "hmi-digital/bot_platform",
"path": "/NLPEngine/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>A DVC stage is executed with the following command:
.. prompt:: bash
dvc repro -s NAME_OF_STAGE
**test_dr_drift**:
Tests the model by loading the last checkpoints from the folder
checkpoints/dr_drift and creates the results folder with the test results
**make_video_dr_drift**:
Takes the results fro... | code_fim | hard | {
"lang": "python",
"repo": "KITcar-Team/kitcar-gazebo-simulation",
"path": "/simulation/utils/machine_learning/cycle_gan/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KITcar-Team/kitcar-gazebo-simulation path: /simulation/utils/machine_learning/cycle_gan/__init__.py
"""The Cycle GAN can be used to convert simulated images into real looking images.
During training, a class A image is "translated" to class B using a generator
and "retranslated" to class A using... | code_fim | hard | {
"lang": "python",
"repo": "KITcar-Team/kitcar-gazebo-simulation",
"path": "/simulation/utils/machine_learning/cycle_gan/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> f = open(SNPS_TWO_POPS, 'r')
# next, make it guess
d = read_arlequin(f)
assert isinstance(d, list)
def test_iterate_arlequin_with_dict_return():
"""iterate_arlequin with default options"""
for entry in iterate_arlequin(SNPS_TWO_POPS_TEXT):
assert isinstance(entry, dict)
d... | code_fim | hard | {
"lang": "python",
"repo": "ryanraaum/oldowan.arlequin",
"path": "/tests/test_read_arlequin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ryanraaum/oldowan.arlequin path: /tests/test_read_arlequin.py
from oldowan.arlequin.iterate import iterate_arlequin
from oldowan.arlequin.read import read_arlequin
import os
SNPS_TWO_POPS = os.path.join(os.path.dirname(__file__),
'test_files', 'snps_two_pops.arp')
f = open(SNPS_TWO_PO... | code_fim | hard | {
"lang": "python",
"repo": "ryanraaum/oldowan.arlequin",
"path": "/tests/test_read_arlequin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = self.selectModel(modelname)
if itemid.isdigit(): itemid = int(itemid)
item = model.get_by_id(itemid)
auth(self, "delete", item)
if not item: self.abort(404)
self.deleteItems(model, [item])
self.abort(204)
... | code_fim | hard | {
"lang": "python",
"repo": "WCF/restfulgae",
"path": "/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _get(self, modelname):
model = self.selectModel(modelname)
return model, self.getCollection(model.query())
def get(self, modelname):
itemlist = self.getCollection(self.selectModel(modelname).query())
auth(self, "get", itemlist)
... | code_fim | hard | {
"lang": "python",
"repo": "WCF/restfulgae",
"path": "/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WCF/restfulgae path: /__init__.py
from google.appengine.ext import db
from google.appengine.api import users
import operator
import webapp2
import webapp2_extras.routes
import json
import types
import base64
import datetime
operators = {
"==": operator.eq, "<": operator.lt, ">": operator.gt... | code_fim | hard | {
"lang": "python",
"repo": "WCF/restfulgae",
"path": "/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tl32rodan/Domain-Adaptation-with-Conditional-Distribution-Matching-and-Generalized-Label-Shift path: /train_digits.py
rk
from data_list import build_uspsmnist, sample_ratios, subsampling
def write_list(f, l):
f.write(",".join(map(str, l)) + "\n")
f.flush()
sys.stdout.flush()
def t... | code_fim | hard | {
"lang": "python",
"repo": "tl32rodan/Domain-Adaptation-with-Conditional-Distribution-Matching-and-Generalized-Label-Shift",
"path": "/train_digits.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Set random number seed.
np.random.seed(args.seed)
torch.manual_seed(args.seed)
os.environ["CUDA_VISIBLE_DEVICES"] = '0'
if args.task == 'usps2mnist':
# CDAN parameters
decay_epoch = 6
decay_frac = 0.5
lr = 0.02
start_epoch = 1
model =... | code_fim | hard | {
"lang": "python",
"repo": "tl32rodan/Domain-Adaptation-with-Conditional-Distribution-Matching-and-Generalized-Label-Shift",
"path": "/train_digits.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.task == 'usps2mnist':
# CDAN parameters
decay_epoch = 6
decay_frac = 0.5
lr = 0.02
start_epoch = 1
model = network.LeNet(args.ma)
build_dataset = build_uspsmnist
source_list = os.path.join(args.root_folder, 'usps_train.txt')
... | code_fim | hard | {
"lang": "python",
"repo": "tl32rodan/Domain-Adaptation-with-Conditional-Distribution-Matching-and-Generalized-Label-Shift",
"path": "/train_digits.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mnfienen/pyemu path: /autotest/da/two_dim_flow.py
import os, sys
import numpy as np
import flopy
import platform
import pyemu
# https://modflowpy.github.io/flopydoc/tutorial2.html
bin_folder = r"..\..\bin"
def model_setup():
# Model domain and grid definition
Lx = 1000.
Ly = 1000.
... | code_fim | hard | {
"lang": "python",
"repo": "mnfienen/pyemu",
"path": "/autotest/da/two_dim_flow.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Make list for stress period 1
stageleft = 10.
stageright = 10.
bound_sp1 = []
for il in range(nlay):
condleft = hk * (stageleft - zbot) * delc
condright = hk * (stageright - zbot) * delc
for ir in range(nrow):
bound_sp1.append([il, ir, 0, stageleft... | code_fim | hard | {
"lang": "python",
"repo": "mnfienen/pyemu",
"path": "/autotest/da/two_dim_flow.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: andrubor/keras-galaxies path: /try_convnet_default.py
]=1 #lence
#WEIGHTS[20]=1 #disturbed
#WEIGHTS[21]=1 #irregular
#WEIGHTS[22]=1 #other
#WEIGHTS[23]=1 #merger
#WEIGHTS[24]=1 #dust lane
WEIGHTS=WEIGHTS/WEIGHTS[WEIGHTS.argmax()]
GEN_BUFFER_SIZE = 1
TRAIN_LOSS_SF_PATH = "trainingNmbrs_def... | code_fim | hard | {
"lang": "python",
"repo": "andrubor/keras-galaxies",
"path": "/try_convnet_default.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #if USE_LLERROR: mean_valid_loss = np.mean(losses)
#else:
mean_valid_loss = np.sqrt(np.mean(losses))
mean_valid_loss_ll = np.mean(losses_ll)
if USE_WEIGHTS: mean_valid_loss_weighted = np.sqrt(np.mean(losses_weighted))
print " mean validation loss (RMSE):\t\t%.6f" % ... | code_fim | hard | {
"lang": "python",
"repo": "andrubor/keras-galaxies",
"path": "/try_convnet_default.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
this generates the training data in order, for postprocessing. Do not use this for actual training.
"""
data_gen_train = ra.realtime_fixed_augmented_data_gen(train_indices, 'train',
ds_transforms=ds_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes)
return load_da... | code_fim | hard | {
"lang": "python",
"repo": "andrubor/keras-galaxies",
"path": "/try_convnet_default.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> signed_change_request_obj = signed_change_request_class.deserialize_from_dict(
signed_change_request_dict
)
break
else:
raise NotImplementedError(f'message.block_type "{instance_block_type}" is not supported')
... | code_fim | hard | {
"lang": "python",
"repo": "Devcentralized/thenewboston-node",
"path": "/thenewboston_node/business_logic/models/block.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Devcentralized/thenewboston-node path: /thenewboston_node/business_logic/models/block.py
import logging
import warnings
from dataclasses import dataclass
from typing import Optional, Type, TypeVar
from thenewboston_node.business_logic.exceptions import ValidationError
from thenewboston_node.busi... | code_fim | hard | {
"lang": "python",
"repo": "Devcentralized/thenewboston-node",
"path": "/thenewboston_node/business_logic/models/block.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wanghaisheng/Hashtag-Monitor path: /hashtag_monitor/apps/monitor/tests/test_models.py
values())
self.assertIn('name', cm.exception.message_dict)
self.assertIn('This field cannot be blank.', msgs[0])
def test_hashtag_must_have_a_color(self):
h = Hashtag.objects.create(... | code_fim | hard | {
"lang": "python",
"repo": "wanghaisheng/Hashtag-Monitor",
"path": "/hashtag_monitor/apps/monitor/tests/test_models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wanghaisheng/Hashtag-Monitor path: /hashtag_monitor/apps/monitor/tests/test_models.py
elf.assertEqual(usr.screen_name, updated_user.screen_name)
self.assertEqual(usr.friends_count, updated_user.friends_count)
def test_update_or_create_should_create_when_user_not_exist(self):
... | code_fim | hard | {
"lang": "python",
"repo": "wanghaisheng/Hashtag-Monitor",
"path": "/hashtag_monitor/apps/monitor/tests/test_models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> query = Tweet.get_tweets_per_lang(top=1, hashtag_name=h1.name)
self.assertNotIn("fr", query)
self.assertIn("en", query)
self.assertEqual(2, query['en'])
self.assertEqual(1, query['others'])
def test_get_hashtag_tweets_per_day(self):
h1 = Hashtag.object... | code_fim | hard | {
"lang": "python",
"repo": "wanghaisheng/Hashtag-Monitor",
"path": "/hashtag_monitor/apps/monitor/tests/test_models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns
------------
mantraml.BaseModel type object - any BaseModel type objects found within the modle
"""
model = None
for obj_key, obj_value in model_module.__dict__.items():
if obj_key in BASE_MODEL_CLASSES:
continue
elif hasattr(model_module.__di... | code_fim | hard | {
"lang": "python",
"repo": "RJT1990/mantra",
"path": "/mantraml/data/finders.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RJT1990/mantra path: /mantraml/data/finders.py
from .Dataset import Dataset
from .ImageDataset import ImageDataset
from .TabularDataset import TabularDataset
from mantraml.models import MantraModel
from mantraml.tasks.Task import Task
# Bade model and data for training
BASE_MODEL_CLASSES = ['Ma... | code_fim | hard | {
"lang": "python",
"repo": "RJT1990/mantra",
"path": "/mantraml/data/finders.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if is_tf_available():
from .modeling_tf_mt5 import TFMT5EncoderModel, TFMT5ForConditionalGeneration, TFMT5Model<|fim_prefix|># repo: e-budur/transformers path: /src/transformers/models/mt5/__init__.py
# flake8: noqa
# There's no way to ignore "F401 '...' imported but unused" warnings in this
# module... | code_fim | hard | {
"lang": "python",
"repo": "e-budur/transformers",
"path": "/src/transformers/models/mt5/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: e-budur/transformers path: /src/transformers/models/mt5/__init__.py
# flake8: noqa
# There's no way to ignore "F401 '...' imported but unused" warnings in this
# module, but to preserve other warnings. So, don't check this module at all.
from ...file_utils import is_sentencepiece_available, is_t... | code_fim | hard | {
"lang": "python",
"repo": "e-budur/transformers",
"path": "/src/transformers/models/mt5/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if is_torch_available():
from .modeling_mt5 import MT5EncoderModel, MT5ForConditionalGeneration, MT5Model
if is_tf_available():
from .modeling_tf_mt5 import TFMT5EncoderModel, TFMT5ForConditionalGeneration, TFMT5Model<|fim_prefix|># repo: e-budur/transformers path: /src/transformers/models/mt5/_... | code_fim | medium | {
"lang": "python",
"repo": "e-budur/transformers",
"path": "/src/transformers/models/mt5/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Vertical section
ax = plt.subplot(326)
mesh.plot_slice(
m_true, ax=ax, normal="Y", ind=midx, grid=True, clim=(vmin, vmax)
)
plt.plot(
([mesh.cell_centers_x[0], mesh.cell_centers_x[-1]]),
([mesh.cell_centers_z[zpanel], mesh.cell_... | code_fim | hard | {
"lang": "python",
"repo": "simpeg/simpeg",
"path": "/examples/_archived/plot_inv_grav_linear.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: simpeg/simpeg path: /examples/_archived/plot_inv_grav_linear.py
"""
PF: Gravity: Inversion Linear
=============================
Create a synthetic block model and invert
with a compact norm
"""
import numpy as np
import matplotlib.pyplot as plt
from discretize import TensorMesh
from discretize... | code_fim | hard | {
"lang": "python",
"repo": "simpeg/simpeg",
"path": "/examples/_archived/plot_inv_grav_linear.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ahmadelsallab/StockMarketPrediction path: /crawl_thread.py
from datetime import datetime
from app.models import Sources, Stocks, Opinion, Tweeter, Matrix
from django.utils import timezone
from Filter.Filter import Filter
import threading, time
import datetime
import unicodedata
import os
from Que... | code_fim | hard | {
"lang": "python",
"repo": "ahmadelsallab/StockMarketPrediction",
"path": "/crawl_thread.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> item2.tweeter_followers_count = tweet['user']['followers_count']
item2.tweeter_followings_count = tweet['user']['friends_count']
item2.tweeter_statuses_count = tweet['user']['statuses_count']
item2.tweeter_likes = tweet['user']['favourites_count']
... | code_fim | hard | {
"lang": "python",
"repo": "ahmadelsallab/StockMarketPrediction",
"path": "/crawl_thread.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> mylist = input_text.split(',')
return [list(mylist)]
if __name__ == '__main__':
#print("This is the 2nd arg: ", sys.argv[2])
#print("This is the 3rd arg: ", sys.argv[3])
input_app = sys.argv[2]
#print(json_load(sys.argv[3]))
cv2.setNumThreads(0)
config, unparsed = get_con... | code_fim | hard | {
"lang": "python",
"repo": "leticiapinto/flaskapp",
"path": "/cocoapi2/PythonAPI/Text2Scene2/tools/abstract_demo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def prepare_data(input_text):
mylist = input_text.split(',')
return [list(mylist)]
if __name__ == '__main__':
#print("This is the 2nd arg: ", sys.argv[2])
#print("This is the 3rd arg: ", sys.argv[3])
input_app = sys.argv[2]
#print(json_load(sys.argv[3]))
cv2.setNumThreads(0)
... | code_fim | hard | {
"lang": "python",
"repo": "leticiapinto/flaskapp",
"path": "/cocoapi2/PythonAPI/Text2Scene2/tools/abstract_demo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: leticiapinto/flaskapp path: /cocoapi2/PythonAPI/Text2Scene2/tools/abstract_demo.py
#!/usr/bin/env python
import _init_paths
import math, cv2, random
import numpy as np
import os.path as osp
from copy import deepcopy
import matplotlib.pyplot as plt
from datasets.abstract_scene import abstract_sce... | code_fim | medium | {
"lang": "python",
"repo": "leticiapinto/flaskapp",
"path": "/cocoapi2/PythonAPI/Text2Scene2/tools/abstract_demo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: skyportal/skyportal path: /alembic/versions/529166dc7732_plans_api.py
"""plans API
Revision ID: 529166dc7732
Revises: 46a40b35cdbb
Create Date: 2022-02-12 20:55:46.665147
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = '529166dc7732'
down_revision = '46a40b35cdb... | code_fim | hard | {
"lang": "python",
"repo": "skyportal/skyportal",
"path": "/alembic/versions/529166dc7732_plans_api.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>alter table "public"."instruments" alter column api_classname type "public"."followup_apis" using api_classname::text::"public"."followup_apis";
alter table "public"."instruments" alter column api_classname_obsplan type "public"."followup_apis" using api_classname_obsplan::text::"public"."followup_apis";... | code_fim | hard | {
"lang": "python",
"repo": "skyportal/skyportal",
"path": "/alembic/versions/529166dc7732_plans_api.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>drop type "public"."followup_apis__old_version_to_be_dropped";
"""
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###<|fim_prefix|># repo: skyportal/skyportal path: /alembic/versions/529... | code_fim | medium | {
"lang": "python",
"repo": "skyportal/skyportal",
"path": "/alembic/versions/529166dc7732_plans_api.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>class AllegroLokalnieScraper(Scraper):
def scrape(self, url, which_one):
response = self.open_connection(url)
tree = lxml.html.fromstring(response.content)
articles = tree.xpath("//a[@class='card offer-card']")
data = {which_one: []}
for article in articles:
... | code_fim | hard | {
"lang": "python",
"repo": "dualsky/poszukiwacz_aukcji",
"path": "/aukcje/scrapers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dualsky/poszukiwacz_aukcji path: /aukcje/scrapers.py
import requests
import lxml.html
import random
from bs4 import BeautifulSoup
def get_element(list):
try:
return list[0].text.replace('\n','')
except:
return None
class Node:
@staticmethod
def childTexts(node):... | code_fim | hard | {
"lang": "python",
"repo": "dualsky/poszukiwacz_aukcji",
"path": "/aukcje/scrapers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _create_common_request(self, service_provider, token_id):
headers = {'Content-Type': 'application/json'}
body = {
'auth': {
'identity': {
'methods': ['token'],
'token': {
'id': token_id
... | code_fim | hard | {
"lang": "python",
"repo": "openstack/python-keystoneclient",
"path": "/keystoneclient/v3/contrib/federation/saml.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstack/python-keystoneclient path: /keystoneclient/v3/contrib/federation/saml.py
# 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 at
#
# http://www.apache... | code_fim | hard | {
"lang": "python",
"repo": "openstack/python-keystoneclient",
"path": "/keystoneclient/v3/contrib/federation/saml.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def create_saml_assertion(self, service_provider, token_id):
"""Create a SAML assertion from a token.
Equivalent Identity API call:
POST /auth/OS-FEDERATION/saml2
:param service_provider: Service Provider resource.
:type service_provider: string
:param... | code_fim | hard | {
"lang": "python",
"repo": "openstack/python-keystoneclient",
"path": "/keystoneclient/v3/contrib/federation/saml.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def log_kv(self, key_values: Dict[str, Any], timestamp: Optional[float] = None) -> 'Span':
if self.is_sampled():
timestamp = timestamp if timestamp else time.time()
# TODO handle exception logging, 'python.exception.type' etc.
log = thrift.make_log(
... | code_fim | hard | {
"lang": "python",
"repo": "jaegertracing/jaeger-client-python",
"path": "/jaeger_client/span.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jaegertracing/jaeger-client-python path: /jaeger_client/span.py
# Copyright (c) 2016-2018 Uber Technologies, Inc.
#
# 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 at
#
# ht... | code_fim | hard | {
"lang": "python",
"repo": "jaegertracing/jaeger-client-python",
"path": "/jaeger_client/span.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def majorityMedian(l):
if not l:
raise ValueError("no median for empty data")
return nlargest(len(l) / 2 + 1, l)[-1]<|fim_prefix|># repo: matthewnorman/kontiki path: /kontiki/fundamentals.py
from heapq import heapify, heappop
<|fim_middle|>def nlargest(n, l):
if not l:
retur... | code_fim | medium | {
"lang": "python",
"repo": "matthewnorman/kontiki",
"path": "/kontiki/fundamentals.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matthewnorman/kontiki path: /kontiki/fundamentals.py
from heapq import heapify, heappop
<|fim_suffix|> if not l:
return l
leastL = [-el for el in l]
heapify(leastL)
return [-heappop(leastL) for _ in xrange(min(n, len(l)))]
def majorityMedian(l):
if not l:
ra... | code_fim | easy | {
"lang": "python",
"repo": "matthewnorman/kontiki",
"path": "/kontiki/fundamentals.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matthewnorman/kontiki path: /kontiki/fundamentals.py
from heapq import heapify, heappop
def nlargest(n, l):
<|fim_suffix|>
def majorityMedian(l):
if not l:
raise ValueError("no median for empty data")
return nlargest(len(l) / 2 + 1, l)[-1]<|fim_middle|> if not l:
retu... | code_fim | medium | {
"lang": "python",
"repo": "matthewnorman/kontiki",
"path": "/kontiki/fundamentals.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: comicencyclo/Keras_TestTimeAugmentation path: /Keras_TTA.py
# coding: utf-8
# In[ ]:
import numpy as np
from scipy import ndimage
class Keras_TTA():
""" Test time augmentation (TTA) wrapper for Keras Image Classification models. This makes prediction for one image at
a time. This ... | code_fim | hard | {
"lang": "python",
"repo": "comicencyclo/Keras_TestTimeAugmentation",
"path": "/Keras_TTA.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> predctr = 0
arrlist=[]
if self.use_origimg ==True:
predctr+=1.0
score = model.predict(X)
arrlist.append(score)
if self.fliplr ==True:
predctr+=1.0
img2 = np.fliplr(X)
score = model.predict(img2)
... | code_fim | hard | {
"lang": "python",
"repo": "comicencyclo/Keras_TestTimeAugmentation",
"path": "/Keras_TTA.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: broadinstitute/pytos path: /pytos/securechange/xml_objects/restapi/step/server_decommission/server_decommission.py
from pytos.securechange.xml_objects.restapi.step.access_request.accessrequest import Any_Access_Request_Device, \
Named_Access_Request_Device, IP_Range_Access_Request_Target, IP_... | code_fim | hard | {
"lang": "python",
"repo": "broadinstitute/pytos",
"path": "/pytos/securechange/xml_objects/restapi/step/server_decommission/server_decommission.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Initialize the object from a XML node.
:param xml_node: The XML node from which all necessary parameters will be parsed.
:type xml_node: xml.etree.Element
"""
order = get_xml_text_value(xml_node, Elements.ORDER)
server_decommission_id = get_xml_i... | code_fim | hard | {
"lang": "python",
"repo": "broadinstitute/pytos",
"path": "/pytos/securechange/xml_objects/restapi/step/server_decommission/server_decommission.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> :return stock_data: (DataFrame)
"""
try:
stock_data = pd.read_csv(file_name + '.csv', parse_dates=['date']).dropna()
stock_data = stock_data.sort_values(by=['date'])
except ValueError:
stock_data = pd.read_csv(file_name + '.csv').dropna()
if company is not None... | code_fim | hard | {
"lang": "python",
"repo": "willbelucky/willbelucky_ML",
"path": "/data/data_reader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: willbelucky/willbelucky_ML path: /data/data_reader.py
# -*- coding: utf-8 -*-
"""
:Author: Jaekyoung Kim
:Date: 2017. 11. 27.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import collections
import numpy as np
import pandas as p... | code_fim | hard | {
"lang": "python",
"repo": "willbelucky/willbelucky_ML",
"path": "/data/data_reader.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def load_dir(framework: str, path: str, get_front_classes: callable):
"""
Assuming the following sub-directory structure for path:
front/
<framework>/
<other_files>.py
<other_directories>/
<other_files>.py
ops/
<ops_f... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/openvino",
"path": "/tools/mo/openvino/tools/mo/utils/import_extensions.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openvinotoolkit/openvino path: /tools/mo/openvino/tools/mo/utils/import_extensions.py
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import importlib
import logging as log
import os
import pkgutil
import sys
from openvino.tools.mo.back.replacement import BackR... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/openvino",
"path": "/tools/mo/openvino/tools/mo/utils/import_extensions.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> EXT_DIR_NAME = '.'
return os.path.abspath(os.getcwd().join(EXT_DIR_NAME))
def load_dir(framework: str, path: str, get_front_classes: callable):
"""
Assuming the following sub-directory structure for path:
front/
<framework>/
<other_files>.py
... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/openvino",
"path": "/tools/mo/openvino/tools/mo/utils/import_extensions.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pauvrepetit/leetcode path: /46/main.py
# 46. 全排列
#
# 20200917
# huao
from typing import List
<|fim_suffix|> def permute(self, nums: List[int]) -> List[List[int]]:
if len(nums) == 0:
return []
if len(nums) == 1:
return [[nums[0]]]
numList = []
... | code_fim | easy | {
"lang": "python",
"repo": "pauvrepetit/leetcode",
"path": "/46/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def permute(self, nums: List[int]) -> List[List[int]]:
if len(nums) == 0:
return []
if len(nums) == 1:
return [[nums[0]]]
numList = []
for i in range(len(nums)):
subList = self.permute(nums[:i] + nums[i+1:])
for sub in sub... | code_fim | easy | {
"lang": "python",
"repo": "pauvrepetit/leetcode",
"path": "/46/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(nums) == 0:
return []
if len(nums) == 1:
return [[nums[0]]]
numList = []
for i in range(len(nums)):
subList = self.permute(nums[:i] + nums[i+1:])
for sub in subList:
numList.append([nums[i]] + sub)
... | code_fim | medium | {
"lang": "python",
"repo": "pauvrepetit/leetcode",
"path": "/46/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lowRISC/opentitan path: /util/dvsim/qsubopts.py
jobs submitted using the -now yes option. Please note that
regardless of the reservation request, job reserva‐
tion might be disabled using max_reservation in sched_conf(5)
and might be limited only ... | code_fim | hard | {
"lang": "python",
"repo": "lowRISC/opentitan",
"path": "/util/dvsim/qsubopts.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if prog in ['qsub', 'qsh', 'qrsh', 'qlogin', 'qalter']:
self.parser.add_argument('-masterq',
nargs='+',
metavar='wc_queue_list',
help="""\
Available for qsub, qr... | code_fim | hard | {
"lang": "python",
"repo": "lowRISC/opentitan",
"path": "/util/dvsim/qsubopts.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if prog in ['qsub', 'qrsh', 'qalter']:
self.parser.add_argument('-notify',
action='store_true',
help="""\
Available for qsub, qrsh (with command) and qalter only.
This flag, when set ... | code_fim | hard | {
"lang": "python",
"repo": "lowRISC/opentitan",
"path": "/util/dvsim/qsubopts.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: juancarlosdiaztorres/Ansible-OpenStack path: /filesystems/vnx_rootfs_lxc_ubuntu64-16.04-v025-openstack-compute/rootfs/usr/lib/python2.7/dist-packages/oslo_messaging/tests/drivers/zmq/test_zmq_address.py
# Copyright 2016 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the ... | code_fim | hard | {
"lang": "python",
"repo": "juancarlosdiaztorres/Ansible-OpenStack",
"path": "/filesystems/vnx_rootfs_lxc_ubuntu64-16.04-v025-openstack-compute/rootfs/usr/lib/python2.7/dist-packages/oslo_messaging/tests/drivers/zmq/test_zmq_address.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> target = oslo_messaging.Target(topic='topic', server='server',
fanout=True)
key = zmq_address.target_to_key(target, self.listener_type)
self.assertEqual(self.listener_type + '/topic', key)
@testtools.skipIf(zmq is None, "zmq not available... | code_fim | hard | {
"lang": "python",
"repo": "juancarlosdiaztorres/Ansible-OpenStack",
"path": "/filesystems/vnx_rootfs_lxc_ubuntu64-16.04-v025-openstack-compute/rootfs/usr/lib/python2.7/dist-packages/oslo_messaging/tests/drivers/zmq/test_zmq_address.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> execute_multiple: bool = False) -> tuple:
conn = None
cur = None
try:
params = config()
conn = psycopg2.connect(**params)
cur = conn.cursor()
if param is not None:
if execute_multiple:
for index in range(0, le... | code_fim | medium | {
"lang": "python",
"repo": "tomaskourim/mathsport2021",
"path": "/database_operations.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tomaskourim/mathsport2021 path: /database_operations.py
# support file to manipulate with SQLite and Postgresql database
import logging
from configparser import ConfigParser
from typing import Optional
import psycopg2
def config(filename: str = './database.ini', section: str = 'postgresql') ->... | code_fim | hard | {
"lang": "python",
"repo": "tomaskourim/mathsport2021",
"path": "/database_operations.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carlylagrotta/MSI path: /src/MSI/master_equation/master_equation_six_parameter_fit.py
xp_dict_list[0]['simulation'].processor.solution.reaction_equations()
index_of_reaction_in_cti = reactions_in_cti_file.index(reaction_string)
column_of_array = array[:,index_of_re... | code_fim | hard | {
"lang": "python",
"repo": "carlylagrotta/MSI",
"path": "/src/MSI/master_equation/master_equation_six_parameter_fit.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> AsNsEas =[[] for x in range(len(master_equation_reactions))]
for x in range(len(As)):
AsNsEas[x].append(As[x])
AsNsEas[x].append(Ns[x])
AsNsEas[x].append(Eas[x])
innerDict = ['A','n','Ea']
l = [dict(zip(inne... | code_fim | hard | {
"lang": "python",
"repo": "carlylagrotta/MSI",
"path": "/src/MSI/master_equation/master_equation_six_parameter_fit.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for k,wl in enumerate(wavelengths):
temp = []
for reaction in master_equation_reactions:
column = slicing_out_reactions(reaction,absorbance_k_sens[wl][2])
array_mapped_to_sensitivity... | code_fim | hard | {
"lang": "python",
"repo": "carlylagrotta/MSI",
"path": "/src/MSI/master_equation/master_equation_six_parameter_fit.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jamesmloy/fvm path: /tools/build/packages/Pystatistics.py
from build_packages import *
class Pystatistics(BuildPkg):
<|fim_suffix|> return self.sys_log("python setup.py build")
def _install(self):
return self.sys_log("python setup.py install --prefix=%s" % self.blddir)<|fim_mi... | code_fim | medium | {
"lang": "python",
"repo": "jamesmloy/fvm",
"path": "/tools/build/packages/Pystatistics.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.sys_log("python setup.py install --prefix=%s" % self.blddir)<|fim_prefix|># repo: jamesmloy/fvm path: /tools/build/packages/Pystatistics.py
from build_packages import *
class Pystatistics(BuildPkg):
requires = ['numpy']
def _configure(self):
<|fim_middle|> return self.... | code_fim | medium | {
"lang": "python",
"repo": "jamesmloy/fvm",
"path": "/tools/build/packages/Pystatistics.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> true_data: tf.Tensor,
pred_data: tf.Tensor,
step: int = None,
max_outputs=4):
true_data = convert_tensor_uint8(true_data)
pred_data = convert_tensor_uint8(pred_data)
image_s... | code_fim | hard | {
"lang": "python",
"repo": "Zelgunn/Video-Latent-Lerp",
"path": "/code/callbacks/ImageCallback.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Zelgunn/Video-Latent-Lerp path: /code/callbacks/ImageCallback.py
import tensorflow as tf
from tensorflow import keras
from tensorflow.python.eager import def_function
from typing import List, Union, Callable
from callbacks import TensorBoardPlugin
from misc_utils.summary_utils import image_summa... | code_fim | hard | {
"lang": "python",
"repo": "Zelgunn/Video-Latent-Lerp",
"path": "/code/callbacks/ImageCallback.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def repeated_function(data, step):
_inputs, _outputs = data
decoded = autoencoder(_inputs)
return repeated_base_function(name=name, true_data=_outputs, pred_data=decoded, step=step)
one_shot_callback = ImageCallback(summary_function=one_shot_function, s... | code_fim | hard | {
"lang": "python",
"repo": "Zelgunn/Video-Latent-Lerp",
"path": "/code/callbacks/ImageCallback.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.RemoveField(
model_name="study",
name="exit_url",
),
]<|fim_prefix|># repo: lookit/lookit-api path: /studies/migrations/0075_remove_exit_url.py
# Generated by Django 3.0.14 on 2021-08-11 13:13
from django.db import migrations
<|... | code_fim | medium | {
"lang": "python",
"repo": "lookit/lookit-api",
"path": "/studies/migrations/0075_remove_exit_url.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lookit/lookit-api path: /studies/migrations/0075_remove_exit_url.py
# Generated by Django 3.0.14 on 2021-08-11 13:13
from django.db import migrations
<|fim_suffix|> dependencies = [
("studies", "0074_update_config_ember_frame_player"),
]
operations = [
migrations.Rem... | code_fim | easy | {
"lang": "python",
"repo": "lookit/lookit-api",
"path": "/studies/migrations/0075_remove_exit_url.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Migration(migrations.Migration):
dependencies = [
("studies", "0074_update_config_ember_frame_player"),
]
operations = [
migrations.RemoveField(
model_name="study",
name="exit_url",
),
]<|fim_prefix|># repo: lookit/lookit-api path: ... | code_fim | easy | {
"lang": "python",
"repo": "lookit/lookit-api",
"path": "/studies/migrations/0075_remove_exit_url.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kevensen/forseti-security path: /google/cloud/forseti/notifier/notifiers/base_email_notification.py
# Copyright 2017 The Forseti Security Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Lic... | code_fim | hard | {
"lang": "python",
"repo": "kevensen/forseti-security",
"path": "/google/cloud/forseti/notifier/notifiers/base_email_notification.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
**kwargs: Arbitrary keyword arguments.
"""
pass
@abc.abstractmethod
def _compose(self, **kwargs):
"""Compose notifications.
Args:
**kwargs: Arbitrary keyword arguments.
"""
pass<|fim_prefix|># repo: kevensen/fo... | code_fim | medium | {
"lang": "python",
"repo": "kevensen/forseti-security",
"path": "/google/cloud/forseti/notifier/notifiers/base_email_notification.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: salmanhiro/cora path: /cora/util/cosmology.py
"""
Cosmology routines: A module for various cosmological calculations.
The bulk of the work is within the class :py:class:`Cosmology` which stores a cosmology and can
calculate quantities like distance measures.
"""
import math
import numpy as np
... | code_fim | hard | {
"lang": "python",
"repo": "salmanhiro/cora",
"path": "/cora/util/cosmology.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def luminosity_distance(self, z):
r"""The luminosity distance to redshift z. This
routine is vectorized.
Parameters
----------
z : array_like
The redshift(s) to calculate at.
Returns
-------
dist : array_like
The... | code_fim | hard | {
"lang": "python",
"repo": "salmanhiro/cora",
"path": "/cora/util/cosmology.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def setUp( self ):
conf_dir = "target"
environ[ "CONF_DIR" ] = conf_dir
if exists( conf_dir ) is False:
mkdir( conf_dir )
copyfile( f"test/resources/{self.filename}", f"{conf_dir}/{self.filename}" )
def tearDown( self ):
rmtree( environ.get... | code_fim | medium | {
"lang": "python",
"repo": "magi-platform/magi-utils",
"path": "/test/HbaseSiteFileOverwriteTestSuite.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: magi-platform/magi-utils path: /test/HbaseSiteFileOverwriteTestSuite.py
import unittest
from os import environ
from os import mkdir
from os.path import exists
from shutil import rmtree, copyfile
from common.helpers import read_xml, overwrite_file
from hbase.helpers import process
from test.asser... | code_fim | hard | {
"lang": "python",
"repo": "magi-platform/magi-utils",
"path": "/test/HbaseSiteFileOverwriteTestSuite.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MediaMath/djangopypi2 path: /djangopypi2/website/urls.py
import logging
import urlparse
from django.conf.urls import patterns, include, url
from django.conf import settings
from django.core.urlresolvers import reverse
from django.views.static import serve as static_serve
from django.contrib impor... | code_fim | medium | {
"lang": "python",
"repo": "MediaMath/djangopypi2",
"path": "/djangopypi2/website/urls.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>urlpatterns = patterns('',
url(r'^' + (settings.USER_SETTINGS['WEB_ROOT'].strip('/') + r'/' ).lstrip('/'), include('djangopypi2.urls')),
url(r'^' + (settings.USER_SETTINGS['WEB_ROOT'].strip('/') + r'/admin/').lstrip('/'), include(admin.site.urls)),
url(r'^' + (settings.USER_SETTINGS['WEB_... | code_fim | hard | {
"lang": "python",
"repo": "MediaMath/djangopypi2",
"path": "/djangopypi2/website/urls.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''Returns urls for for static file serving from this server. In case
the STATIC_URL points to an absolute server, we don't serve static
files from this server.
'''
parsed_url = urlparse.urlparse(settings.STATIC_URL)
if parsed_url.netloc:
log.debug('Cannot serve STATIC file... | code_fim | medium | {
"lang": "python",
"repo": "MediaMath/djangopypi2",
"path": "/djangopypi2/website/urls.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: valiyakath/code path: /dynamic_programming/max_subset_sum_no_adjacent.py
# O(n) time | O(n) space
def maxSubsetSumNoAdjacent(array):
if not len(array):
return 0
elif len(array) == 1:
return array[0]
maxSums = [array[0]]
maxSums.append(max(array[0], array[1]))
f... | code_fim | medium | {
"lang": "python",
"repo": "valiyakath/code",
"path": "/dynamic_programming/max_subset_sum_no_adjacent.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not len(array):
return 0
elif len(array) == 1:
return array[0]
first = array[0]
second = max(array[0], array[1])
for i in range(2, len(array)):
maxSum = max(second, first + array[i])
first = second
second = maxSum
return second<|fim_prefix... | code_fim | medium | {
"lang": "python",
"repo": "valiyakath/code",
"path": "/dynamic_programming/max_subset_sum_no_adjacent.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: duranrojasm/symphony path: /cli/psym/graphql/query/search.py
#!/usr/bin/env python3
# @generated AUTOGENERATED file. Do not Change!
from dataclasses import dataclass, field as _field
from ...config import custom_scalars, datetime
from gql_client.runtime.variables import encode_variables
from gql... | code_fim | hard | {
"lang": "python",
"repo": "duranrojasm/symphony",
"path": "/cli/psym/graphql/query/search.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # fmt: off
@classmethod
def execute(cls, client: Client, name: str, after: Optional[str] = None, first: Optional[int] = 10, before: Optional[str] = None, last: Optional[int] = None) -> SearchQueryData.SearchNodesConnection:
variables: Dict[str, Any] = {"name": name, "after": after, "fi... | code_fim | hard | {
"lang": "python",
"repo": "duranrojasm/symphony",
"path": "/cli/psym/graphql/query/search.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: revolunet/extdirect.django path: /extdirect/django/test_urls.py
from django.conf.urls.defaults import *
import tests
urlpatterns = patterns(
'',
(r'^re<|fim_suffix|> tests.polling_provider.router),
(r'^polling/provider.js/$', tests.polling_provider.script)
)<|fim_middle|>moting/route... | code_fim | medium | {
"lang": "python",
"repo": "revolunet/extdirect.django",
"path": "/extdirect/django/test_urls.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> tests.polling_provider.router),
(r'^polling/provider.js/$', tests.polling_provider.script)
)<|fim_prefix|># repo: revolunet/extdirect.django path: /extdirect/django/test_urls.py
from django.conf.urls.defaults import *
import tests
urlpatterns = patterns(
'',
(r'^re<|fim_middle|>moting/route... | code_fim | medium | {
"lang": "python",
"repo": "revolunet/extdirect.django",
"path": "/extdirect/django/test_urls.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>tems_list_create',
),
path(
'pdf/',
ItemListPDFView.as_view(),
name='items_list_pdf',
),
path(
'<pk>/',
ItemRetrieveUpdateDestroyApiView.as_view(),
name='items_retrieve_update_destroy',
),
]<|fim_prefix|># repo: jahidulrudro/Invoice-Maker... | code_fim | medium | {
"lang": "python",
"repo": "jahidulrudro/Invoice-Maker-Django-VueJs",
"path": "/backend/items/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jahidulrudro/Invoice-Maker-Django-VueJs path: /backend/items/urls.py
from django.urls import path
from .apiviews import ItemListCreateApiView, ItemRetrieveUpdateDestroyApiView
from .views import ItemListPDFView
app_name = 'items'
urlpatterns = [
path(
'',
ItemListCreateApiVi... | code_fim | medium | {
"lang": "python",
"repo": "jahidulrudro/Invoice-Maker-Django-VueJs",
"path": "/backend/items/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> json_path = '/root/panda/annotations/vehicle_bbox_test.json'
with open(json_path, "r") as fp:
json_data = json.load(fp)
cvt_annotations(json_data, '/root/panda/annotations/vehicle_test.json')
print('Done!')
if __name__ == '__main__':
main()<|fim_prefix|># repo: Harzva/gigavis... | code_fim | medium | {
"lang": "python",
"repo": "Harzva/gigavision",
"path": "/my_tools/my_code/mmdetection/tools/giga/panda2coco_vehicle_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Harzva/gigavision path: /my_tools/my_code/mmdetection/tools/giga/panda2coco_vehicle_test.py
import os.path as osp
import json
from glob import glob
import mmcv
from PIL import Image
from tqdm import tqdm
def cvt_annotations(json_bbox, out_file):
<|fim_suffix|> json_path = '/root/panda/annota... | code_fim | hard | {
"lang": "python",
"repo": "Harzva/gigavision",
"path": "/my_tools/my_code/mmdetection/tools/giga/panda2coco_vehicle_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GT4SD/gt4sd-core path: /src/gt4sd/frameworks/granular/dataloader/sampler.py
#
# MIT License
#
# Copyright (c) 2022 GT4SD team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the S... | code_fim | hard | {
"lang": "python",
"repo": "GT4SD/gt4sd-core",
"path": "/src/gt4sd/frameworks/granular/dataloader/sampler.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
sample array.
"""
splitter = StratifiedShuffleSplit(
n_splits=self.number_of_splits, test_size=self.test_size
)
data_placeholder = torch.randn(self.targets.size(0), 2).numpy()
targets = self.targets.numpy()
splitter.g... | code_fim | hard | {
"lang": "python",
"repo": "GT4SD/gt4sd-core",
"path": "/src/gt4sd/frameworks/granular/dataloader/sampler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.