text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>and one dictionary: # Import only the person1 dictionary from the module: from mymodule import person1 print(person1["age"])<|fim_prefix|># repo: VaishnaviReddyGuddeti/Python_programs path: /Python_Modules/ImportFromModule.py # You can choose to import only parts from a module, by using <|fim_middle|>t...
code_fim
medium
{ "lang": "python", "repo": "VaishnaviReddyGuddeti/Python_programs", "path": "/Python_Modules/ImportFromModule.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: biznixcn/WR path: /apps/googlemaps_localities/models.py ities.utils import get_redis_connection from common.utils.debug import writelog from rest.utils import render_as_json class GoogleMapsAddressComponent(models.Model): """ Implements a Google Maps component address object """ ...
code_fim
hard
{ "lang": "python", "repo": "biznixcn/WR", "path": "/apps/googlemaps_localities/models.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: biznixcn/WR path: /apps/googlemaps_localities/models.py o.core.exceptions import MultipleObjectsReturned from googlemaps_localities import settings as localities_settings from googlemaps_localities import strings, constants from googlemaps_localities.utils import get_redis_connection from common....
code_fim
hard
{ "lang": "python", "repo": "biznixcn/WR", "path": "/apps/googlemaps_localities/models.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> @staticmethod def stack_components(components): first = None current = None for c in components: if first is None: first = c current = first continue else: current['parent'] = c ...
code_fim
hard
{ "lang": "python", "repo": "biznixcn/WR", "path": "/apps/googlemaps_localities/models.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Juniorexz/ExerciciosPython path: /Calculobasealtura.py #Faça um programa que peça a base #e a altura de um retângulo e calcule #e mostre na tela a área e o perímetro. <|fim_suffix|>print(f'O retângulo digitado tem base {base} e altura {altura}.') print(f'A área deste retângulo é: {area}') print...
code_fim
medium
{ "lang": "python", "repo": "Juniorexz/ExerciciosPython", "path": "/Calculobasealtura.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>print(f'O retângulo digitado tem base {base} e altura {altura}.') print(f'A área deste retângulo é: {area}') print(f'O perímetro deste retângulo é: {perimetro}')<|fim_prefix|># repo: Juniorexz/ExerciciosPython path: /Calculobasealtura.py #Faça um programa que peça a base #e a altura de um retângulo e cal...
code_fim
easy
{ "lang": "python", "repo": "Juniorexz/ExerciciosPython", "path": "/Calculobasealtura.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>EB.py', 1), ('WilbRLW3.py', 1), ('MereHHB2.py', 1)]<|fim_prefix|># repo: psdh/WhatsintheVector path: /indices/extrins.py ii = [('LyelCPG2.py', 2), ('MarrFDI.py', 1), ('God<|fim_middle|>wWSL2.py', 1), ('CookGHP.py', 1), ('ChalTPW2.py', 1), ('LyelCPG.py', 2), ('DibdTRL2.py', 2), ('WadeJ
code_fim
medium
{ "lang": "python", "repo": "psdh/WhatsintheVector", "path": "/indices/extrins.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: psdh/WhatsintheVector path: /indices/extrins.py ii = [('LyelCPG2.py', 2), ('MarrFDI.py', 1), ('GodwWSL2.py', 1), ('CookGHP.py', 1), ('ChalTPW2.py', <|fim_suffix|>EB.py', 1), ('WilbRLW3.py', 1), ('MereHHB2.py', 1)]<|fim_middle|>1), ('LyelCPG.py', 2), ('DibdTRL2.py', 2), ('WadeJ
code_fim
easy
{ "lang": "python", "repo": "psdh/WhatsintheVector", "path": "/indices/extrins.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: jordanmslack/jordanslack.com path: /app/__init__.py import os from flask import Flask from dotenv import load_dotenv def create_app(): <|fim_suffix|> app.config['CSRF_SESSION_KEY'] = os.environ.get('CSRF_SESSION_KEY') app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY') from app...
code_fim
medium
{ "lang": "python", "repo": "jordanmslack/jordanslack.com", "path": "/app/__init__.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> dotenv_path = os.path.join(os.path.dirname(__file__), '..', '.env') load_dotenv(dotenv_path) app = Flask(__name__, template_folder='templates') app.config['CSRF_SESSION_KEY'] = os.environ.get('CSRF_SESSION_KEY') app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY') from app.c...
code_fim
easy
{ "lang": "python", "repo": "jordanmslack/jordanslack.com", "path": "/app/__init__.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: JeonJaewon/2019_JGP2_LISEO path: /mypage.py #-*- coding: utf-8 -*- import os import time import textManager import rule #import main #import main이라고 써놔서 main.py에서 여기로 넘어올떄 충돌생기는것 같아서 주석처리했습니다. ( by 계) def printStudentinfo(code): #학생정보출력 os.system('cls') print("=" * 18, end...
code_fim
hard
{ "lang": "python", "repo": "JeonJaewon/2019_JGP2_LISEO", "path": "/mypage.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if choice == '입력 실패': print("데이터 값을 입력해 주세요.") time.sleep(2) os.system('cls') continue elif rule.numberRule(choice)==0: #숫자입력규칙 적용, import main 주석처리해서 __import__로 즉석해서 import함 time.sleep(2) os.system('cls') ...
code_fim
hard
{ "lang": "python", "repo": "JeonJaewon/2019_JGP2_LISEO", "path": "/mypage.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: cpoenisch/cicd-voting path: /app/urls.py from django.urls import path from . import views <|fim_suffix|>urlpatterns = [ # "/app" path('', views.index, name='index'), path('<int:question_id>/', views.detail, name='detail'), path('<int:question_id>/results/', views.results, name='r...
code_fim
easy
{ "lang": "python", "repo": "cpoenisch/cicd-voting", "path": "/app/urls.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>urlpatterns = [ # "/app" path('', views.index, name='index'), path('<int:question_id>/', views.detail, name='detail'), path('<int:question_id>/results/', views.results, name='results'), path('<int:question_id>/favorite/', views.favorite, name='favorite') ]<|fim_prefix|># repo: cpoenisc...
code_fim
easy
{ "lang": "python", "repo": "cpoenisch/cicd-voting", "path": "/app/urls.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: gabriel376/exercism path: /python/raindrops/raindrops.py def raindrops(number): drops = { 3: 'Pling', 5: 'Plang', 7: 'Plong', } <|fim_suffix|> return ''.join(sound) or str(number)<|fim_middle|> sound = [drops[n] for n in drops if number % n == 0]
code_fim
easy
{ "lang": "python", "repo": "gabriel376/exercism", "path": "/python/raindrops/raindrops.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> sound = [drops[n] for n in drops if number % n == 0] return ''.join(sound) or str(number)<|fim_prefix|># repo: gabriel376/exercism path: /python/raindrops/raindrops.py def raindrops(number): <|fim_middle|> drops = { 3: 'Pling', 5: 'Plang', 7: 'Plong', }
code_fim
medium
{ "lang": "python", "repo": "gabriel376/exercism", "path": "/python/raindrops/raindrops.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: gabriel376/exercism path: /python/raindrops/raindrops.py def raindrops(number): <|fim_suffix|> return ''.join(sound) or str(number)<|fim_middle|> drops = { 3: 'Pling', 5: 'Plang', 7: 'Plong', } sound = [drops[n] for n in drops if number % n == 0]
code_fim
medium
{ "lang": "python", "repo": "gabriel376/exercism", "path": "/python/raindrops/raindrops.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>,-1,-1): for j in range(size-2,-1,-1): depmin=min(dep[i+1][j],dep[i][j+1]) dep[i][j]=max(1,depmin-list1[i][j]) print(dep[0][0])<|fim_prefix|># repo: AdamZhouSE/pythonHomework path: /Code/CodeRecords/2566/60720/282221.py size=int(input()) list1=[] for i in range(size): lis0=input()...
code_fim
medium
{ "lang": "python", "repo": "AdamZhouSE/pythonHomework", "path": "/Code/CodeRecords/2566/60720/282221.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: AdamZhouSE/pythonHomework path: /Code/CodeRecords/2566/60720/282221.py size=int(input()) list1=[] for i in range(size): lis0=input().split(',') lis0=[int(x) for x in lis0] list1.append(lis0) dep=[[0 for i in range(size)] for j in range(size)] dep[size-1][size-1]=max(1,1-list1[size-1][...
code_fim
medium
{ "lang": "python", "repo": "AdamZhouSE/pythonHomework", "path": "/Code/CodeRecords/2566/60720/282221.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Gamboua/challenge_labs path: /src/conftest.py import asyncio import datetime import pytest from aiocache import caches from django.utils import timezone from jose import jwt from model_mommy import mommy from simple_settings import settings from challenge import app as _app from challenge.appli...
code_fim
hard
{ "lang": "python", "repo": "Gamboua/challenge_labs", "path": "/src/conftest.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> @pytest.fixture def catalog_response(product_id): return { 'price': 55.9, 'image': 'http://challenge-api.luizalabs.com/b.jpg', 'brand': 'tramontina', 'id': product_id, 'title': 'Jogo de Inox para Torta Copacabana 7 Peças' }<|fim_prefix|># repo: Gamboua/chal...
code_fim
hard
{ "lang": "python", "repo": "Gamboua/challenge_labs", "path": "/src/conftest.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: flagship-open/flagship-multimodal_emotion_age_gender_recognition path: /module/preprocessing/pp_flask.py import os import tensorflow as tf os.environ["CUDA_VISIBLE_DEVICES"]= "0" config = tf.ConfigProto() config.gpu_options.allow_growth = True sess= tf.Session(config=config) from inference impo...
code_fim
hard
{ "lang": "python", "repo": "flagship-open/flagship-multimodal_emotion_age_gender_recognition", "path": "/module/preprocessing/pp_flask.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>app = Flask(__name__) graph = tf.get_default_graph() init_time = time.time() @app.route('/', methods=['POST', 'GET']) def video_preprocessing(): global graph with graph.as_default(): input_video = request.form['input_path'] num_second = request.form['num_second'] output_p...
code_fim
medium
{ "lang": "python", "repo": "flagship-open/flagship-multimodal_emotion_age_gender_recognition", "path": "/module/preprocessing/pp_flask.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: ab8266339/MLH_prime path: /review_to_vector/miscellaneous.py import re import numpy as np class Miscellaneous(object): @staticmethod def ConvertStrToBagOfWords(reg, reg_exclude, document_in_a_sentence): # find all words match regular expression document_word_list = ...
code_fim
medium
{ "lang": "python", "repo": "ab8266339/MLH_prime", "path": "/review_to_vector/miscellaneous.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> sorted_value_list = [word_dict[x] for x in sorted(word_dict)] word_array = np.array([sorted_value_list]) return word_array<|fim_prefix|># repo: ab8266339/MLH_prime path: /review_to_vector/miscellaneous.py import re import numpy as np class Miscellaneous(object): @staticm...
code_fim
hard
{ "lang": "python", "repo": "ab8266339/MLH_prime", "path": "/review_to_vector/miscellaneous.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: cceh/m-salt-api path: /server/server.py #!/usr/bin/python3 # -*- encoding: utf-8 -*- """An API for the Critical Pāli Dictionary""" import argparse import configparser import datetime import json import logging import os.path import re import flask from flask import request, current_app import ...
code_fim
hard
{ "lang": "python", "repo": "cceh/m-salt-api", "path": "/server/server.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> res = [] for row in reversed (res1.fetchall ()): res.append (row[:3]) for row in res2: res.append (row[:3]) return make_headwords_response (res, limit) def make_article (row, lang = LANG): """ row is: article_id """ return { 'arti...
code_fim
hard
{ "lang": "python", "repo": "cceh/m-salt-api", "path": "/server/server.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: bruceakerseattle/Dat1ClassProject path: /code/weather_stn_data.py # weather_stn_data.py - Used by extract_numbers.py, get_info_from_mshr.py, get_past_observations_cdo.py, get_daily_normals_cdo.py # Location of each of the following numbers in the image corresponds to a city (or weather station...
code_fim
hard
{ "lang": "python", "repo": "bruceakerseattle/Dat1ClassProject", "path": "/code/weather_stn_data.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>':'Yellowstone Lake'}, {'icao_code':'KPDX','row':513,'col':101,'stn_id_cdo':'GHCND:USW00024229','state':'OR','weather_station':'Portland International Airport'}, {'icao_code':'KPHX','row':249,'col':206,'stn_id_cdo':'GHCND:USW00023183','state':'AZ','weather_station':'Phoenix Sky Harbor International Airp...
code_fim
hard
{ "lang": "python", "repo": "bruceakerseattle/Dat1ClassProject", "path": "/code/weather_stn_data.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: liu311/PriorNetworks-OLD path: /prior_networks/dirichlet/data_processing/step_process_omniglot.py #!/usr/bin/python import argparse import os import sys import matplotlib #matplotlib.use('agg') from matplotlib import pyplot as plt from PIL import Image import numpy as np import tensorflow as t...
code_fim
hard
{ "lang": "python", "repo": "liu311/PriorNetworks-OLD", "path": "/prior_networks/dirichlet/data_processing/step_process_omniglot.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> imResize=np.reshape(imResize, (args.size*args.size)) imResize_raw = imResize.tostring() example = tf.train.Example(features=tf.train.Features(feature={ 'height': tfrecord_utils.int64_feature([args.size]), 'width': tfre...
code_fim
hard
{ "lang": "python", "repo": "liu311/PriorNetworks-OLD", "path": "/prior_networks/dirichlet/data_processing/step_process_omniglot.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: jakudapi/aoc2016 path: /day09-1.py """--- Day 9: Explosives in Cyberspace --- Wandering around a secure area, you come across a datalink port to a new part of the network. After briefly scanning it for interesting files, you find one file in particular that catches your attention. It's compressed...
code_fim
hard
{ "lang": "python", "repo": "jakudapi/aoc2016", "path": "/day09-1.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> decompressed += compressed[index:index + int(chars_repeat[0])] * int(chars_repeat[1]) index += int(chars_repeat[0]) # set index now after the substring that was repeated print(len(decompressed)) else: # end of file decompressed += compressed[index:] break end = time()...
code_fim
hard
{ "lang": "python", "repo": "jakudapi/aoc2016", "path": "/day09-1.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Sapphirine/Santander-Customer-Satisfaction path: /pca_features.py import numpy as np import pandas as pd from scipy.stats.stats import pearsonr np.random.seed(12324) from sklearn.cross_validation import StratifiedKFold from sklearn.decomposition import PCA from sklearn.preprocessing import normal...
code_fim
medium
{ "lang": "python", "repo": "Sapphirine/Santander-Customer-Satisfaction", "path": "/pca_features.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>train, test = process_base(train, test) train, test = drop_sparse(train, test) train, test = drop_duplicated(train, test) train, test = add_features(train, test, ['SumZeros']) flist = [x for x in train.columns if not x in ['ID','TARGET']] pca = PCA(n_components=2) x_train_projected = pca.fit_transform(n...
code_fim
medium
{ "lang": "python", "repo": "Sapphirine/Santander-Customer-Satisfaction", "path": "/pca_features.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>for _ in range(t): arr = list(map(int, input().split(" "))) a, b = arr[0], arr[1] if a > b: b *= 2 else: a *= 2 if a > b: result = a * a else: result = b * b print(result)<|fim_prefix|># repo: Tconan99/Codeforces path: /ac/Codeforces 1360A - Min...
code_fim
medium
{ "lang": "python", "repo": "Tconan99/Codeforces", "path": "/ac/Codeforces 1360A - Minimal Square.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Tconan99/Codeforces path: /ac/Codeforces 1360A - Minimal Square.py # https://codeforces.com/problemset/problem/1360/A import sys import os import heapq try: path = "./file/input.txt" if os.path.exists(path): sys.stdin = open(path, 'r') # sys.stdout = open(r"./file/output.txt...
code_fim
medium
{ "lang": "python", "repo": "Tconan99/Codeforces", "path": "/ac/Codeforces 1360A - Minimal Square.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> tags = Tag.objects.filter(application_id=app_id) for tag in tags: sync_by_tag(app_id, tag.name, token, count, is_show)<|fim_prefix|># repo: softformance/django-instagram-photo-api path: /django_instagram_photo_api/management/commands/sync_by_app.py from django.core...
code_fim
hard
{ "lang": "python", "repo": "softformance/django-instagram-photo-api", "path": "/django_instagram_photo_api/management/commands/sync_by_app.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def eye_open(image): landmarks = get_landmarks(image) if landmarks == "error": return image,0,0 image_with_landmarks = annotate_landmarks(image,landmarks) left_ear = left_eye(landmarks) #print(top_lip_center) right_ear = right_eye(landmarks) #print(left_ear) #print(right_ear) ...
code_fim
hard
{ "lang": "python", "repo": "dungeongod/AngelHacks2018", "path": "/eye_blink.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: dungeongod/AngelHacks2018 path: /eye_blink.py import cv2 import dlib import numpy as np from scipy.spatial import distance as dist PREDICTOR_PATH = "shape_predictor_68_face_landmarks.dat" predictor = dlib.shape_predictor(PREDICTOR_PATH) detector = dlib.get_frontal_face_detector() """ ...
code_fim
hard
{ "lang": "python", "repo": "dungeongod/AngelHacks2018", "path": "/eye_blink.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># %% part_words_set = set(part_words) print(len(part_words_set)) # %% import numpy as np # 将正常邮件与垃圾邮件的单词都整理为句子,单词间以空格相隔,CountVectorizer()的句子里,单词是以空格分隔的 train_part_texts = [' '.join(text) for text in np.concatenate((spam_train_part.values, ham_train_part.values))] # 训练集所有的单词整理成句子 train_all_texts = [' '.j...
code_fim
hard
{ "lang": "python", "repo": "zippermonkey/MachineLearning", "path": "/spam_ham/spam.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: zippermonkey/MachineLearning path: /spam_ham/spam.py # To add a new cell, type '# %%' # To add a new markdown cell, type '# %% [markdown]' # %% import pandas as pd # %% data = pd.read_csv('spam_ham_dataset.csv') data = data.iloc[:,2:] # ham/0 spam/1 # %% data.head(5) # %% import matplotlib...
code_fim
hard
{ "lang": "python", "repo": "zippermonkey/MachineLearning", "path": "/spam_ham/spam.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pass def top_3_longest(db, first_letter): pass<|fim_prefix|># repo: pierrevermeulen/data-challenges-v2 path: /01-Python/04-SQL-Advanced/03-Rank-And-Partition/query.py # pylint:disable=C0111,C0103 def movie_duration_buckets(db): <|fim_middle|> pass def longest_movies_by_director(db, first_...
code_fim
medium
{ "lang": "python", "repo": "pierrevermeulen/data-challenges-v2", "path": "/01-Python/04-SQL-Advanced/03-Rank-And-Partition/query.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: pierrevermeulen/data-challenges-v2 path: /01-Python/04-SQL-Advanced/03-Rank-And-Partition/query.py # pylint:disable=C0111,C0103 def movie_duration_buckets(db): pass <|fim_suffix|> def top_3_longest(db, first_letter): pass<|fim_middle|> def longest_movies_by_director(db, first_letter): ...
code_fim
medium
{ "lang": "python", "repo": "pierrevermeulen/data-challenges-v2", "path": "/01-Python/04-SQL-Advanced/03-Rank-And-Partition/query.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: shivampip/ItsBoring path: /app/player.py import tkinter as tk from pynput import mouse from pynput import keyboard from pynput.mouse import Button, Controller from pynput.keyboard import Key, Controller as KeyController import time import pickle root= tk.Tk() root.title("Its Boring Player") ####...
code_fim
hard
{ "lang": "python", "repo": "shivampip/ItsBoring", "path": "/app/player.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def play(data, mouse, keyc): global live for dd in data: type= dd['type'] dur= dd['dur']/ float(speedx) time.sleep(dur) if(not live): break if(type=='mouse'): x, y = dd['pos'] btn= dd['btn'] pressed= dd['pres...
code_fim
hard
{ "lang": "python", "repo": "shivampip/ItsBoring", "path": "/app/player.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: abollaert/CSMM.101.x path: /project1/src/driver.py #! /usr/bin/python2 from sys import argv from math import sqrt from Queue import Queue from Queue import PriorityQueue from time import time import resource class Statistics: def __init__(self): self.__nodes_expanded = 0 se...
code_fim
hard
{ "lang": "python", "repo": "abollaert/CSMM.101.x", "path": "/project1/src/driver.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>def search(initial_state, next_state_function, frontier_add_function, is_frontier_empty, reverse): start_time = time() visited = set() frontier = set() statistics = Statistics() frontier_add_function(initial_state) frontier.add(hash(initial_state)) goal_state = None whi...
code_fim
hard
{ "lang": "python", "repo": "abollaert/CSMM.101.x", "path": "/project1/src/driver.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> entry = self._cache.get(key) if not entry or entry.age > self.ttl: if entry: del self._cache[key] return None return entry.data def set(self, key, data): self._cache[key] = self.Entry(datetime.datetime.now().timestamp(), data) ...
code_fim
hard
{ "lang": "python", "repo": "DrJackilD/kube_weather", "path": "/server/weather_api/cache.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: DrJackilD/kube_weather path: /server/weather_api/cache.py import datetime import typing as t from dataclasses import dataclass class InMemoryCache: default_ttl = 600 @dataclass class Entry: ts: float data: dict <|fim_suffix|> def get(self, key): entry = ...
code_fim
hard
{ "lang": "python", "repo": "DrJackilD/kube_weather", "path": "/server/weather_api/cache.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self._cache[key] = self.Entry(datetime.datetime.now().timestamp(), data) def get_cache(): return InMemoryCache()<|fim_prefix|># repo: DrJackilD/kube_weather path: /server/weather_api/cache.py import datetime import typing as t from dataclasses import dataclass class InMemoryCache: def...
code_fim
medium
{ "lang": "python", "repo": "DrJackilD/kube_weather", "path": "/server/weather_api/cache.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: pulumi/pulumi-alicloud path: /sdk/python/pulumi_alicloud/eflo/outputs.py # coding=utf-8 # *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** # *** Do not edit by hand unless you're certain you know what you are doing! *** import copy import warnings import pulu...
code_fim
hard
{ "lang": "python", "repo": "pulumi/pulumi-alicloud", "path": "/sdk/python/pulumi_alicloud/eflo/outputs.py", "mode": "psm", "license": "MPL-2.0", "source": "the-stack-v2" }
<|fim_suffix|> @property @pulumi.getter(name="subnetName") def subnet_name(self) -> str: """ The Subnet name. """ return pulumi.get(self, "subnet_name") @property @pulumi.getter def type(self) -> str: """ Eflo subnet usage type, optional value: ...
code_fim
hard
{ "lang": "python", "repo": "pulumi/pulumi-alicloud", "path": "/sdk/python/pulumi_alicloud/eflo/outputs.py", "mode": "spm", "license": "MPL-2.0", "source": "the-stack-v2" }
<|fim_suffix|>print(ord('b')) B = bytes([97, 98, 99]) # Integer iterable print(B) B = 'spam'.encode() # str.encode() (or bytes()) print(B) S = B.decode() # bytes.decode() (or str()) print(S) ''' From a functional perspective, the last two of t...
code_fim
hard
{ "lang": "python", "repo": "bimri/learning-python", "path": "/chapter_37/bytes-seq-operations.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>B = 'spam'.encode() # str.encode() (or bytes()) print(B) S = B.decode() # bytes.decode() (or str()) print(S) ''' From a functional perspective, the last two of these operations are really tools for converting between str and bytes '''<|fim_prefix|># r...
code_fim
hard
{ "lang": "python", "repo": "bimri/learning-python", "path": "/chapter_37/bytes-seq-operations.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: bimri/learning-python path: /chapter_37/bytes-seq-operations.py "Sequence Operations" ''' Besides method calls, all the usual generic sequence operations from strings and lists; work as expected on both str and bytes. Including indexing, slicing, concatenation, and so on. <|fim_suffix|>B = bytes...
code_fim
hard
{ "lang": "python", "repo": "bimri/learning-python", "path": "/chapter_37/bytes-seq-operations.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: raulrm75/CubIntHom path: /alexander_whitney.py from chain_map import linear_extension from cells import Simplex, CubicalCell @linear_extension def AW(cell): <|fim_suffix|> if __name__ == '__main__': print(Simplex((0, 1, 2)).AW())<|fim_middle|> if isinstance(cell, Simplex): return...
code_fim
hard
{ "lang": "python", "repo": "raulrm75/CubIntHom", "path": "/alexander_whitney.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if isinstance(cell, Simplex): return cell.AW() elif isinstance(cell, CubicalCell): return cell.AW() else: raise NotImplementedError('Alexander-Whitney diagonal approximation is only defined' ' for simplices or cubical cells.') if __na...
code_fim
easy
{ "lang": "python", "repo": "raulrm75/CubIntHom", "path": "/alexander_whitney.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: andrthu/mek4250 path: /adjoint/outputDir/latexTables/append_tables.py import sys def append_tables(append_file, table_file): a_file = open(append_file,'a') t_file = open(table_file,'r') a_file.write('\\\\ \n') a_file.write('''\\\\ \n''') name_split = table_file[:-4].split('...
code_fim
medium
{ "lang": "python", "repo": "andrthu/mek4250", "path": "/adjoint/outputDir/latexTables/append_tables.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> t_file.close() a_file.close() def main(): try: a_file = sys.argv[1] files = sys.argv[2:] except: print 'input plz' return for f in files: append_tables(a_file,f) if __name__ == '__main__': main()<|fim_prefix|># repo: andrthu/mek42...
code_fim
hard
{ "lang": "python", "repo": "andrthu/mek4250", "path": "/adjoint/outputDir/latexTables/append_tables.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Ahmad-Ihsan/nikkei path: /insert_days.py # -*- coding: utf-8 -*- """ Created on Tue Aug 27 15:05:40 2019 @author: lenovo """ from sql.connect import DBConnection <|fim_suffix|>db = DBConnection() conn = db.connection() c = conn.cursor() #for i in range(len(morning_cat_id)): # ...
code_fim
medium
{ "lang": "python", "repo": "Ahmad-Ihsan/nikkei", "path": "/insert_days.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#for i in range(len(morning_cat_id)): # c.execute("insert into categories (category_id, category_name, version) values(?, ?, ?)", (morning_cat_id[i], morning_categories[i], 'M')) # conn.commit() #conn.close() for i in range(len(day_id)): c.execute("insert into days (day_id, day_kanji, day...
code_fim
hard
{ "lang": "python", "repo": "Ahmad-Ihsan/nikkei", "path": "/insert_days.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> import time time.sleep(3) self.callback('DONE') class ThreadHandler(BaseHandler): @asynchronous def get(self): self.printblah() Worker(self.worker_done).start() def worker_done(self, value): self.finish(value)<|fim_prefix|># repo: adampielak/ss...
code_fim
medium
{ "lang": "python", "repo": "adampielak/sslparty", "path": "/app/handlers/thread.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def run(self): import time time.sleep(3) self.callback('DONE') class ThreadHandler(BaseHandler): @asynchronous def get(self): self.printblah() Worker(self.worker_done).start() def worker_done(self, value): self.finish(value)<|fim_prefix|># r...
code_fim
medium
{ "lang": "python", "repo": "adampielak/sslparty", "path": "/app/handlers/thread.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: adampielak/sslparty path: /app/handlers/thread.py from app.handlers.base import BaseHandler from app.handlers.base import * class Worker(threading.Thread): def __init__(self, callback=None, *args, **kwargs): super(Worker, self).__init__(*args, **kwargs) self.callback = callba...
code_fim
medium
{ "lang": "python", "repo": "adampielak/sslparty", "path": "/app/handlers/thread.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: AndrewLu1992/lintcodes path: /94_binary-tree-maximum-path-sum/binary-tree-maximum-path-sum.py # coding:utf-8 ''' @Copyright:LintCode @Author: hanqiao @Problem: http://www.lintcode.com/problem/binary-tree-maximum-path-sum @Language: Python @Datetime: 16-05-19 03:43 ''' """ Definition of TreeN...
code_fim
medium
{ "lang": "python", "repo": "AndrewLu1992/lintcodes", "path": "/94_binary-tree-maximum-path-sum/binary-tree-maximum-path-sum.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if root is None: return -sys.maxint, 0 left = self.helper(root.left) right = self.helper(root.right) single = max(left[1]+root.val, right[1]+root.val, 0) maxpath = max(left[0], right[0], left[1] + right[1] + root.val) return maxpath, single...
code_fim
hard
{ "lang": "python", "repo": "AndrewLu1992/lintcodes", "path": "/94_binary-tree-maximum-path-sum/binary-tree-maximum-path-sum.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def getterRoots(self): return self.roots def setterRoots(self, value): self.roots = value # noinspection PyMethodMayBeStatic def getDefaultRootsValue(self): return dict(ROOTS_DEFAULT_VALUE) def loadCfg(self): # noinspection PyBroadException tr...
code_fim
hard
{ "lang": "python", "repo": "italic-r/maya-prefs", "path": "/scripts/fxpt/fx_refsystem/roots_cfg_handler.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if len(self.roots) < 1: self.roots = self.getDefaultRootsValue() return if '' not in self.roots: self.roots = self.getDefaultRootsValue() return activeCount = len([v for v in self.roots.values() if v]) if activeCount == 1: ...
code_fim
hard
{ "lang": "python", "repo": "italic-r/maya-prefs", "path": "/scripts/fxpt/fx_refsystem/roots_cfg_handler.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: italic-r/maya-prefs path: /scripts/fxpt/fx_refsystem/roots_cfg_handler.py import os from fxpt.fx_prefsaver import prefsaver, serializers from com import REF_ROOT_VAR_NAME ROOTS_CFG_OPT_VAR = 'fx_refsystem_roots' ROOTS_DEFAULT_VALUE = {'': True} # noinspection PyAttributeOutsideInit class Root...
code_fim
hard
{ "lang": "python", "repo": "italic-r/maya-prefs", "path": "/scripts/fxpt/fx_refsystem/roots_cfg_handler.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def _get_existing_instance(self, related_model, value): """Retrieve the related object from an existing instance in the DB. :param related_model: The related model to query :param value: The serialized value to mapto an existing instance. :raises NoResultFound: if ther...
code_fim
hard
{ "lang": "python", "repo": "marshmallow-code/marshmallow-sqlalchemy", "path": "/src/marshmallow_sqlalchemy/fields.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: marshmallow-code/marshmallow-sqlalchemy path: /src/marshmallow_sqlalchemy/fields.py import warnings from marshmallow import fields from marshmallow.utils import is_iterable_but_not_string from sqlalchemy import inspect from sqlalchemy.orm.exc import NoResultFound def get_primary_keys(model): ...
code_fim
hard
{ "lang": "python", "repo": "marshmallow-code/marshmallow-sqlalchemy", "path": "/src/marshmallow_sqlalchemy/fields.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> logging.basicConfig( format="%(levelname)-6s %(message)-48s %(filename)s:%(lineno)d", level=args.log.upper(), ) bases = base_branches() logging.debug(f"using base branches: {bases}") if args.dry_run: logging.info(f"switching to branch {bases[0]}") lo...
code_fim
hard
{ "lang": "python", "repo": "henrywallace/dotfiles", "path": "/home/bin/gmp", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: henrywallace/dotfiles path: /home/bin/gmp #!/usr/bin/env python3 # Switch to default branch, pull, and deleted already merged branches. Branches # are considered already merged, if they contain no commits not already present # on the default branch, recent release branches, or any custom base br...
code_fim
hard
{ "lang": "python", "repo": "henrywallace/dotfiles", "path": "/home/bin/gmp", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def move(self): cur = self.postions[0] x, y = self.direction new = ((cur[0] + (x*GRID_SIZE) % WINDOW_WIDTH, (cur[1]+(y * GRID_SIZE) % WINDOW_HEIGHT)) if __name__=='__main__': pygame.init() window = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT), 0, 32) ...
code_fim
hard
{ "lang": "python", "repo": "sunho-park/Notebook", "path": "/tfcert/creating_Game.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if __name__=='__main__': pygame.init() window = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT), 0, 32) pygame.display.set_caption('Python Game') surface = pygame.Surface(window.get_size()) surface = surface.convert() surface.fill(WHITE) clock = pygame.time.Clock() p...
code_fim
hard
{ "lang": "python", "repo": "sunho-park/Notebook", "path": "/tfcert/creating_Game.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: sunho-park/Notebook path: /tfcert/creating_Game.py import pygame import sys import time import random from pygame.locals import * WINDOW_WIDTH=800 WINDOW_HEIGHT=600 GRID_SIZE = 20 GRID_WIDTH = WINDOW_WIDTH / GRID_SIZE GRID_HEIGHT = WINDOW_HEIGHT / GRID_SIZE WHITE=(255, 255, 255) GREEN = (0, 50...
code_fim
medium
{ "lang": "python", "repo": "sunho-park/Notebook", "path": "/tfcert/creating_Game.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: juliawiktoria/ros_project path: /scripts/odom_path.py #!/usr/bin/python3 import rospy from nav_msgs.msg import Path, Odometry from geometry_msgs.msg import PoseStamped <|fim_suffix|> if __name__ == "__main__": rospy.init_node("odompath") path_odom = Path() odom_subscriber = rospy.S...
code_fim
hard
{ "lang": "python", "repo": "juliawiktoria/ros_project", "path": "/scripts/odom_path.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>if __name__ == "__main__": rospy.init_node("odompath") path_odom = Path() odom_subscriber = rospy.Subscriber('/odom', Odometry, odom_path) odom_path_publisher = rospy.Publisher('/odompath', Path, queue_size=10) rospy.spin()<|fim_prefix|># repo: juliawiktoria/ros_project path: /scripts...
code_fim
hard
{ "lang": "python", "repo": "juliawiktoria/ros_project", "path": "/scripts/odom_path.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: shwetajoshi601/datacamp-deep-learning-in-python path: /2_optimizing_nn_backward_propagation/3_calculate_slope.py import numpy as np input_data = np.array([1,2,3]) weights = np.array([0, 2, 1]) target = 0 <|fim_suffix|># Calculate the slope: slope slope = 2 * input_data * error # Print the slop...
code_fim
medium
{ "lang": "python", "repo": "shwetajoshi601/datacamp-deep-learning-in-python", "path": "/2_optimizing_nn_backward_propagation/3_calculate_slope.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># Calculate the error: error error = preds - target # Calculate the slope: slope slope = 2 * input_data * error # Print the slope print(slope)<|fim_prefix|># repo: shwetajoshi601/datacamp-deep-learning-in-python path: /2_optimizing_nn_backward_propagation/3_calculate_slope.py import numpy as np input_...
code_fim
medium
{ "lang": "python", "repo": "shwetajoshi601/datacamp-deep-learning-in-python", "path": "/2_optimizing_nn_backward_propagation/3_calculate_slope.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: raj713335/Django path: /library_project_api/books/models.py # books/models.py from django.db import models <|fim_suffix|>class Book(models.Model): title=models.CharField(max_length=250) subtitle=models.CharField(max_length=250) author=models.CharField(max_length=100) isbn=model...
code_fim
easy
{ "lang": "python", "repo": "raj713335/Django", "path": "/library_project_api/books/models.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def __str__(self): return self.title<|fim_prefix|># repo: raj713335/Django path: /library_project_api/books/models.py # books/models.py from django.db import models # Create your models here. <|fim_middle|>class Book(models.Model): title=models.CharField(max_length=250) subtitle=m...
code_fim
hard
{ "lang": "python", "repo": "raj713335/Django", "path": "/library_project_api/books/models.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ADC = Pi_hat_adc() def main(): raw_data=ADC.get_all_adc_raw_data() vol_data=ADC.get_all_vol_milli_data() ratio_data=ADC.get_all_ratio_0_1_data() print("raw data for each channel:(1-8chan)(12 bit-max=4096):") print(raw_data) print("voltage for each channel:(unit:mv,max=3300mv):") ...
code_fim
hard
{ "lang": "python", "repo": "Seeed-Studio/grove.py", "path": "/grove/adc_8chan_12bit.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: MiT-HEP/MonoX path: /monophoton/main/compareShapes.py #!/usr/bin/env python import sys from argparse import ArgumentParser argParser = ArgumentParser(description = 'Spit out plots showing shape variations.') argParser.add_argument('input', metavar = 'PATH', help = 'Histogram ROOT file.') argPa...
code_fim
hard
{ "lang": "python", "repo": "MiT-HEP/MonoX", "path": "/monophoton/main/compareShapes.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>lumi = 0. for sName in monophConfig.obs.samples: lumi += allsamples[sName.name].lumi def getHist(name, syst = '', split = ''): if syst: path = variable + split + '/' + name + '_' + syst # /samples else: path = variable + split + '/' + name # /samples print path return...
code_fim
hard
{ "lang": "python", "repo": "MiT-HEP/MonoX", "path": "/monophoton/main/compareShapes.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if hist.Integral(): hist.Scale( 1. / hist.Integral() ) scanvas.legend.add(sample, title = sample, mcolor = colors[iS], lcolor = colors[iS], lwidth = 2) scanvas.legend.apply(sample, hist) sID = scanvas.addHistogram(hist, drawOpt = 'HIST') print rID, sID ...
code_fim
hard
{ "lang": "python", "repo": "MiT-HEP/MonoX", "path": "/monophoton/main/compareShapes.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.RenameField( model_name='change', old_name='new_status', new_name='current_status', ), migrations.AlterField( model_name='change', name='old_status', field=models.IntegerField(blan...
code_fim
medium
{ "lang": "python", "repo": "juli212/kitchenin", "path": "/items/migrations/0004_auto_20170518_1639.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def testRowColumns(self): a = self.ali self.assertEqual(a.rows[1].columns[4].id, a.columns[4][0].id) self.assertEqual(a.rows[1].columns[4].column, a.columns[4][0].column) self.assertEqual(a.rows[1].columns[4].residue.type, a.columns[4][0].residue.type)...
code_fim
hard
{ "lang": "python", "repo": "dtklinh/Protein-Rigid-Domains-Estimation", "path": "/venv/lib/python3.5/site-packages/csb/test/cases/bio/sequence/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.assertRaises(TypeError, lambda: a['', :]) self.assertRaises(TypeError, lambda: a[:, '']) self.assertRaises(ValueError, lambda: a[[], :]) self.assertRaises(ValueError, lambda: a[:, []]) self.assertRaises(IndexError, lambda: a[-1:, :]) self.assertRaises...
code_fim
hard
{ "lang": "python", "repo": "dtklinh/Protein-Rigid-Domains-Estimation", "path": "/venv/lib/python3.5/site-packages/csb/test/cases/bio/sequence/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: tharsus-ltd/protohype path: /tests/unit/test_schemas/base_pb2.py # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: base.proto """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import message ...
code_fim
medium
{ "lang": "python", "repo": "tharsus-ltd/protohype", "path": "/tests/unit/test_schemas/base_pb2.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>Base = _reflection.GeneratedProtocolMessageType('Base', (_message.Message,), { 'DESCRIPTOR' : _BASE, '__module__' : 'base_pb2' # @@protoc_insertion_point(class_scope:ex.protos.Base) }) _sym_db.RegisterMessage(Base) # @@protoc_insertion_point(module_scope)<|fim_prefix|># repo: tharsus-ltd/protohy...
code_fim
hard
{ "lang": "python", "repo": "tharsus-ltd/protohype", "path": "/tests/unit/test_schemas/base_pb2.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: eddiewu6/LeetCode path: /80. Remove Duplicates from Sorted Array II.py class Solution: def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ count = 0 for n in nums: if count < 2 or n > nums[count-2]: ...
code_fim
hard
{ "lang": "python", "repo": "eddiewu6/LeetCode", "path": "/80. Remove Duplicates from Sorted Array II.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if not nums: return 0 count = 0 for i in range(1,len(nums)): if nums[count] != nums[i] or (count>0 and nums[count] != nums[count-1]) or count==0: count += 1 nums[count] = nums[i] return count+1<|fim_prefix|>#...
code_fim
hard
{ "lang": "python", "repo": "eddiewu6/LeetCode", "path": "/80. Remove Duplicates from Sorted Array II.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> query_string_values['cache_ok'] = options['cache_ok'] if 'cache_ok' in options else self.cache_ok query_string_values['full_render'] = options['full_render'] if 'full_render' in options else self.full_render query_string_values['version'] = options['version'] if 'version' in opti...
code_fim
hard
{ "lang": "python", "repo": "wbdana/opengraph-io-python", "path": "/opengraphio/opengraphio.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if len(stack) != 0: answer = False return answer<|fim_prefix|># repo: JangGiWon/LeetCode path: /Valid Parentheses.py class Solution: def isValid(self, s: str) -> bool: b_list = list(s) answer = True stack = [] <|fim_middle|> for b ...
code_fim
hard
{ "lang": "python", "repo": "JangGiWon/LeetCode", "path": "/Valid Parentheses.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: JangGiWon/LeetCode path: /Valid Parentheses.py class Solution: def isValid(self, s: str) -> bool: b_list = list(s) answer = True stack = [] <|fim_suffix|> if len(stack) != 0: answer = False return answer<|fim_middle|> for b ...
code_fim
hard
{ "lang": "python", "repo": "JangGiWon/LeetCode", "path": "/Valid Parentheses.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: sayeed007/PythonProgramming path: /Numpy/7_NumPy_Array_Shape.py import numpy as np arr = np.array([[1, 2, 3, 4], [5, 6, 7, 8]]) print('The shape of an array is the number of elements in each dimension.') #Print the shape of a 2-D array print(arr.shape) #Print the shape of a 5-D array arr = np....
code_fim
medium
{ "lang": "python", "repo": "sayeed007/PythonProgramming", "path": "/Numpy/7_NumPy_Array_Shape.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#Returns Copy or View? print('Base/Return Type of reshape:', newarr) #Unknown Dimension newarr = arr.reshape(2, 2, -1) #Numpy calculate the dimension print(newarr)<|fim_prefix|># repo: sayeed007/PythonProgramming path: /Numpy/7_NumPy_Array_Shape.py import numpy as np arr = np.array([[1, 2, 3, 4], [5,...
code_fim
hard
{ "lang": "python", "repo": "sayeed007/PythonProgramming", "path": "/Numpy/7_NumPy_Array_Shape.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: stella-shen/bilibili path: /depart_videos.py # encoding=utf-8 import os root_dir = '../data/iqiyi/' for video_path in os.listdir(root_dir): video_dir = root_dir + video_path if os.path.isfile(video_dir): video_id = video_path.strip().split('.')[0].split('_')[-1] print 'l...
code_fim
medium
{ "lang": "python", "repo": "stella-shen/bilibili", "path": "/depart_videos.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }