text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> def get_access_control_allow_headers(self, integration_response_params):
allow_headers_value = integration_response_params['method.response.header.Access-Control-Allow-Headers']
split_headers = map(lambda x: x.strip(), allow_headers_value[1:-1].split(','))
split_headers = filt... | code_fim | hard | {
"lang": "python",
"repo": "evilmint/aws-openapi-lint",
"path": "/aws_openapi_lint/rules/CORSInconsistentHeadersRule.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: evilmint/aws-openapi-lint path: /aws_openapi_lint/rules/CORSInconsistentHeadersRule.py
from .rule_validator import RuleViolation
from .rules_helper import get_apigateway_integration, get_path_headers, get_integration_response_parameters, \
get_path_verbs
class CORSInconsistentHeadersRule:
... | code_fim | hard | {
"lang": "python",
"repo": "evilmint/aws-openapi-lint",
"path": "/aws_openapi_lint/rules/CORSInconsistentHeadersRule.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anthonywchen/generative-nli path: /src/gnli_dataset_reader.py
import logging
import numpy as np
from overrides import overrides
import random
from typing import Callable, Dict, Iterable, Iterator, List
from allennlp.common import Params, Tqdm
from allennlp.data.dataset_readers.dataset_reader imp... | code_fim | hard | {
"lang": "python",
"repo": "anthonywchen/generative-nli",
"path": "/src/gnli_dataset_reader.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ####################
##### Create instance
####################
metadata = {'premise': premise,
'hypothesis': hypothesis,
'premise_tokens': premise_tokens,
'hypothesis_tokens': hypothesis_tokens,
'label': label, 'tag': tag}
fields = {'src': ArrayField(np.array(src), dtyp... | code_fim | hard | {
"lang": "python",
"repo": "anthonywchen/generative-nli",
"path": "/src/gnli_dataset_reader.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># Bewege die in rand_num_to_move definierte Anzahl zufälliger Elemente pro
# Klasse in den Testordner.
for target_dir_name in glob.glob(target_directory + "/" + train_directory_name + "/*"):
target_dir_classes = glob.glob(target_dir_name + "/*")
# Wähle für diese Klasse rand_num_to_move zufällige ... | code_fim | hard | {
"lang": "python",
"repo": "sesch023/SignLanguageRecognition",
"path": "/sign_language_image/datasets/kaggle_2/DatasetPrepareOrig.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sesch023/SignLanguageRecognition path: /sign_language_image/datasets/kaggle_2/DatasetPrepareOrig.py
import shutil
import os
import glob
import random
"""
Dieses Skript verarbeitet die Daten für den Kaggle ASL-Alphabet
Datensatz (https://www.kaggle.com/grassknoted/asl-alphabet), welche im Ordner
... | code_fim | hard | {
"lang": "python",
"repo": "sesch023/SignLanguageRecognition",
"path": "/sign_language_image/datasets/kaggle_2/DatasetPrepareOrig.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>model.cuda()
decoder.cuda()
loss_fn = torch.nn.MSELoss()
optim = torch.optim.Adam(list(model.parameters())+list(decoder.parameters()), lr=args.lr)
for itr in range(10000):
ims = train_input_handle.get_batch()
ims = preprocess.reshape_patch(ims, args.patch_size)
#print(ims.shape)# (8, 20, 16, ... | code_fim | medium | {
"lang": "python",
"repo": "ML4HPC/predrnn-pp",
"path": "/train_dev.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ML4HPC/predrnn-pp path: /train_dev.py
import torch
import argparse
import numpy as np
from data_provider import datasets_factory
from utils import preprocess, metrics
from layers import CausalLSTMStack # noqa
parser = argparse.ArgumentParser(description='Process some integers.')
args = parser.... | code_fim | hard | {
"lang": "python",
"repo": "ML4HPC/predrnn-pp",
"path": "/train_dev.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tohaker/AdventOfCode2019 path: /advent_of_code/day6/test_day6.py
from day6 import part_one, part_two
class TestDay6:
def test_part_one(self):
input = ['COM)B', 'B)C', 'C)D', 'D)E', 'E)F', 'B)G',
'G)H', 'D)I', 'E)J', 'J)K', 'K)L']
assert part_one(input) == 42... | code_fim | easy | {
"lang": "python",
"repo": "Tohaker/AdventOfCode2019",
"path": "/advent_of_code/day6/test_day6.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> input = ['COM)B', 'B)C', 'C)D', 'D)E', 'E)F', 'B)G',
'G)H', 'D)I', 'E)J', 'J)K', 'K)L', 'K)YOU', 'I)SAN']
assert part_two(input) == 4<|fim_prefix|># repo: Tohaker/AdventOfCode2019 path: /advent_of_code/day6/test_day6.py
from day6 import part_one, part_two
class TestDay6... | code_fim | easy | {
"lang": "python",
"repo": "Tohaker/AdventOfCode2019",
"path": "/advent_of_code/day6/test_day6.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def process(self):
if enable_dashboard:
self.camera_saturation = int(SmartDashboard.GetNumber(camera_saturation_title)
self.angle_to_robot = int(SmartDashboard.GetNumber(angle_to_robot_title)
self.camera_offset_postion = int(SmartDashboard.GetNumber(camera_offset_position_title)... | code_fim | hard | {
"lang": "python",
"repo": "team3238/VisionProcessing",
"path": "/image_processor_2.0.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #comment above line and uncomment next line to ignore hue channel til we sort out red light hue matching around zero.
#self.combined = bitwise_and(self.s_clipped, self.v_clipped)
self.combined = morphologyEx(src=self.combined, op=MORPH_CLOSE, kernel=self.kernel, iterations=self.... | code_fim | hard | {
"lang": "python",
"repo": "team3238/VisionProcessing",
"path": "/image_processor_2.0.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: team3238/VisionProcessing path: /image_processor_2.0.py
80*window_scale))
from cv2 import *
import numpy as np
import sys
import math
import commands
if enable_dashboard:
from pynetworktables import *
if enable_dashboard:
SmartDashboard.init()
#pretend the robot is on the network reporting... | code_fim | hard | {
"lang": "python",
"repo": "team3238/VisionProcessing",
"path": "/image_processor_2.0.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> a=0
for element in b_set_about:
element_count=0
for movie in Movie_Details.objects.all():
#if b3 in q.genre.split(','):
if movie.about:
movie_genre11=movie.about.split(',')
if element in movie_genre11:
element_co... | code_fim | hard | {
"lang": "python",
"repo": "vineet-sejwal/CAMO",
"path": "/MORE_Rating_Prediction.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> element_count=0
for movie in Movie_Details.objects.all():
#if b3 in q.genre.split(','):
if movie.based_on:
movie_genre11=movie.based_on.split(',')
if element in movie_genre11:
element_count=element_count+1
else:
ele... | code_fim | hard | {
"lang": "python",
"repo": "vineet-sejwal/CAMO",
"path": "/MORE_Rating_Prediction.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vineet-sejwal/CAMO path: /MORE_Rating_Prediction.py
set_genre:
element_count=0
for movie in Movie_Details.objects.all():
#if b3 in q.genre.split(','):
if movie.genre:
movie_genre11=movie.genre.split(',')
if element in movie_genre11:
... | code_fim | hard | {
"lang": "python",
"repo": "vineet-sejwal/CAMO",
"path": "/MORE_Rating_Prediction.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhangfang615/Tuberculosis path: /simulation/cluster.py
from __future__ import division
from random import shuffle
import random
import pandas
def get_cluster_truth(clusters_truth_file):
cluster_truth = {}
line = clusters_truth_file.readline().strip()
i = 0
while line:
... | code_fim | hard | {
"lang": "python",
"repo": "zhangfang615/Tuberculosis",
"path": "/simulation/cluster.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def claculate_TPTN(cluster_numbers):
TP = 0
TN = 0
FP = 0
total = 0
for i in range(len(cluster_numbers)):
total_local = 0
for cluster in cluster_numbers[i].keys():
total += cluster_numbers[i][cluster]
total_local += cluster_numbers[i][cl... | code_fim | hard | {
"lang": "python",
"repo": "zhangfang615/Tuberculosis",
"path": "/simulation/cluster.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> TP, TN, FP_TP, total = claculate_TPTN(cluster_numbers)
TN /= 2
FN = combination(total) - FP_TP - TN
# print "TP:" + str(TP)
# print "TN:" + str(TN)
# print "FP_TP:" + str(FP_TP)
# print "FN:" + str(FN)
# print total
# RI = (TP+TN)/combination(total)
p =... | code_fim | hard | {
"lang": "python",
"repo": "zhangfang615/Tuberculosis",
"path": "/simulation/cluster.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if crawl_type.lower() == 'favorites':
self.run_favorite_crawl(state, log_file_name)
return HttpResponse("control/log/%s" % log_file_tag)
def run_favorite_crawl(self, state, log_file_name):
args = "python %s -s %s > %s" % (FAVORITE_CRAWL_PATH, state, log_file_name)... | code_fim | hard | {
"lang": "python",
"repo": "omairshamshir/controladmin",
"path": "/admincontrol/web/controls/views/crawl.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: omairshamshir/controladmin path: /admincontrol/web/controls/views/crawl.py
import subprocess
import time
from django.shortcuts import render, HttpResponse
from django.views.generic import View
from usa import STATES
from admincontrol.script_paths import *
class CrawlView(View):
template_n... | code_fim | medium | {
"lang": "python",
"repo": "omairshamshir/controladmin",
"path": "/admincontrol/web/controls/views/crawl.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(4):
nx = x + dx[i]
ny = y + dy[i]
if 0 <= nx < n and 0 <= ny < n and not visited[nx][ny]:
visited[nx][ny] = True
if graph[nx][ny] == 1:
heapq.heappush(q, (cnt, nx, ny))
else: # 검은 방인 경우 흰 방으로 바꿔주고 cnt++
graph[nx][ny] = 0
heapq.heappush(q, (cnt+1, nx, ny))<... | code_fim | hard | {
"lang": "python",
"repo": "Jdoublee/CodingTestPractice",
"path": "/boj/최단경로/2665_미로만들기.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>while q:
cnt, x, y = heapq.heappop(q)
if x == n-1 and y == n-1: # 최종 목적지 도달 시 cnt 출력 및 종료
print(cnt)
break
for i in range(4):
nx = x + dx[i]
ny = y + dy[i]
if 0 <= nx < n and 0 <= ny < n and not visited[nx][ny]:
visited[nx][ny] = True
if graph[nx][ny] == 1:
heapq.heappush... | code_fim | hard | {
"lang": "python",
"repo": "Jdoublee/CodingTestPractice",
"path": "/boj/최단경로/2665_미로만들기.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jdoublee/CodingTestPractice path: /boj/최단경로/2665_미로만들기.py
import heapq
import sys
input = sys.stdin.readline
dx = [-1, 0, 0, 1]
dy = [0, -1, 1, 0]
<|fim_suffix|>while q:
cnt, x, y = heapq.heappop(q)
if x == n-1 and y == n-1: # 최종 목적지 도달 시 cnt 출력 및 종료
print(cnt)
break
for i in range(4... | code_fim | hard | {
"lang": "python",
"repo": "Jdoublee/CodingTestPractice",
"path": "/boj/최단경로/2665_미로만들기.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Test for non existent region
self.assertFalse(
aws_s3_upload(
csv_file,
self.region_name,
self.aws_access_key_id,
self.aws_secret_access_key,
"nonexistentbucketname",
)
)
... | code_fim | hard | {
"lang": "python",
"repo": "vandanakiran2211/SteelEyeAssignment",
"path": "/steel_eye_unittest.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Test for correct data
self.assertEqual(create_csv(xml_file, self.csvfile), csv_file)
# Test for incorrect input xml file
self.assertEqual(create_csv("somerandomfile", self.csvfile), None)
# Test for incorrect path to write csv to
self.assertEqual(create_... | code_fim | hard | {
"lang": "python",
"repo": "vandanakiran2211/SteelEyeAssignment",
"path": "/steel_eye_unittest.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vandanakiran2211/SteelEyeAssignment path: /steel_eye_unittest.py
# -*- coding: utf-8 -*-
"""
@author: Abhilash Raj
Unit Testing module for Steel Eye Assigment
"""
import unittest
from controller import load_config
from helper_functions import *
import os
class TestSteelEye(unittest.TestCase):... | code_fim | hard | {
"lang": "python",
"repo": "vandanakiran2211/SteelEyeAssignment",
"path": "/steel_eye_unittest.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_annotated_with_overridden_methods():
@dataclass
class DataClass(DataClassDictMixin):
foo: Annotated[date, "foo"]
bar: Annotated[date, "bar"]
baz: Annotated[date, "baz"]
class Config(BaseConfig):
serialization_strategy = {
Annota... | code_fim | hard | {
"lang": "python",
"repo": "Fatal1ty/mashumaro",
"path": "/tests/test_annotated.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Fatal1ty/mashumaro path: /tests/test_annotated.py
from dataclasses import dataclass
from datetime import date, datetime
from typing_extensions import Annotated
from mashumaro import DataClassDictMixin
from mashumaro.config import BaseConfig
def test_annotated():
@dataclass
class DataC... | code_fim | hard | {
"lang": "python",
"repo": "Fatal1ty/mashumaro",
"path": "/tests/test_annotated.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: janphilippelavoie/genetics path: /src/main/python/genetics/chromosome_factory.py
__author__ = 'ejanlav'
from abc import ABCMeta, abstractmethod
class ChromosomeFactory:
__metaclass__ = ABCMeta
<|fim_suffix|> pass
@abstractmethod
def create_chromosome(self, bits):
pa... | code_fim | medium | {
"lang": "python",
"repo": "janphilippelavoie/genetics",
"path": "/src/main/python/genetics/chromosome_factory.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> __metaclass__ = ABCMeta
@abstractmethod
def create_random_chromosome(self):
pass
@abstractmethod
def create_chromosome(self, bits):
pass<|fim_prefix|># repo: janphilippelavoie/genetics path: /src/main/python/genetics/chromosome_factory.py
__author__ = 'ejanlav'
from ... | code_fim | easy | {
"lang": "python",
"repo": "janphilippelavoie/genetics",
"path": "/src/main/python/genetics/chromosome_factory.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> @abstractmethod
def create_chromosome(self, bits):
pass<|fim_prefix|># repo: janphilippelavoie/genetics path: /src/main/python/genetics/chromosome_factory.py
__author__ = 'ejanlav'
from abc import ABCMeta, abstractmethod
class ChromosomeFactory:
__metaclass__ = ABCMeta
<|fim_middle... | code_fim | medium | {
"lang": "python",
"repo": "janphilippelavoie/genetics",
"path": "/src/main/python/genetics/chromosome_factory.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: monikaprajapt/loop path: /to do app.py
task=[]
status=[]
user=int(input("enter the how many task : "))
i=0
while i<user:
t=input("enter the task : ")
task.append(t)
print(task)
s=input("enter the status : ")
status.append(s)
print(status)
i=i+1
c=0
p=len(task)
p=len(st... | code_fim | hard | {
"lang": "python",
"repo": "monikaprajapt/loop",
"path": "/to do app.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>2)
c=0
p=len(task)
p=len(status)
while c<p:
print(task[c],"=",status[c])
c=c+1
user1=input("what you want to do ? ")
if user1=="remove":
task3=input("enter the task : ")
status4=input("enter the status : ")
task.remove(task3)
status.remove(status4)
c=0
p=len(task)
p=len(status)
whi... | code_fim | hard | {
"lang": "python",
"repo": "monikaprajapt/loop",
"path": "/to do app.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for i in range(M):
money = heapq.heappop(A)
money *= -1
money //= 2
money *= -1
heapq.heappush(A, money)
print(sum(A)*-1)<|fim_prefix|># repo: Aasthaengg/IBMdataset path: /Python_codes/p02912/s983790374.py
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import d... | code_fim | hard | {
"lang": "python",
"repo": "Aasthaengg/IBMdataset",
"path": "/Python_codes/p02912/s983790374.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return int(sys.stdin.readline())
def S():
return sys.stdin.readline()[:-1]
def C(line):
return [sys.stdin.readline() for _ in range(line)]
N, M = zz()
A = zz()
A = [-a for a in A]
heapq.heapify(A)
for i in range(M):
money = heapq.heappop(A)
money *= -1
money //= 2
money ... | code_fim | medium | {
"lang": "python",
"repo": "Aasthaengg/IBMdataset",
"path": "/Python_codes/p02912/s983790374.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aasthaengg/IBMdataset path: /Python_codes/p02912/s983790374.py
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setr... | code_fim | medium | {
"lang": "python",
"repo": "Aasthaengg/IBMdataset",
"path": "/Python_codes/p02912/s983790374.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ateReporter, name="create-reporter"),
path('', HomeReporter.as_view(), name="home-reporter"),
]<|fim_prefix|># repo: wcreativo/docxTPL path: /mixDjangoChallenge/docxtpl_Reporter/urls.py
from django.urls import path
from .views import *<|fim_middle|>
urlpatterns = [
path('create/reporter/', Cre | code_fim | easy | {
"lang": "python",
"repo": "wcreativo/docxTPL",
"path": "/mixDjangoChallenge/docxtpl_Reporter/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wcreativo/docxTPL path: /mixDjangoChallenge/docxtpl_Reporter/urls.py
from django.urls import path
from .views import *<|fim_suffix|>, HomeReporter.as_view(), name="home-reporter"),
]<|fim_middle|>
urlpatterns = [
path('create/reporter/', CreateReporter, name="create-reporter"),
path('' | code_fim | medium | {
"lang": "python",
"repo": "wcreativo/docxTPL",
"path": "/mixDjangoChallenge/docxtpl_Reporter/urls.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>, HomeReporter.as_view(), name="home-reporter"),
]<|fim_prefix|># repo: wcreativo/docxTPL path: /mixDjangoChallenge/docxtpl_Reporter/urls.py
from django.urls import path
from .views import *
urlpatterns = [
path('create/reporter/', Cre<|fim_middle|>ateReporter, name="create-reporter"),
path('' | code_fim | easy | {
"lang": "python",
"repo": "wcreativo/docxTPL",
"path": "/mixDjangoChallenge/docxtpl_Reporter/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
return frame
def main():
#Cascade of classifers that detect faces based on Haar features
face_cascade = face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
#Trained CNN model
model = ks.models.load_model('CNN_lowest')
#Capture ... | code_fim | hard | {
"lang": "python",
"repo": "DankaiBankai/emotion-detection",
"path": "/face_detect.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Capture video from webcam
vidstream = cv2.VideoCapture('http://10.0.0.142:4747/video') #cv2.VideoCapture(0, cv2.CAP_DSHOW)
while True:
#Get frame -> to gray scale -> detect faces
_, frame = vidstream.read()
gray_scale = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
... | code_fim | hard | {
"lang": "python",
"repo": "DankaiBankai/emotion-detection",
"path": "/face_detect.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DankaiBankai/emotion-detection path: /face_detect.py
import cv2
import tensorflow as tf
import keras as ks
import numpy as np
#List of emotions
emotions = ('angry', 'disgust', 'fear', 'happy', 'sad', 'surprise', 'neutral')
#Detection loop
def detect(gray_scale, frame, face_cascade, model):
... | code_fim | hard | {
"lang": "python",
"repo": "DankaiBankai/emotion-detection",
"path": "/face_detect.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>str2 = '135 7766 8899 , 湖南号码' # 多个空格
result_04 = re.sub('(\d+)\s+(\d+) (\d+)',r'\1\2\3',str2) # r 原字符集,不会被转码
print(result_04)
result_05 = re.sub('\s,.*$','',str2) # 135 7766 8899
print(result_05)<|fim_prefix|># repo: kcbklb/Line_API_TEST_FRAME path: /samples/re_01/07_sub.py
# re.sub函数
# 用于替换字符串中的匹配项
#... | code_fim | hard | {
"lang": "python",
"repo": "kcbklb/Line_API_TEST_FRAME",
"path": "/samples/re_01/07_sub.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kcbklb/Line_API_TEST_FRAME path: /samples/re_01/07_sub.py
# re.sub函数
# 用于替换字符串中的匹配项
# re.sub(pattern,repl,string,count=0,flags=0)
# pattern 正则中的模式字符串
# repl 替换的字符串,也可为一个函数
# string 要被查找替换的原始字符串
# count 模式匹配后替换的最大次数,默认0表示替换所有的匹配
import re
# 13577668899 , 湖南号码
str1 = '135 7766 8899 , 湖南号码'
result_... | code_fim | hard | {
"lang": "python",
"repo": "kcbklb/Line_API_TEST_FRAME",
"path": "/samples/re_01/07_sub.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ResolveWang/algorithm_qa path: /arrandmatrix/牛牛与妞妞.py
"""
问题描述: 牛牛与妞妞闲来无聊,便拿出扑克牌来进行游戏。游戏的规则很简单,两个人随机
抽取四张牌,四张牌的数字和最大的取胜(该扑克牌总张数为52张,没有大小王,A=1,J=11,
Q=12,K=13,每种数字有四张牌),现在两人已经分别亮出了自己的前三张牌,牛牛想要知
道自己要赢得游戏的概率有多大。
输入包含两行,第一行输入三个整数a1,b1,c1(1≤a1,b1,c1≤13),表示牛牛亮出的扑克牌。
第二行输入三个整数a2,b2,c2(1≤a2,b2,c2≤13),表示... | code_fim | hard | {
"lang": "python",
"repo": "ResolveWang/algorithm_qa",
"path": "/arrandmatrix/牛牛与妞妞.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_properties(self, a1, a2, a3, b1, b2, b3):
a = [0 for _ in range(60)]
vis = [0 for _ in range(15)]
vis[a1] += 1
vis[a2] += 1
vis[a3] += 1
vis[b1] += 1
vis[b2] += 1
vis[b3] += 1
sum1 = a1 + a2 + a3
sum2 = b1 + b2 + b... | code_fim | medium | {
"lang": "python",
"repo": "ResolveWang/algorithm_qa",
"path": "/arrandmatrix/牛牛与妞妞.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# ben wins
ben_score += 1
else:
# tie
pass
if abigal_score > ben_score:
return "Abigail"
elif abigal_score == ben_score:
return "Tie"
else:
return "Benson"<|fim_prefix|># repo: BeatMil/programming_excersice path:... | code_fim | hard | {
"lang": "python",
"repo": "BeatMil/programming_excersice",
"path": "/edabit/rock_paper_scissor.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BeatMil/programming_excersice path: /edabit/rock_paper_scissor.py
def calculate_score(games):
abigal_score = 0
ben_score = 0
for game in games:
if game[0] == "R" and game[1] == "P":
# ben wins
ben_score += 1
elif game[0] == "P" and game[1] == "... | code_fim | hard | {
"lang": "python",
"repo": "BeatMil/programming_excersice",
"path": "/edabit/rock_paper_scissor.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: globality-corp/microcosm-elasticsearch path: /microcosm_elasticsearch/main.py
"""
CLI entry point hook.
"""
from argparse import ArgumentParser
from json import loads
def createall_main(graph):
<|fim_suffix|>def query_main(graph, default_index):
"""
Run a query.
"""
parser = A... | code_fim | hard | {
"lang": "python",
"repo": "globality-corp/microcosm-elasticsearch",
"path": "/microcosm_elasticsearch/main.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
parser = ArgumentParser()
parser.add_argument("-i", "--index", default=default_index)
parser.add_argument("-q", "--query", default='{"match_all": {}}')
parser.add_argument("-f", "--flat", action="store_true")
args = parser.parse_args()
try:
query = loads(args.query... | code_fim | medium | {
"lang": "python",
"repo": "globality-corp/microcosm-elasticsearch",
"path": "/microcosm_elasticsearch/main.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: miky-roze/Python-exercises path: /exercise_9.py
# Function checks if given number is palindromic in both binary and decimal systems
<|fim_suffix|> binNumber = bin(number)
if str(number) == str(number)[::-1] and binNumber[2:] == binNumber[-1: 1: -1]:
return True
else:
... | code_fim | easy | {
"lang": "python",
"repo": "miky-roze/Python-exercises",
"path": "/exercise_9.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if str(number) == str(number)[::-1] and binNumber[2:] == binNumber[-1: 1: -1]:
return True
else:
return False
# is_palindrome(7)<|fim_prefix|># repo: miky-roze/Python-exercises path: /exercise_9.py
# Function checks if given number is palindromic in both binary and decimal syste... | code_fim | easy | {
"lang": "python",
"repo": "miky-roze/Python-exercises",
"path": "/exercise_9.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> j = 0
for k in range(0, len(R) - 1):
j += 1
# plot every <show_every> steps
if j%show_every == 0:
if L[k] >= core_limit: # outside core
if F_C[k] > 0.0: # plot convection outside core
circle_red = plt.Circle((0, 0), ... | code_fim | hard | {
"lang": "python",
"repo": "MrTorstein/AST3310",
"path": "/Python programmer/cross_section.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MrTorstein/AST3310 path: /Python programmer/cross_section.py
import numpy as np
import matplotlib.pyplot as plt
def cross_section(R, L, F_C, show_every = 20, nr = 10, lagre = "N", fs = 10):
"""
plot cross section of star
:param R: radius, array
:param L: luminosity, array
:pa... | code_fim | hard | {
"lang": "python",
"repo": "MrTorstein/AST3310",
"path": "/Python programmer/cross_section.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> core_limit = 0.995 * L_sun
j = 0
for k in range(0, len(R) - 1):
j += 1
# plot every <show_every> steps
if j%show_every == 0:
if L[k] >= core_limit: # outside core
if F_C[k] > 0.0: # plot convection outside core
... | code_fim | hard | {
"lang": "python",
"repo": "MrTorstein/AST3310",
"path": "/Python programmer/cross_section.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def setOp(dataset):
#bad set
#badfiles = ['bad_video.log','act100.txt','bdnet.txt']
badfiles = ['bad_video.log','act.txt','k400.txt','bdnet.txt']
badset = set()
for badfile in badfiles:
if os.path.exists(badfile) == True:
tmpset = readTXTSet(badfile)
ba... | code_fim | hard | {
"lang": "python",
"repo": "bdus/DatasetDownload",
"path": "/dataDownload/dataact/du_worker.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bdus/DatasetDownload path: /dataDownload/dataact/du_worker.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import argparse
import time
import threading
from bypy import ByPy, const
import youtube_dl
from downlib.JsonLoader import readJsonSet
fr... | code_fim | hard | {
"lang": "python",
"repo": "bdus/DatasetDownload",
"path": "/dataDownload/dataact/du_worker.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _cloud_exist(self,youtube_id):
lfpath = os.path.join(self.LDlDir,''.join([youtube_id,'.',self.ext]))
rfpath = os.path.join(self.RDir,''.join([youtube_id,'.',self.ext]) )
assert os.path.exists(fpath)
try:
ans = self.bp.meta(rfpath)
if ... | code_fim | hard | {
"lang": "python",
"repo": "bdus/DatasetDownload",
"path": "/dataDownload/dataact/du_worker.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rrlins/python3-exercicios path: /python_exercicios/ex050.py
# Desafio 050 - Desenvolva um programa que leia seis números inteiros e mostre
# a <|fim_suffix|>o.
s = 0
for c in range(0,6):
n = int(input('Digite o {} número: '.format(c+1)))
if n % 2 == 0:
s += n
els... | code_fim | medium | {
"lang": "python",
"repo": "rrlins/python3-exercicios",
"path": "/python_exercicios/ex050.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> == 0:
s += n
else:
continue
print('A soma dos números pares é: {}'.format(s))<|fim_prefix|># repo: rrlins/python3-exercicios path: /python_exercicios/ex050.py
# Desafio 050 - Desenvolva um programa que leia seis números inteiros e mostre
# a <|fim_middle|>soma apenas da... | code_fim | medium | {
"lang": "python",
"repo": "rrlins/python3-exercicios",
"path": "/python_exercicios/ex050.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># print "run : --- Write scores to file"
# file_name = "evolution.json"
# Tools.WriteEvolutionToJSON(evolution,points,fitness,file_name)
# print "run : --- Write genotype to file"
# file_name = "genotype.json"
# Tools.WriteGenotypeToJSON(fittest[0],file_name,coding=coding_used)
# print "run : --- Wri... | code_fim | hard | {
"lang": "python",
"repo": "The-Victoria-Initiative/copernicium",
"path": "/code/04/solveLinesProblem.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: The-Victoria-Initiative/copernicium path: /code/04/solveLinesProblem.py
###################
print "run : --- Match a pattern with a genetic algorithm"
###################
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-W", "--width", help="width", ... | code_fim | hard | {
"lang": "python",
"repo": "The-Victoria-Initiative/copernicium",
"path": "/code/04/solveLinesProblem.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>азрешен.')
else:
print('Доступ запрещен.')<|fim_prefix|># repo: Garric81/Python path: /old_files/age2.py
age = int(input('Сколько вам лет?: '))
grade = int(input('В каком классе вы учитесь?: '))
if<|fim_middle|> age >= 12 and grade >= 7:
print('Доступ р | code_fim | easy | {
"lang": "python",
"repo": "Garric81/Python",
"path": "/old_files/age2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Garric81/Python path: /old_files/age2.py
age = int(input('Сколько вам лет?: '))
grade =<|fim_suffix|>азрешен.')
else:
print('Доступ запрещен.')<|fim_middle|> int(input('В каком классе вы учитесь?: '))
if age >= 12 and grade >= 7:
print('Доступ р | code_fim | medium | {
"lang": "python",
"repo": "Garric81/Python",
"path": "/old_files/age2.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_element(id):
element = None
try:
element = WebDriverWait(driver, 10, ignored_exceptions=ignored_exceptions).until(
expected_conditions.presence_of_element_located((By.ID, id))
)
except:
pass
return element if element else None
driver.get("http:... | code_fim | hard | {
"lang": "python",
"repo": "avholloway/100DaysOfCode",
"path": "/day049/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_element(id):
element = None
try:
element = WebDriverWait(driver, 10, ignored_exceptions=ignored_exceptions).until(
expected_conditions.presence_of_element_located((By.ID, id))
)
except:
pass
return element if element else None
driver.get("http... | code_fim | hard | {
"lang": "python",
"repo": "avholloway/100DaysOfCode",
"path": "/day049/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: avholloway/100DaysOfCode path: /day049/main.py
from time import sleep
from selenium import webdriver
from selenium.common.exceptions import (NoSuchElementException,
StaleElementReferenceException)
from selenium.webdriver.common.by import By
from selenium.w... | code_fim | hard | {
"lang": "python",
"repo": "avholloway/100DaysOfCode",
"path": "/day049/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BIDMAL/codewarsish path: /LeetCode/Python/1-TwoSum.py
from typing import List
"""
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same... | code_fim | hard | {
"lang": "python",
"repo": "BIDMAL/codewarsish",
"path": "/LeetCode/Python/1-TwoSum.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
# two pointers
begin, end = 0, len(nums) - 1
idxd_nums = [(idx, num) for idx, num in enumerate(nums)]
idxd_nums.sort(key=lambda x: x[1])
while begin < end:
curr = idxd_nums[... | code_fim | medium | {
"lang": "python",
"repo": "BIDMAL/codewarsish",
"path": "/LeetCode/Python/1-TwoSum.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> test(
[2, 7, 11, 15],
9,
expected=[0, 1]
)
test(
[3, 2, 4],
6,
expected=[1, 2]
)
test(
[3, 3],
6,
expected=[0, 1]
)<|fim_prefix|># repo: BIDMAL/codewarsish path: /LeetCode/Python/1-TwoSum.py
from typing impo... | code_fim | hard | {
"lang": "python",
"repo": "BIDMAL/codewarsish",
"path": "/LeetCode/Python/1-TwoSum.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>) == 0 :
continue
client.send(msg.encode())
date = client.recv(1024)
print('来自服务器:',date.decode())
client.close()<|fim_prefix|># repo: ZhangChengL/s14 path: /day8/socket_client.py
import socket
client = socket.socket()
client.connect(('localhost<|fim_middle|>',6969))
while True:
... | code_fim | medium | {
"lang": "python",
"repo": "ZhangChengL/s14",
"path": "/day8/socket_client.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>client.recv(1024)
print('来自服务器:',date.decode())
client.close()<|fim_prefix|># repo: ZhangChengL/s14 path: /day8/socket_client.py
import socket
client = socket.socket()
client.connect(('localhost<|fim_middle|>',6969))
while True:
msg = input('>>:').strip()
if len(msg) == 0 :
continu... | code_fim | medium | {
"lang": "python",
"repo": "ZhangChengL/s14",
"path": "/day8/socket_client.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ZhangChengL/s14 path: /day8/socket_client.py
import socket
client = socket.socket()
client.connect(('localhost<|fim_suffix|>client.recv(1024)
print('来自服务器:',date.decode())
client.close()<|fim_middle|>',6969))
while True:
msg = input('>>:').strip()
if len(msg) == 0 :
continu... | code_fim | medium | {
"lang": "python",
"repo": "ZhangChengL/s14",
"path": "/day8/socket_client.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='customer',
name='id',
field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='order',
nam... | code_fim | hard | {
"lang": "python",
"repo": "ArifChaudhary/Django-CRM-project",
"path": "/salestracker/mainapp/migrations/0002_auto_20210713_2226.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ArifChaudhary/Django-CRM-project path: /salestracker/mainapp/migrations/0002_auto_20210713_2226.py
# Generated by Django 3.2.5 on 2021-07-13 16:56
from django.db import migrations, models
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
migrations.AlterField(
... | code_fim | hard | {
"lang": "python",
"repo": "ArifChaudhary/Django-CRM-project",
"path": "/salestracker/mainapp/migrations/0002_auto_20210713_2226.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Solution(object):
def middleNode(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
# 快慢指针,快指针每次走2步,慢指针每次走1步
if head is None and head.next is None:
return head
slow = head
fast = head
while fast and fast... | code_fim | medium | {
"lang": "python",
"repo": "houhailun/leetcode",
"path": "/链表/leetcode876_链表的中间结点.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: houhailun/leetcode path: /链表/leetcode876_链表的中间结点.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Time: 2019/10/15 11:14
# Author: Hou hailun
class ListNode(object):
<|fim_suffix|> self.val = x
self.next = None
class Solution(object):
def middleNode(self, head):
"""... | code_fim | medium | {
"lang": "python",
"repo": "houhailun/leetcode",
"path": "/链表/leetcode876_链表的中间结点.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ahnt-moe-heinn/SandBox path: /oddName.py
"""Import the name and print all characters"""
name = input("Enter your name")
<|fim_suffix|>while len(name) <= 0:
print("Name is blank. Enter again")
name = input("Enter your name")
#Print odd character in the name
print(name[1:len(name):2])
pr... | code_fim | easy | {
"lang": "python",
"repo": "ahnt-moe-heinn/SandBox",
"path": "/oddName.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ahnt-moe-heinn/SandBox path: /oddName.py
"""Import the name and print all characters"""
<|fim_suffix|>while len(name) <= 0:
print("Name is blank. Enter again")
name = input("Enter your name")
#Print odd character in the name
print(name[1:len(name):2])
print(name[::2])
#Print odd charac... | code_fim | medium | {
"lang": "python",
"repo": "ahnt-moe-heinn/SandBox",
"path": "/oddName.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#Print odd character in the name
for i in range(0, len(name), 2):
print(name[i])<|fim_prefix|># repo: ahnt-moe-heinn/SandBox path: /oddName.py
"""Import the name and print all characters"""
name = input("Enter your name")
"""Check the name is not blank"""
while len(name) <= 0:
print("Name is b... | code_fim | medium | {
"lang": "python",
"repo": "ahnt-moe-heinn/SandBox",
"path": "/oddName.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: davidvilla/sillygames path: /terminal/old_pycon.py
#!/usr/bin/env python
#
import sys
import copy
from pycondriver import TxtSurface
from pycondriver import Terminal
_ESC = chr(0x1B)
_SPC = 32
# ATTRIBS
_RESET = 0
_BRIGHT = 1
_DIM = 2
_UNDERSCORE = 3
_BLINK = 5
_REVERSE ... | code_fim | hard | {
"lang": "python",
"repo": "davidvilla/sillygames",
"path": "/terminal/old_pycon.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def close(self, with_clear = False):
self.__set_attributes(449)
if with_clear:
self.__cls()
def __getConsoleSize(self):
def ioctl_GWINSZ(fd):
try:
import fcntl, termios, struct, os
cr = struct.unpack('hh',
... | code_fim | hard | {
"lang": "python",
"repo": "davidvilla/sillygames",
"path": "/terminal/old_pycon.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> size = self.__getConsoleSize()
if (size != self.size):
self.resize(size)
self.frame()
def frame(self):
attribute = -1
self.__setCursorPos((0, 0))
for ind in range(len(self.srf)):
char = self.srf[ind]
new_attribute = (... | code_fim | hard | {
"lang": "python",
"repo": "davidvilla/sillygames",
"path": "/terminal/old_pycon.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Rshahatit/wikiracer path: /assignment/find_path/scripts/sync_sol/graph.py
from .get_links import get_all_links
from queue import PriorityQueue
class Graph():
def __init__(self, source, destination):
self.graph = {}
self.start = source
self.end = destination
se... | code_fim | hard | {
"lang": "python",
"repo": "Rshahatit/wikiracer",
"path": "/assignment/find_path/scripts/sync_sol/graph.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def make_path(self, title):
try:
t = title
previous = self.graph[t]["previous"]
path = [t]
while(previous != '0'):
path.append(previous)
print(path)
t = previous
previous = self.gra... | code_fim | hard | {
"lang": "python",
"repo": "Rshahatit/wikiracer",
"path": "/assignment/find_path/scripts/sync_sol/graph.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = np.array(gtTrace)
time = np.array(gtTime)
hr = np.array(gtHR)
return data,hr
MIN_FRAME = 50
def read_video(filename,data):
cap = cv.VideoCapture(filename)
success = 1
graph_height = 200
graph_width = 0
count = 0
value = []
fourcc = cv.VideoW... | code_fim | hard | {
"lang": "python",
"repo": "GemZq/RealTime-HearRate-detection-from-camera",
"path": "/UBFC2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
class Super:
superman="LHM"
def __init__(self):
self.data1="Katiana"
self.data2="Lorena"
#class Sub(Super,ListInstance):
#class Sub(Super,ListInherited):
class Sub(Super,ListTree):
def __init__(self):
Super.__init__(self)
self.data3="Salinas"
self.d... | code_fim | hard | {
"lang": "python",
"repo": "lherrada/python",
"path": "/misc/classes/chapter30/lister.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lherrada/python path: /misc/classes/chapter30/lister.py
import types
class ListTree:
def __str__(self):
self.__visited = {}
return '<Instance of {0},address {1}:\n{2}{3}>'.format(
self.__class__.__name__,
id(self),
self.__attrnames(self,0),
self.__listclass(self.__class__,4... | code_fim | hard | {
"lang": "python",
"repo": "lherrada/python",
"path": "/misc/classes/chapter30/lister.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aaronswei/BEVNet path: /src/tasks/baselines/iv2bev.py
from pytorch_helper.settings.options import TaskMode
from pytorch_helper.settings.spaces import Spaces
from pytorch_helper.task import Batch
from tasks.bevnet import BEVNetTask
@Spaces.register(Spaces.NAME.TASK, 'IV2BEVTask')
class IV2BEVTas... | code_fim | hard | {
"lang": "python",
"repo": "Aaronswei/BEVNet",
"path": "/src/tasks/baselines/iv2bev.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.pose_oracle:
h_cam = batch.gt['camera_height']
p_cam = batch.gt['camera_angle']
else:
h_cam = pred['camera_height']
p_cam = pred['camera_angle']
if self.cc_oracle:
input_map = batch.gt[self.iv_map] * self.map_scal... | code_fim | hard | {
"lang": "python",
"repo": "Aaronswei/BEVNet",
"path": "/src/tasks/baselines/iv2bev.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self, batch: Batch, backward=False
):
image = batch.gt['image']
fu, fv = batch.gt['camera_fu'], batch.gt['camera_fv']
pred = self.model.forward(image, fu, fv)
if self.pose_oracle:
h_cam = batch.gt['camera_height']
p_cam = batch.gt['camer... | code_fim | hard | {
"lang": "python",
"repo": "Aaronswei/BEVNet",
"path": "/src/tasks/baselines/iv2bev.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> driver = webdriver.Firefox()
driver.get("http://www.tpshop.com/Home/user/login.html")
return driver<|fim_prefix|># repo: chenmingxin/PO_01 path: /base/get_driver.py
from appium import webdriver
from selenium import webdriver
<|fim_middle|>def get_driver():
| code_fim | easy | {
"lang": "python",
"repo": "chenmingxin/PO_01",
"path": "/base/get_driver.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chenmingxin/PO_01 path: /base/get_driver.py
from appium import webdriver
from selenium import webdriver
<|fim_suffix|> driver = webdriver.Firefox()
driver.get("http://www.tpshop.com/Home/user/login.html")
return driver<|fim_middle|>def get_driver():
| code_fim | easy | {
"lang": "python",
"repo": "chenmingxin/PO_01",
"path": "/base/get_driver.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cintiazago/surebets-finder path: /surebets_finder/raw_content/aplication/importer.py
from logging import Logger
from typing import List
from bson.objectid import ObjectId
from kink import inject
from surebets_finder.raw_content.aplication.clients.betclick_client import BetClickClient
from sureb... | code_fim | medium | {
"lang": "python",
"repo": "cintiazago/surebets-finder",
"path": "/surebets_finder/raw_content/aplication/importer.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._logger.info("Importer has started!")
for provider in Provider:
for category in Category:
urls = UrlFactory.create(provider, category).get_urls()
client = self._get_client(provider, urls)
self._logger.info(
... | code_fim | hard | {
"lang": "python",
"repo": "cintiazago/surebets-finder",
"path": "/surebets_finder/raw_content/aplication/importer.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> client = self._get_client(provider, urls)
self._logger.info(
f"Importing data from category={category.value} and provider={provider.value} using {str(client)}"
)
content = client.get_raw_data()
raw_conte... | code_fim | hard | {
"lang": "python",
"repo": "cintiazago/surebets-finder",
"path": "/surebets_finder/raw_content/aplication/importer.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sgdecker/python-awips path: /awips/test/dafTests/testBufrMosHpc.py
##
##
from __future__ import print_function
from awips.dataaccess import DataAccessLayer as DAL
import baseBufrMosTestCase
import unittest
#
# Test DAF support for bufrmosHPC data
#
# SOFTWARE HISTORY
#
# Date ... | code_fim | medium | {
"lang": "python",
"repo": "sgdecker/python-awips",
"path": "/awips/test/dafTests/testBufrMosHpc.py",
"mode": "psm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_suffix|>class BufrMosHpcTestCase(baseBufrMosTestCase.BufrMosTestCase):
"""Test DAF support for bufrmosHPC data"""
datatype = "bufrmosHPC"
# Most tests inherited from superclass
def testGetGeometryData(self):
req = DAL.newDataRequest(self.datatype)
req.setLocationNames("KOMA")
... | code_fim | hard | {
"lang": "python",
"repo": "sgdecker/python-awips",
"path": "/awips/test/dafTests/testBufrMosHpc.py",
"mode": "spm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def state(self):
return self.get_state(celery)
Schedule = create_schedule(ScheduleABC, db.Model, persister=persister)
class ScheduleSchema(get_base_schema(Schedule, json_field='dict')):
state = fields.Method('get_state')
def get_state(self, schedule):
return ... | code_fim | hard | {
"lang": "python",
"repo": "kuc2477/anchor-backend",
"path": "/app/schedules/models.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.