text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|># repo: sammypudjianto/PythonLib path: /Finance/PerformanceComparison/numba_cuda_cython.py """ Speed comparison between straigt python loop vs numba """ import time import matplotlib.pyplot as plt import numba import numpy as np <|fim_suffix|> res = [] for iteration in iterations: start...
code_fim
hard
{ "lang": "python", "repo": "sammypudjianto/PythonLib", "path": "/Finance/PerformanceComparison/numba_cuda_cython.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> print(' all list', res) x = [x for x, y, z in res] y = [y for x, y, z in res] z = [z for x, y, z in res] plt.figure(figsize=(10, 5)) plt.plot(x, y, 'r') plt.plot(x, z, 'b') plt.grid(True) plt.xlabel('iterations') plt.ylabel('time (ms)') plt.show()<|fim_prefix|>#...
code_fim
hard
{ "lang": "python", "repo": "sammypudjianto/PythonLib", "path": "/Finance/PerformanceComparison/numba_cuda_cython.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> flair = nib.load(os.path.join(path_to_file, base_name + str(i), base_name + str(i) + "_flair.nii.gz")) t2 = nib.load(os.path.join(path_to_file, base_name + str(i), base_name + str(i) + "_t2.nii.gz")) t1 = nib.load(os.path.join(path_to_file, base_name + str(i), base_name + str(i) + "_t1.nii.gz"...
code_fim
hard
{ "lang": "python", "repo": "jordan-colman/DR-Unet104", "path": "/convert_nii_to_png.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: jordan-colman/DR-Unet104 path: /convert_nii_to_png.py from PIL import Image import numpy as np import os import nibabel as nib import cv2 path_to_file = 'Data\MICCAI_BraTS2020_ValidationData' path_to_mask_output = 'Data\BRATS_20_Training_masks_png' path_to_output = 'Data\BRATS_20_Validation_data...
code_fim
hard
{ "lang": "python", "repo": "jordan-colman/DR-Unet104", "path": "/convert_nii_to_png.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ##include if converting segmentation mask ''' slice_m[:,:,0] = cv2.resize(MASK[:,:,j].astype(np.uint8),(H,W)) slice_m[:, :, 1] = cv2.resize(MASK[:, :, j].astype(np.uint8), (H, W)) slice_m[:, :, 2] = cv2.resize(MASK[:, :, j].astype(np.uint8), (H, W)) sm_png =...
code_fim
hard
{ "lang": "python", "repo": "jordan-colman/DR-Unet104", "path": "/convert_nii_to_png.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>a2 = np.array([[1.0, -1.0, 2.0], [3.0, 2.0, 1.0], [2.0, -3.0, -2.0]]) b2 = np.array([5.0, 10.0, -10.0]) print(30*'-') print("Przyklad B\n") print("Sprawdzenie czy macierz a jest diagonalnie dominujaca. Jesli zwrocony zostal wektor jedynek to jest diagonalnie dominujaca.") print(diag_dom_test(a2)) print("J...
code_fim
hard
{ "lang": "python", "repo": "matbocz/kurs-mn-python-pwsz-elblag", "path": "/MN_lab_12/MN_lab12_zad_1.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: matbocz/kurs-mn-python-pwsz-elblag path: /MN_lab_12/MN_lab12_zad_1.py #ZADANIE 1 #Wykorzystaj metode iteracyjna Jacobiego do #znalezienia rozwiazan ukladow rownan a) – d). Wykonaj #obliczenia w przy uzyciu arkusza kalkulacyjnego oraz programu #napisanego w Python. import numpy as np; def diag_d...
code_fim
hard
{ "lang": "python", "repo": "matbocz/kurs-mn-python-pwsz-elblag", "path": "/MN_lab_12/MN_lab12_zad_1.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nearkyh/artik-project path: /artik_server/face_net.py import tensorflow as tf import re flags = tf.app.flags FLAGS = flags.FLAGS FLAGS.image_size = 96 FLAGS.image_color = 3 FLAGS.maxpool_filter_size = 2 FLAGS.num_classes = 5 FLAGS.batch_size = 100 FLAGS.learning_rate = 0.0001 FLAGS.lo...
code_fim
hard
{ "lang": "python", "repo": "nearkyh/artik-project", "path": "/artik_server/face_net.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|># fully connected layer 2 def fc2(input_data): FLAGS.fc2_layer_size = 256 with tf.name_scope('fc_2'): W_fc2 = tf.Variable(tf.truncated_normal([FLAGS.fc1_layer_size, FLAGS.fc2_layer_size], stddev=0.1)) b_fc2 = tf.Variable(tf.truncated_normal( [FLAGS.fc2_layer_siz...
code_fim
hard
{ "lang": "python", "repo": "nearkyh/artik-project", "path": "/artik_server/face_net.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> global lastToken lastToken = token def writeHeader(): state = State() h = state.h toc1 = state.toc1 toc2 = state.toc2 mt = state.mt if not h: h = state.title if not toc1: toc1 = state.title if not toc2: toc2 = state.title if not mt:...
code_fim
hard
{ "lang": "python", "repo": "mondele/tools", "path": "/usfm/usfm2rc.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def takeAsIs(key, value): state = State() if state.chapter < 1: # header has not been written, chapter 1 has not started state.addPostHeader(key, value) # sys.stdout.write(u"addPostHeader(" + key + u", " + str(len(value)) + u")\n") else: # sys.stdout.write(u"takeA...
code_fim
hard
{ "lang": "python", "repo": "mondele/tools", "path": "/usfm/usfm2rc.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mondele/tools path: /usfm/usfm2rc.py # -*- coding: utf-8 -*- # This script produces one or more .usfm files in resource container format from valid USFM source text. # Chunk division and paragraph locations are based on an English resource container of the same Bible book. # Uses parseUsfm module...
code_fim
hard
{ "lang": "python", "repo": "mondele/tools", "path": "/usfm/usfm2rc.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: magic428/work_note path: /tools-dl-cv/useful_examples/code/train_eassy/calc_amount_and_extract_fixed_amount_data.py #coding=gbk import os import random import shutil def mkdir_if_not_exists(path): if not os.path.exists(path): os.makedirs(path) data_dir = "roi" origin_dir = "error...
code_fim
hard
{ "lang": "python", "repo": "magic428/work_note", "path": "/tools-dl-cv/useful_examples/code/train_eassy/calc_amount_and_extract_fixed_amount_data.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> classes = os.listdir(origin_dir) files_of_class = {} for c in classes: copy_files = [] c_full = os.path.join(origin_dir, c) c_dst = os.path.join(dst_dir, c) mkdir_if_not_exists(c_dst) files = os.listdir(c_full) for f in files: copy_files.append(os.path.join(c_full, f)) ...
code_fim
medium
{ "lang": "python", "repo": "magic428/work_note", "path": "/tools-dl-cv/useful_examples/code/train_eassy/calc_amount_and_extract_fixed_amount_data.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>os.chdir(FUZZDIR) g = gdb.Gdb(FUZZBIN, timeout=10) g.setup() todo = [] for f in files: h = check_output(['sha1sum', f]).split(b' ')[0].decode('utf-8') crashname = ROOTDIR + '/crashes/' + h + '.bsp' if not os.path.exists(crashname): todo.append((f, h)) print("TODO %d files" % len(todo...
code_fim
hard
{ "lang": "python", "repo": "fengjixuchui/bspfuzz", "path": "/triage/triage.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: fengjixuchui/bspfuzz path: /triage/triage.py #!/usr/bin/env python3 import argparse import gdb import glob import hashlib import os import random import shutil import sys import tempfile from subprocess import Popen, check_output ROOTDIR = os.path.dirname(os.path.abspath(__file__)) FUZZDIR = ROO...
code_fim
hard
{ "lang": "python", "repo": "fengjixuchui/bspfuzz", "path": "/triage/triage.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>-Send your location to get Vaccine availability in your Pin-Code -Enter your district to search for Vaccine availability in your district Type *Help* anytime to to learn how to interact with me. ''' help_message = f''' -Say *Hi* to begin an interaction with me anytime. -Enter your pincode to get vaccine ...
code_fim
medium
{ "lang": "python", "repo": "adybose/cowin-whatsapp-tracker", "path": "/constants.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: adybose/cowin-whatsapp-tracker path: /constants.py # Constants and default messages for the WhatsApp bot greeting_tokens = ['hi', 'hello', 'hey'] # Default messages welcome_message = f''' Hi there! I am a bot that gives you the latest information on Covid-19 Vaccine availability in India nearby...
code_fim
hard
{ "lang": "python", "repo": "adybose/cowin-whatsapp-tracker", "path": "/constants.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def query(db,statement): DBV = e32db.Db_view() DBV.prepare(db, unicode(statement)) n = DBV.count_line() DBV.first_line() data=[] for i in xrange(n): DBV.get_line() line=[] for j in xrange(DBV.col_count()): line.append(DBV.col(1+j)) t=DBV.col_type(1+j) print "Colum...
code_fim
hard
{ "lang": "python", "repo": "tuankien2601/python222", "path": "/ext/e32db/test_e32db.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: tuankien2601/python222 path: /ext/e32db/test_e32db.py # Copyright (c) 2005 Nokia 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://www.apache.o...
code_fim
hard
{ "lang": "python", "repo": "tuankien2601/python222", "path": "/ext/e32db/test_e32db.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>db=e32db.Dbms() FILE=u'c:\\bardb' if os.path.isfile(FILE): os.remove(FILE) db.create(FILE) db.open(FILE) db.execute(u'create table data (a long varchar, b integer)') db.execute(u"insert into data values('"+('x'*10)+"',42)") print query(db,u'select * from data') #db.execute(u"insert into data values('"+('...
code_fim
hard
{ "lang": "python", "repo": "tuankien2601/python222", "path": "/ext/e32db/test_e32db.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: eclee25/flu-SDI-exploratory-age path: /scripts/OR_allweeks_hhsreg.py pstat_zip3_season_cl.csv, /home/elee/Dropbox/Elizabeth_Bansal_Lab/SDI_Data/explore/R_export/OR_zip3_week_cl.csv ###Command Line: python ############################################## ### notes ### ### packages/modules ### ...
code_fim
hard
{ "lang": "python", "repo": "eclee25/flu-SDI-exploratory-age", "path": "/scripts/OR_allweeks_hhsreg.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # d_ILI[(zip3, season, agegroup, wk)] = ILI for week in sorted(weeklist): incidwk_child = sum([d_ILI[(zip3, seasonnum, 'C', week)] for zip3 in zip3list if (zip3, seasonnum, 'C', week) in d_ILI]) incidwk_adult = sum([d_ILI[(zip3, seasonnum, 'A', week)] for zip3 in zip3list if (zip3, seasonnum, 'A', w...
code_fim
hard
{ "lang": "python", "repo": "eclee25/flu-SDI-exploratory-age", "path": "/scripts/OR_allweeks_hhsreg.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: eclee25/flu-SDI-exploratory-age path: /scripts/OR_allweeks_hhsreg.py faultdict from itertools import product from time import clock ## local modules ## ### data structures ### # d_pop[(zip3, season, agegroup)] = popstat # d_z3hhs[zip3] = hhs region d_pop, d_z3hhs = {}, {} # from pop data # d_I...
code_fim
hard
{ "lang": "python", "repo": "eclee25/flu-SDI-exploratory-age", "path": "/scripts/OR_allweeks_hhsreg.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: stfxecutables/MLE-Image-Classification path: /src/CNN_Answer_Predictor.py import numpy as np from sklearn.model_selection import train_test_split from tensorflow import keras from tensorflow.keras.callbacks import EarlyStopping, TerminateOnNaN from tensorflow.keras.layers import Dropout, Dense, F...
code_fim
hard
{ "lang": "python", "repo": "stfxecutables/MLE-Image-Classification", "path": "/src/CNN_Answer_Predictor.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> train_labels = keras.utils.to_categorical( train_labels, num_classes=self.num_classes ) val_labels = keras.utils.to_categorical( val_labels, num_classes=self.num_classes ) self.model.fit( x=train_data, y=train_labels,...
code_fim
hard
{ "lang": "python", "repo": "stfxecutables/MLE-Image-Classification", "path": "/src/CNN_Answer_Predictor.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Trains CNN model to generate softmax scores from :param input_scores: numpy array of prediction matrices :param true_labels: numpy array of labels corresponding to each prediction matrix :return: None """ self.model.compile( loss="cat...
code_fim
hard
{ "lang": "python", "repo": "stfxecutables/MLE-Image-Classification", "path": "/src/CNN_Answer_Predictor.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: universalturtles/Lisibilite path: /code/common/Constants.py HEADER_CORE_METRICS = "Core Metrics" HEADER_TOTAL_COUNT = "Total Count" <|fim_suffix|>FRES = "Flesch Reading Ease Score" FKGL = "Flesch-Kincaid Grade Level" GFI = "Gunning Fog Index" ARI = "Automated Readability Index" SMOG = "Simple M...
code_fim
hard
{ "lang": "python", "repo": "universalturtles/Lisibilite", "path": "/code/common/Constants.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>METRICS_HEADERS = [HEADER_ALGORITHM, HEADER_SCORE, HEADER_DESCRIPTION] FRES = "Flesch Reading Ease Score" FKGL = "Flesch-Kincaid Grade Level" GFI = "Gunning Fog Index" ARI = "Automated Readability Index" SMOG = "Simple Measure of Gobbledygook" CLI = "Coleman-Liau Index" LWS = "Linsear Write Score" FRY = ...
code_fim
hard
{ "lang": "python", "repo": "universalturtles/Lisibilite", "path": "/code/common/Constants.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>HEADER_ALGORITHM = "Algorithm" HEADER_SCORE = "Score" HEADER_DESCRIPTION = "Description" METRICS_HEADERS = [HEADER_ALGORITHM, HEADER_SCORE, HEADER_DESCRIPTION] FRES = "Flesch Reading Ease Score" FKGL = "Flesch-Kincaid Grade Level" GFI = "Gunning Fog Index" ARI = "Automated Readability Index" SMOG = "Sim...
code_fim
medium
{ "lang": "python", "repo": "universalturtles/Lisibilite", "path": "/code/common/Constants.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ulate __all__ = [ "Learner", "emulate", "BaseEmulator", "CholeskyNnEmulator", "InterpolationEmulator", "TorchEmulator", ]<|fim_prefix|># repo: auckland-cosmo/LearnAsYouGoEmulator path: /layg/__init__.py from .emulator import ( BaseEmulator, CholeskyNnEmulator, Int<|fi...
code_fim
medium
{ "lang": "python", "repo": "auckland-cosmo/LearnAsYouGoEmulator", "path": "/layg/__init__.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: auckland-cosmo/LearnAsYouGoEmulator path: /layg/__init__.py from .emulator import ( BaseEmulator, CholeskyNnEmulator, Int<|fim_suffix|>ulate __all__ = [ "Learner", "emulate", "BaseEmulator", "CholeskyNnEmulator", "InterpolationEmulator", "TorchEmulator", ]<|fi...
code_fim
medium
{ "lang": "python", "repo": "auckland-cosmo/LearnAsYouGoEmulator", "path": "/layg/__init__.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>"CholeskyNnEmulator", "InterpolationEmulator", "TorchEmulator", ]<|fim_prefix|># repo: auckland-cosmo/LearnAsYouGoEmulator path: /layg/__init__.py from .emulator import ( BaseEmulator, CholeskyNnEmulator, Int<|fim_middle|>erpolationEmulator, TorchEmulator, ) from .learner import L...
code_fim
medium
{ "lang": "python", "repo": "auckland-cosmo/LearnAsYouGoEmulator", "path": "/layg/__init__.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self, *args, **kwargs): self.args = args self.kwargs = kwargs def pipe_reader(self, input_pipe): return self.wrapper_cls(input_pipe, *self.args, **self.kwargs) def pipe_writer(self, output_pipe): return self.wrapper_cls(output_pipe, *self.args, **...
code_fim
hard
{ "lang": "python", "repo": "targets-fs/targets-python", "path": "/targets/format/wrapped.py", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> def __del__(self, *args): # io.TextIOWrapper close the file on __del__, let the underlying file decide if not self.closed and self.writable(): super(TextWrapper, self).flush() try: self._stream.__del__(*args) except AttributeError: p...
code_fim
hard
{ "lang": "python", "repo": "targets-fs/targets-python", "path": "/targets/format/wrapped.py", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|># repo: targets-fs/targets-python path: /targets/format/wrapped.py import io import locale import os import re import warnings from targets import six from targets.format.format import Format class BaseWrapper(object): def __init__(self, stream, *args, **kwargs): self._stream = stream ...
code_fim
hard
{ "lang": "python", "repo": "targets-fs/targets-python", "path": "/targets/format/wrapped.py", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|># repo: skazi0/yaia path: /migrations/versions/d19921d7f126_added_sent_on_field.py """added sent_on field Revision ID: d19921d7f126 Revises: 534381d04908 Create Date: 2016-08-11 12:11:11.940043 <|fim_suffix|> def downgrade(): op.drop_column('invoices', 'sent_on')<|fim_middle|>""" # revision identi...
code_fim
hard
{ "lang": "python", "repo": "skazi0/yaia", "path": "/migrations/versions/d19921d7f126_added_sent_on_field.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def downgrade(): op.drop_column('invoices', 'sent_on')<|fim_prefix|># repo: skazi0/yaia path: /migrations/versions/d19921d7f126_added_sent_on_field.py """added sent_on field Revision ID: d19921d7f126 Revises: 534381d04908 Create Date: 2016-08-11 12:11:11.940043 """ # revision identifiers, used by ...
code_fim
medium
{ "lang": "python", "repo": "skazi0/yaia", "path": "/migrations/versions/d19921d7f126_added_sent_on_field.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> op.add_column('invoices', sa.Column('sent_on', sa.DateTime(), nullable=True)) def downgrade(): op.drop_column('invoices', 'sent_on')<|fim_prefix|># repo: skazi0/yaia path: /migrations/versions/d19921d7f126_added_sent_on_field.py """added sent_on field Revision ID: d19921d7f126 Revises: 534381d...
code_fim
medium
{ "lang": "python", "repo": "skazi0/yaia", "path": "/migrations/versions/d19921d7f126_added_sent_on_field.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: PingLu8/django-twitter path: /inbox/api/views.py from inbox.api.serializers import ( NotificationSerializer, NotificationSerializerForUpdate, ) from rest_framework import viewsets, status from rest_framework.decorators import action from rest_framework.permissions import IsAuthenticated f...
code_fim
hard
{ "lang": "python", "repo": "PingLu8/django-twitter", "path": "/inbox/api/views.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # GET /api/notifications/unread-count/ count = self.get_queryset().filter(unread=True).count() return Response({'unread_count':count}, status=status.HTTP_200_OK) @action(methods=['POST'], detail=False, url_path='mark-all-as-read') @method_decorator(ratelimit(key='user', ra...
code_fim
hard
{ "lang": "python", "repo": "PingLu8/django-twitter", "path": "/inbox/api/views.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def format_time(t): """Format seconds into a human readable form. >>> format_time(10.4) '10.4s' >>> format_time(1000.4) '16min 40.4s' >>> format_time(100000.4) '27hr 46min 40.4s' """ m, s = divmod(t, 60) h, m = divmod(m, 60) if h: return f"{h:2.0f}hr {m...
code_fim
hard
{ "lang": "python", "repo": "dask/distributed", "path": "/distributed/diagnostics/progress.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: dask/distributed path: /distributed/diagnostics/progress.py from __future__ import annotations import asyncio import logging import warnings from collections import defaultdict from timeit import default_timer from typing import ClassVar from tlz import groupby, valmap from dask.base import to...
code_fim
hard
{ "lang": "python", "repo": "dask/distributed", "path": "/distributed/diagnostics/progress.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>dif -%] [% if extract_product -%] # extract_product=True in your pipeline.yaml file, declare a "product" # variable inside this function [% endif -%] pass<|fim_prefix|># repo: ploomber/ploomber path: /src/ploomber/resources/ploomber_add/function.py def [[function_name]](product): ...
code_fim
medium
{ "lang": "python", "repo": "ploomber/ploomber", "path": "/src/ploomber/resources/ploomber_add/function.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: ploomber/ploomber path: /src/ploomber/resources/ploomber_add/function.py def [[function_name]](product): """Add description here """ [% if extract_upstream -%] # extract_upstream=True in your pipeline.yaml file, if this task has<|fim_suffix|> pipeline.yaml file, if this task has...
code_fim
medium
{ "lang": "python", "repo": "ploomber/ploomber", "path": "/src/ploomber/resources/ploomber_add/function.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> context = {'person': flavio} result = schema.execute(query, context=context) full_name = result.data['person']['fullName'] self.assertEqual(full_name, 'Flavio Fernandes')<|fim_prefix|># repo: flaviogf/examples path: /hello_graphql_python/tests/test_exemplo_02.py import ...
code_fim
hard
{ "lang": "python", "repo": "flaviogf/examples", "path": "/hello_graphql_python/tests/test_exemplo_02.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: flaviogf/examples path: /hello_graphql_python/tests/test_exemplo_02.py import unittest from hello_graphql_python.exemplo_02 import Person, schema class PersonTests(unittest.TestCase): def test_should_returns_full_name(self): query = ''' query { person { ...
code_fim
hard
{ "lang": "python", "repo": "flaviogf/examples", "path": "/hello_graphql_python/tests/test_exemplo_02.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: atviriduomenys/spinta path: /spinta/types/namespace.py import uuid import collections from typing import NamedTuple from typing import Union from typing import overload import itertools from typing import Any from typing import Dict from typing import Iterable from typing import Iterator from ty...
code_fim
hard
{ "lang": "python", "repo": "atviriduomenys/spinta", "path": "/spinta/types/namespace.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@commands.getall.register(Context, Namespace) def getall( context: Context, ns: Namespace, *, action: Optional[Action] = None, dataset_: Optional[str] = None, resource: Optional[str] = None, **kwargs ): return _query_data(context, ns, action, dataset_, resource, **kwargs) ...
code_fim
hard
{ "lang": "python", "repo": "atviriduomenys/spinta", "path": "/spinta/types/namespace.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> context: Context, ns: Namespace, action: Action, dataset_: Optional[str] = None, resource: Optional[str] = None, ) -> Iterable[_NodeAndData]: items: Iterable[Union[Namespace, Model]] = itertools.chain( ns.names.values(), ns.models.values(), ) for item in it...
code_fim
hard
{ "lang": "python", "repo": "atviriduomenys/spinta", "path": "/spinta/types/namespace.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: lanxinplus/lanxinplus-openapi-python-sdk path: /lanxinplus_openapi/api/addrbk_tags_api.py 1_tags_meta_fetch', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ 'app_token', ...
code_fim
hard
{ "lang": "python", "repo": "lanxinplus/lanxinplus-openapi-python-sdk", "path": "/lanxinplus_openapi/api/addrbk_tags_api.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Args: app_token (str): app_token v1_tag_groups_create_request_body (V1TagGroupsCreateRequestBody): Request Body Keyword Args: user_token (str): user_token. [optional] Returns: V1TagGroupsCreateResponse If the method ...
code_fim
hard
{ "lang": "python", "repo": "lanxinplus/lanxinplus-openapi-python-sdk", "path": "/lanxinplus_openapi/api/addrbk_tags_api.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Returns: V1TagGroupsFetchResponse If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( ...
code_fim
hard
{ "lang": "python", "repo": "lanxinplus/lanxinplus-openapi-python-sdk", "path": "/lanxinplus_openapi/api/addrbk_tags_api.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: IFarhankhan/qb path: /cli.py import click from qanta import logging from qanta.util.environment import ENVIRONMENT from qanta.util.vw import format_audit from qanta.wikipedia.cached_wikipedia import CachedWikipedia from qanta.wikipedia import wikification from qanta.streaming import start_qanta_...
code_fim
hard
{ "lang": "python", "repo": "IFarhankhan/qb", "path": "/cli.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @main.command() def spark_stream(): start_spark_streaming() @main.command() def qanta_stream(): start_qanta_streaming() @main.command() @click.argument('wiki_cache') def init_wiki_cache(wiki_cache): CachedWikipedia.initialize_cache(wiki_cache) @main.command() @click.argument('output') d...
code_fim
medium
{ "lang": "python", "repo": "IFarhankhan/qb", "path": "/cli.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@main.command() def qanta_stream(): start_qanta_streaming() @main.command() @click.argument('wiki_cache') def init_wiki_cache(wiki_cache): CachedWikipedia.initialize_cache(wiki_cache) @main.command() @click.argument('output') def wikify(output): wikification.wikify(output) @main.command(...
code_fim
hard
{ "lang": "python", "repo": "IFarhankhan/qb", "path": "/cli.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>for i in range(10): t = threading.Thread(name="Thread no. " + str(i), target=func, args=(i,)) t.start()<|fim_prefix|># repo: tsarpaul/poolhub path: /test.py import threading from time import sleep import poolhub a = 5 def bunk(): sleep(3) a = 5 a.b <|fim_middle|> def func(b): ...
code_fim
medium
{ "lang": "python", "repo": "tsarpaul/poolhub", "path": "/test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: tsarpaul/poolhub path: /test.py import threading from time import sleep import poolhub a = 5 <|fim_suffix|> for i in range(10): t = threading.Thread(name="Thread no. " + str(i), target=func, args=(i,)) t.start()<|fim_middle|> def bunk(): sleep(3) a = 5 a.b def func(b): ...
code_fim
medium
{ "lang": "python", "repo": "tsarpaul/poolhub", "path": "/test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mhogg/cgtools path: /cgtools/mesh/laplacian.py import numpy as np import scipy.sparse as sparse from .. import vector as V def compute_mesh_laplacian(verts, tris, weight_type='cotangent', return_vertex_area=True, area_type='mixed', add_di...
code_fim
hard
{ "lang": "python", "repo": "mhogg/cgtools", "path": "/cgtools/mesh/laplacian.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for all weight types: w_ii = sum(w_ij for j in [1..n]) if area_type == 'mixed': compute the vertex area as the voronoi area for non-obtuse triangles, use the barycentric area for obtuse triangles (according to Mark Meyer's 2002 paper) if area_type == 'lumped...
code_fim
hard
{ "lang": "python", "repo": "mhogg/cgtools", "path": "/cgtools/mesh/laplacian.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Leek727/InverseKinematics path: /table_generator_no_visual.py import math import time import json # arm length arm_lengths = [100, 100, 100] # sums two vectors def sum_vector(A, B): # A = (x, y) return (A[0] + B[0], A[1] + B[1]) # converts polar to the other one def convert_cartesian(A...
code_fim
hard
{ "lang": "python", "repo": "Leek727/InverseKinematics", "path": "/table_generator_no_visual.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # ------------------ hash map making part ------------------ end_point = [] key = str(round(cum_vector[0])) + "," + str(round(cum_vector[1])) try: end_point = data[key] except: ...
code_fim
hard
{ "lang": "python", "repo": "Leek727/InverseKinematics", "path": "/table_generator_no_visual.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: parametersky/ServerTest path: /data.py from sqlalchemy import (create_engine,Table,Column,Integer,String,MetaData) from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker engine = create_engine("mysql://root:YES@localhost/orders") Base = declarative_base...
code_fim
medium
{ "lang": "python", "repo": "parametersky/ServerTest", "path": "/data.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @property def serial(self): return { "uid":self.uid, "validTime":self.validTime, "length":self.length } Base.metadata.bind=engine Base.metadata.create_all() Session = sessionmaker(bind=engine) ses = Session()<|fim_prefix|># repo: parametersky/Ser...
code_fim
medium
{ "lang": "python", "repo": "parametersky/ServerTest", "path": "/data.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> with connection: with connection.cursor() as cursor: cursor.execute('DROP TABLE test_table') if __name__ == '__main__': create_test_table() read_test_table() cleanup()<|fim_prefix|># repo: regananalytics/kubism.dev path: /old/sql/test.py import os import psycopg2 fr...
code_fim
medium
{ "lang": "python", "repo": "regananalytics/kubism.dev", "path": "/old/sql/test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: regananalytics/kubism.dev path: /old/sql/test.py import os import psycopg2 from dotenv import load_dotenv load_dotenv() connection = psycopg2.connect(os.environ['DATABASE_URL']) CREATE_TEST_TABLE = """CREATE TABLE IF NOT EXISTS test_table ( id SERIAL PRIMARY KEY, test_field TEXT, ...
code_fim
hard
{ "lang": "python", "repo": "regananalytics/kubism.dev", "path": "/old/sql/test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jsmartini/Cubesat-Telemetry path: /node_test.py import util.radio as radio <|fim_suffix|>node = radio.zumlink("COM11") config = radio.generate_config(radioMode="Gateway", txPower=0) node.setup(config) node.Terminal()<|fim_middle|>#device = "COM8" #device serial port if windows i.e. COM8; if li...
code_fim
medium
{ "lang": "python", "repo": "jsmartini/Cubesat-Telemetry", "path": "/node_test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jsmartini/Cubesat-Telemetry path: /node_test.py import util.radio as radio <|fim_suffix|>node = radio.zumlink("COM11") config = radio.generate_config(radioMode="Gateway", txPower=0) node.setup(config) node.Terminal()<|fim_middle|> #device = "COM8" #device serial port if windows i.e. COM8; if li...
code_fim
medium
{ "lang": "python", "repo": "jsmartini/Cubesat-Telemetry", "path": "/node_test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>config = radio.generate_config(radioMode="Gateway", txPower=0) node.setup(config) node.Terminal()<|fim_prefix|># repo: jsmartini/Cubesat-Telemetry path: /node_test.py import util.radio as radio <|fim_middle|> #device = "COM8" #device serial port if windows i.e. COM8; if linux tr /dev/tty..... or similar...
code_fim
medium
{ "lang": "python", "repo": "jsmartini/Cubesat-Telemetry", "path": "/node_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: vasilydenisenko/modbus_rtu_slave path: /tests/mb_stop_bit_tests.py # MIT License # Copyright (c) 2021 Vasily Denisenko, Sergey Kuznetsov # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to...
code_fim
hard
{ "lang": "python", "repo": "vasilydenisenko/modbus_rtu_slave", "path": "/tests/mb_stop_bit_tests.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Check if response received response_received = mb_bsp.get_pdu_status('Master', 'PDU status') if response_received: print('Response received') else: print('Response isn\'t received') mb_util.print_error_count() def run_test_m_stop_bit(speed, conf_bit): print('Run test for ma...
code_fim
hard
{ "lang": "python", "repo": "vasilydenisenko/modbus_rtu_slave", "path": "/tests/mb_stop_bit_tests.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ActivationFunction.__init__( self, lambda x: x, lambda x: 1.0)<|fim_prefix|># repo: DomenicD/dom_ml_playground path: /python/src/neurons/activation_functions/linear_activation.py from python.src.neurons.activation_functions.activation_function import ActivationFunction class Linea...
code_fim
easy
{ "lang": "python", "repo": "DomenicD/dom_ml_playground", "path": "/python/src/neurons/activation_functions/linear_activation.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self): ActivationFunction.__init__( self, lambda x: x, lambda x: 1.0)<|fim_prefix|># repo: DomenicD/dom_ml_playground path: /python/src/neurons/activation_functions/linear_activation.py from python.src.neurons.activation_functions.activation_function import Activatio...
code_fim
easy
{ "lang": "python", "repo": "DomenicD/dom_ml_playground", "path": "/python/src/neurons/activation_functions/linear_activation.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: DomenicD/dom_ml_playground path: /python/src/neurons/activation_functions/linear_activation.py from python.src.neurons.activation_functions.activation_function import ActivationFunction <|fim_suffix|> ActivationFunction.__init__( self, lambda x: x, lambda x: 1.0)<|fim_middl...
code_fim
medium
{ "lang": "python", "repo": "DomenicD/dom_ml_playground", "path": "/python/src/neurons/activation_functions/linear_activation.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Shatha1978/Optimisation-algorithm-examples path: /src/CircularList.py # Import the collections package for the circular list import collections # Import the numpy package for mean and std import numpy as np <|fim_suffix|> return list(self.data); def mean(self): return np.mea...
code_fim
hard
{ "lang": "python", "repo": "Shatha1978/Optimisation-algorithm-examples", "path": "/src/CircularList.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self.data = collections.deque(maxlen=maxlen); self.last_element = None; if not isinstance(default_value, NoneType): for i in range(maxlen): self.data.append(default_value); self.last_element = default_value; def append(self, i): ...
code_fim
medium
{ "lang": "python", "repo": "Shatha1978/Optimisation-algorithm-examples", "path": "/src/CircularList.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>=======================================================================<|fim_prefix|># repo: tejasukhavasi24/my-repo path: /teja.py I love mmy India #!/usr/bin/python #title :teja.py #description :good guy #author :tsukha #date :20180320 #version :123456 #usage :<|fim_middle|>python teja.py dum...
code_fim
medium
{ "lang": "python", "repo": "tejasukhavasi24/my-repo", "path": "/teja.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>python teja.py dummy #notes : #python_version :2.6.6.143.142 #=============================================================================<|fim_prefix|># repo: tejasukhavasi24/my-repo path: /teja.py I love mmy India #!/usr/bin/python #title :teja.py #description :go<|fim_middle|>od guy #author :t...
code_fim
medium
{ "lang": "python", "repo": "tejasukhavasi24/my-repo", "path": "/teja.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: tejasukhavasi24/my-repo path: /teja.py I love mmy India #!/usr/bin/python #title :teja.py #description :good guy #author :tsukha #date :20180320 #version :123456 #usage :<|fim_suffix|>=======================================================================<|fim_middle|>python teja.py dum...
code_fim
medium
{ "lang": "python", "repo": "tejasukhavasi24/my-repo", "path": "/teja.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: chemlove/polyply_1.0 path: /polyply/src/gen_seq.py # Copyright 2020 University of Groningen # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org...
code_fim
hard
{ "lang": "python", "repo": "chemlove/polyply_1.0", "path": "/polyply/src/gen_seq.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def _find_terminal_nodes(graph): """ Find all termini of a graph and return the node key. A termini is defined as a node with degree of 1. Note that graph is assumed to be undirected. """ termini = [] for node in graph.nodes: if graph.degree(node) == 1: ter...
code_fim
hard
{ "lang": "python", "repo": "chemlove/polyply_1.0", "path": "/polyply/src/gen_seq.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """ Find all termini of a graph and return the node key. A termini is defined as a node with degree of 1. Note that graph is assumed to be undirected. """ termini = [] for node in graph.nodes: if graph.degree(node) == 1: termini.append(node) return term...
code_fim
hard
{ "lang": "python", "repo": "chemlove/polyply_1.0", "path": "/polyply/src/gen_seq.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Ryan-Amaral/general-game-playing-tpg path: /random-scores.py # imports and helper methods import gym import gym.spaces import multiprocessing as mp import psutil import os """ Run each agent in this method for parallization. Args: args: (TpgAgent, envName, scoreList, numEpisodes, numFrames)...
code_fim
medium
{ "lang": "python", "repo": "Ryan-Amaral/general-game-playing-tpg", "path": "/random-scores.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># all of the titles we will be general game playing on # we chose games that we know TPG does OK in alone envNames = ['Alien-v0','Asteroids-v0','Atlantis-v0','BankHeist-v0', 'BattleZone-v0','Bowling-v0','Boxing-v0','Centipede-v0', 'ChopperCommand-v0','DoubleDunk-v0','FishingD...
code_fim
medium
{ "lang": "python", "repo": "Ryan-Amaral/general-game-playing-tpg", "path": "/random-scores.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> print(str(env.env) + ': ' + str(scoreTotal/10)) env.close() # https://stackoverflow.com/questions/42103367/limit-total-cpu-usage-in-python-multiprocessing/42130713 def limit_cpu(): p = psutil.Process(os.getpid()) p.nice(10) # all of the titles we will be general game play...
code_fim
hard
{ "lang": "python", "repo": "Ryan-Amaral/general-game-playing-tpg", "path": "/random-scores.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # We have to write the rules for programming the switch to the file: st = "table_set_default send_frame _drop" print >> f_handle,st st = "table_set_default forward _drop" print >> f_handle,st st = "table_set_default ipv4_lpm _drop" ...
code_fim
hard
{ "lang": "python", "repo": "bramamurthy/P4SwitchesInMaxiNet", "path": "/MaxiNet/WorkerServer/mygraph.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: bramamurthy/P4SwitchesInMaxiNet path: /MaxiNet/WorkerServer/mygraph.py witch_list = [] switch_list = self.__graph_dict[switch_name] return switch_list def diameter(self): """ Calculates the diameter of the graph """ v = self.vertices() pairs = [ (v[i]...
code_fim
hard
{ "lang": "python", "repo": "bramamurthy/P4SwitchesInMaxiNet", "path": "/MaxiNet/WorkerServer/mygraph.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: bramamurthy/P4SwitchesInMaxiNet path: /MaxiNet/WorkerServer/mygraph.py ) (vertex1, vertex2) = tuple(edge) if vertex1 not in self.__graph_dict: self.__graph_dict[vertex1] = [] dbg_str = "Vertex being initialized .." + str(vertex1) # logging.debug...
code_fim
hard
{ "lang": "python", "repo": "bramamurthy/P4SwitchesInMaxiNet", "path": "/MaxiNet/WorkerServer/mygraph.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> try: callback(*args) except Exception as err: msg = 'Library import callback threw an unexpected exception' RideLogException(message=msg, exception=err, level='WARN').publish() def fetch_keywords(self, library_name, library_args, callback): ...
code_fim
hard
{ "lang": "python", "repo": "robotframework/RIDE", "path": "/src/robotide/spec/librarymanager.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def _handle_insert_keywords_message(self, message): _, library_name, library_args, result_queue = message keywords = self._fetch_keywords(library_name, library_args) self._insert(library_name, library_args, keywords, lambda res: result_queue.put(res, timeou...
code_fim
hard
{ "lang": "python", "repo": "robotframework/RIDE", "path": "/src/robotide/spec/librarymanager.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: robotframework/RIDE path: /src/robotide/spec/librarymanager.py # Copyright 2008-2015 Nokia Networks # Copyright 2016- Robot Framework Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You ma...
code_fim
hard
{ "lang": "python", "repo": "robotframework/RIDE", "path": "/src/robotide/spec/librarymanager.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> np.random.seed(0) self.input_shape = [3, 4, 10, 10] self.output_shape = [3, 4, 5, 5] self.pool_size = (2, 2) self.maxpool = compile_maxpool(self.output_shape, self.pool_size) def test_maxpool_non_edge_case(self): """ Test MaxPooling on a non-...
code_fim
hard
{ "lang": "python", "repo": "oval-group/pl-cnn", "path": "/src/tests/maxpool.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> np.random.seed(0) self.input_shape = [3, 4, 10, 10] self.output_shape = [3, 4, 5, 5] self.pool_size = (2, 2) self.maxpool = compile_maxpool(self.output_shape, self.pool_size) def test_maxpool_non_edge_case(self): """ Test MaxPooling on a non-e...
code_fim
hard
{ "lang": "python", "repo": "oval-group/pl-cnn", "path": "/src/tests/maxpool.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: oval-group/pl-cnn path: /src/tests/maxpool.py import unittest import numpy as np import theano import theano.tensor as T from utils.patches import my_pool_2d def compile_maxpool(output_shape, pool_size): X = T.tensor4() # compute output with both methods out1 = T.signal.pool.pool...
code_fim
hard
{ "lang": "python", "repo": "oval-group/pl-cnn", "path": "/src/tests/maxpool.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ok, frame = capture.read() position = capture.get(0) print('Current position:', position) if ok == True: current_state, frame_count = frame_handler(frame, frame_count, current_state) else: break except Key...
code_fim
hard
{ "lang": "python", "repo": "sahupr/highlight-bot", "path": "/stream-capture-service/main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sahupr/highlight-bot path: /stream-capture-service/main.py import os import time import streamlink from PIL import Image import cv2 import game_screen import goal_event_producer CHANNEL_NAME = os.getenv('CHANNEL_NAME') KAFKA_TOPIC_GOAL_EVENTS = 'hbot.core.goal-events' def frame_handler(frame,...
code_fim
hard
{ "lang": "python", "repo": "sahupr/highlight-bot", "path": "/stream-capture-service/main.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Hacky # TODO: Formalize this current_state = None # Debug: # time.sleep(14) # print('Away goal detected') # goal_event_producer.send_goal_event(int(time.time()), KAFKA_TOPIC_GOAL_EVENTS) while capture.isOpened(): try: # Capture every cap...
code_fim
hard
{ "lang": "python", "repo": "sahupr/highlight-bot", "path": "/stream-capture-service/main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: somuncudayi/depthai-experiments path: /gen2-age-gender/main.py import argparse import queue import time from pathlib import Path import blobconverter import cv2 import depthai as dai import numpy as np from imutils.video import FPS parser = argparse.ArgumentParser() parser.add_argument('-nd', '-...
code_fim
hard
{ "lang": "python", "repo": "somuncudayi/depthai-experiments", "path": "/gen2-age-gender/main.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # If there is a face detected, there will also be an age/gender # inference result available soon, so we can wait for it det = age_gender_q.get() age = int(float(np.squeeze(np.array(det.getLayerFp16('age_conv3')))) * 100) ...
code_fim
hard
{ "lang": "python", "repo": "somuncudayi/depthai-experiments", "path": "/gen2-age-gender/main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>model = Model(input=[input_var], output=[softmax]) model.compile(loss='categorical_crossentropy', optimizer='adadelta', metrics=['accuracy']) model.fit(X_train, Y_train, batch_size=batch_size, nb_epoch=nb_epoch, verbose=1, validation_data=(X_test, Y_test)) model.save...
code_fim
hard
{ "lang": "python", "repo": "mark14wu/Fashion-MNIST_Contest", "path": "/fashion-mnist.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }