text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: faustyang/PySyft path: /packages/syft/src/syft/proto/core/node/common/service/heritage_update_service_pb2.py
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: proto/core/node/common/service/heritage_update_service.proto
"""Generated protocol buffer code.... | code_fim | hard | {
"lang": "python",
"repo": "faustyang/PySyft",
"path": "/packages/syft/src/syft/proto/core/node/common/service/heritage_update_service_pb2.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sudharkj/sudoku-solver path: /sudoku/constraint.py
# sudoku/constraints.py
class Constraint:
"""
Constraint on each cell.
"""
def __init__(self, point):
<|fim_suffix|> def __lt__(self, other):
return len(self.allowed) < len(other.allowed)<|fim_middle|> self.cell ... | code_fim | medium | {
"lang": "python",
"repo": "sudharkj/sudoku-solver",
"path": "/sudoku/constraint.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return len(self.allowed) < len(other.allowed)<|fim_prefix|># repo: sudharkj/sudoku-solver path: /sudoku/constraint.py
# sudoku/constraints.py
class Constraint:
"""
Constraint on each cell.
"""
def __init__(self, point):
<|fim_middle|> self.cell = point
self.allowed ... | code_fim | medium | {
"lang": "python",
"repo": "sudharkj/sudoku-solver",
"path": "/sudoku/constraint.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("*** Sample #"+str(i))
seconds = data.get_imu_data().timestamp.get_seconds() - first_ts.get_seconds()
print(" * Relative timestamp: "+str(seconds)+" sec")
# Filtered orientation quaternion
zed_imu = data.get_imu_data()
#Display the IMU acceleratoin
... | code_fim | hard | {
"lang": "python",
"repo": "rbonghi/zed-python-api",
"path": "/tutorials/tutorial 7 - sensor data/sensor_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rbonghi/zed-python-api path: /tutorials/tutorial 7 - sensor data/sensor_data.py
########################################################################
#
# Copyright (c) 2020, STEREOLABS.
#
# All rights reserved.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" A... | code_fim | hard | {
"lang": "python",
"repo": "rbonghi/zed-python-api",
"path": "/tutorials/tutorial 7 - sensor data/sensor_data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Barometer temperature
location = sl.SENSOR_LOCATION.BAROMETER
baro_temp = data.get_temperature_data().get(location)
if baro_temp != -1:
print(" * Barometer temperature: "+str(temp)+"C")
# Camera temperat... | code_fim | hard | {
"lang": "python",
"repo": "rbonghi/zed-python-api",
"path": "/tutorials/tutorial 7 - sensor data/sensor_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: konnected-io/home-assistant path: /tests/components/aemet/test_init.py
"""Define tests for the AEMET OpenData init."""
from unittest.mock import patch
import requests_mock
from homeassistant.components.aemet.const import DOMAIN
from homeassistant.config_entries import ConfigEntryState
from home... | code_fim | hard | {
"lang": "python",
"repo": "konnected-io/home-assistant",
"path": "/tests/components/aemet/test_init.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(config_entry.entry_id)
await hass.async_block_till_done()
asse... | code_fim | hard | {
"lang": "python",
"repo": "konnected-io/home-assistant",
"path": "/tests/components/aemet/test_init.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().__init__(name)
def move(self, coordinates):
print("flying to ", coordinates)
def display(self, data):
print("displaying holographic data", data)
def morph(self):
print("morphing into vehicle...")
class Cleaner_robot(Robot):
def __init__(self, na... | code_fim | medium | {
"lang": "python",
"repo": "Hriday039/DesignPatterns",
"path": "/strategy-pattern/example_1/prob.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Hriday039/DesignPatterns path: /strategy-pattern/example_1/prob.py
class Robot:
def __init__(self, name):
self.name = name
def move(self, coordinates):
print("moving to ", coordinates)
def display(self, data):
print(data)
def morph(self):
print("... | code_fim | medium | {
"lang": "python",
"repo": "Hriday039/DesignPatterns",
"path": "/strategy-pattern/example_1/prob.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NULLCT/LOMC path: /src/data/1265.py
import collections
N, Q = map(int, input().split())
graph = [[] for _ in range(N)]
for i in range(N - 1):
a, b = map(int, input().split())
graph[a - 1].append(b - 1)
graph[b - 1].append(a - 1)
q = collections.deque()
q.append(0)
dist = [-1] * N
dis... | code_fim | medium | {
"lang": "python",
"repo": "NULLCT/LOMC",
"path": "/src/data/1265.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> q.popleft()
d = dist[v]
for w in graph[v]:
if dist[w] > -1:
continue
dist[w] = d + 1
q.append(w)
for i in range(Q):
c, d = map(int, input().split())
if (dist[c - 1] + dist[d - 1]) % 2 == 0:
print('Town')
else:
print('Road')<|fim_pref... | code_fim | medium | {
"lang": "python",
"repo": "NULLCT/LOMC",
"path": "/src/data/1265.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> centerboxes = (center1+center2)/2
return lidar_to_rear_axle_coords(centerboxes)
def calculate_goalpoint_one_box(laser_data):
p0 = get_lidar_point_at_angle(laser_data, -80)
p1 = get_lidar_point_at_angle(laser_data, -70)
p2 = get_lidar_point_at_angle(laser_data, 70)
p3 = get_lidar... | code_fim | hard | {
"lang": "python",
"repo": "f1tenth/F110CPSWeek2018",
"path": "/Connecticut/AutoCar/src/pure_pursuit/src/calculate_goalpoint.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> poly = PolygonStamped()
center = PointStamped()
p1 = get_lidar_point_at_angle(laser_data, -80)
p2 = get_lidar_point_at_angle(laser_data, -70)
p3 = get_lidar_point_at_angle(laser_data, 70)
p4 = get_lidar_point_at_angle(laser_data, 80)
poly.header = Header(stamp=rospy.Time.now(... | code_fim | hard | {
"lang": "python",
"repo": "f1tenth/F110CPSWeek2018",
"path": "/Connecticut/AutoCar/src/pure_pursuit/src/calculate_goalpoint.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: f1tenth/F110CPSWeek2018 path: /Connecticut/AutoCar/src/pure_pursuit/src/calculate_goalpoint.py
from lidar_utils import *
import rospy
from geometry_msgs.msg import PolygonStamped, Point32, PointStamped, Point
from std_msgs.msg import Header
pub_poly1 = rospy.Publisher('polygons/p1', PolygonStam... | code_fim | hard | {
"lang": "python",
"repo": "f1tenth/F110CPSWeek2018",
"path": "/Connecticut/AutoCar/src/pure_pursuit/src/calculate_goalpoint.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: huzhe007/learn-python path: /demo/logging/d5/d5.py
import yaml
import logging.config
import os
def setup_logging(default_path = "logging.yaml",default_level = logging.INFO,env_key = "LOG_CFG"):
<|fim_suffix|> logging.info("start func")
logging.info("exec func")
logging.info("end fun... | code_fim | hard | {
"lang": "python",
"repo": "huzhe007/learn-python",
"path": "/demo/logging/d5/d5.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> logging.info("end func")
if __name__ == "__main__":
setup_logging(default_path = "logging.yaml")
func()<|fim_prefix|># repo: huzhe007/learn-python path: /demo/logging/d5/d5.py
import yaml
import logging.config
import os
def setup_logging(default_path = "logging.yaml",default_level = logging... | code_fim | hard | {
"lang": "python",
"repo": "huzhe007/learn-python",
"path": "/demo/logging/d5/d5.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qcmuu/Crawl path: /爬虫之起步篇/python数据库的使用/shujuku.py
from sqlalchemy import create_engine,MetaData,Table
from sqlalchemy import Column,String,Integer,select
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
#创建基类
Base = declarative_base()
engine = create... | code_fim | hard | {
"lang": "python",
"repo": "qcmuu/Crawl",
"path": "/爬虫之起步篇/python数据库的使用/shujuku.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#Base.metadata.create_all(engine)
if __name__ == '__main__':
Session = sessionmaker(bind=engine)
sess = Session()#创建实例
h = Host(hostname='test1',ip_addr='127.0.0.1')
h2 = Host(hostname='test2',ip_addr='192.168.0.1',port=80001)
h3 = Host(hostname='test3',ip_addr='192.168.0.2',port=80002... | code_fim | hard | {
"lang": "python",
"repo": "qcmuu/Crawl",
"path": "/爬虫之起步篇/python数据库的使用/shujuku.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fsan/micro-tcg path: /tests/mocks/mock_client.py
import asyncio
from aiohttp import ClientSession
from micro_tcg import routes
from micro_tcg.models.user import User
from tests.unit.storage.user_repo import user_data
class MicroTCGClient:
def __init__(self, session: ClientSession):
... | code_fim | hard | {
"lang": "python",
"repo": "fsan/micro-tcg",
"path": "/tests/mocks/mock_client.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def login_with_wrong_password(self):
bkp = self.user.password
self.user.password += 'wrong'
response = await self.login(expect_success=False)
self.user.password = bkp
return response
async def enter_waiting_list(self):
url = self.base_url + ro... | code_fim | hard | {
"lang": "python",
"repo": "fsan/micro-tcg",
"path": "/tests/mocks/mock_client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> logger.info("Converting Dicom to Nifty - END")
logger.info("Removing extra VOI - START")
move_extra_vois(output_images_folder, archive_folder)
logger.info("Removing extra VOI - END")
logger.info("Renaming files- START")
correct_names(output_images_folder, name_mapping)
logger.i... | code_fim | hard | {
"lang": "python",
"repo": "Amirhosein2c/hecktor",
"path": "/src/data/make_dataset.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Amirhosein2c/hecktor path: /src/data/make_dataset.py
from pathlib import Path
import logging
logging.basicConfig(
filename="dicom_conversion.log",
level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logging.captureWarnings(True)
logger = logging.getLog... | code_fim | hard | {
"lang": "python",
"repo": "Amirhosein2c/hecktor",
"path": "/src/data/make_dataset.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lamlion/eduid-webapp path: /src/eduid_webapp/reset_password/tests/test_msgs.py
# -*- coding: utf-8 -*-
import unittest
from eduid_webapp.reset_password.helpers import ResetPwMsg
class MessagesTests(unittest.TestCase):
def test_messages(self):
""""""
self.assertEqual(ResetP... | code_fim | hard | {
"lang": "python",
"repo": "lamlion/eduid-webapp",
"path": "/src/eduid_webapp/reset_password/tests/test_msgs.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>no-code-in-data')
self.assertEqual(ResetPwMsg.chpass_weak.value, 'chpass.weak-password')
self.assertEqual(ResetPwMsg.chpass_no_data.value, 'chpass.no-data')
self.assertEqual(ResetPwMsg.mfa_no_data.value, 'mfa.no-request-data')
self.assertEqual(ResetPwMsg.fido_token_fail.val... | code_fim | hard | {
"lang": "python",
"repo": "lamlion/eduid-webapp",
"path": "/src/eduid_webapp/reset_password/tests/test_msgs.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> keys = []
for i in range(self.size):
key = self._GD.GetKeyByIndex(i, key="")
if key != "":
keys.append(key)
return keys
@property
def size(self):
return self._GD.size
@property
def values(self):
vals... | code_fim | hard | {
"lang": "python",
"repo": "ramonmassip/TS_PLAT_API",
"path": "/GlobalDictionary.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _encode_dictionary(data, name="Second", sub=False):
"""Encodes a Python dictionary to be used as an EasyLanguage dictionary.
If sub is True, a sub-dictionary is returned as an XML element.
If sub is False, a string representing the entire XML structure is returned.
Example when sub =... | code_fim | hard | {
"lang": "python",
"repo": "ramonmassip/TS_PLAT_API",
"path": "/GlobalDictionary.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ramonmassip/TS_PLAT_API path: /GlobalDictionary.py
"""
GlobalDictionary.py: A module for interfacing with a TradeStation
Easylanguage GlobalDictionary through a COM object.
This file requires that win32com (pywin32) be installed in your environment.
Steps to install pywin32:
... | code_fim | hard | {
"lang": "python",
"repo": "ramonmassip/TS_PLAT_API",
"path": "/GlobalDictionary.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def find(checkinList):
"""Return a list of one Inspiration object per checkin."""
return [Inspiration(item) for item in checkinList]
# snagged from http://code.activestate.com/recipes/577305/ (r1), MIT License
_all_states = {
'AK': 'Alaska',
'AL': 'Alabama',
'AR': 'Arkans... | code_fim | hard | {
"lang": "python",
"repo": "simbha/how-you-been",
"path": "/src/howyoubeen/Inspiration.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: simbha/how-you-been path: /src/howyoubeen/Inspiration.py
# Routines to grab some bits of data from the chec data. The front end will randomly
from string import Template
from webapp2_extras import json
class Inspiration:
"""This class picks a bunch of data out of the retrieved checkin dat... | code_fim | hard | {
"lang": "python",
"repo": "simbha/how-you-been",
"path": "/src/howyoubeen/Inspiration.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not hasattr(self.filename_or_fileobject, "read"): # only close the file if it was opened by this class in the first place (if the file was originally given as a path)
self.audio_reader.close()
self.stream = None
self.DURATION = None
def get_flac_converter():
"... | code_fim | hard | {
"lang": "python",
"repo": "NikoKalbitzer/speech_processing_v2",
"path": "/audio/audio_file.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NikoKalbitzer/speech_processing_v2 path: /audio/audio_file.py
import wave
import aifc
import subprocess
import io
import audioop
import os
import platform
import sys
import stat
from audio.audio_file_stream import AudioFileStream
class AudioSource(object):
def __init__(self):
raise... | code_fim | hard | {
"lang": "python",
"repo": "NikoKalbitzer/speech_processing_v2",
"path": "/audio/audio_file.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __enter__(self):
assert self.stream is None, "This audio source is already inside a context manager"
try:
# attempt to read the file as WAV
self.audio_reader = wave.open(self.filename_or_fileobject, "rb")
self.little_endian = True # RIFF WAV is ... | code_fim | hard | {
"lang": "python",
"repo": "NikoKalbitzer/speech_processing_v2",
"path": "/audio/audio_file.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DIN-DKE/IEC_61850__keith-gray-powereng_goose path: /goose/goose.py
from struct import pack
from scapy.packet import Packet
from scapy.fields import XShortField
<|fim_suffix|> def post_build(self, packet, payload):
goose_pdu_length = len(packet) + len(payload)
packet = packet[... | code_fim | hard | {
"lang": "python",
"repo": "DIN-DKE/IEC_61850__keith-gray-powereng_goose",
"path": "/goose/goose.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> goose_pdu_length = len(packet) + len(payload)
packet = packet[:2] + pack('!H', goose_pdu_length) + packet[4:]
return packet + payload<|fim_prefix|># repo: DIN-DKE/IEC_61850__keith-gray-powereng_goose path: /goose/goose.py
from struct import pack
from scapy.packet import Packet
fr... | code_fim | hard | {
"lang": "python",
"repo": "DIN-DKE/IEC_61850__keith-gray-powereng_goose",
"path": "/goose/goose.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_make_periodic_step():
step = tf.range(20)
start_step = 0
period_duration_in_steps = 10
unit_step = tf_util.make_periodic_step(step, start_step, period_duration_in_steps)
assert np.allclose(unit_step[:10], unit_step[10:])<|fim_prefix|># repo: mritv/edflow path: /tests/test_tf... | code_fim | easy | {
"lang": "python",
"repo": "mritv/edflow",
"path": "/tests/test_tf_util.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mritv/edflow path: /tests/test_tf_util.py
import pytest
from edflow import tf_util
import tensorflow as tf
<|fim_suffix|>def test_make_periodic_step():
step = tf.range(20)
start_step = 0
period_duration_in_steps = 10
unit_step = tf_util.make_periodic_step(step, start_step, period... | code_fim | easy | {
"lang": "python",
"repo": "mritv/edflow",
"path": "/tests/test_tf_util.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fm = FileManager(MEDIA_ROOT)
return fm.render(request, path)<|fim_prefix|># repo: aman-roy/django-filemanager path: /tests/views.py
from filemanager import FileManager
from settings import MEDIA_ROOT
<|fim_middle|>def view(request, path):
| code_fim | easy | {
"lang": "python",
"repo": "aman-roy/django-filemanager",
"path": "/tests/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aman-roy/django-filemanager path: /tests/views.py
from filemanager import FileManager
from settings import MEDIA_ROOT
<|fim_suffix|> fm = FileManager(MEDIA_ROOT)
return fm.render(request, path)<|fim_middle|>
def view(request, path):
| code_fim | easy | {
"lang": "python",
"repo": "aman-roy/django-filemanager",
"path": "/tests/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def execute_strategy(self, *args, **kwargs):
pass<|fim_prefix|># repo: Grusinator/optimize-life path: /optimize_life/economic_iterators/economic_iterator.py
from abc import abstractmethod, ABC
from typing import Iterator
class EconomicIterator(ABC):
<|fim_middle|>
@abstractmethod
de... | code_fim | medium | {
"lang": "python",
"repo": "Grusinator/optimize-life",
"path": "/optimize_life/economic_iterators/economic_iterator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Grusinator/optimize-life path: /optimize_life/economic_iterators/economic_iterator.py
from abc import abstractmethod, ABC
from typing import Iterator
<|fim_suffix|> pass
def execute_strategy(self, *args, **kwargs):
pass<|fim_middle|>
class EconomicIterator(ABC):
@abstrac... | code_fim | medium | {
"lang": "python",
"repo": "Grusinator/optimize-life",
"path": "/optimize_life/economic_iterators/economic_iterator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Azure Blob Service has no concept of mass-delete, so we must nuke
# each blob one-by-one...
for blob in page:
try:
self.wabs_conn.delete_blob(self.container, blob.name)
except AzureMissingResourceHttpError:
logger.warning(
... | code_fim | medium | {
"lang": "python",
"repo": "linz/wal-e",
"path": "/wal_e/worker/wabs/wabs_deleter.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: linz/wal-e path: /wal_e/worker/wabs/wabs_deleter.py
from wal_e import retries
from wal_e import log_help
from wal_e.worker.base import _Deleter
try:
# New class name in the Azure SDK sometime after v1.0.
#
# See
# https://github.com/Azure/azure-sdk-for-python/blob/master/ChangeLo... | code_fim | medium | {
"lang": "python",
"repo": "linz/wal-e",
"path": "/wal_e/worker/wabs/wabs_deleter.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>guesses_left = 3
# Start your game!
while (guesses_left > 0):
guesses_left -= 1
guess = int(raw_input("Your guess: "))
if guess == random_number:
print ("You win!")
break
else:
print ("You lose")<|fim_prefix|># repo: amalshehu/Python-Introduction path: /num_guess.py
# Fil... | code_fim | medium | {
"lang": "python",
"repo": "amalshehu/Python-Introduction",
"path": "/num_guess.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amalshehu/Python-Introduction path: /num_guess.py
# File: lnum_guess.py
# Purpose: Example : While loop test
# Programmer: Amal Shehu
# Course: Codecademy
# Date: Tuesday 30th August 2016, 12:20 PM
<|fim_suffix|>guesses_left = 3
# Start your game!
while (guesses_left > 0)... | code_fim | medium | {
"lang": "python",
"repo": "amalshehu/Python-Introduction",
"path": "/num_guess.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rule bam_sort:
input:
'{file}.bam'
output:
'{file}.sorted.bam'
shell:
'samtools sort {input[0]} -o {output[0]}'
rule bam_index:
input:
'{file}.bam'
output:
'{file}.bam.bai'
shell:
'samtools index {input[0]} {output[0]} 2> {output[0]}.log'
#######
# BWA #
#######
rule bwa_index:
input... | code_fim | hard | {
"lang": "python",
"repo": "compbiomed-unito/ngs_basic",
"path": "/Pipelines/ngs_basic.smk",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rule bwa_mem_single_end:
input:
#ref=lambda w: reference_sequences[w.ref] + '.bwa_index',
ref=lambda w: get_resource(w.ref, 'sequences') + '.bwa_index',
reads='{file}.R1.fastq.gz'
output:
bwamemse_stem
log:
bwamemse_stem + '.log'
benchmark:
bwamemse_stem + '.benchmark.txt'
threads: 8
par... | code_fim | hard | {
"lang": "python",
"repo": "compbiomed-unito/ngs_basic",
"path": "/Pipelines/ngs_basic.smk",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: compbiomed-unito/ngs_basic path: /Pipelines/ngs_basic.smk
# config fields: scratch_root
# SAMPLE SHEET HANDLING #
def make_fastq_table(dirs, pattern=None):
'''Find fastq files in some directories and assemble them in a read sheet
dirs -- iterator of pairs of name and path to a directory
pa... | code_fim | hard | {
"lang": "python",
"repo": "compbiomed-unito/ngs_basic",
"path": "/Pipelines/ngs_basic.smk",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @classmethod
def tearDownClass(cls):
cls.clear_caselevel(cls)
cls.clear_testsuite(cls)
def clear_testsuite(self):
self.delete_test_suite("testsuite1")
self.delete_test_suite("testsuite2")
self.delete_test_suite("testsuite3")
self.delete_test_sui... | code_fim | hard | {
"lang": "python",
"repo": "fj11/APIClinic",
"path": "/src/restapi/tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.create_caselevel("l6")
caselevel = CaseLevel.objects.get(name="l6")
id = caselevel.id
caselevel.name = "l7"
serialized = CaseLevelSerializer(caselevel, many=False)
response = self.client.put("http://127.0.0.1:8000/caselevel/", data={"id": id, "name":"l7... | code_fim | hard | {
"lang": "python",
"repo": "fj11/APIClinic",
"path": "/src/restapi/tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fj11/APIClinic path: /src/restapi/tests.py
from django.test import TestCase
from django.urls import reverse
from rest_framework.test import APITestCase, APIClient
from rest_framework.views import status
from .models import Feature, CaseLevel, TestCase, APIMethod
from .serializers import FeatureSe... | code_fim | hard | {
"lang": "python",
"repo": "fj11/APIClinic",
"path": "/src/restapi/tests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """"""
return Response(
self.serializer_class(context=self.get_serializer_context()).data
)
class CaptchaViewSet(generics.CreateAPIView, GetAPIView, generics.GenericAPIView):
permission_classes = ()
authentication_classes = ()
serializer_class = CaptchaSer... | code_fim | hard | {
"lang": "python",
"repo": "Nekmo/django-rest-framework-security",
"path": "/rest_framework_security/brute_force_protection/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class CaptchaViewSet(generics.CreateAPIView, GetAPIView, generics.GenericAPIView):
permission_classes = ()
authentication_classes = ()
serializer_class = CaptchaSerializer
class LoginProtectionViewSet(GetAPIView, generics.GenericAPIView):
permission_classes = ()
authentication_classe... | code_fim | hard | {
"lang": "python",
"repo": "Nekmo/django-rest-framework-security",
"path": "/rest_framework_security/brute_force_protection/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Nekmo/django-rest-framework-security path: /rest_framework_security/brute_force_protection/views.py
from functools import wraps
from rest_framework import generics, views
from rest_framework.exceptions import ValidationError, PermissionDenied
from rest_framework.response import Response
from re... | code_fim | medium | {
"lang": "python",
"repo": "Nekmo/django-rest-framework-security",
"path": "/rest_framework_security/brute_force_protection/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: boada/planckClusters path: /MOSAICpipe/plugins/_utils.py
import os
import sys
from astropy.io.fits import getheader
import numpy as np
# get the utils from the parent directory
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from utils import check_exe
def calc_air... | code_fim | hard | {
"lang": "python",
"repo": "boada/planckClusters",
"path": "/MOSAICpipe/plugins/_utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # set the scale options
minscales = '0.005'
maxscales = '0.997,0.994,0.992'
else:
red = './{}{}.fits'.format(self.tilename, 'i')
green = './{}{}.fits'.format(self.tilename, 'r')
blue = './{}{}.fits'.format(self.tilename, 'g')
bands = 'irg'
... | code_fim | hard | {
"lang": "python",
"repo": "boada/planckClusters",
"path": "/MOSAICpipe/plugins/_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: py4/SFUTranslate path: /src/translate/readers/datareader.py
"""
Provides the general dataset functionalities in the abstract class :type AbsDatasetReader:
To create your own dataset reader you only need to extend this class and augment it with the functionalities
you might need. :type DummyData... | code_fim | hard | {
"lang": "python",
"repo": "py4/SFUTranslate",
"path": "/src/translate/readers/datareader.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
The class method to provide useful trained data (e.g. vocabulary objects) mainly from TRAIN dataset reader to
the TEST and DEV dataset readers.
"""
raise NotImplementedError
@property
@abstractmethod
def instance_schema(self):
"""
... | code_fim | hard | {
"lang": "python",
"repo": "py4/SFUTranslate",
"path": "/src/translate/readers/datareader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
:return: the total size of instances in the dataset (not just the buffered instances)
"""
raise NotImplementedError
@abstractmethod
def __getitem__(self, idx):
"""
:return: the instance in index :param idx: of the dataset (can be simply calling ... | code_fim | hard | {
"lang": "python",
"repo": "py4/SFUTranslate",
"path": "/src/translate/readers/datareader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@ROLES_BP.post("api/roles/<role_id>/owners")
@authorized()
async def add_role_owner(request, role_id):
"""Add an owner to a role."""
required_fields = ["id"]
utils.validate_fields(required_fields, request.json)
txn_key, txn_user_id = await utils.get_transactor_key(request)
proposal_i... | code_fim | hard | {
"lang": "python",
"repo": "hugocicl/sawtooth-next-directory",
"path": "/rbac/server/api/roles.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hugocicl/sawtooth-next-directory path: /rbac/server/api/roles.py
# Copyright 2019 Contributors to Hyperledger Sawtooth
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#... | code_fim | hard | {
"lang": "python",
"repo": "hugocicl/sawtooth-next-directory",
"path": "/rbac/server/api/roles.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # f.close()
f = open('test2.txt', 'r')
print(f.name)
for n in f:
print(n,end='')
f.close()<|fim_prefix|># repo: YeMinMyat/PythonSample path: /Python File IO/open.py
with open('test.txt', 'r') as f:
# scope_to_read = 1
# f_text = f.read(scope_to_read)
# while len(f_text) > 0:
# print(f_t... | code_fim | easy | {
"lang": "python",
"repo": "YeMinMyat/PythonSample",
"path": "/Python File IO/open.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: YeMinMyat/PythonSample path: /Python File IO/open.py
with open('test.txt', 'r') as f:
# scope_to_read = 1
# f_text = f.read(scope_to_read)
<|fim_suffix|> # f.close()
f = open('test2.txt', 'r')
print(f.name)
for n in f:
print(n,end='')
f.close()<|fim_middle|> # while len(f_text) > 0:... | code_fim | hard | {
"lang": "python",
"repo": "YeMinMyat/PythonSample",
"path": "/Python File IO/open.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Utaro-M/lecture2021 path: /student_projects/kanazawa/deepbots/tutorials/controllers/robotSupervisorController/PPO_agent.py
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.distributions import Categorical
from torch import from_numpy, no_grad, save, loa... | code_fim | hard | {
"lang": "python",
"repo": "Utaro-M/lecture2021",
"path": "/student_projects/kanazawa/deepbots/tutorials/controllers/robotSupervisorController/PPO_agent.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Repeat the update procedure for ppo_update_iters
for i in range(self.ppo_update_iters):
# Create randomly ordered batches of size batchSize from buffer
for index in BatchSampler(SubsetRandomSampler(range(len(self.buffer))), batchSize, False):
# Cal... | code_fim | hard | {
"lang": "python",
"repo": "Utaro-M/lecture2021",
"path": "/student_projects/kanazawa/deepbots/tutorials/controllers/robotSupervisorController/PPO_agent.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: irfansofyana/if4020-steganografi path: /src/image/extractor.py
import numpy as np
import random
import base64
from src.helper.file import File
from src.helper.cipher import decrypt_vigenere
Wc = np.indices((8, 8)).sum(axis=0) % 2
class Extractor:
def __init__(self, file_dir, key):
... | code_fim | hard | {
"lang": "python",
"repo": "irfansofyana/if4020-steganografi",
"path": "/src/image/extractor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if encrypted:
self.string_message = decrypt_vigenere(message, self.key)
else:
self.string_message = message
def parse_message(self):
message_info = self.string_message.split("#")
self.len_message = int(message_info[0])
self.extension = ... | code_fim | hard | {
"lang": "python",
"repo": "irfansofyana/if4020-steganografi",
"path": "/src/image/extractor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: group1BSE1/BSE-2021 path: /src/chapter3/exercise4.py
try:
age = int(input('Enter your age: '))
if age >= 18:
<|fim_suffix|> print('Too young to vote')
else :
print("Your a time traveller")
except:
print('Please enter age as an integer')<|fim_middle|> print('You ca... | code_fim | medium | {
"lang": "python",
"repo": "group1BSE1/BSE-2021",
"path": "/src/chapter3/exercise4.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('Too young to vote')
else :
print("Your a time traveller")
except:
print('Please enter age as an integer')<|fim_prefix|># repo: group1BSE1/BSE-2021 path: /src/chapter3/exercise4.py
try:
age = int(input('Enter your age: '))
if age >= 18:
<|fim_middle|> print('You ca... | code_fim | medium | {
"lang": "python",
"repo": "group1BSE1/BSE-2021",
"path": "/src/chapter3/exercise4.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: naman1303/Python path: /web_programming/helper.py
import sys
from contextlib import contextmanager
<|fim_suffix|> """
All traceback information is suppressed and only the exception type and value are printed
"""
default_value = getattr(
sys, "tracebacklimit", 1000
) #... | code_fim | easy | {
"lang": "python",
"repo": "naman1303/Python",
"path": "/web_programming/helper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
All traceback information is suppressed and only the exception type and value are printed
"""
default_value = getattr(
sys, "tracebacklimit", 1000
) # `1000` is a Python's default value
sys.tracebacklimit = 0
yield
sys.tracebacklimit = default_value<|fim_prefix... | code_fim | easy | {
"lang": "python",
"repo": "naman1303/Python",
"path": "/web_programming/helper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bopopescu/docker_images_a path: /contract_management/store_build_contracts.py
import json
import sys
<|fim_suffix|>contract_string = json.dumps(contract_names)
File_object = open("contracts_to_load.json","w")
File_object.write(contract_string)
File_object.close()<|fim_middle|>contract_na... | code_fim | medium | {
"lang": "python",
"repo": "bopopescu/docker_images_a",
"path": "/contract_management/store_build_contracts.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>contract_string = json.dumps(contract_names)
File_object = open("contracts_to_load.json","w")
File_object.write(contract_string)
File_object.close()<|fim_prefix|># repo: bopopescu/docker_images_a path: /contract_management/store_build_contracts.py
import json
import sys
<|fim_middle|>contract_na... | code_fim | medium | {
"lang": "python",
"repo": "bopopescu/docker_images_a",
"path": "/contract_management/store_build_contracts.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@addon.webpanel(key='webpanel.key', name='Panel')
def web_panel():
return "This is a panel"
if __name__ == '__main__':
addon.run(host="0.0.0.0")<|fim_prefix|># repo: olivaq/ac-flask-hipchat path: /test.py
import random
from ac_flask.hipchat import Addon, room_client, addon_client, sender, contex... | code_fim | hard | {
"lang": "python",
"repo": "olivaq/ac-flask-hipchat",
"path": "/test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: olivaq/ac-flask-hipchat path: /test.py
import random
from ac_flask.hipchat import Addon, room_client, addon_client, sender, context
from ac_flask.hipchat.glance import Glance
from flask import Flask
addon = Addon(app=Flask(__name__),
key="test-addon",
name="Test AddOn... | code_fim | medium | {
"lang": "python",
"repo": "olivaq/ac-flask-hipchat",
"path": "/test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> label = 'Update count: {}'.format(random.randint(1, 100))
glance_data = Glance().with_label(label).with_lozenge('progress', 'current').data
addon_client.update_room_glance('glance.key', glance_data, context['room_id'])
return '', 204
@addon.glance(key='glance.key', name='Glance', target='... | code_fim | medium | {
"lang": "python",
"repo": "olivaq/ac-flask-hipchat",
"path": "/test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jungssi/Komolon path: /Komolon/__init__.py
import os
from flask import Flask
def create_app(test_config=None):
app = Flask(__name__, instance_relative_config=True)
app.config.from_mapping(
SECRET_KEY="dev",
# store the database in the instance folder
#DATABASE=os.path.join(app.instance... | code_fim | medium | {
"lang": "python",
"repo": "jungssi/Komolon",
"path": "/Komolon/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return "Hello, Komolon!"
app.add_url_rule("/", endpoint="index")
return app<|fim_prefix|># repo: jungssi/Komolon path: /Komolon/__init__.py
import os
from flask import Flask
def create_app(test_config=None):
app = Flask(__name__, instance_relative_config=True)
app.config.from_mapping(
SECRE... | code_fim | medium | {
"lang": "python",
"repo": "jungssi/Komolon",
"path": "/Komolon/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Code
for i in range(len(qline)):
titles = titleList[i]
values = qline[i]
print titles, ": ", values<|fim_prefix|># repo: atultegar/PersonalFinance path: /PersonalFinance/PersonalFinance/fetchquote.py
from urllib2 import Request, urlopen
import re
url = 'https:/... | code_fim | medium | {
"lang": "python",
"repo": "atultegar/PersonalFinance",
"path": "/PersonalFinance/PersonalFinance/fetchquote.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: atultegar/PersonalFinance path: /PersonalFinance/PersonalFinance/fetchquote.py
from urllib2 import Request, urlopen
import re
url = 'https://www.amfiindia.com/spages/NAVAll.txt'
req = Request(url)
resp = urlopen(req)
nav = resp.read()
title = 'Scheme Code;ISIN Div Payout/ ISIN Growth;ISIN Div Rei... | code_fim | medium | {
"lang": "python",
"repo": "atultegar/PersonalFinance",
"path": "/PersonalFinance/PersonalFinance/fetchquote.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> if cfg.local_rank == 0:
progress_bar = tqdm.tqdm(total=len(dataloader), leave=True, desc='eval', dynamic_ncols=True)
start_time = time.time()
result_dicts_list = []
for i, batch_dict in enumerate(dataloader):
load_data_to_gpu(batch_dict)
with torch.no_grad():
... | code_fim | hard | {
"lang": "python",
"repo": "Carlzhangk/trajectory-prediction",
"path": "/tools/eval_utils/trajectory_prediction.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Carlzhangk/trajectory-prediction path: /tools/eval_utils/trajectory_prediction.py
import tqdm
import time
import pickle
import numpy as np
import torch
from nnlib.models import load_data_to_gpu
def eval_trajectory_prediction(cfg, model, dataloader, logger, dist_test=False, save_to_file=False, re... | code_fim | hard | {
"lang": "python",
"repo": "Carlzhangk/trajectory-prediction",
"path": "/tools/eval_utils/trajectory_prediction.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kprabesh/GANs-n-reels path: /src/Generation/Decoding/Audio_Converter.py
from midi2audio import FluidSynth
from pydub import AudioSegment
import tempfile
# TODO - Determine why MIDI saves correctly, but WAVa nd MP3 do not.
default = '/Users/calebg/Documents/School/Code Repository/GANs-n-reels/sr... | code_fim | hard | {
"lang": "python",
"repo": "kprabesh/GANs-n-reels",
"path": "/src/Generation/Decoding/Audio_Converter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("file_in: {}".format(file_in))
# If the input is MIDI, we need to use a temporary file to convert to WAV.
if self.tune[-3:] == 'mid':
fs = FluidSynth()
temp_wav = tempfile.NamedTemporaryFile()
fs.midi_to_audio(file_in, temp_wav.name)
... | code_fim | hard | {
"lang": "python",
"repo": "kprabesh/GANs-n-reels",
"path": "/src/Generation/Decoding/Audio_Converter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def save_song_from_file(self):
file_in = default+self.tune
file_out = default + '{}.{}'.format(self.file_name, self.out_type)
print("file_in: {}".format(file_in))
# If the input is MIDI, we need to use a temporary file to convert to WAV.
if self.tune[-3:] == '... | code_fim | hard | {
"lang": "python",
"repo": "kprabesh/GANs-n-reels",
"path": "/src/Generation/Decoding/Audio_Converter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> thisdir = os.path.dirname(os.path.abspath(__file__))
exampledir = os.path.normpath(os.path.join(thisdir,'..','examples'))
for filename in os.listdir(exampledir):
filebase, ext = os.path.splitext(filename)
if ext != '.xml':
continue
print filename
tr ... | code_fim | medium | {
"lang": "python",
"repo": "tymiles003/hescore-hpxml",
"path": "/hescorehpxml/create_all_example_json.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tymiles003/hescore-hpxml path: /hescorehpxml/create_all_example_json.py
import os
from hescorehpxml import HPXMLtoHEScoreTranslator
<|fim_suffix|> thisdir = os.path.dirname(os.path.abspath(__file__))
exampledir = os.path.normpath(os.path.join(thisdir,'..','examples'))
for filename in ... | code_fim | medium | {
"lang": "python",
"repo": "tymiles003/hescore-hpxml",
"path": "/hescorehpxml/create_all_example_json.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>['host']=f[2]
d['port']=int(f[3])
d['passw']=f[4]
return d<|fim_prefix|># repo: Ematrix163/Dublin_bikes path: /src/db/getconfig.py
def getConfig():
'''Gets all database parameters from file and returns them in dictionary format'''
f=open('config.config','r').read<|fim_middle|>().sp... | code_fim | medium | {
"lang": "python",
"repo": "Ematrix163/Dublin_bikes",
"path": "/src/db/getconfig.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ematrix163/Dublin_bikes path: /src/db/getconfig.py
def getConfig():
'''Gets all database parameters from file and returns them in dictionary format'''
f=open('config.config','r').read<|fim_suffix|>['host']=f[2]
d['port']=int(f[3])
d['passw']=f[4]
return d<|fim_middle|>().sp... | code_fim | medium | {
"lang": "python",
"repo": "Ematrix163/Dublin_bikes",
"path": "/src/db/getconfig.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>().split('\n')
d={}
d['database']=f[1]
d['user']=f[0]
d['host']=f[2]
d['port']=int(f[3])
d['passw']=f[4]
return d<|fim_prefix|># repo: Ematrix163/Dublin_bikes path: /src/db/getconfig.py
def getConfig():
'''Gets all database parameters from file and ret<|fim_middle|>urns ... | code_fim | medium | {
"lang": "python",
"repo": "Ematrix163/Dublin_bikes",
"path": "/src/db/getconfig.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.basic = ['musket']<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/otherforms/_muskets.py
#calss header
class _MUSKETS():
def __init__(self,):
self.name = "MUSKETS"
self.definitions = musket
<|fim_middle|> self.parents = []
self.childen = []
self.properties = []
self.js... | code_fim | medium | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/otherforms/_muskets.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/otherforms/_muskets.py
#calss header
class _MUSKETS():
<|fim_suffix|> self.name = "MUSKETS"
self.definitions = musket
self.parents = []
self.childen = []
self.properties = []
self.jsondata = {}
self.basic = ['musket']<|fim_middle|> def __in... | code_fim | easy | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/otherforms/_muskets.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fns, concurrency=40,
progress=None, total=None, batch_size=1,
):
if total is None:
try:
total = len(fns)
except TypeError: # generators don't have len
pass
pbar = tqdm(total=total, desc=progress, disable=(not progress))
results = []
def updatefn(fn):
def rea... | code_fim | hard | {
"lang": "python",
"repo": "ZettaAI/python-task-queue",
"path": "/taskqueue/scheduler.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pbar.close()
def schedule_green_jobs(
fns, concurrency=40,
progress=None, total=None, batch_size=1,
):
if total is None:
try:
total = len(fns)
except TypeError: # generators don't have len
pass
pbar = tqdm(total=total, desc=progress, disable=(not progress))
result... | code_fim | hard | {
"lang": "python",
"repo": "ZettaAI/python-task-queue",
"path": "/taskqueue/scheduler.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ZettaAI/python-task-queue path: /taskqueue/scheduler.py
import sys
from concurrent.futures import ThreadPoolExecutor
import gevent.pool
import gevent.monkey
from tqdm import tqdm
from cloudvolume.lib import yellow
def schedule_threaded_jobs(
fns, concurrency=40,
progress=None, total=... | code_fim | medium | {
"lang": "python",
"repo": "ZettaAI/python-task-queue",
"path": "/taskqueue/scheduler.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>cat= [clip.subclip(20.00, 22.00),
clip.subclip(24.00, 29.00),
clip.subclip(30.00, 35.00),
clip.subclip(41.00, 45),
clip.subclip(46.5, 48),
clip.subclip(51, 53),
clip.subclip(56, 64),
clip.subclip(80, 82),
]
final= concatenate_videoclips(cat, method= 'compose')
fi... | code_fim | medium | {
"lang": "python",
"repo": "dariober/ASCIIGenome",
"path": "/docs/video_moviepy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dariober/ASCIIGenome path: /docs/video_moviepy.py
#!/usr/bin/env ipython
from moviepy.editor import *
from moviepy import editor
from moviepy.video.tools.subtitles import SubtitlesClip
import os
# ---------------------- 8< ----------------------------------------------------
def annotate(clip,... | code_fim | medium | {
"lang": "python",
"repo": "dariober/ASCIIGenome",
"path": "/docs/video_moviepy.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: probml/pyprobml path: /deprecated/scripts/linear_autoencoder_pca_tf.py
# Linear autoencoder (ie PCA) applied to a 3d dataset projecting to 2d
#https://github.com/ageron/handson-ml2/blob/master/17_autoencoders_and_gans.ipynb
import superimport
import numpy as np
import matplotlib.pyplot as plt
i... | code_fim | hard | {
"lang": "python",
"repo": "probml/pyprobml",
"path": "/deprecated/scripts/linear_autoencoder_pca_tf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def generate_3d_data(m, w1=0.1, w2=0.3, noise=0.1):
angles = np.random.rand(m) * 3 * np.pi / 2 - 0.5
data = np.empty((m, 3))
data[:, 0] = np.cos(angles) + np.sin(angles)/2 + noise * np.random.randn(m) / 2
data[:, 1] = np.sin(angles) * 0.7 + noise * np.random.randn(m) / 2
data[:, 2] = d... | code_fim | medium | {
"lang": "python",
"repo": "probml/pyprobml",
"path": "/deprecated/scripts/linear_autoencoder_pca_tf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>X_train = generate_3d_data(60)
X_train = X_train - X_train.mean(axis=0, keepdims=0)
np.random.seed(42)
tf.random.set_seed(42)
encoder = keras.models.Sequential([keras.layers.Dense(2, input_shape=[3])])
decoder = keras.models.Sequential([keras.layers.Dense(3, input_shape=[2])])
autoencoder = keras.models... | code_fim | hard | {
"lang": "python",
"repo": "probml/pyprobml",
"path": "/deprecated/scripts/linear_autoencoder_pca_tf.py",
"mode": "spm",
"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.