text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: magnickolas/formal-grammars path: /formal_grammars/grammar.py
from collections import defaultdict
from collections import namedtuple
from typing import NewType
from typing import Union
import yaml
## TYPES
class Rule(namedtuple("Rule", ["left", "right"])):
__slots__ = ()
def __repr__... | code_fim | hard | {
"lang": "python",
"repo": "magnickolas/formal-grammars",
"path": "/formal_grammars/grammar.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def parse_rules(s):
left, right = map(lambda x: "".join(x.split()), s.split(RULE_SEPARATOR))
right_parts = map(
lambda x: "".join(x.split()), right.split(RULE_RIGHT_PARTS_SEPARATOR)
)
return [Rule(left=left, right=right) for right in right_parts]
EMPTY = Grammar["empty"]
LAST = "... | code_fim | hard | {
"lang": "python",
"repo": "magnickolas/formal-grammars",
"path": "/formal_grammars/grammar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LyonLee190/StringPullingMonitorLite path: /app/home/hardware_manager.py
# Need to install advpistepper (have to be install by python setup.py) & hx711 (pip)
import subprocess
import logging
import pigpio
from hx711 import HX711
import sys
from Motor import ULN2003
import busio
import digitalio
i... | code_fim | hard | {
"lang": "python",
"repo": "LyonLee190/StringPullingMonitorLite",
"path": "/app/home/hardware_manager.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> else:
# speed not equals to 0, run the motor with speed
self.run_motor()
speed.value = self.speed
s.value = self.speed
time.sleep(0.25)
if self.distance.value >= steps:
break
# job... | code_fim | hard | {
"lang": "python",
"repo": "LyonLee190/StringPullingMonitorLite",
"path": "/app/home/hardware_manager.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fig, ax = plt.subplots()
plt.title(title)
ax.plot(numbers, data, label='steps')
ax.plot(numbers, time_comp, dashes=[6, 2], label='time complexity')
ax.legend()
plt.show()
if __name__ == '__main__':
print(random_list(1024))<|fim_prefix|># repo: oierajenjo/q-Grover-Algorithm ... | code_fim | medium | {
"lang": "python",
"repo": "oierajenjo/q-Grover-Algorithm",
"path": "/algorithm_comparison/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(0, n):
numbers.append(2 ** i)
fig, ax = plt.subplots()
plt.title(title)
ax.plot(numbers, data, label='steps')
ax.plot(numbers, time_comp, dashes=[6, 2], label='time complexity')
ax.legend()
plt.show()
if __name__ == '__main__':
print(random_list(... | code_fim | medium | {
"lang": "python",
"repo": "oierajenjo/q-Grover-Algorithm",
"path": "/algorithm_comparison/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: oierajenjo/q-Grover-Algorithm path: /algorithm_comparison/utils.py
import random
import matplotlib.pyplot as plt
def random_list(size):
<|fim_suffix|> numbers = []
for i in range(0, n):
numbers.append(2 ** i)
fig, ax = plt.subplots()
plt.title(title)
ax.plot(numbe... | code_fim | medium | {
"lang": "python",
"repo": "oierajenjo/q-Grover-Algorithm",
"path": "/algorithm_comparison/utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@crawl_tasks.route('', methods=['POST'])
@use_args(create_crawl_task_schema, locations=('json',))
def create_crawl_task(args):
"""
创建爬虫任务
:param args:
:return:
"""
crawl_task_biz = CrawlTaskBiz()
data = crawl_task_biz.create_crawl_task(**args)
return jsonify({
'sta... | code_fim | medium | {
"lang": "python",
"repo": "turnsgreen/crawloop",
"path": "/services/spider/webs/api/views/crawl_tasks.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
创建爬虫任务
:param args:
:return:
"""
crawl_task_biz = CrawlTaskBiz()
data = crawl_task_biz.create_crawl_task(**args)
return jsonify({
'status': True,
'data': data
}), 201<|fim_prefix|># repo: turnsgreen/crawloop path: /services/spider/webs/api/views/cr... | code_fim | medium | {
"lang": "python",
"repo": "turnsgreen/crawloop",
"path": "/services/spider/webs/api/views/crawl_tasks.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: turnsgreen/crawloop path: /services/spider/webs/api/views/crawl_tasks.py
# -*- coding: utf-8 -*-
from flask import Blueprint, jsonify
from webargs.flaskparser import use_args
from webs.api.bizs.crawl_task import CrawlTaskBiz
from webs.api.schemas.crawl_tasks import create_crawl_task_schema
<|f... | code_fim | hard | {
"lang": "python",
"repo": "turnsgreen/crawloop",
"path": "/services/spider/webs/api/views/crawl_tasks.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> rm = Modification()
assert Modification.is_zero(rm) == True
rm.angle = 1.
assert Modification.is_zero(rm) == False
rm = Modification()
assert Modification.is_zero(rm) == True
rm.offset = Point(1., 0., 0.)
assert Modification.is_zero(rm) ==... | code_fim | hard | {
"lang": "python",
"repo": "HuaiLeiTang/rosweld_tools",
"path": "/src/tests/test_bead.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HuaiLeiTang/rosweld_tools path: /src/tests/test_bead.py
from ..rosweld.bead import Bead
from ..rosweld.point import Point
from ..rosweld.modification import Modification
from ..rosweld.weldingstate import WeldingState
class TestBead(object):
def test_init(self):
b1 = Bead(None, {}, {... | code_fim | hard | {
"lang": "python",
"repo": "HuaiLeiTang/rosweld_tools",
"path": "/src/tests/test_bead.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ws = WeldingState()
ws.amperage = 111.
rm.welding_parameters = ws
assert Modification.is_zero(rm) == False
rm = Modification()
assert Modification.is_zero(rm) == True
rm.angle = 1.
assert Modification.is_zero(rm) == False
rm = Modi... | code_fim | hard | {
"lang": "python",
"repo": "HuaiLeiTang/rosweld_tools",
"path": "/src/tests/test_bead.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: uptick/gitops path: /gitops/utils/cli.py
from colorama import Fore
def colourise(value, colour, condition=None):
"""Colour a piece of text. If a condition callback is passed in, the text will only be
coloured if the condition is met.
"""
if condition is not None:
if not ... | code_fim | medium | {
"lang": "python",
"repo": "uptick/gitops",
"path": "/gitops/utils/cli.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def confirm_dangerous_command():
message = (
"You are about to execute a dangerous command against a"
f" {colourise('production' , Fore.RED)} environment. Please ensure you are pairing with"
" someone else."
)
# TODO. Include an actual multi person MFA to proceed.
... | code_fim | hard | {
"lang": "python",
"repo": "uptick/gitops",
"path": "/gitops/utils/cli.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cieske/exercises path: /Beakjoon/1316.py
n = int(input())
x = []
for i in range(n):
s = str(input())
d <|fim_suffix|> s = s[num:]
if d:
x.append(1)
print(x)
print(x.count(1))<|fim_middle|>= True
while len(s) != 0:
num = s.count(s[0])
if s[:num].count(s[0]... | code_fim | medium | {
"lang": "python",
"repo": "cieske/exercises",
"path": "/Beakjoon/1316.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> s = s[num:]
if d:
x.append(1)
print(x)
print(x.count(1))<|fim_prefix|># repo: cieske/exercises path: /Beakjoon/1316.py
n = int(input())
x = []
for i in range(n):
s = str(input())
d <|fim_middle|>= True
while len(s) != 0:
num = s.count(s[0])
if s[:num].count(s[0]... | code_fim | medium | {
"lang": "python",
"repo": "cieske/exercises",
"path": "/Beakjoon/1316.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: finalwee/Cloudia path: /core/tool.py
import os
import subprocess
import numpy as np
from cv2 import cv2
import time
class adbKit():
def __init__(self, device, NOX=False, debug=False) -> None:
self.path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
self.debug ... | code_fim | hard | {
"lang": "python",
"repo": "finalwee/Cloudia",
"path": "/core/tool.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def load_template(self, img_path, template_list):
imgs = []
for template in template_list:
img = os.path.join(img_path, template)
imgs.append(self.cv_read(img))
return imgs
def compare(self, img_list, gach=False, acc=0.85):
imgs = []
... | code_fim | hard | {
"lang": "python",
"repo": "finalwee/Cloudia",
"path": "/core/tool.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lemonnader/LeetCode-Solution-Well-Formed path: /hash-table/Python/0454-4sum-ii-2.py
from typing import List
class Solution:
def fourSumCount(self, A: List[int], B: List[int], C: List[int], D: List[int]) -> int:
<|fim_suffix|> res = 0
for num1 in A:
for num2 in B:
... | code_fim | hard | {
"lang": "python",
"repo": "lemonnader/LeetCode-Solution-Well-Formed",
"path": "/hash-table/Python/0454-4sum-ii-2.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> res = 0
for num1 in A:
for num2 in B:
s = num1 + num2
if -s in hash_map:
res += hash_map[-s]
return res<|fim_prefix|># repo: lemonnader/LeetCode-Solution-Well-Formed path: /hash-table/Python/0454-4sum-ii-2.py
from typ... | code_fim | hard | {
"lang": "python",
"repo": "lemonnader/LeetCode-Solution-Well-Formed",
"path": "/hash-table/Python/0454-4sum-ii-2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cctbx/cctbx_project path: /mmtbx/command_line/map_to_structure_factors.py
from __future__ import absolute_import, division, print_function
# LIBTBX_SET_DISPATCHER_NAME phenix.map_to_structure_factors
import iotbx.ccp4_map
from cctbx.array_family import flex
import mmtbx.utils
import sys
from lib... | code_fim | hard | {
"lang": "python",
"repo": "cctbx/cctbx_project",
"path": "/mmtbx/command_line/map_to_structure_factors.py",
"mode": "psm",
"license": "BSD-3-Clause-LBNL",
"source": "the-stack-v2"
} |
<|fim_suffix|> # shift_cart is shift away from (0,0,0)
if new_origin != (0,0,0,):
shift_cart=get_shift_cart(map_data=mm.map_data(), crystal_symmetry=mm.crystal_symmetry(),
origin=new_origin)
else:
shift_cart=(0,0,0,)
# Shift the map data if necessary
mm.shift_origin()
f_obs_cmpl = mm.map_as_f... | code_fim | hard | {
"lang": "python",
"repo": "cctbx/cctbx_project",
"path": "/mmtbx/command_line/map_to_structure_factors.py",
"mode": "spm",
"license": "BSD-3-Clause-LBNL",
"source": "the-stack-v2"
} |
<|fim_suffix|>class RegistrationForm(UserCreationForm): # extending from superclass
email = forms.EmailField(required=True)
# define meta data
class Meta:
model = User
fields = (
'username',
'first_name',
'last_name',
'email',
'p... | code_fim | hard | {
"lang": "python",
"repo": "MFOSSociety/NSP",
"path": "/accounts/forms.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = User
fields = (
'username',
'first_name',
'last_name',
'email',
'password1',
'password2'
)
def __init__(self, *args, **kwargs):
super(RegistrationForm, self).__init__(*args, **kwargs)
... | code_fim | hard | {
"lang": "python",
"repo": "MFOSSociety/NSP",
"path": "/accounts/forms.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MFOSSociety/NSP path: /accounts/forms.py
from django import forms
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from accounts.models import (
Skill,
UserProfile,
User,
)
class ImageFileUploadForm(forms.ModelForm):
class Meta:
model = UserProfile... | code_fim | hard | {
"lang": "python",
"repo": "MFOSSociety/NSP",
"path": "/accounts/forms.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gurizab/NAS_Predictors path: /naslib/search_spaces/nasbench101/graph.py
import os
import pickle
import numpy as np
import copy
import random
import torch
import torch.nn as nn
from naslib.search_spaces.core import primitives as ops
from naslib.search_spaces.core.graph import Graph, EdgeData
from... | code_fim | hard | {
"lang": "python",
"repo": "gurizab/NAS_Predictors",
"path": "/naslib/search_spaces/nasbench101/graph.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> random.shuffle(nbhd)
return nbhd
def get_type(self):
return 'nasbench101'
def _set_node_ops(current_edge_data, C):
ops = [
ReLUConvBN(C, C, kernel_size=1),
# ops.Zero(stride=1), #! recheck about the hardcoded second operation
ReLUConvBN(C, C... | code_fim | hard | {
"lang": "python",
"repo": "gurizab/NAS_Predictors",
"path": "/naslib/search_spaces/nasbench101/graph.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> wait_on_job(jobids)
if __name__=='__main__':
import sys
input = sys.argv[1]
commands = ['qsub -v input=%s blat_job.sh' % (input)]
print commands
launch_job(commands)<|fim_prefix|># repo: RobinQi/BioUtils path: /qsub.py
'''The code is a modified version of cluster_utils.py
from M... | code_fim | hard | {
"lang": "python",
"repo": "RobinQi/BioUtils",
"path": "/qsub.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RobinQi/BioUtils path: /qsub.py
'''The code is a modified version of cluster_utils.py
from MISO package.
'''
import time
import subprocess
def check_job(jobid):
'''Returns True is a job is finished,
otherwise False.
'''
output = subprocess.Popen('qstat %i' %(jobid),
... | code_fim | hard | {
"lang": "python",
"repo": "RobinQi/BioUtils",
"path": "/qsub.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = obj.findRuntime(values, params)
# print( "RESULT: ", result )
return result
x = np.array([point[f'p{i}'] for i in range(len(point))])
results = plopper_func(x)
print('OUTPUT:%f',results)
return results
Problem = TuningProblem(
task_space=None,
input_space=input_space... | code_fim | hard | {
"lang": "python",
"repo": "E4S-Project/testsuite",
"path": "/validation_tests/llvm/SOLLVE/pragmas/tau-module/adi/problem.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: E4S-Project/testsuite path: /validation_tests/llvm/SOLLVE/pragmas/tau-module/adi/problem.py
import numpy as np
from numpy import abs, cos, exp, mean, pi, prod, sin, sqrt, sum
from autotune import TuningProblem
from autotune.space import *
import os
import sys
import time
import json
import math
... | code_fim | hard | {
"lang": "python",
"repo": "E4S-Project/testsuite",
"path": "/validation_tests/llvm/SOLLVE/pragmas/tau-module/adi/problem.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def plopper_func(x):
x = np.asarray_chkfinite(x) # ValueError if any NaN or Inf
values = [ point[k] for k in x1 ]
print('VALUES:',point[x1[0]])
# params = ["P0","P1","P2","P3","L0","L1","L2","L3","L4","L5","L6","L7"]
params = ["P0","P1","P2","P3","L0","L1"]
# params = ["P0","P1"... | code_fim | hard | {
"lang": "python",
"repo": "E4S-Project/testsuite",
"path": "/validation_tests/llvm/SOLLVE/pragmas/tau-module/adi/problem.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.mode == "STUDENT_INFO":
pass
elif self.mode == "COURSEWORK":
self.base.change_state(CombatState)
elif self.mode == "OPTIONS":
pass
elif self.mode == "QUIT":
sys.exit()
def escape(self):
if self.mode is not None:
super(LobbyState, self).escape()
self.ui_selecti... | code_fim | hard | {
"lang": "python",
"repo": "Moguri/odin",
"path": "/src/main.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Moguri/odin path: /src/main.py
import sys
import os
os.environ['PANDA_PRC_DIR'] = os.path.join(os.path.dirname(__file__), 'etc')
# This import should be kept near the top to avoid issues with CEF/Chromium hooking malloc
from cefpanda import CEFPanda
from direct.showbase.ShowBase import ShowB... | code_fim | hard | {
"lang": "python",
"repo": "Moguri/odin",
"path": "/src/main.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: princesinghtomar/Classic-Brick-Breaker path: /fire.py
from headerfile import *
from items import *
from inherit_brick import *
from bricks import *
class fire:
def __init__(self,x,y):
self.cur_x = x
self.cur_y = y
self.initial_x = x
self.initial_y = y
... | code_fim | hard | {
"lang": "python",
"repo": "princesinghtomar/Classic-Brick-Breaker",
"path": "/fire.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #flag = True , draw otherwise clear
def fdraw(self,screen_array,flag):
if(self.alive):
if(flag):
screen_array[self.cur_x][self.cur_y] = '.'
else:
screen_array[self.cur_x][self.cur_y] = ' '<|fim_prefix|># repo: princesinghtomar/Classi... | code_fim | hard | {
"lang": "python",
"repo": "princesinghtomar/Classic-Brick-Breaker",
"path": "/fire.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pncnmnp/Movie-Recommendation path: /fetch_posters.py
from file_paths import *
import pandas as pd
import requests
from PIL import Image
import time
import os
<|fim_suffix|>for i in range(0, 45466):
if os.path.exists("./flask/static/posters/" + poster_df["id"][i] + ".jpg"):
if int(poster_df["i... | code_fim | hard | {
"lang": "python",
"repo": "pncnmnp/Movie-Recommendation",
"path": "/fetch_posters.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>poster_df = pd.read_csv(PATH_POSTERS)
poster_df["poster_path"] = POSTER_BASE_URL + poster_df["poster_path"]
movie_ids = pd.read_csv(PATH_MOVIES)["id"].tolist()
for i in range(0, 45466):
if os.path.exists("./flask/static/posters/" + poster_df["id"][i] + ".jpg"):
if int(poster_df["id"][i]) in movie_ids... | code_fim | medium | {
"lang": "python",
"repo": "pncnmnp/Movie-Recommendation",
"path": "/fetch_posters.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@router.get('/cars', response_model=list[CarRead])
async def get_cars(session: AsyncSession = Depends(get_session)) -> list[Car]:
"""
List all cars in the database
"""
result = await session.execute(select(Car))
return [Car(name=car.name, manufacturer=car.manufacturer, id=car.id) for c... | code_fim | medium | {
"lang": "python",
"repo": "daniwk/templates",
"path": "/fastapi/{{ cookiecutter.project_name }}/app/api/api_v1/endpoints/cars.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: daniwk/templates path: /fastapi/{{ cookiecutter.project_name }}/app/api/api_v1/endpoints/cars.py
from fastapi import APIRouter, Depends
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
<|fim_suffix|>@router.post('/cars', response_model=CarRead)
async def add_car(car:... | code_fim | hard | {
"lang": "python",
"repo": "daniwk/templates",
"path": "/fastapi/{{ cookiecutter.project_name }}/app/api/api_v1/endpoints/cars.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Leterax/code-jam-6 path: /wandering-warriors/modules/operations.py
from kivy.uix.widget import Widget
from kivy.uix.image import Image
<|fim_suffix|> return f'assets/graphics/{operation}.png'
def send_operation(self, operation: str) -> None:
img_source = self.button_image(op... | code_fim | medium | {
"lang": "python",
"repo": "Leterax/code-jam-6",
"path": "/wandering-warriors/modules/operations.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> img_source = self.button_image(operation)
self.parent.children[2].add_middle(Image(source=img_source))<|fim_prefix|># repo: Leterax/code-jam-6 path: /wandering-warriors/modules/operations.py
from kivy.uix.widget import Widget
from kivy.uix.image import Image
<|fim_middle|>class Operatio... | code_fim | medium | {
"lang": "python",
"repo": "Leterax/code-jam-6",
"path": "/wandering-warriors/modules/operations.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rohit-shekhar26/py4e path: /code/pagerank/sprank.py
import sqlite3
conn = sqlite3.connect('spider.sqlite')
cur = conn.cursor()
# Βρείτε τα αναγνωριστικά που στέλνουν την κατάταξη σελίδων - μας ενδιαφέρουν
# μόνο οι σελίδες στο SCC που έχουν συνδέσμους εισόδου και εξόδου
cur.execute('''S... | code_fim | hard | {
"lang": "python",
"repo": "rohit-shekhar26/py4e",
"path": "/code/pagerank/sprank.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # rotate
prev_ranks = next_ranks
# Τοποθέτηση ξανά των τελικών βαθμολογιών στη βάση δεδομένων
print(list(next_ranks.items())[:5])
cur.execute('''UPDATE Pages SET old_rank=new_rank''')
for (id, new_rank) in list(next_ranks.items()) :
cur.execute('''UPDATE Pages SET new_rank=? WHERE id=?... | code_fim | hard | {
"lang": "python",
"repo": "rohit-shekhar26/py4e",
"path": "/code/pagerank/sprank.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yosef-gao/aqidatapuller path: /bin/data_puller.py
import urllib2
import json
import socket
import re
class DataPuller(object):
# URL = 'http://aqicn.org/aqicn/json/android/%s/json'
URL = 'http://aqicn.org/map/world'
TRYTIMES = 10
<|fim_suffix|> if data:
fullMapJso... | code_fim | hard | {
"lang": "python",
"repo": "yosef-gao/aqidatapuller",
"path": "/bin/data_puller.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if data:
fullMapJsonString = re.search("(?<=mapInitWithData\()\[.*\](?=\))", data)
cities = None
if fullMapJsonString:
self.cities = json.loads(fullMapJsonString.group(0))
def pull_data(self, site_id):
for city in self.cities:
... | code_fim | hard | {
"lang": "python",
"repo": "yosef-gao/aqidatapuller",
"path": "/bin/data_puller.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yichuanluanma/douban path: /douban/spiders/movie.py
#-*- coding: utf-8 -*-
import random
import re
import sys
import logging
import requests
import utils
import config
from scrapy.http import HtmlResponse
from scrapy.http import Request
from scrapy.spiders import Rule
from scrapy.spiders import... | code_fim | hard | {
"lang": "python",
"repo": "yichuanluanma/douban",
"path": "/douban/spiders/movie.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> command = (
"CREATE TABLE IF NOT EXISTS {} ("
"`id` INT(8) NOT NULL AUTO_INCREMENT UNIQUE ,"
"`title` TEXT NOT NULL,"
"`average` FLOAT NOT NULL,"
"`rating_people` INT(7) DEFAULT NULL,"
"`rating_five` CHAR(5) DEFAULT NULL,"
... | code_fim | hard | {
"lang": "python",
"repo": "yichuanluanma/douban",
"path": "/douban/spiders/movie.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: akshah/iodb path: /back-end/src/analysis/NeuralNet/655/nn_reducer.py
#!/usr/bin/env python
#
# Adapted from an example by Michael G. Noll at:
#
# http://www.michael-noll.com/wiki/Writing_An_Hadoop_MapReduce_Program_In_Python
#
from __future__ import with_statement
from operator import itemgetter... | code_fim | hard | {
"lang": "python",
"repo": "akshah/iodb",
"path": "/back-end/src/analysis/NeuralNet/655/nn_reducer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>X = data[:,1:]
T = data[:,0].reshape((-1,1))
trainf = 0.8
c1I,_ = np.where(T == 1)
c2I,_ = np.where(T == 2)
c3I,_ = np.where(T == 3)
c1I = np.random.permutation(c1I)
c2I = np.random.permutation(c2I)
c3I = np.random.permutation(c3I)
nc1 = len(c1I)
nc2 = len(c2I)
nc3 = len(c3I)
n = round(trainf*len(c1I)... | code_fim | hard | {
"lang": "python",
"repo": "akshah/iodb",
"path": "/back-end/src/analysis/NeuralNet/655/nn_reducer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.fixture(scope="session")
def parted_alltypes(client):
return client.table("functional_alltypes_parted")
@pytest.fixture(scope="session")
def parted_df(parted_alltypes):
return parted_alltypes.execute()
@pytest.fixture(scope="session")
def struct_table(client):
return client.table("... | code_fim | hard | {
"lang": "python",
"repo": "stjordanis/ibis-bigquery",
"path": "/tests/system/conftest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return client.table("numeric_table")
@pytest.fixture(scope="session")
def public(project_id, credentials):
return bq.connect(
project_id=project_id,
dataset_id="bigquery-public-data.stackoverflow",
credentials=credentials,
)<|fim_prefix|># repo: stjordanis/ibis-bigque... | code_fim | hard | {
"lang": "python",
"repo": "stjordanis/ibis-bigquery",
"path": "/tests/system/conftest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stjordanis/ibis-bigquery path: /tests/system/conftest.py
import os
import ibis # noqa: F401
import pytest
from google.oauth2 import service_account
import ibis_bigquery
PROJECT_ID = os.environ.get("GOOGLE_BIGQUERY_PROJECT_ID", "ibis-gbq")
DATASET_ID = "testing"
bq = ibis_bigquery.Backend()
... | code_fim | hard | {
"lang": "python",
"repo": "stjordanis/ibis-bigquery",
"path": "/tests/system/conftest.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Read linear Acceleration data
# accel_x,accel_y,accel_z = bno.read_linear_acceleration()
# Read full acceleration data (with gravity)
accel_x, accel_y, accel_z = bno.read_line... | code_fim | hard | {
"lang": "python",
"repo": "tunnelsnake/SnakeNDOF",
"path": "/IMU/ServerV2/server.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("System Confirmed.")
time.sleep(.25)
while True:
p = Process(target=self.startlistener, args=(bno,))
while True:
if(self.active_connection):
while True:
if(self.kill_proc == True):
... | code_fim | hard | {
"lang": "python",
"repo": "tunnelsnake/SnakeNDOF",
"path": "/IMU/ServerV2/server.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tunnelsnake/SnakeNDOF path: /IMU/ServerV2/server.py
import socket
import time
from multiprocessing import Process
from Adafruit_BNO055 import BNO055
class Server():
logfile = "logs/rawdata.csv"
host = "192.168.0.104"
port = "8080"
active_connection = False
collect_data =... | code_fim | hard | {
"lang": "python",
"repo": "tunnelsnake/SnakeNDOF",
"path": "/IMU/ServerV2/server.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mopidy/mopidy path: /mopidy/commands.py
lp,
)
def __call__(
self, parser, namespace, values, option_string=None # noqa: ARG002
) -> NoReturn:
raise _HelpError
class Command:
"""Command parser and runner for building trees of commands.
This class provid... | code_fim | hard | {
"lang": "python",
"repo": "mopidy/mopidy",
"path": "/mopidy/commands.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self,
config: config_lib.Config,
mixer: Optional[MixerProxy],
) -> AudioProxy:
logger.info("Starting Mopidy audio")
return cast(AudioProxy, Audio.start(config=config, mixer=mixer).proxy())
def start_backends(
self,
config: config_lib.Config,... | code_fim | hard | {
"lang": "python",
"repo": "mopidy/mopidy",
"path": "/mopidy/commands.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mopidy/mopidy path: /mopidy/commands.py
tion_string=None # noqa: ARG002
) -> NoReturn:
raise _HelpError
class Command:
"""Command parser and runner for building trees of commands.
This class provides a wraper around :class:`argparse.ArgumentParser`
for handling this ty... | code_fim | hard | {
"lang": "python",
"repo": "mopidy/mopidy",
"path": "/mopidy/commands.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: engapa/modeldb-basic path: /modeldb/thrift/modeldb/ModelDBService.py
__(self, other):
return not (self == other)
class storeTransformEvent_args(object):
"""
Attributes:
- te
"""
thrift_spec = (
None, # 0
(1, TType.STRUCT, 'te', (TransformEvent, Tra... | code_fim | hard | {
"lang": "python",
"repo": "engapa/modeldb-basic",
"path": "/modeldb/thrift/modeldb/ModelDBService.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.success = success
self.rnfEx = rnfEx
self.ioEx = ioEx
self.brEx = brEx
self.svEx = svEx
def read(self, iprot):
if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
... | code_fim | hard | {
"lang": "python",
"repo": "engapa/modeldb-basic",
"path": "/modeldb/thrift/modeldb/ModelDBService.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> args = storeGridSearchCrossValidationEvent_args()
args.read(iprot)
iprot.readMessageEnd()
result = storeGridSearchCrossValidationEvent_result()
try:
result.success = self._handler.storeGridSearchCrossValidationEvent(args.gscve)
msg_type = TMe... | code_fim | hard | {
"lang": "python",
"repo": "engapa/modeldb-basic",
"path": "/modeldb/thrift/modeldb/ModelDBService.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: greglandrum/rdkit path: /Contrib/FreeWilson/freewilson.py
tAtomMapNum()
if atommap:
atommaps[atommap] = idx
counts[atommap] += 1
next_atommap = max(atommaps) + 1
add_atommap = []
for fragment in frags[1:]:
for idx in fragment:
a... | code_fim | hard | {
"lang": "python",
"repo": "greglandrum/rdkit",
"path": "/Contrib/FreeWilson/freewilson.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self,
rgroups, rgroup_to_descriptor_idx, fitter,
r2, descriptors, row_decomposition,
num_training, num_reconstructed):
self.rgroups = rgroups # dictionary 'Core':[core1, core1], 'R1': [rgroup1, rgroup2], ...
self.rgroup_to... | code_fim | hard | {
"lang": "python",
"repo": "greglandrum/rdkit",
"path": "/Contrib/FreeWilson/freewilson.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> decomposer.Process()
logger.info(f"Matched {len(matched_scores)} out of {len(mols)}")
if not(matched_scores):
logger.error("No scaffolds matched the input molecules")
return
decomposition = decomposer.GetRGroupsAsRows(asSmiles=True)
logger.info("Get unique rgroups..."... | code_fim | hard | {
"lang": "python",
"repo": "greglandrum/rdkit",
"path": "/Contrib/FreeWilson/freewilson.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lenchik13/Testing path: /test/test_edit_contact.py
from model.contact import Contact
import random
def test_edit_contact(app, db, check_ui):
app.open_home_page()
if app.contact.count() == 0:
app.contact.create(Contact(firstname="Contact", lastname="", nickname="",
... | code_fim | hard | {
"lang": "python",
"repo": "Lenchik13/Testing",
"path": "/test/test_edit_contact.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>old_contacts.remove(rcontact)
old_contacts.append(contact)
assert sorted(old_contacts, key=Contact.id_or_max) == sorted(new_contacts, key=Contact.id_or_max)
if check_ui:
assert sorted(new_contacts, key=Contact.id_or_max) == sorted(app.contact.get_contact_list(), key=Contact.id_or_max)<... | code_fim | hard | {
"lang": "python",
"repo": "Lenchik13/Testing",
"path": "/test/test_edit_contact.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: khoehlein/fV-SRN-Ensemble-Compression path: /inference/model/latent_features/marginal/temporal_features.py
from typing import Optional, Tuple, List, Any
from torch import Tensor
from inference.model.latent_features.indexing.time_indexer import TimeIndexer
from inference.model.latent_features.in... | code_fim | hard | {
"lang": "python",
"repo": "khoehlein/fV-SRN-Ensemble-Compression",
"path": "/inference/model/latent_features/marginal/temporal_features.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def __init__(
self,
key_times: List[Any],
num_channels: int, initializer: Optional[IInitializer] = None,
debug: Optional[bool] = False,
dtype=None, device=None
):
super(TemporalFeatureVector, self).__init__(key_times, 3, num_chan... | code_fim | hard | {
"lang": "python",
"repo": "khoehlein/fV-SRN-Ensemble-Compression",
"path": "/inference/model/latent_features/marginal/temporal_features.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> raise NotImplementedError()
class TemporalFeatureVector(ITemporalFeatures):
def __init__(
self,
key_times: List[Any],
num_channels: int, initializer: Optional[IInitializer] = None,
debug: Optional[bool] = False,
dtype=None, device=... | code_fim | hard | {
"lang": "python",
"repo": "khoehlein/fV-SRN-Ensemble-Compression",
"path": "/inference/model/latent_features/marginal/temporal_features.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sugarsack/sugar path: /sugar/lib/loader/virtual.py
# coding: utf-8
"""
Module loader for virtual objects
"""
import os
import abc
import importlib
import sugar.lib.exceptions
from sugar.lib.loader.base import BaseModuleLoader
from sugar.lib.loader.util import RunnerDataValidator
class VirtualM... | code_fim | hard | {
"lang": "python",
"repo": "sugarsack/sugar",
"path": "/sugar/lib/loader/virtual.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def defer_to_call(*args, **kwargs):
"""
Defer bound method for a post-call for validation.
:param args: generic arguments
:param kwargs: generic keywords
:return: generic object
"""
... | code_fim | hard | {
"lang": "python",
"repo": "sugarsack/sugar",
"path": "/sugar/lib/loader/virtual.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hasancaslan/3D_multiview_reg path: /train.py
import sys
import os
import logging
import torch
import time
import argparse
import numpy as np
import torch.optim as optim
from tensorboardX import SummaryWriter
import lib.config as config
from lib.utils import load_config
from lib.data import make_... | code_fim | hard | {
"lang": "python",
"repo": "hasancaslan/3D_multiview_reg",
"path": "/train.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if metric_val_best == np.inf or metric_val_best == -np.inf:
metric_val_best = -model_selection_sign * np.inf
logger.info('Current best validation metric ({}): {:.5f}'.format(
model_selection_metric, metric_val_best))
# Training parameters
stat_interval = cfg['train']['sta... | code_fim | hard | {
"lang": "python",
"repo": "hasancaslan/3D_multiview_reg",
"path": "/train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> predictions = {}
for key, value in self._predictions_map.items():
predictions[key] = value
# Unnest if it wasn't a dictionary to begin with.
default_predictions_key = util.default_dict_key(
eval_constants.PREDICTIONS_NAME)
if list(predictions) == [default_predictions_key]... | code_fim | hard | {
"lang": "python",
"repo": "tensorflow/model-analysis",
"path": "/tensorflow_model_analysis/eval_metrics_graph/eval_metrics_graph.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Lock should be acquired before calling this function.
return self._session.run(fetches=self._metric_variable_nodes)
def get_metric_variables(self) -> List[Any]:
"""Returns a list containing the metric variable values."""
with self._lock:
return self._get_metric_variables()
de... | code_fim | hard | {
"lang": "python",
"repo": "tensorflow/model-analysis",
"path": "/tensorflow_model_analysis/eval_metrics_graph/eval_metrics_graph.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tensorflow/model-analysis path: /tensorflow_model_analysis/eval_metrics_graph/eval_metrics_graph.py
BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Abstract ... | code_fim | hard | {
"lang": "python",
"repo": "tensorflow/model-analysis",
"path": "/tensorflow_model_analysis/eval_metrics_graph/eval_metrics_graph.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> N = len(var_names)
n = 0
i = 0
while n <= N:
print("Plotting {:} of {:}".format(n, N))
plot_vars = var_names[n : n + max_panel]
az.plot_trace(trace, var_names=plot_vars)
plt.savefig(figstem.format(i))
plt.close("all")
n += max_panel
... | code_fim | hard | {
"lang": "python",
"repo": "iancze/TWA-3-orbit",
"path": "/src/twa/plot_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iancze/TWA-3-orbit path: /src/twa/plot_utils.py
import collections
import arviz as az
import matplotlib.colors
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.collections import LineCollection
from matplotlib.colors import LinearSegmentedColormap
# Create our own custom color... | code_fim | hard | {
"lang": "python",
"repo": "iancze/TWA-3-orbit",
"path": "/src/twa/plot_utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def __init__(self, game, x, y, width, height):
self.groups = game.walls
pg.sprite.Sprite.__init__(self, self.groups)
self.game = game
self.rect = pg.Rect(x, y, width, height)
self.x = x
self.y = y
self.rect.x = x
self.rect.y = y<|fim_pre... | code_fim | easy | {
"lang": "python",
"repo": "mohan488/zombie-game",
"path": "/zombie_game/walls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mohan488/zombie-game path: /zombie_game/walls.py
# python
from __future__ import unicode_literals
# libs
from zombie_game.settings import *
<|fim_suffix|>
def __init__(self, game, x, y, width, height):
self.groups = game.walls
pg.sprite.Sprite.__init__(self, self.groups)
... | code_fim | easy | {
"lang": "python",
"repo": "mohan488/zombie-game",
"path": "/zombie_game/walls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def exclude_directories(self):
excluded_dirs = list()
for f in self.file_list:
if os.path.isdir(f):
excluded_dirs.append(f)
log.debug(u"Directories are removed from list: {}".format(repr(excluded_dirs)))
self.file_list = set(self.file_list).s... | code_fim | hard | {
"lang": "python",
"repo": "luis12614/File2Mail",
"path": "/file_ops.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: luis12614/File2Mail path: /file_ops.py
# -*- coding: utf-8 -*-
"""
Application file operations
"""
import mimetypes
import os
import shutil
import time
from logger import log
from settings import SETTINGS
__author__ = 'Sencer Hamarat'
class FSTools():
"""
File System Tools Class
cr... | code_fim | hard | {
"lang": "python",
"repo": "luis12614/File2Mail",
"path": "/file_ops.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def user_path(self):
return os.path.expanduser(u"~")
def target_dir_path(self):
return os.path.join(self.user_path, self.directory)
def make_directory(self):
created = False
try:
os.makedirs(self.target_dir_path())
created... | code_fim | hard | {
"lang": "python",
"repo": "luis12614/File2Mail",
"path": "/file_ops.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shadesdhiman/InterviewBit-Solutions path: /Heaps and Maps/Profit Maximisation.py
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 6 22:58:57 2021
@author: Dhiman
"""
<|fim_suffix|>
A = [2, 3]
B = 3
obj = Solution()
print(obj.solve(A,B))<|fim_middle|>class Solution:
# @par... | code_fim | hard | {
"lang": "python",
"repo": "shadesdhiman/InterviewBit-Solutions",
"path": "/Heaps and Maps/Profit Maximisation.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> import heapq
H = []
heapq.heapify(H)
for i in range(len(A)):
heapq.heappush(H, -1 * A[i])
profit = 0
for i in range(B):
x= -1*heapq.heappop(H)
profit+=x
x=x-1
heapq.heappush(H, -x)
... | code_fim | medium | {
"lang": "python",
"repo": "shadesdhiman/InterviewBit-Solutions",
"path": "/Heaps and Maps/Profit Maximisation.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>
A = [2, 3]
B = 3
obj = Solution()
print(obj.solve(A,B))<|fim_prefix|># repo: shadesdhiman/InterviewBit-Solutions path: /Heaps and Maps/Profit Maximisation.py
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 6 22:58:57 2021
@author: Dhiman
"""
class Solution:
# @param A : l... | code_fim | hard | {
"lang": "python",
"repo": "shadesdhiman/InterviewBit-Solutions",
"path": "/Heaps and Maps/Profit Maximisation.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vipermu/bigotis path: /server/models/taming/taming_decoder.py
import os
import yaml
import math
import glob
from typing import *
import torch
import torchvision.transforms as T
import torchvision.transforms.functional as TF
import torch.nn.functional as F
from PIL import Image
import numpy as np... | code_fim | hard | {
"lang": "python",
"repo": "vipermu/bigotis",
"path": "/server/models/taming/taming_decoder.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> optimizer = torch.optim.AdamW(
params=[z_logits],
lr=lr,
betas=(0.9, 0.999),
weight_decay=0.1,
)
gen_img_list = []
z_logits_list = []
for step in range(num_generations):
with torch.no_grad... | code_fim | hard | {
"lang": "python",
"repo": "vipermu/bigotis",
"path": "/server/models/taming/taming_decoder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: oussa/bootcamp-ihealth path: /bootcamp/core/tryton.py
__author__ = 'oussama'
from django.conf import settings
import sys, os
import warnings
warnings.filterwarnings("ignore", message="Old style callback, usecb_func(ok, store) instead")
TRYTOND_PATH = settings.TRYTOND_PATH
DIR = os.path.abspath... | code_fim | medium | {
"lang": "python",
"repo": "oussa/bootcamp-ihealth",
"path": "/bootcamp/core/tryton.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Instantiate the database and the pool
DB = Database(settings.TRYTON_DB).connect()
POOL = Pool(settings.TRYTON_DB)
POOL.init()
user_obj = POOL.get('res.user')
cursor = DB.cursor()
Cache.clean(settings.TRYTON_DB)
try:
# User 0 is root user. We use it to get the user id:
USER = user_obj.search(curs... | code_fim | medium | {
"lang": "python",
"repo": "oussa/bootcamp-ihealth",
"path": "/bootcamp/core/tryton.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: danielogen/msc_research path: /utils/popc/ds_class_clustering.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 6 14:42:06 2020
@author: danielogenrwot
"""
from sklearn.cluster import KMeans
#import numpy as np
import pandas as pd
from disp import display
from popc impor... | code_fim | medium | {
"lang": "python",
"repo": "danielogen/msc_research",
"path": "/utils/popc/ds_class_clustering.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># locate the binary file
data_k9_binary = pd.read_csv('../Analytics/Results/csv/all_labeled_data_desktop_18_01_2021.csv')
X = data_k9_binary.iloc[:, [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]].values
kmeans = KMeans(n_clusters=6, random_state=0).fit(X)
result = []
for i in range(l... | code_fim | medium | {
"lang": "python",
"repo": "danielogen/msc_research",
"path": "/utils/popc/ds_class_clustering.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>kmeans = KMeans(n_clusters=6, random_state=0).fit(X)
result = []
for i in range(len(X)):
result.append([kmeans.labels_[i], X[i]])
display(result, 'kmeans')
labels = popc(X)
print(labels)
# add new column to the dataframe
data_k9_binary['cluster'] = labels
# write new dataframe to csv
data_k9_bin... | code_fim | hard | {
"lang": "python",
"repo": "danielogen/msc_research",
"path": "/utils/popc/ds_class_clustering.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>thread1 = Sleeper( "4 second thread done!", 4 )
thread1.start()
thread2 = Sleeper( "2 second thread done!", 2 )
thread2.start()
raw_input( "Waiting for threads to exit.\n\n" )<|fim_prefix|># repo: verhulstm/python-training path: /kevin-harris-python-tutorial/py_threading/sleeper_thread_class.py
#... | code_fim | hard | {
"lang": "python",
"repo": "verhulstm/python-training",
"path": "/kevin-harris-python-tutorial/py_threading/sleeper_thread_class.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: verhulstm/python-training path: /kevin-harris-python-tutorial/py_threading/sleeper_thread_class.py
#------------------------------------------------------------------------------
# Name: sleeper_thread_class.py
# Author: Kevin Harris
# Last Modified: 02/13/04
# Descripti... | code_fim | medium | {
"lang": "python",
"repo": "verhulstm/python-training",
"path": "/kevin-harris-python-tutorial/py_threading/sleeper_thread_class.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>thread2 = Sleeper( "2 second thread done!", 2 )
thread2.start()
raw_input( "Waiting for threads to exit.\n\n" )<|fim_prefix|># repo: verhulstm/python-training path: /kevin-harris-python-tutorial/py_threading/sleeper_thread_class.py
#--------------------------------------------------------------------... | code_fim | hard | {
"lang": "python",
"repo": "verhulstm/python-training",
"path": "/kevin-harris-python-tutorial/py_threading/sleeper_thread_class.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> usrepr = observed_coo.represent_as(UnitSphericalRepresentation)
lon = usrepr.lon.to_value(u.radian)
lat = usrepr.lat.to_value(u.radian)
if isinstance(observed_coo, AltAz):
# the 'A' indicates zen/az inputs
coord_type = "A"
lat = PIOVER2 - lat
else:
coor... | code_fim | hard | {
"lang": "python",
"repo": "astropy/astropy",
"path": "/astropy/coordinates/builtin_frames/icrs_observed_transforms.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Create loopback transformations
frame_transform_graph._add_merged_transform(AltAz, ICRS, AltAz)
frame_transform_graph._add_merged_transform(HADec, ICRS, HADec)
# for now we just implement this through ICRS to make sure we get everything
# covered
# Before, this was using CIRS as intermediate frame, how... | code_fim | hard | {
"lang": "python",
"repo": "astropy/astropy",
"path": "/astropy/coordinates/builtin_frames/icrs_observed_transforms.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.