text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: mozman/steputils path: /docs/stepcode/ifc4x2.py
olumeonrelatedelement(self, value):
if value != None: # OPTIONAL attribute
if not check_type(value, ifcsolidorshell):
self._volumeonrelatedelement = ifcsolidorshell(value)
else:
self._... | code_fim | hard | {
"lang": "python",
"repo": "mozman/steputils",
"path": "/docs/stepcode/ifc4x2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # print error
if printError != 0:
print(error)
print(par)
fail = 0
except:
error = np.nan
fail = 1
return error, [], fail
### define the optimization components
... | code_fim | hard | {
"lang": "python",
"repo": "GonzaloForero/HAPI-1",
"path": "/Web_application/HAPI/function/Calibration.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# read data
### meteorological data
prec=GIS.ReadRastersFolder(PrecPath)
evap=GIS.ReadRastersFolder(Evap_Path)
temp=GIS.ReadRastersFolder(TempPath)
print("meteorological data are read successfully")
#### GIS data
# dem= gdal.Open(DemPath)
acc=gdal.Open(FlowAccPath)... | code_fim | hard | {
"lang": "python",
"repo": "GonzaloForero/HAPI-1",
"path": "/Web_application/HAPI/function/Calibration.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GonzaloForero/HAPI-1 path: /Web_application/HAPI/function/Calibration.py
# -*- coding: utf-8 -*-
"""
Calibration
calibration wrapper to connect the parameter distribution function with the
distRMM
@author: Mostafa
"""
#%links
#%library
import os
import numpy as np
import gdal
from pyOpt i... | code_fim | hard | {
"lang": "python",
"repo": "GonzaloForero/HAPI-1",
"path": "/Web_application/HAPI/function/Calibration.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> l2 = Label(frame1, text="Player 1 : ", font=('time', 10, 'bold'))
l2.grid(row=0, column=0)
entry1 = Entry(frame1, text="", font=('time', 10, 'bold'))
entry1.grid(row=0, column=1)
l3 = Label(frame1, text="Player 2 : ", font=('time', 10, 'bold'))
l3.grid(row=1, column=0)
... | code_fim | hard | {
"lang": "python",
"repo": "p506/PyThon-ProGrammIng",
"path": "/tic-tac-toe.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: p506/PyThon-ProGrammIng path: /tic-tac-toe.py
from tkinter import *
from tkinter.messagebox import showinfo, showwarning
x = 0
# array holding the block no occupied by each player respectively
player_1 = []
player_2 = []
# funtion to check the winning condition
def check_winner_pla... | code_fim | hard | {
"lang": "python",
"repo": "p506/PyThon-ProGrammIng",
"path": "/tic-tac-toe.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # plot time series
fig, ax = plt.subplots(figsize=(8, 4))
ax.plot(x_new, dw_new, marker, color=div(0.0), linewidth=2)
ax.plot(x_new, up_new, marker, color=div(1.0), linewidth=2)
# hide borders
ax.spines['top'].set_visible(False)
ax.spines['right'].s... | code_fim | hard | {
"lang": "python",
"repo": "matheusccouto/network-stability",
"path": "/network_stability/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Save results
self.speed_data = self.speed_data.append(results, ignore_index=True)
return self.speed_data
def speed_test_interval(self, seconds=0, minutes=0, hours=0, days=0, timeout=60):
"""
Test network speed for a time interval.
:param seconds: dur... | code_fim | hard | {
"lang": "python",
"repo": "matheusccouto/network-stability",
"path": "/network_stability/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matheusccouto/network-stability path: /network_stability/__init__.py
import time
import datetime
from os.path import splitext
import speedtest
import pandas as pd
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
import numpy as np
import socket
class NetworkTest(object):
... | code_fim | hard | {
"lang": "python",
"repo": "matheusccouto/network-stability",
"path": "/network_stability/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Best Solution
print(f'a0 é: {a_optimum[0][0]}')
print(f'a1 é: {a_optimum[1][0]}')
print(a_optimum)<|fim_prefix|># repo: LuizAugusto20/Exemplos-TP-555 path: /aula3/linear_regression.py
import numpy as np
N= 100
# Vetor de ruído
x = 2*np.random.rand(N,1)
# Esperamos encontra algo próximo à y = 4 + 3
... | code_fim | medium | {
"lang": "python",
"repo": "LuizAugusto20/Exemplos-TP-555",
"path": "/aula3/linear_regression.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>X_b = np.c_[np.ones((N,1)),x]
# Implementação da esquação normal
a_optimum = np.linalg.inv(X_b.T.dot(X_b)).dot(X_b.T).dot(y)
# Best Solution
print(f'a0 é: {a_optimum[0][0]}')
print(f'a1 é: {a_optimum[1][0]}')
print(a_optimum)<|fim_prefix|># repo: LuizAugusto20/Exemplos-TP-555 path: /aula3/linear_regr... | code_fim | medium | {
"lang": "python",
"repo": "LuizAugusto20/Exemplos-TP-555",
"path": "/aula3/linear_regression.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LuizAugusto20/Exemplos-TP-555 path: /aula3/linear_regression.py
import numpy as np
N= 100
# Vetor de ruído
x = 2*np.random.rand(N,1)
<|fim_suffix|>X_b = np.c_[np.ones((N,1)),x]
# Implementação da esquação normal
a_optimum = np.linalg.inv(X_b.T.dot(X_b)).dot(X_b.T).dot(y)
# Best Solution
pri... | code_fim | medium | {
"lang": "python",
"repo": "LuizAugusto20/Exemplos-TP-555",
"path": "/aula3/linear_regression.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> global np
import numpy as np
global plt
from matplotlib import pyplot as plt<|fim_prefix|># repo: n1amr/dotfiles path: /config/ipython/profile_default/startup/00-imports.py
import os
import re
import sys
from math import *
<|fim_middle|>def import_math():
| code_fim | easy | {
"lang": "python",
"repo": "n1amr/dotfiles",
"path": "/config/ipython/profile_default/startup/00-imports.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: n1amr/dotfiles path: /config/ipython/profile_default/startup/00-imports.py
import os
import re
import sys
from math import *
<|fim_suffix|> global np
import numpy as np
global plt
from matplotlib import pyplot as plt<|fim_middle|>
def import_math():
| code_fim | easy | {
"lang": "python",
"repo": "n1amr/dotfiles",
"path": "/config/ipython/profile_default/startup/00-imports.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> close_match_run = cv.models.CloseMatchRun.objects.get(id=options["cmr"][0])
unreviewed_sets = (
close_match_run.close_match_sets.annotate(
n_images=Count("memberships"),
n_redundant_images=Count(
"memberships",
... | code_fim | hard | {
"lang": "python",
"repo": "cmu-lib/campi",
"path": "/rest/cv/management/commands/auto_accept_cms.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cmu-lib/campi path: /rest/cv/management/commands/auto_accept_cms.py
from django.core.management.base import BaseCommand
from django.db.models import Count, Q, F, ExpressionWrapper, BooleanField
from django.contrib.auth.models import User
from rest_framework.reverse import reverse
import cv
clas... | code_fim | hard | {
"lang": "python",
"repo": "cmu-lib/campi",
"path": "/rest/cv/management/commands/auto_accept_cms.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # setup composition
comp = f.create.CompositionMob()
comp.name = mob_name
comp.usage_code = "Usage_Template"
timeline = f.create.TimelineMobSlot()
timeline.editrate = "24000/1001"
timeline.slot_id = 1
timeline.segment = title_op
comp.append_slot(timeline)
f.storag... | code_fim | hard | {
"lang": "python",
"repo": "markreidvfx/pct_titles",
"path": "/examples/aaf_title_create.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # buf = bytearray(os.path.getsize(pct_file_path))
# pct = open(pct_file_path, 'rb')
#
# pct.readinto(buf)
gfx = f.create.ConstantValue(graphic_fx_paramdef, pct_data)
effect_id = f.create.ConstantValue(effect_id_paramdef, bytearray(b'EFF2_BLEND_GRAPHIC\x00'))
title_op.add_para... | code_fim | hard | {
"lang": "python",
"repo": "markreidvfx/pct_titles",
"path": "/examples/aaf_title_create.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: markreidvfx/pct_titles path: /examples/aaf_title_create.py
import os
from StringIO import StringIO
import aaf
import aaf.define
from aaf.util import AUID
import fractions
import pct_titles
import traceback
def setup_avid_extensions(f):
uint8_typedef = f.dictionary.lookup_typedef("UInt8")
... | code_fim | hard | {
"lang": "python",
"repo": "markreidvfx/pct_titles",
"path": "/examples/aaf_title_create.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hensir/badusb path: /qtui/recycle.py
# @pyqtSlot() # Cut 操作
# def on_actEdit_Cut_triggered(self):
# # self.formDoc = self.ui.mdi.activeSubWindow().widget()
# self.formDoc.textCut()
#
# @pyqtSlot() # Copy 操作
# def on_actEdit_Copy_triggered(self):
# # self.formDoc = self.ui.mdi.active... | code_fim | hard | {
"lang": "python",
"repo": "hensir/badusb",
"path": "/qtui/recycle.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>i.act_Paste.triggered.disconnect(mdicurentwidget.tE.paste)
# self.ui.act_SelectAll.triggered.disconnect(mdicurentwidget.tE.selectAll)
# self.ui.act_Font.triggered.connect(self.formDoc.textSetFont)
# print("上一个窗口组件信号已解除")
# except Exception as e:
# pr... | code_fim | hard | {
"lang": "python",
"repo": "hensir/badusb",
"path": "/qtui/recycle.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with ThreadPoolExecutor(MAX_WORKERS) as executor:
future_to_repo = {
executor.submit(repo().pull, url): repo
for repo in repos
}
for future in as_completed(future_to_repo):
try:
yield [future_to_repo[future]].extend(future.res... | code_fim | hard | {
"lang": "python",
"repo": "redodo/saltaway",
"path": "/saltaway/api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: redodo/saltaway path: /saltaway/api.py
# -*- coding: utf-8 -*-
from concurrent.futures import ThreadPoolExecutor, as_completed
from .repositories import ArchiveIs, InternetArchive
REPOSITORIES = (
ArchiveIs,
InternetArchive,
)
<|fim_suffix|>
def push(url, repos=REPOSITORIES, max_age=... | code_fim | medium | {
"lang": "python",
"repo": "redodo/saltaway",
"path": "/saltaway/api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def pull(url, repos=REPOSITORIES):
with ThreadPoolExecutor(MAX_WORKERS) as executor:
future_to_repo = {
executor.submit(repo().pull, url): repo
for repo in repos
}
for future in as_completed(future_to_repo):
try:
yield [futur... | code_fim | hard | {
"lang": "python",
"repo": "redodo/saltaway",
"path": "/saltaway/api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: karnatyrohit/nanomos2.5_python path: /doping.py
# A M file to specify the function that generates the doping profile
# With different overlaps and different doping gradient on the drain and source side
# By sebastien Goasguen October 2001/ Purdue
from readinput import *
import numpy as np
import... | code_fim | hard | {
"lang": "python",
"repo": "karnatyrohit/nanomos2.5_python",
"path": "/doping.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if ox_pnt_flag == 1:
Nd[(Nx*t_topa):(Nx*t_topa) + junction_l] = (N_sd-N_body)/2.0
Nd[(Nx*t_topa)+junction_l:(Nx*t_topa-Nx)+junction_r-1] = -N_body/2.0
Nd[(Nx*t_topa)+junction_r-1:(Nx*(t_topa+1))] = (N_sd-N_body)/2.0
Nd[(Ntotal-Nx*(t_bota+2)):(Ntotal-... | code_fim | hard | {
"lang": "python",
"repo": "karnatyrohit/nanomos2.5_python",
"path": "/doping.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for iii_col in np.arange(junction_r-1, Nx):
i_node = iii_row*Nx+iii_col
Nd[i_node] = N_sd-N_body
if ox_pnt_flag == 1:
Nd[(Nx*t_topa):(Nx*t_topa) + junction_l] = (N_sd-N_body)/2.0
Nd[(Nx*t_topa)+junction_l:(Nx*t_topa-Nx)+junction_... | code_fim | hard | {
"lang": "python",
"repo": "karnatyrohit/nanomos2.5_python",
"path": "/doping.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> file_processed.append(video)
out = {
'filesProcessed': file_processed,
'activities': activitys,
}
with open(args.out_file, 'w') as fout:
json.dump(out, fout, indent=2)
def main():
args = cmd_arguments()
try:
do_job(args)
except:
traceback.print_exc()
if __name__ ==... | code_fim | hard | {
"lang": "python",
"repo": "wenhel/Argus",
"path": "/code/diva_evaluation_cli/src/implementation/pipeline/merge.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print 'p1b_conv_rnn'
if os.path.exists(p1b_conv_rnn_file):
with open(p1b_conv_rnn_file) as f:
data = json.load(f)
for activity in data['activities']:
if activity['activity'] == 'Riding' or activity['activity'] == 'Interacts': ## CLASS Interacts is removed
... | code_fim | hard | {
"lang": "python",
"repo": "wenhel/Argus",
"path": "/code/diva_evaluation_cli/src/implementation/pipeline/merge.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wenhel/Argus path: /code/diva_evaluation_cli/src/implementation/pipeline/merge.py
import argparse
import os
import json
import traceback
def cmd_arguments():
parser = argparse.ArgumentParser(description='''
functions:
merge output from different models in one chunk
''',
formatter_cla... | code_fim | hard | {
"lang": "python",
"repo": "wenhel/Argus",
"path": "/code/diva_evaluation_cli/src/implementation/pipeline/merge.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>atexit.register(gpiozero_shutdown)
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
__version__ = '0.2.0'<|fim_prefix|># repo: Gadgetoid/python-gpiozero path: /gpiozero/__init__.py
from __future__ import absolute_import
import atexit
from RPi import GPIO
from .devices import (
_gpio_threads_shutdow... | code_fim | medium | {
"lang": "python",
"repo": "Gadgetoid/python-gpiozero",
"path": "/gpiozero/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Gadgetoid/python-gpiozero path: /gpiozero/__init__.py
from __future__ import absolute_import
import atexit
from RPi import GPIO
from .devices import (
_gpio_threads_shutdown,
GPIODeviceError,
GPIODevice,
)
from .input_devices import (
InputDeviceError,
InputDevice,
Butt... | code_fim | medium | {
"lang": "python",
"repo": "Gadgetoid/python-gpiozero",
"path": "/gpiozero/__init__.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # TODO
auction = Auction.objects.get(post__id=post_id)
auction.complete()
return HttpResponse([auction.post.id, auction.post.is_active])
@login_required
def write(request):
form = WritePostForm(request.POST or None, request.FILES or None)
if request.method == 'POST' and form.is_va... | code_fim | medium | {
"lang": "python",
"repo": "NA5G/coco-server-was",
"path": "/coco/posts/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NA5G/coco-server-was path: /coco/posts/views.py
# -*- coding: utf-8 -*-
from django.shortcuts import render, redirect
from django.shortcuts import render_to_response
from django.template.loader import render_to_string
from django.utils import timezone
from django.views.decorators.csrf import csr... | code_fim | hard | {
"lang": "python",
"repo": "NA5G/coco-server-was",
"path": "/coco/posts/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@login_required
def complete_deal(request, post_id=None):
# TODO
auction = Auction.objects.get(post__id=post_id)
auction.complete()
return HttpResponse([auction.post.id, auction.post.is_active])
@login_required
def write(request):
form = WritePostForm(request.POST or None, request.FIL... | code_fim | medium | {
"lang": "python",
"repo": "NA5G/coco-server-was",
"path": "/coco/posts/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Attempt to guess the filename from the URL. In the future,
# if it is required, we may have another field in the requirements.
filename = url_to_filename(url)
assert(filename is not None and len(filename) > 0)
filepath = os.path.join(dataset_dir, filename)
... | code_fim | hard | {
"lang": "python",
"repo": "ChewKokWah/DataMine",
"path": "/data_mine/zookeeper/download_center.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ChewKokWah/DataMine path: /data_mine/zookeeper/download_center.py
import os
from data_mine import Collection
from data_mine.utils import msg
from data_mine.utils import (
datamine_cache_dir,
download_file_if_missing,
extract_archive,
is_archive,
url_to_fil... | code_fim | hard | {
"lang": "python",
"repo": "ChewKokWah/DataMine",
"path": "/data_mine/zookeeper/download_center.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AddField(
model_name='question',
name='audio_asset',
field=models.FileField(blank=True, help_text='Audio asset for the given question.', null=True, upload_to=''),
),
migrations.AddField(
model_name='quest... | code_fim | medium | {
"lang": "python",
"repo": "haideralipunjabi/django_quiz",
"path": "/quiz_app/migrations/0010_auto_20170515_1020.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: haideralipunjabi/django_quiz path: /quiz_app/migrations/0010_auto_20170515_1020.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-05-15 04:50
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
<|fim_suffix|> op... | code_fim | medium | {
"lang": "python",
"repo": "haideralipunjabi/django_quiz",
"path": "/quiz_app/migrations/0010_auto_20170515_1020.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def on_draw(self):
""" Render the screen. """
# Clear the screen to the background color
self.camera.use()
#self.clear()
self.window.clear()
arcade.start_render()
self.scene.draw()
self.center_on_player()
self.gui_camera.... | code_fim | hard | {
"lang": "python",
"repo": "pyweeker/rafale",
"path": "/raf_13.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dest_x = self.crosshair_sprite.center_x
dest_y = self.crosshair_sprite.center_y
# Do math to calculate how to get the bullet to the destination.
# Calculation the angle in radians between the start points
# and end points. This is the angle the... | code_fim | hard | {
"lang": "python",
"repo": "pyweeker/rafale",
"path": "/raf_13.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pyweeker/rafale path: /raf_13.py
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class InstructionView(arcade.View):
def __init__(self):
super().__init__(... | code_fim | hard | {
"lang": "python",
"repo": "pyweeker/rafale",
"path": "/raf_13.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TimeViewers/signalworks path: /signalworks/tracking/__init__.py
# -*- coding: utf-8 -*-
import logging
from pathlib import Path
from typing import List, Optional
import numpy as np
from scipy.io.wavfile import read as wav_read
from .error import LabreadError, MultiChannelError # noqa
from .eve... | code_fim | hard | {
"lang": "python",
"repo": "TimeViewers/signalworks",
"path": "/signalworks/tracking/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if np.issubdtype(value.dtype, np.integer):
multiTrack[k].min = np.iinfo(value.dtype).min
multiTrack[k].max = np.iinfo(value.dtype).max
elif np.issubdtype(value.dtype, np.floating):
multiTrack[k].min = -1.0
multiTrack[k].max = 1.0
else... | code_fim | hard | {
"lang": "python",
"repo": "TimeViewers/signalworks",
"path": "/signalworks/tracking/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> presence. of a GigE adapter is detected, else 0.')
endptGIGESWVER = MibScalar((1, 3, 6, 1, 4, 1, 6889, 2, 69, 2, 5, 7), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: endptGIGESWVER.setStatus('current')
if mibBuilder.loadTexts: endptGIGESWVER.setDescription('GigE adapter software vers... | code_fim | hard | {
"lang": "python",
"repo": "agustinhenze/mibs.snmplabs.com",
"path": "/pysnmp-with-texts/Avaya-96xxIPTelephone-MIB.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: agustinhenze/mibs.snmplabs.com path: /pysnmp-with-texts/Avaya-96xxIPTelephone-MIB.py
('current')
if mibBuilder.loadTexts: endptWMLPROXY.setDescription('96xx Web Proxy Server. This variable returns an IP addresses, in dotted-decimal or DNS format, of an HTTP proxy server. Used by the 96xx Browser ... | code_fim | hard | {
"lang": "python",
"repo": "agustinhenze/mibs.snmplabs.com",
"path": "/pysnmp-with-texts/Avaya-96xxIPTelephone-MIB.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>MibScalar((1, 3, 6, 1, 4, 1, 6889, 2, 69, 2, 1, 75), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: endptFONT.setStatus('current')
if mibBuilder.loadTexts: endptFONT.setDescription('Font file identifier. This variable returns a text string with the name of the font file stored in the p... | code_fim | hard | {
"lang": "python",
"repo": "agustinhenze/mibs.snmplabs.com",
"path": "/pysnmp-with-texts/Avaya-96xxIPTelephone-MIB.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PyCOMPLETE/PyPIC path: /GPU/poisson_solver/poisson_solver.py
'''
Abstract base class for poisson solvers
@author Stefan Hegglin, Adrian Oeftiger
'''
from abc import ABCMeta, abstractmethod
<|fim_suffix|> '''PoissonSolver instances are prepared for a fixed parameter set
(among others a ce... | code_fim | medium | {
"lang": "python",
"repo": "PyCOMPLETE/PyPIC",
"path": "/GPU/poisson_solver/poisson_solver.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''PoissonSolver instances are prepared for a fixed parameter set
(among others a certain mesh). Given a charge distribution rho on this mesh,
a PoissonSolver solves the corresponding discrete Poisson equation
for a potential phi:
-divgrad phi = rho / epsilon_0
'''
@abstrac... | code_fim | medium | {
"lang": "python",
"repo": "PyCOMPLETE/PyPIC",
"path": "/GPU/poisson_solver/poisson_solver.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''Solve -divgrad phi = rho / epsilon_0 for the potential phi,
given as input the charge distribution rho on the mesh.
'''
pass<|fim_prefix|># repo: PyCOMPLETE/PyPIC path: /GPU/poisson_solver/poisson_solver.py
'''
Abstract base class for poisson solvers
@author Stefan Hegg... | code_fim | hard | {
"lang": "python",
"repo": "PyCOMPLETE/PyPIC",
"path": "/GPU/poisson_solver/poisson_solver.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def show_result(graph=Graph(), mode='cmd'):
node_count = node_statistic(graph)
node_count_text = 'User_number:%d\n' \
'Review_number:%d\n' \
'Product_number:%d\n' % \
(node_count[0],
node_count[1],
... | code_fim | hard | {
"lang": "python",
"repo": "imiss-opinion-spam-detection/opinion-spam-detection-for-dianping",
"path": "/compute/data.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: imiss-opinion-spam-detection/opinion-spam-detection-for-dianping path: /compute/data.py
return selection
except ValueError:
pass
print('InputError: Invalid Input\a\n')
def get_data(selection=0, table='dianpingcontent'):
"""
Usage : ... | code_fim | hard | {
"lang": "python",
"repo": "imiss-opinion-spam-detection/opinion-spam-detection-for-dianping",
"path": "/compute/data.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: imiss-opinion-spam-detection/opinion-spam-detection-for-dianping path: /compute/data.py
class
from random import randint
from time import localtime, strftime, time
from networkx import Graph
from compute.classes import User, Product, Review
def select() -> int:
while True:
... | code_fim | hard | {
"lang": "python",
"repo": "imiss-opinion-spam-detection/opinion-spam-detection-for-dianping",
"path": "/compute/data.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WilliamsRizzi/ProcessMiningUNIPD2019_20 path: /src/encoding/models.py
from enum import Enum
from django.db import models
from django.contrib.postgres.fields import JSONField
from src.clustering.models import Clustering
from src.common.models import CommonModel
from src.labelling.models import L... | code_fim | medium | {
"lang": "python",
"repo": "WilliamsRizzi/ProcessMiningUNIPD2019_20",
"path": "/src/encoding/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data_encoding = models.CharField(choices=DATA_ENCODING_MAPPINGS, default='label_encoder', max_length=max(len(el[1]) for el in DATA_ENCODING_MAPPINGS)+1)
value_encoding = models.CharField(choices=VALUE_ENCODING_MAPPINGS, default='simpleIndex', max_length=max(len(el[1]) for el in VALUE_ENCODING_MAPP... | code_fim | hard | {
"lang": "python",
"repo": "WilliamsRizzi/ProcessMiningUNIPD2019_20",
"path": "/src/encoding/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>LRIG_DATA_FOLDER = None # If None data folder will be ..\\iblrig_data from IBLRIG_FOLDER # noqa<|fim_prefix|># repo: eejd/iblrig path: /tasks/_iblrig_calibration_input_listner/task_settings.py
# =============================================================================
# TASK PARAMETER<|fim_middle|>... | code_fim | medium | {
"lang": "python",
"repo": "eejd/iblrig",
"path": "/tasks/_iblrig_calibration_input_listner/task_settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eejd/iblrig path: /tasks/_iblrig_calibration_input_listner/task_settings.py
# =============================================================================
# TASK PARAMETER<|fim_suffix|>===========================================
# IBL rig root folder
IBLRIG_FOLDER = 'C:\\iblrig'
IBLRIG_DATA_FOLD... | code_fim | medium | {
"lang": "python",
"repo": "eejd/iblrig",
"path": "/tasks/_iblrig_calibration_input_listner/task_settings.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alldatacenter/alldata path: /ai/mmdetection/tests/test_datasets/test_transforms/test_instaboost.py
import os.path as osp
import unittest
import numpy as np
from mmdet.registry import TRANSFORMS
from mmdet.utils import register_all_modules
register_all_modules()
class TestInstaboost(unittest.... | code_fim | hard | {
"lang": "python",
"repo": "alldatacenter/alldata",
"path": "/ai/mmdetection/tests/test_datasets/test_transforms/test_instaboost.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_repr(self):
instaboost_transform = TRANSFORMS.build(dict(type='InstaBoost'))
self.assertEqual(
repr(instaboost_transform), 'InstaBoost(aug_ratio=0.5)')<|fim_prefix|># repo: alldatacenter/alldata path: /ai/mmdetection/tests/test_datasets/test_transforms/test_insta... | code_fim | hard | {
"lang": "python",
"repo": "alldatacenter/alldata",
"path": "/ai/mmdetection/tests/test_datasets/test_transforms/test_instaboost.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Deepak898/flask_ishuhui path: /ishuhui/csrf.py
import binascii
import os
from flask import session
<|fim_suffix|> if '_csrf_token' not in session:
session['_csrf_token'] = binascii.b2a_hex(os.urandom(15)).decode("utf-8")
return session['_csrf_token']
app.jinja_e... | code_fim | easy | {
"lang": "python",
"repo": "Deepak898/flask_ishuhui",
"path": "/ishuhui/csrf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def generate_csrf_token():
if '_csrf_token' not in session:
session['_csrf_token'] = binascii.b2a_hex(os.urandom(15)).decode("utf-8")
return session['_csrf_token']
app.jinja_env.globals['csrf_token'] = generate_csrf_token<|fim_prefix|># repo: Deepak898/flask_ishuhui p... | code_fim | easy | {
"lang": "python",
"repo": "Deepak898/flask_ishuhui",
"path": "/ishuhui/csrf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ricardobonna/python-MoC path: /MoC/SDF.py
"""
Author: Ricardo Bonna
Creation date: 22/may/2018
Module description: This module provides the class Actor for creating
SDF actors.
"""
from MoC_Core import *
class Actor(Process):
"""
The Actor class is used to create SDF actors.
"""
... | code_fim | hard | {
"lang": "python",
"repo": "ricardobonna/python-MoC",
"path": "/MoC/SDF.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return [[a[0][0]+a[0][1], a[0][0]-a[0][2]]]
# Process definition
proc = Actor([3], [2], func_test, [q1], [q2])
proc.start()
for i in range(6):
q1.put(i+1)
print(q2.get())
print(q2.get())
print(q2.get())
print(q2.get())
proc.terminate()<|fim_prefix|># r... | code_fim | hard | {
"lang": "python",
"repo": "ricardobonna/python-MoC",
"path": "/MoC/SDF.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Source of land data
source = self.get_topo(url)
case_type = st.selectbox(
"Case type", ["confirmed", "recovered", "dead"], 0, key="case_type_map"
)
st.header(f"Countries contribution rate to {case_type} cases")
global_cases = get_global_case... | code_fim | hard | {
"lang": "python",
"repo": "alesanmed-educational-projects/core-data-covid-project",
"path": "/dashboard/app/src/pages/general_data.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alesanmed-educational-projects/core-data-covid-project path: /dashboard/app/src/pages/general_data.py
from datetime import datetime
from typing import List
import altair as alt
import pandas as pd
import streamlit as st
from streamlit.delta_generator import DeltaGenerator
from ..charts import b... | code_fim | hard | {
"lang": "python",
"repo": "alesanmed-educational-projects/core-data-covid-project",
"path": "/dashboard/app/src/pages/general_data.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> st.header("Global cases by country")
cols: List[DeltaGenerator] = st.columns(2)
rank_num = int(
cols[0].number_input(
"Top N countries",
0,
len(countries) or len(all_countries),
len(countries) or min(len(... | code_fim | hard | {
"lang": "python",
"repo": "alesanmed-educational-projects/core-data-covid-project",
"path": "/dashboard/app/src/pages/general_data.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: torico-tokyo/python-phone-number-jp path: /phone_number_jp/prefix_numbers.py
# flake8: NOQA
phone_number_prefixes = {3: {'042', '075', '078', '058', '089', '026', '048', '073', '053', '017', '028', '050', '096', '082', '086', '025', '027', '088', '077', '047', '087', '084', '020', '029', '052', '... | code_fim | hard | {
"lang": "python",
"repo": "torico-tokyo/python-phone-number-jp",
"path": "/phone_number_jp/prefix_numbers.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> '0285', '0875', '0884', '0974', '0226', '0297', '0598', '0994', '0428', '0986', '0547', '0895', '0185', '0172', '0439', '0594', '0889', '0123', '0564', '0198', '0768', '0795', '0865', '0982', '0183', '0256', '0947', '0493', '0966', '0893', '0158', '0766', '0157', '0422', '0467', '0134', '0291', '0956', '... | code_fim | hard | {
"lang": "python",
"repo": "torico-tokyo/python-phone-number-jp",
"path": "/phone_number_jp/prefix_numbers.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return 1
def parse_args():
parser = argparse.ArgumentParser(
description='Creates or updates a CloudFormation stack')
parser.add_argument('-c', '--create', action='store_true')
parser.add_argument('-t', '--template',
choices=[
'... | code_fim | hard | {
"lang": "python",
"repo": "skyer9/CloudFormationForPython",
"path": "/cfn.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: skyer9/CloudFormationForPython path: /cfn.py
#!/usr/bin/env python
import argparse
import boto
import boto.s3
import boto.cloudformation
from configuration import (
stack_base_name,
region_name,
)
def cfn_connect(region_name_to_connect):
return boto.cloudformation.connect_to_region... | code_fim | hard | {
"lang": "python",
"repo": "skyer9/CloudFormationForPython",
"path": "/cfn.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if template_name == 'cluster':
from templates import cluster as template
cfn_create(cfn_conn, stack_name, template.get(), capabilities=['CAPABILITY_IAM'])
return 0
if template_name == 'ecs':
from templates import ecs as template
cfn_create(cfn_conn, stack_n... | code_fim | hard | {
"lang": "python",
"repo": "skyer9/CloudFormationForPython",
"path": "/cfn.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: google/uncertainty-baselines path: /uncertainty_baselines/datasets/tfds/tfds_builder_from_sql_client_data.py
# coding=utf-8
# Copyright 2023 The Uncertainty Baselines Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with... | code_fim | hard | {
"lang": "python",
"repo": "google/uncertainty-baselines",
"path": "/uncertainty_baselines/datasets/tfds/tfds_builder_from_sql_client_data.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self._cd.client_ids
def _load_sql_client_data_metadata(database_filepath: str) -> pd.DataFrame:
"""Load the metadata from a SqlClientData database.
This function will first fetch the SQL database to a local temporary
directory if `database_filepath` is a remote directory.
Args:
... | code_fim | hard | {
"lang": "python",
"repo": "google/uncertainty-baselines",
"path": "/uncertainty_baselines/datasets/tfds/tfds_builder_from_sql_client_data.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # @param key is from mapper
# @param values is a set of value with the same key
def reducer(self, key, values):
# Please use 'yield key, value' here
yield key, list(values)<|fim_prefix|># repo: RideGreg/LintCode path: /Python/anagram-map-reduce.py
'''
Use Map Reduce to find an... | code_fim | hard | {
"lang": "python",
"repo": "RideGreg/LintCode",
"path": "/Python/anagram-map-reduce.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RideGreg/LintCode path: /Python/anagram-map-reduce.py
'''
Use Map Reduce to find anagrams in a given list of words.
Example:
Given ["lint", "intl", "inlt", "code"], return ["lint", "inlt", "intl"],["code"].
Given ["ab", "ba", "cd", "dc", "e"], return ["ab", "ba"], ["cd", "dc"], ["e"].
'''
<|fi... | code_fim | hard | {
"lang": "python",
"repo": "RideGreg/LintCode",
"path": "/Python/anagram-map-reduce.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def write_to_file(file_name, solution):
file_handle = open(file_name, 'w')
file_handle.write(solution)
def main():
# create a parser object
parser = ap.ArgumentParser()
# specify what arguments will be coming from the terminal/commandline
parser.add_argument("input_file_name"... | code_fim | hard | {
"lang": "python",
"repo": "chenwenhang/AlgorithmPractice",
"path": "/src/special/planpath.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chenwenhang/AlgorithmPractice path: /src/special/planpath.py
ing tends to degrade when the map is large, here I take the priority queue
to improve the performance. I use heapq and rewrite __lt__ function
"""
if self.f_value < other.f_value:
return -1
el... | code_fim | hard | {
"lang": "python",
"repo": "chenwenhang/AlgorithmPractice",
"path": "/src/special/planpath.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chenwenhang/AlgorithmPractice path: /src/special/planpath.py
#################################################
# You can run this code from terminal by executing the following command
# python planpath.py <INPUT/input#.txt> <OUTPUT/output#.txt> <flag>
# for example: python planpath.py INP... | code_fim | hard | {
"lang": "python",
"repo": "chenwenhang/AlgorithmPractice",
"path": "/src/special/planpath.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # print(inputs[0].shape) # torch.Size([8, 42])
# print(targets.shape) # torch.Size([8, 42])
margin = 3
samples_i = []
samples_i_label = []
# print(features.shape) # torch.Size([8, 64])
targets = targets.cpu()
for i in range(4):
samples_i.append(tor... | code_fim | medium | {
"lang": "python",
"repo": "Adherer/CIKM-Improved-Work",
"path": "/code/unit_test_experiment/test_for_margin_loss.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Adherer/CIKM-Improved-Work path: /code/unit_test_experiment/test_for_margin_loss.py
import torch
import torch.nn.functional as F
import numpy as np
import random
# 这里有待验证一下
def margin_regularization_1(targets, features, LAMBDA):
graph_source = torch.sum(targets[:, None, :] * targets[None, :,... | code_fim | hard | {
"lang": "python",
"repo": "Adherer/CIKM-Improved-Work",
"path": "/code/unit_test_experiment/test_for_margin_loss.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> samples_i = torch.stack(samples_i, 0)
samples_i_label = torch.stack(samples_i_label, 0)
# print(samples_i.shape) # torch.Size([8, 8, 42])
# print(samples_i_label.shape) # torch.Size([8, 8])
samples_j = torch.stack([features for _ in range(4)], 0) # 大x_j
samples_j_label = ... | code_fim | hard | {
"lang": "python",
"repo": "Adherer/CIKM-Improved-Work",
"path": "/code/unit_test_experiment/test_for_margin_loss.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> op = fields.Str(required=True)
path = fields.Str(required=True)
value = fields.Raw()
class BaseDataEndpointResponse(Schema):
id = fields.Str()
name = fields.Str()
description = fields.Str()
created_at = fields.DateTime()
user_id = fields.Int()
data_hash = fields.Str()... | code_fim | hard | {
"lang": "python",
"repo": "pchtsp/cornflow-server",
"path": "/cornflow/schemas/common.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pchtsp/cornflow-server path: /cornflow/schemas/common.py
"""
File with the common schemas used in cornflow
"""
from marshmallow import fields, Schema
<|fim_suffix|> limit = fields.Int(required=False, default=20)
offset = fields.Int(required=False, default=0)
creation_date_gte = field... | code_fim | medium | {
"lang": "python",
"repo": "pchtsp/cornflow-server",
"path": "/cornflow/schemas/common.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jpmjim/CIntermedioPython path: /2list_comprenhensions.py
def run():
# List normal
squares1 = []
for i in range(1, 101):
if i % 3 != 0:
squares1.append(i**2)
print(squares1)
# List comprehensions
squares = [i**2 for i in range(1, 101) if i % 3 != 0... | code_fim | medium | {
"lang": "python",
"repo": "jpmjim/CIntermedioPython",
"path": "/2list_comprenhensions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Reto divisibles de 4 6 y 9
squares2 = [i for i in range(1, 1000) if i % 36 == 0]
print(squares2)
# solución del reto
my_list = [i for i in range(1, 100000) if i % 4 == 0 and i % 6 == 0 and i % 9 == 0]
print(my_list)
if __name__ == "__main__":
run()<|fim_prefix|># repo: jpm... | code_fim | medium | {
"lang": "python",
"repo": "jpmjim/CIntermedioPython",
"path": "/2list_comprenhensions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>FUNCTION_NAME_MAIN: str = '____phpytex_main';
FUNCTION_NAME_FILE: str = '____phpytex_generate_file';
FUNCTION_NAME_PRE: str = '____phpytex_generate_pre';<|fim_prefix|># repo: RLogik/phpytex path: /src/setup/templates/exports.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
<|fim_middle|># ~~~~~~~~~~~~... | code_fim | medium | {
"lang": "python",
"repo": "RLogik/phpytex",
"path": "/src/setup/templates/exports.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RLogik/phpytex path: /src/setup/templates/exports.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
<|fim_suffix|>FUNCTION_NAME_MAIN: str = '____phpytex_main';
FUNCTION_NAME_FILE: str = '____phpytex_generate_file';
FUNCTION_NAME_PRE: str = '____phpytex_generate_pre';<|fim_middle|># ~~~~~~~~~~~~... | code_fim | medium | {
"lang": "python",
"repo": "RLogik/phpytex",
"path": "/src/setup/templates/exports.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: millerbest/zero_to_docs path: /sphinx_template/my_package/viz.py
import numpy as np
import matplotlib.pyplot as plt
<|fim_suffix|> """Plot some random dots"""
if ax is None:
fig, ax = plt.subplots()
if cmap is None:
cmap = plt.cm.viridis
dots = np.random.randn(2, ... | code_fim | easy | {
"lang": "python",
"repo": "millerbest/zero_to_docs",
"path": "/sphinx_template/my_package/viz.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Plot some random dots"""
if ax is None:
fig, ax = plt.subplots()
if cmap is None:
cmap = plt.cm.viridis
dots = np.random.randn(2, N)
size = dots * scale
ax.scatter(*dots, s=size, cmap=cmap)
return ax<|fim_prefix|># repo: millerbest/zero_to_docs path: /sphinx... | code_fim | easy | {
"lang": "python",
"repo": "millerbest/zero_to_docs",
"path": "/sphinx_template/my_package/viz.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> W = self.linearReg.main(self.X3, self.y3)
boolean_array = np.isclose(W, self.W3_correct, atol=0.1)
self.assertTrue(boolean_array.all())
def test_zeros(self):
W = self.linearReg.main(self.X4, self.y4)
boolean_array = np.isclose(W, self.W4_correct, atol=0.1)
... | code_fim | medium | {
"lang": "python",
"repo": "aladdinpersson/Machine-Learning-Collection",
"path": "/ML_tests/LinearRegression_tests/LinearRegression_GD.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aladdinpersson/Machine-Learning-Collection path: /ML_tests/LinearRegression_tests/LinearRegression_GD.py
# Import folder where sorting algorithms
import sys
import unittest
import numpy as np
# For importing from different folders
# OBS: This is supposed to be done with automated testing,
# henc... | code_fim | hard | {
"lang": "python",
"repo": "aladdinpersson/Machine-Learning-Collection",
"path": "/ML_tests/LinearRegression_tests/LinearRegression_GD.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: phamhuuhuyhoang/ImageClassifier path: /predict.py
import argparse
import json
import torch
import numpy as np
from torchvision import models
from PIL import Image
def process_image(image_path):
im = Image.open(image_path)
if im.height > im.width:
(width,height) = 256,im.hei... | code_fim | hard | {
"lang": "python",
"repo": "phamhuuhuyhoang/ImageClassifier",
"path": "/predict.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>parser = argparse.ArgumentParser() # create a new argument parser
parser.add_argument('input',
help="path to input images") # specify path to input images
parser.add_argument('checkpoint',
help="model checkpoint") # specify a checkpoint for pretrained model
parser.... | code_fim | hard | {
"lang": "python",
"repo": "phamhuuhuyhoang/ImageClassifier",
"path": "/predict.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># define the hardware device to run the analysis
if args.gpu: # if gpu is specified
if torch.cuda.is_available(): # check if gpu is available
device = torch.device("cuda")
else:
device = torch.device("cpu") # fall back to cpu and print a warning
print("WARNING : gpu specif... | code_fim | hard | {
"lang": "python",
"repo": "phamhuuhuyhoang/ImageClassifier",
"path": "/predict.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>color = [-1] * (N + 1)
color[1] = 0
que = deque()
que.append(1)
while que:
v = que.popleft()
for u in Graph[v]:
if color[u] != -1:
continue
color[u] = (color[v] + 1) % 2
que.append(u)
for _ in range(Q):
c, d = MI()
if color[c] == color[d]:
print... | code_fim | medium | {
"lang": "python",
"repo": "NULLCT/LOMC",
"path": "/src/data/696.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NULLCT/LOMC path: /src/data/696.py
from collections import deque
LI = lambda: list(map(int, input().split()))
LS = lambda: list(map(str, input().split()))
MI = lambda: map(int, input().split())
MS = lambda: map(str, input().split())
<|fim_suffix|>for _ in range(Q):
c, d = MI()
if color[... | code_fim | hard | {
"lang": "python",
"repo": "NULLCT/LOMC",
"path": "/src/data/696.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ecohealthalliance/geoname-annotator-training path: /expand_geonames.py
from epitator.get_database_connection import get_database_connection
from collections import defaultdict
import sqlite3
import os
EXPAND_GEONAMES = False
EXPANDED_GEONAME_DB_PATH = ".geoname_expansions.sqlitedb"
if EXPAND_G... | code_fim | hard | {
"lang": "python",
"repo": "ecohealthalliance/geoname-annotator-training",
"path": "/expand_geonames.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> epitator_connection = get_database_connection()
epitator_connection.row_factory = sqlite3.Row
epitator_cursor = epitator_connection.cursor()
# ADM geonames are considered equivalent to the geonames they directly contain
# (have matching adm[1-4] properties) and sha... | code_fim | hard | {
"lang": "python",
"repo": "ecohealthalliance/geoname-annotator-training",
"path": "/expand_geonames.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FairyDevicesRD/statistical-quality-estimation path: /optimize.py
asible=True,
)
"""
m = np.identity(n_class)
m = np.vstack([m, np.ones(n_class)])
lb = [epsilon] * n_class
lb.append(1.0)
ub = [1.0 - epsilon] * n_class
ub.append(1.0)
c = scipy.optimize.LinearCo... | code_fim | hard | {
"lang": "python",
"repo": "FairyDevicesRD/statistical-quality-estimation",
"path": "/optimize.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FairyDevicesRD/statistical-quality-estimation path: /optimize.py
ze)(
artifact_id,
log_penalty,
qs_init[artifact_id],
args=(a, bs, ys, config),
method="trust-constr",
jac="2-point",
hess=scipy.optimize.BFGS(),
... | code_fim | hard | {
"lang": "python",
"repo": "FairyDevicesRD/statistical-quality-estimation",
"path": "/optimize.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.