text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>print(random_string_gen.util.generate_chance(5))
print(random_string_gen.util.generate_chance(2))
print(random_string_gen.util.generate_chance(7))
print(random_string_gen.util.generate_chance(10))<|fim_prefix|># repo: Mespyr/Random-String-Generator path: /test1.py
import sys
sys.path.append("..")
import... | code_fim | medium | {
"lang": "python",
"repo": "Mespyr/Random-String-Generator",
"path": "/test1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Mespyr/Random-String-Generator path: /test1.py
import sys
sys.path.append("..")
<|fim_suffix|>print(random_string_gen.util.generate_chance(5))
print(random_string_gen.util.generate_chance(2))
print(random_string_gen.util.generate_chance(7))
print(random_string_gen.util.generate_chance(10))<|fim_... | code_fim | medium | {
"lang": "python",
"repo": "Mespyr/Random-String-Generator",
"path": "/test1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self,
rows: Sequence,
style: Style,
name: Optional[str] = None,
caption: Optional[str] = None,
**kwargs
):
super().__init__(
"table",
{"rows": rows, "name": name, "caption": caption, "style": style},
**kwargs
... | code_fim | medium | {
"lang": "python",
"repo": "melonora/pandas-profiling",
"path": "/src/ydata_profiling/report/presentation/core/table.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: melonora/pandas-profiling path: /src/ydata_profiling/report/presentation/core/table.py
from typing import Any, Optional, Sequence
from ydata_profiling.config import Style
from ydata_profiling.report.presentation.core.item_renderer import ItemRenderer
<|fim_suffix|> def __init__(
sel... | code_fim | medium | {
"lang": "python",
"repo": "melonora/pandas-profiling",
"path": "/src/ydata_profiling/report/presentation/core/table.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dp[1] = 1
dp[2] = 2
for i in range(3, n + 1):
dp[i] = dp[i - 1] + dp[i - 2]
return dp[-1]
if __name__ == "__main__":
A = Solution1()
print(A.numWays(7))<|fim_prefix|># repo: wenhaoliang/leetcode path: /leetcode/offerIsComing/动态规划/剑指 Offer 10- II. 青蛙跳... | code_fim | hard | {
"lang": "python",
"repo": "wenhaoliang/leetcode",
"path": "/leetcode/offerIsComing/动态规划/剑指 Offer 10- II. 青蛙跳台阶问题.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wenhaoliang/leetcode path: /leetcode/offerIsComing/动态规划/剑指 Offer 10- II. 青蛙跳台阶问题.py
"""
一只青蛙一次可以跳上1级台阶,也可以跳上2级台阶。求该青蛙跳上一个 n级的台阶总共有多少种跳法。
答案需要取模 1e9+7(1000000007),如计算初始结果为:1000000008,请返回 1。
示例 1:
输入:n = 2
输出:2
示例 2:
输入:n = 7
输出:21
示例 3:
输入:n = 0
输出:1
链接:https://leetcode-cn.com/problems/qing-wa-tia... | code_fim | hard | {
"lang": "python",
"repo": "wenhaoliang/leetcode",
"path": "/leetcode/offerIsComing/动态规划/剑指 Offer 10- II. 青蛙跳台阶问题.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> view = View("view", select(table.c.id), view_options=[
('check_option', 'cascaded'),
('security_barrier', 't'),
])
stmt = CreateView(view)
assert literal_compile(stmt) == (
'CREATE VIEW view '
'WITH (check_option = cascaded, security_barrier = t) '
'... | code_fim | hard | {
"lang": "python",
"repo": "agdsn/pycroft",
"path": "/tests/model/ddl/test_view.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: agdsn/pycroft path: /tests/model/ddl/test_view.py
import pytest
from sqlalchemy import select
from pycroft.model.ddl import View, CreateView, DropView
from . import create_table, literal_compile
@pytest.fixture(scope='session')
def table():
return create_table("table") # must be named `ta... | code_fim | hard | {
"lang": "python",
"repo": "agdsn/pycroft",
"path": "/tests/model/ddl/test_view.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> view = View("view", select(table.c.id))
stmt = DropView(view)
assert literal_compile(stmt) == (
'DROP VIEW view'
)
def test_drop_view_if_exists(table):
view = View("view", select(table.c.id))
stmt = DropView(view, if_exists=True)
assert literal_compile(stmt) == (
... | code_fim | hard | {
"lang": "python",
"repo": "agdsn/pycroft",
"path": "/tests/model/ddl/test_view.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def virial_vel(self, halos=None, subhalo=False):
#Does nothing: just there to be overridden
def get_filt(self, elem, ion, thresh = 1):
#Transform the spectra for analysis.
#To test.
def add_noise(self, snr, tau, seed):
#Statistics.
#To test.
def _rho_abs(self, thresh=10**20.3, upthresh=10**40, elem = "... | code_fim | hard | {
"lang": "python",
"repo": "sbird/fake_spectra",
"path": "/fake_spectra/tests/test_spectra.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sbird/fake_spectra path: /fake_spectra/tests/test_spectra.py
# -*- coding: utf-8 -*-
"""
Tests for the spectrum module.
Methods in spectra.py:
def __init__(self,num, base,cofm, axis, res=1., cdir=None, savefile="spectra.hdf5", savedir=None, reload_file = False, spec_res = 8):
#IO.
#Not tes... | code_fim | hard | {
"lang": "python",
"repo": "sbird/fake_spectra",
"path": "/fake_spectra/tests/test_spectra.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
"""
import numpy as np
from fake_spectra import spectra as ss
from fake_spectra import unitsystem
from fake_spectra import spec_utils
from fake_spectra import voigtfit
from fake_spectra import halocat
#def setup():
#"""Load the fake data section and module to be used by these tests"""
def testRho... | code_fim | hard | {
"lang": "python",
"repo": "sbird/fake_spectra",
"path": "/fake_spectra/tests/test_spectra.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ChaoticMarauder/Project_Rosalind path: /Textbook/BA1N.py
from Chapter1 import hamming_distance
def neighbours(pattern, d):
if d==0:
return [pattern]
if len(pattern)==1:
return ['A','C','G','T']
neighbourhood=[]
suffix_neighbours = neighbours(pattern[1:le... | code_fim | medium | {
"lang": "python",
"repo": "ChaoticMarauder/Project_Rosalind",
"path": "/Textbook/BA1N.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with open('datasets/rosalind_ba1n.txt') as input_data:
pattern, d = input_data.read().strip().split('\n')
d = int(d)
neighbourhood = neighbours(pattern, d)
print('\n'.join(neighbourhood))
with open('solutions/rosalind_ba1n.txt', 'w') as output_file:
o... | code_fim | medium | {
"lang": "python",
"repo": "ChaoticMarauder/Project_Rosalind",
"path": "/Textbook/BA1N.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('\n'.join(neighbourhood))
with open('solutions/rosalind_ba1n.txt', 'w') as output_file:
output_file.write('\n'.join(neighbourhood))
if(__name__=='__main__'):
main()<|fim_prefix|># repo: ChaoticMarauder/Project_Rosalind path: /Textbook/BA1N.py
from Chapter1 import h... | code_fim | hard | {
"lang": "python",
"repo": "ChaoticMarauder/Project_Rosalind",
"path": "/Textbook/BA1N.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: VieAnonime/Verge-Discord path: /cogs/balance.py
import discord
from discord.ext import commands
from utils import rpc_module, mysql_module
#result_set = database response with parameters from query
#db_bal = nomenclature for result_set["balance"]
#snowflake = snowflake from message context, iden... | code_fim | hard | {
"lang": "python",
"repo": "VieAnonime/Verge-Discord",
"path": "/cogs/balance.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(get_transactions) == 0:
db_bal = 0
db_staked = 0
await self.do_embed(name, db_bal, db_staked)
else:
new_balance = 0
new_staked = 0
lasttxid = get_transactions[i]["txid"]
firsttxid = get_transactions[... | code_fim | hard | {
"lang": "python",
"repo": "VieAnonime/Verge-Discord",
"path": "/cogs/balance.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> list_images = []
for ext in IMAGE_EXTENSIONS:
list_images += glob.glob(os.path.join(path_dataset, name + ext))
if not list_images:
logging.warning('missing image: %s', os.path.join(path_dataset, name))
continue
... | code_fim | hard | {
"lang": "python",
"repo": "Borda/keras-yolo3",
"path": "/scripts/annotation_csv.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Borda/keras-yolo3 path: /scripts/annotation_csv.py
"""
Creating training file from own custom dataset
>> python annotation_csv.py \
--path_dataset ~/Data/PeopleDetections \
--path_output ../model_data
"""
import os
import sys
import glob
import argparse
import logging
import pandas as ... | code_fim | hard | {
"lang": "python",
"repo": "Borda/keras-yolo3",
"path": "/scripts/annotation_csv.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for fn in os.listdir(base_dir):
if '.p' not in fn:
continue
base_fn = fn[:-2]
if imageset not in base_fn:
continue
if int(base_fn[:-4].split('_')[-1]) not in image_ids:
continue
print(fn)
# imageset = fn.split('_')[1]
img = scipy.misc.imread(os.path.join... | code_fim | hard | {
"lang": "python",
"repo": "tengyu-liu/Part-GPNN",
"path": "/src/misc/verify_processed.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tengyu-liu/Part-GPNN path: /src/misc/verify_processed.py
import os
import pickle
import numpy as np
import scipy.misc
import matplotlib.pyplot as plt
import vsrl_utils as vu
imageset = 'train'
base_dir = '/home/tengyu/Data/mscoco/v-coco/processed/resnet'
# base_dir = '/home/tengyu/Documents/P... | code_fim | hard | {
"lang": "python",
"repo": "tengyu-liu/Part-GPNN",
"path": "/src/misc/verify_processed.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CircleUp/exception-reports path: /tests/manual_test_uncaught_exceptions.py
import sys
from logging.config import dictConfig
from exception_reports.logs import uncaught_exception_handler, DEFAULT_LOGGING_CONFIG
<|fim_suffix|> class SpecialArgsException(Exception):
def __init__(self, m... | code_fim | hard | {
"lang": "python",
"repo": "CircleUp/exception-reports",
"path": "/tests/manual_test_uncaught_exceptions.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> class SpecialArgsException(Exception):
def __init__(self, message, important_var):
super().__init__(message)
try:
raise SpecialArgsException("<strong>YOLO!!!!</strong>", 24)
except Exception:
raise SpecialArgsException("<strong>HELLO</strong>", 34)<|fim_pre... | code_fim | medium | {
"lang": "python",
"repo": "CircleUp/exception-reports",
"path": "/tests/manual_test_uncaught_exceptions.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> headers = {'Authorization' : 'Bearer ' + self.line_notify_token}
payload = {'message' : message}
response = requests.post(self.LINE_NOTIFY_URL, headers = headers, params = payload)
return response<|fim_prefix|># repo: myusei/docycle path: /line.py
import requests
class L... | code_fim | easy | {
"lang": "python",
"repo": "myusei/docycle",
"path": "/line.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> response = requests.post(self.LINE_NOTIFY_URL, headers = headers, params = payload)
return response<|fim_prefix|># repo: myusei/docycle path: /line.py
import requests
class Line:
LINE_NOTIFY_URL = 'https://notify-api.line.me/api/notify'
def __init__(self, token):
<|fim_middle|> ... | code_fim | medium | {
"lang": "python",
"repo": "myusei/docycle",
"path": "/line.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: myusei/docycle path: /line.py
import requests
class Line:
LINE_NOTIFY_URL = 'https://notify-api.line.me/api/notify'
def __init__(self, token):
self.line_notify_token = token
def send_message(self, message):
<|fim_suffix|> response = requests.post(self.LINE_NOTIFY_URL,... | code_fim | medium | {
"lang": "python",
"repo": "myusei/docycle",
"path": "/line.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>from .moved_before_message import *
from .moved_before_message_parse import *
from .moved_before_message_serializer import *
from .nosub_message import *
from .nosub_message_parser import *
from .nosub_message_serializer import *
from .ready_message import *
from .ready_message_parser import *
from .rea... | code_fim | hard | {
"lang": "python",
"repo": "foxdog-studios/pyddp",
"path": "/ddp/messages/server/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: foxdog-studios/pyddp path: /ddp/messages/server/__init__.py
# -*- coding: utf-8 -*-
# Copyright 2014 Foxdog Studios
#
# 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": "foxdog-studios/pyddp",
"path": "/ddp/messages/server/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for group in self.param_groups:
lr = group["lr"]
weight_decay = group["weight_decay"]
lr_decay = group["lr_decay"]
eps = group["eps"]
maximize = group["maximize"]
for p in group["params"]:
if p.grad is None:
... | code_fim | hard | {
"lang": "python",
"repo": "Cerebras/modelzoo",
"path": "/modelzoo/common/pytorch/optim/Adagrad.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Cerebras/modelzoo path: /modelzoo/common/pytorch/optim/Adagrad.py
# Copyright 2022 Cerebras Systems.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.... | code_fim | hard | {
"lang": "python",
"repo": "Cerebras/modelzoo",
"path": "/modelzoo/common/pytorch/optim/Adagrad.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pabelanger/ansible-role-iptables path: /filter_plugins/getaddrinfo.py
# Copyright (c) 2018 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://w... | code_fim | medium | {
"lang": "python",
"repo": "pabelanger/ansible-role-iptables",
"path": "/filter_plugins/getaddrinfo.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def dns_a(self, value):
return self.dns(value, '4')
def dns_aaaa(self, value):
return self.dns(value, '6')
def filters(self):
return {
'dns_a': self.dns_a,
'dns_aaaa': self.dns_aaaa,
}<|fim_prefix|># repo: pabelanger/ansible-role-iptabl... | code_fim | hard | {
"lang": "python",
"repo": "pabelanger/ansible-role-iptables",
"path": "/filter_plugins/getaddrinfo.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LilliJane/psychic-waffle path: /statues/migrations/0002_auto_20170413_0844.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-04-13 08:44
from __future__ import unicode_literals
<|fim_suffix|> dependencies = [
('statues', '0001_initial'),
]
operations = [
m... | code_fim | medium | {
"lang": "python",
"repo": "LilliJane/psychic-waffle",
"path": "/statues/migrations/0002_auto_20170413_0844.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('statues', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='statue',
name='latitute',
field=models.FloatField(default=52.0715712),
),
migrations.AlterField(
model_name='statue... | code_fim | medium | {
"lang": "python",
"repo": "LilliJane/psychic-waffle",
"path": "/statues/migrations/0002_auto_20170413_0844.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NikaDark16/dotfiles path: /.bin/packages
#!/usr/bin/env python
import subprocess as S
import argparse as AP
import appdirs as AD
import ia256utilities.filesystem as F
def load_data():
data_dirs = AD.user_data_dir('packages', 'icearrow256')
data_file = data_dirs + '/data.json'
data ... | code_fim | hard | {
"lang": "python",
"repo": "NikaDark16/dotfiles",
"path": "/.bin/packages",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def print_packages(packages):
for package in packages:
print(package)
def print_packages_one_line(packages):
result = ''
for package in packages:
result += package + ' '
print(result)
def filter(packages, exclusion_packages):
result = []
for package in packages... | code_fim | hard | {
"lang": "python",
"repo": "NikaDark16/dotfiles",
"path": "/.bin/packages",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser = AP.ArgumentParser(description='Show pacman packages')
parser.add_argument('-e', '--exclude',
action='store_true', help='exclude packages')
parser.add_argument('-d', '--device', action='store_true',
help='show device packages')
parser... | code_fim | hard | {
"lang": "python",
"repo": "NikaDark16/dotfiles",
"path": "/.bin/packages",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tomonari0812/robosys_ros path: /scripts/sub_led.py
#!/usr/bin/env python
import rospy
from std_msgs.msg import Bool
def led1_callback(msg):
with open("/dev/myled0", "w") as f:
f.write("1\n" if msg.data else "0\n")
<|fim_suffix|>if __name__ == "__main__":
rospy.init_node("sub_led")
... | code_fim | hard | {
"lang": "python",
"repo": "Tomonari0812/robosys_ros",
"path": "/scripts/sub_led.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with open("/dev/myled0", "w") as f:
f.write("5\n" if msg.data else "4\n")
if __name__ == "__main__":
rospy.init_node("sub_led")
sub1 = rospy.Subscriber("led1",Bool,led1_callback,queue_size=10)
sub2 = rospy.Subscriber("led2",Bool,led2_callback,queue_size=10)
... | code_fim | medium | {
"lang": "python",
"repo": "Tomonari0812/robosys_ros",
"path": "/scripts/sub_led.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>install_requires=[
'boto3'
],
zip_safe=False,
)<|fim_prefix|># repo: maginetv/ecs-task-balancer path: /setup.py
#!/usr/bin/env python
from setuptools import setup, find_pack<|fim_middle|>ages
setup(
name='ecs_taskbalancer',
version='0.1',
packages=find_packages(),
includ... | code_fim | medium | {
"lang": "python",
"repo": "maginetv/ecs-task-balancer",
"path": "/setup.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> packages=find_packages(),
include_package_data=True,
install_requires=[
'boto3'
],
zip_safe=False,
)<|fim_prefix|># repo: maginetv/ecs-task-balancer path: /setup.py
#!/usr/bin/env python
from setuptools import setup, find_pack<|fim_middle|>ages
setup(
name='ecs_taskbalance... | code_fim | medium | {
"lang": "python",
"repo": "maginetv/ecs-task-balancer",
"path": "/setup.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maginetv/ecs-task-balancer path: /setup.py
#!/usr/bin/env python
from setuptools import setup, find_pack<|fim_suffix|>install_requires=[
'boto3'
],
zip_safe=False,
)<|fim_middle|>ages
setup(
name='ecs_taskbalancer',
version='0.1',
packages=find_packages(),
includ... | code_fim | medium | {
"lang": "python",
"repo": "maginetv/ecs-task-balancer",
"path": "/setup.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
app (class): The instance of the App class "self".
"""
app.exit_message = self.exit_msg
return wrapped(*args, **kwargs)
return completion(instance, *args, **kwargs)<|fim_prefix|># repo: TpyoKnig/tcex path: /tcex/decorators/on_... | code_fim | hard | {
"lang": "python",
"repo": "TpyoKnig/tcex",
"path": "/tcex/decorators/on_success.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TpyoKnig/tcex path: /tcex/decorators/on_success.py
"""App Decorators Module."""
# third-party
import wrapt
class OnSuccess:
"""Set exit message on successful execution.
This decorator will set the supplied msg as the App "exit_message". Typically and App would
only have 1 exit mess... | code_fim | hard | {
"lang": "python",
"repo": "TpyoKnig/tcex",
"path": "/tcex/decorators/on_success.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> encoder_model.train()
optimizer.zero_grad()
z, z1, z2 = encoder_model(data.x, data.edge_index, data.edge_attr)
h1, h2 = [encoder_model.project(x) for x in [z1, z2]]
loss = contrast_model(h1, h2)
loss.backward()
optimizer.step()
return loss.item()
def test(encoder_model, d... | code_fim | hard | {
"lang": "python",
"repo": "juyongjiang/PyGCL",
"path": "/examples/GRACE.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: juyongjiang/PyGCL path: /examples/GRACE.py
import torch
import os.path as osp
import GCL.losses as L
import GCL.augmentors as A
import torch.nn.functional as F
import torch_geometric.transforms as T
from tqdm import tqdm
from torch.optim import Adam
from GCL.eval import get_split, LREvaluator
fr... | code_fim | hard | {
"lang": "python",
"repo": "juyongjiang/PyGCL",
"path": "/examples/GRACE.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> with tqdm(total=1000, desc='(T)') as pbar:
for epoch in range(1, 1001):
loss = train(encoder_model, contrast_model, data, optimizer)
pbar.set_postfix({'loss': loss})
pbar.update()
test_result = test(encoder_model, data)
print(f'(E): Best test F1Mi={... | code_fim | hard | {
"lang": "python",
"repo": "juyongjiang/PyGCL",
"path": "/examples/GRACE.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_apply_window_list_func():
apply_window(df, field_apply, partition='target')
def test_apply_window_DataFrameGroupBy():
apply_window(df.groupby('target'), field_apply).head()
def test_apply_window_all_list():
apply_window(df_g, [np.mean, np.max],
columns=['sepal len... | code_fim | medium | {
"lang": "python",
"repo": "Jhengsh/tidyframe",
"path": "/tests/test_apply_window.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jhengsh/tidyframe path: /tests/test_apply_window.py
import pandas as pd
import numpy as np
from sklearn import datasets
from tidyframe import nest, unnest, apply_window
iris = datasets.load_iris()
df = pd.DataFrame(iris['data'], columns=iris.feature_names)
df['target'] = iris.target
df['target2'... | code_fim | hard | {
"lang": "python",
"repo": "Jhengsh/tidyframe",
"path": "/tests/test_apply_window.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_apply_window_DataFrameGroupBy():
apply_window(df.groupby('target'), field_apply).head()
def test_apply_window_all_list():
apply_window(df_g, [np.mean, np.max],
columns=['sepal length (cm)', 'sepal length (cm)'])
def test_apply_window_lsit_func_and_str_column():
a... | code_fim | medium | {
"lang": "python",
"repo": "Jhengsh/tidyframe",
"path": "/tests/test_apply_window.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def name(self):
return self.__class__.__name__
if __name__ == '__main__':
print(CustomPipeline.__name__)<|fim_prefix|># repo: Dustyposa/goSpider path: /small_projects/rasa_learn/ep2/classification.py
from typing import Text, List, Any
from rasa.nlu.classifiers.classifier ... | code_fim | hard | {
"lang": "python",
"repo": "Dustyposa/goSpider",
"path": "/small_projects/rasa_learn/ep2/classification.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Dustyposa/goSpider path: /small_projects/rasa_learn/ep2/classification.py
from typing import Text, List, Any
from rasa.nlu.classifiers.classifier import IntentClassifier
from rasa.nlu.training_data import Message
class CustomPipeline(IntentClassifier):
@classmethod
def required_packag... | code_fim | hard | {
"lang": "python",
"repo": "Dustyposa/goSpider",
"path": "/small_projects/rasa_learn/ep2/classification.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> item_to_act = forms.CharField(required=False, help_text='what are you cutting', label='item to remove')
target = forms.CharField(required=False, help_text='where are you placing it')
conditional_statement = forms.CharField(required=False)
specify_tool = forms.CharField(required=False)
... | code_fim | medium | {
"lang": "python",
"repo": "Bionetbook/bionetbook",
"path": "/bnbapp/protocols/forms/verbs/cut.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Bionetbook/bionetbook path: /bnbapp/protocols/forms/verbs/cut.py
from protocols.forms import forms
from core.utils import TIME_UNITS
class CutForm(forms.VerbForm):
<|fim_suffix|> item_to_act = forms.CharField(required=False, help_text='what are you cutting', label='item to remove')
targe... | code_fim | medium | {
"lang": "python",
"repo": "Bionetbook/bionetbook",
"path": "/bnbapp/protocols/forms/verbs/cut.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Test that files within the date window are deleted.
tf = tempfile.NamedTemporaryFile(prefix='abcd_')
with open(tf.name, 'w') as f:
f.write("content 1")
f.close()
env.upload_file(tf.name, "dataset")
date_from = datetime.now(timezone.utc)
... | code_fim | hard | {
"lang": "python",
"repo": "SAP/machine-learning-lab",
"path": "/client/tests/test_file_handler.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SAP/machine-learning-lab path: /client/tests/test_file_handler.py
import os
import tempfile
from lab_client import Environment
from .conftest import test_settings
import requests
import pytest
from datetime import datetime, timedelta, timezone
@pytest.mark.integration
class TestFile:
def t... | code_fim | hard | {
"lang": "python",
"repo": "SAP/machine-learning-lab",
"path": "/client/tests/test_file_handler.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if key is None:
return
return self._conn.get(key)
def set_key(self, key=None, value=None):
if key is None:
return
self._conn.set(key, value)
redis_client = RedisClient()<|fim_prefix|># repo: m0sk1t/akch path: /server/app/db/redis_client.py
fr... | code_fim | hard | {
"lang": "python",
"repo": "m0sk1t/akch",
"path": "/server/app/db/redis_client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_key(self, key=None):
if key is None:
return
return self._conn.get(key)
def set_key(self, key=None, value=None):
if key is None:
return
self._conn.set(key, value)
redis_client = RedisClient()<|fim_prefix|># repo: m0sk1t/akch path: ... | code_fim | hard | {
"lang": "python",
"repo": "m0sk1t/akch",
"path": "/server/app/db/redis_client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: m0sk1t/akch path: /server/app/db/redis_client.py
from os import environ
from redis import Redis, ConnectionError
from constants import CM, fmtRed
<|fim_suffix|> def set_key(self, key=None, value=None):
if key is None:
return
self._conn.set(key, value)
redis_c... | code_fim | hard | {
"lang": "python",
"repo": "m0sk1t/akch",
"path": "/server/app/db/redis_client.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xuqinghan/learn-RxPY path: /ex1.py
from rx import create
def push_five_strings(observer, scheduler):
<|fim_suffix|>source_s.subscribe(
on_next = lambda i: print("Received {0}".format(i)),
on_error = lambda e: print("Error Occurred: {0}".format(e)),
on_completed = lambda: print("Done!... | code_fim | hard | {
"lang": "python",
"repo": "xuqinghan/learn-RxPY",
"path": "/ex1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>source_s.subscribe(
on_next = lambda i: print("Received {0}".format(i)),
on_error = lambda e: print("Error Occurred: {0}".format(e)),
on_completed = lambda: print("Done!"),
)<|fim_prefix|># repo: xuqinghan/learn-RxPY path: /ex1.py
from rx import create
def push_five_strings(observer, schedul... | code_fim | hard | {
"lang": "python",
"repo": "xuqinghan/learn-RxPY",
"path": "/ex1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> setup_logger()
return DifferentialEvolution(parse_input_file(instance)).run()
if __name__ == '__main__':
main()<|fim_prefix|># repo: xstupi00/University-Course-Timetabling-Problem path: /src/ucttp.py
import logging
import sys
import click
from differential_evolution import DifferentialEvo... | code_fim | hard | {
"lang": "python",
"repo": "xstupi00/University-Course-Timetabling-Problem",
"path": "/src/ucttp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xstupi00/University-Course-Timetabling-Problem path: /src/ucttp.py
import logging
import sys
import click
from differential_evolution import DifferentialEvolution
from input import get_input_file, parse_input_file
LOGGING_LEVEL = logging.CRITICAL
def setup_logger():
"""
Setup routine... | code_fim | hard | {
"lang": "python",
"repo": "xstupi00/University-Course-Timetabling-Problem",
"path": "/src/ucttp.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> um desconto de {} e seu valor final é de {}'.format(p10, d10))
elif pagamento==2:
print('Você teve um desconto de {} e seu valor final é {}.'.format(p5, d5))
elif pagamento==4:
print('Você teve um acrescimo de {} e seu valor final é de {}'.format(p20, a20))
else:
print('Você pagara {}.'.forma... | code_fim | medium | {
"lang": "python",
"repo": "bruno1906/ExerciciosPython",
"path": "/Exercicios-Python/CursoEmVideo/ex044.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bruno1906/ExerciciosPython path: /Exercicios-Python/CursoEmVideo/ex044.py
valor=float(input('Qual o valor do produto: R$'))
pagamento=float(input('A vista dinheiro/cheque:1\nA vista no cartão:2\nAté 2x no cartão:3\n3x ou mais no ca<|fim_suffix|> um desconto de {} e seu valor final é de {}'.format... | code_fim | medium | {
"lang": "python",
"repo": "bruno1906/ExerciciosPython",
"path": "/Exercicios-Python/CursoEmVideo/ex044.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lx10077/optimpy path: /utils/common.py
import os
import torch
import torchvision.transforms as transforms
import torchvision.datasets as datasets
use_cuda = torch.cuda.is_available()
__all__ = ['prepare_dataset', 'get_flat_grad_from', 'get_flat_para_from']
def get_project_dirpath():
path ... | code_fim | hard | {
"lang": "python",
"repo": "lx10077/optimpy",
"path": "/utils/common.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> grads = []
for param in model_params:
if grad_grad:
grads.append(param.grad.grad.view(-1))
else:
if param.grad is None:
grads.append(torch.zeros(param.data.view(-1).shape))
else:
grads.append(param.grad.view(-1))
... | code_fim | hard | {
"lang": "python",
"repo": "lx10077/optimpy",
"path": "/utils/common.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>"""Disconnect from every camera"""
for camera in cameras:
api.disconnectCamera(camera)<|fim_prefix|># repo: phyorch/mantis_examples path: /python/basic/ConnectToCamera.py
import MantisPyAPI as api
cameras = []
def newCameraCallback(camera):
"""Function that handles new ACOS_CAMERA objects"""
... | code_fim | hard | {
"lang": "python",
"repo": "phyorch/mantis_examples",
"path": "/python/basic/ConnectToCamera.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>"""Print the camera ID and number of microcameras for each acos camera"""
for camera in cameras:
print("Found camera with ID "\
+ str(camera.camID) + " and "\
+ str(camera.numMCams) + " microcameras")
"""Disconnect from every camera"""
for camera in cameras:
api.disconnect... | code_fim | hard | {
"lang": "python",
"repo": "phyorch/mantis_examples",
"path": "/python/basic/ConnectToCamera.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: phyorch/mantis_examples path: /python/basic/ConnectToCamera.py
import MantisPyAPI as api
cameras = []
def newCameraCallback(camera):
"""Function that handles new ACOS_CAMERA objects"""
cameras.append(camera)
"""Connects to an acos camera"""
api.connectToCameraServer("localhost", 9999);... | code_fim | hard | {
"lang": "python",
"repo": "phyorch/mantis_examples",
"path": "/python/basic/ConnectToCamera.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class LayerManagerLaneOrientation(LayerManager):
"..."
def __init__(self, layer):
"..."
LayerManager.__init__(self, layer)
self.layer = layer
def add(self, lane):
"..."
lane_id = lane.id
LayerManager.remove_old_feature(self, lane_id)
... | code_fim | medium | {
"lang": "python",
"repo": "carla-simulator/map",
"path": "/tools/ad_map_access_qgis/ad_map_access_qgis/LayerManagerLaneOrientation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carla-simulator/map path: /tools/ad_map_access_qgis/ad_map_access_qgis/LayerManagerLaneOrientation.py
# ----------------- BEGIN LICENSE BLOCK ---------------------------------
#
# Copyright (C) 2018-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
# ----------------- END LICENSE BLOCK --... | code_fim | medium | {
"lang": "python",
"repo": "carla-simulator/map",
"path": "/tools/ad_map_access_qgis/ad_map_access_qgis/LayerManagerLaneOrientation.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='business',
name='email',
field=models.CharField(max_length=255),
),
migrations.AlterField(
model_name='neighborhood',
name='health_department_contact',
fiel... | code_fim | medium | {
"lang": "python",
"repo": "Brayooh/myHood",
"path": "/neighboor/migrations/0014_auto_20191029_1547.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Brayooh/myHood path: /neighboor/migrations/0014_auto_20191029_1547.py
# Generated by Django 2.2.6 on 2019-10-29 15:47
from django.db import migrations, models
<|fim_suffix|> dependencies = [
('neighboor', '0013_auto_20191029_1546'),
]
operations = [
migrations.AlterF... | code_fim | medium | {
"lang": "python",
"repo": "Brayooh/myHood",
"path": "/neighboor/migrations/0014_auto_20191029_1547.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: awslabs/syne-tune path: /syne_tune/optimizer/schedulers/searchers/bayesopt/models/estimator.py
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the Li... | code_fim | hard | {
"lang": "python",
"repo": "awslabs/syne-tune",
"path": "/syne_tune/optimizer/schedulers/searchers/bayesopt/models/estimator.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>OutputEstimator = Union[Estimator, Dict[str, Estimator]]
@dataclass
class TransformedData:
features: np.ndarray
targets: np.ndarray
mean: float
std: float
def transform_state_to_data(
state: TuningJobState,
active_metric: Optional[str] = None,
normalize_targets: bool = True... | code_fim | hard | {
"lang": "python",
"repo": "awslabs/syne-tune",
"path": "/syne_tune/optimizer/schedulers/searchers/bayesopt/models/estimator.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param state: ``TuningJobState`` to transform
:param active_metric: Name of target metric (optional)
:param normalize_targets: Normalize targets? Defaults to ``True``
:param num_fantasy_samples: Number of fantasy samples. Defaults to 1
:return: Transformed data
"""
if active_me... | code_fim | hard | {
"lang": "python",
"repo": "awslabs/syne-tune",
"path": "/syne_tune/optimizer/schedulers/searchers/bayesopt/models/estimator.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: devord/todo path: /todo/api/mock_helper.py
import random
from faker import Faker
from faker.providers import lorem
from api.models import Label, Item
<|fim_suffix|> fake = Faker()
fake.add_provider(lorem)
labels = []
for _ in range(num_labels):
label = Label(name=fake.... | code_fim | medium | {
"lang": "python",
"repo": "devord/todo",
"path": "/todo/api/mock_helper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fake = Faker()
fake.add_provider(lorem)
labels = []
for _ in range(num_labels):
label = Label(name=fake.word())
label.save()
labels.append(label)
for _ in range(num_items):
item = Item(title=fake.sentence(),
description=fake.paragra... | code_fim | medium | {
"lang": "python",
"repo": "devord/todo",
"path": "/todo/api/mock_helper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: trainindata/testing-and-monitoring-ml-deployments path: /packages/ml_api/tests/test_api.py
import json
import time
import numpy as np
import pytest
from api.persistence.data_access import SECONDARY_VARIABLES_TO_RENAME
from api.persistence.models import (
GradientBoostingModelPredictions,
... | code_fim | hard | {
"lang": "python",
"repo": "trainindata/testing-and-monitoring-ml-deployments",
"path": "/packages/ml_api/tests/test_api.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.mark.integration
def test_prediction_data_saved(client, app, test_inputs_df):
# Given
initial_gradient_count = app.db_session.query(
GradientBoostingModelPredictions
).count()
initial_lasso_count = app.db_session.query(LassoModelPredictions).count()
# When
response... | code_fim | hard | {
"lang": "python",
"repo": "trainindata/testing-and-monitoring-ml-deployments",
"path": "/packages/ml_api/tests/test_api.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Anonymyty/smsgateway path: /common/filelogger.py
#!/usr/bin/python
# Copyright 2015 Neuhold Markus and Kleinsasser Mario
#
# 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": "Anonymyty/smsgateway",
"path": "/common/filelogger.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def write(self, data):
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)
self.logger.error("STDIO: Called from: " + calframe[1][3])
for line in data.splitlines():
self.logger.error("STDIO: " + line)
def flush(self):
... | code_fim | medium | {
"lang": "python",
"repo": "Anonymyty/smsgateway",
"path": "/common/filelogger.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
logger = None
def __init__(self, logger):
self.logger = logger
def write(self, data):
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)
self.logger.error("STDIO: Called from: " + calframe[1][3])
for line in data.splitlin... | code_fim | medium | {
"lang": "python",
"repo": "Anonymyty/smsgateway",
"path": "/common/filelogger.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> p.primers_in_sequence = False
if p.primers is None:
p.primers = []
if len(p.primers) > 0:
p.amplicon = True
if len(p.primers) == 0 and p.amplicon:
p.primers_in_sequence = True
p.trim_primers = False
p.require_forward_primer_mapped = False
p.require_rever... | code_fim | hard | {
"lang": "python",
"repo": "Weeks-UNC/shapemapper2",
"path": "/internals/python/pyshapemap/pipeline_arg_parser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Weeks-UNC/shapemapper2 path: /internals/python/pyshapemap/pipeline_arg_parser.py
ror if
extension not recognized.
"""
fa_exts = [".fa", ".fasta"]
p, ext = os.path.splitext(filename)
if not ext.lower() in fa_exts: # TODO: check if bowtie2, STAR handle gzipped fa files
... | code_fim | hard | {
"lang": "python",
"repo": "Weeks-UNC/shapemapper2",
"path": "/internals/python/pyshapemap/pipeline_arg_parser.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for sample in groups:
sample_args, rest = fileparser.parse_known_args(groups[sample])
if len(rest) > 0:
raise RuntimeError("Error: unrecognized argument(s): {}".format(rest))
store_args(sample, sample_args)
if "modified" not in fastqs and "correct_seq" not in f... | code_fim | hard | {
"lang": "python",
"repo": "Weeks-UNC/shapemapper2",
"path": "/internals/python/pyshapemap/pipeline_arg_parser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: elastic/rally-eventdata-track path: /eventdata/runners/rollover_runner.py
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses t... | code_fim | medium | {
"lang": "python",
"repo": "elastic/rally-eventdata-track",
"path": "/eventdata/runners/rollover_runner.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> It expects the parameter hash to contain a key "alias" specifying the alias to rollover
as well as a key "body" containing the actual rollover request and associated conditions.
"""
await es.indices.rollover(alias=params["alias"], body=params["body"])
return 1, "ops"<|fim_prefix|># re... | code_fim | medium | {
"lang": "python",
"repo": "elastic/rally-eventdata-track",
"path": "/eventdata/runners/rollover_runner.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>__all__ = ["DeterministicPosterior", "GPyTorchPosterior", "Posterior"]<|fim_prefix|># repo: zpao/botorch path: /botorch/posteriors/__init__.py
#! /usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
<|fim_middle|>from .deterministic import DeterministicPosterior
f... | code_fim | medium | {
"lang": "python",
"repo": "zpao/botorch",
"path": "/botorch/posteriors/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zpao/botorch path: /botorch/posteriors/__init__.py
#! /usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
<|fim_suffix|>
__all__ = ["DeterministicPosterior", "GPyTorchPosterior", "Posterior"]<|fim_middle|>from .deterministic import DeterministicPosterior
... | code_fim | medium | {
"lang": "python",
"repo": "zpao/botorch",
"path": "/botorch/posteriors/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _simple_split(self, sentence):
sentence = re.sub('''[^a-z0-9A-Z\u00C0-\u00FF \-'.]''', '', sentence)
return nltk.word_tokenize(
sentence, language=self.language['nltk'])
def _remove_non_ascii_characters(self, sentence):
return sentence.encode("ascii", "ig... | code_fim | hard | {
"lang": "python",
"repo": "isabelchaves/BiGIT",
"path": "/src/data/processing/textual_processing.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: isabelchaves/BiGIT path: /src/data/processing/textual_processing.py
import re
import unicodedata
import inflect
import nltk
import pandas as pd
from nltk.corpus import stopwords
class PreProcessing:
"""
Class with all the necessary functions to process and tokenize an
expression or... | code_fim | hard | {
"lang": "python",
"repo": "isabelchaves/BiGIT",
"path": "/src/data/processing/textual_processing.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
sentence = re.sub('''[^a-z0-9A-Z\u00C0-\u00FF \-'.]''', '', sentence)
return nltk.word_tokenize(
sentence, language=self.language['nltk'])
def _remove_non_ascii_characters(self, sentence):
return sentence.encode("ascii", "ignore").decode()
def _replace_numbe... | code_fim | hard | {
"lang": "python",
"repo": "isabelchaves/BiGIT",
"path": "/src/data/processing/textual_processing.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jaspreetj/gdsfactory path: /gdsfactory/components/disk.py
from typing import Tuple
import numpy as np
import picwriter.components as pc
import gdsfactory as gf
from gdsfactory.component import Component
from gdsfactory.components.waveguide_template import strip
from gdsfactory.types import Comp... | code_fim | hard | {
"lang": "python",
"repo": "jaspreetj/gdsfactory",
"path": "/gdsfactory/components/disk.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Keyword Args:
wg_width: 0.5.
wg_layer: gf.LAYER.WG[0].
wg_datatype: gf.LAYER.WG[1].
clad_layer: gf.LAYER.WGCLAD[0].
clad_datatype: gf.LAYER.WGCLAD[1].
bend_radius: 10.
cladding_offset: 3.
"""
c = pc.Disk(
gf.call_if_func(waveguide_templa... | code_fim | hard | {
"lang": "python",
"repo": "jaspreetj/gdsfactory",
"path": "/gdsfactory/components/disk.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#
# 2. Install files
# Indiscriminately copy all files from the nbextensions, extensions and template directories
# Currently there is no other way, because there is no definition of a notebook extension package
#
# copy extensions to IPython extensions directory
src = 'extensions'
destinatio... | code_fim | hard | {
"lang": "python",
"repo": "zendesk/IPython-notebook-extensions",
"path": "/install.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># copy extensions to IPython extensions directory
src = 'extensions'
destination = os.path.join(data_dir, 'extensions')
if debug is True: print("Install Python extensions to %s" % destination)
recursive_overwrite(src, destination)
# Install templates
src = 'templates'
destination = os.path.join(d... | code_fim | hard | {
"lang": "python",
"repo": "zendesk/IPython-notebook-extensions",
"path": "/install.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zendesk/IPython-notebook-extensions path: /install.py
# -*- coding: utf-8 -*-
# Install notebook extensions
from __future__ import print_function
from jupyter_core.paths import jupyter_data_dir
import os
import sys
import shutil
import IPython
import notebook
debug = False
if IPyth... | code_fim | medium | {
"lang": "python",
"repo": "zendesk/IPython-notebook-extensions",
"path": "/install.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser.add_argument('-g', '--grid_search', action='store', type=str,
nargs=3, dest='grid_params',
metavar=('ESTIMATOR: gbc/svm', 'FEATURES', 'FEATURES'),
help='Model and features to be used for grid search')
parser.add_argume... | code_fim | hard | {
"lang": "python",
"repo": "pushkarmishra/AuthorProfilingAbuseDetection",
"path": "/twitter_model.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.