text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: pfnet/pfrl path: /tests/nn_tests/test_empirical_normalization.py
import unittest
import numpy as np
import pytest
import torch
from pfrl.nn import empirical_normalization
class TestEmpiricalNormalization(unittest.TestCase):
def test_small_cpu(self):
self._test_small(gpu=-1)
@... | code_fim | hard | {
"lang": "python",
"repo": "pfnet/pfrl",
"path": "/tests/nn_tests/test_empirical_normalization.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> shape = (2, 3, 4)
for batch_axis in range(3):
en = empirical_normalization.EmpiricalNormalization(
shape=shape[:batch_axis] + shape[batch_axis + 1 :],
batch_axis=batch_axis,
)
for _ in range(10):
x = np.ran... | code_fim | hard | {
"lang": "python",
"repo": "pfnet/pfrl",
"path": "/tests/nn_tests/test_empirical_normalization.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SaqibMamoon/multimodal-classification path: /code/utils/multimodal_prediction_helper.py
"""
Created on Mon Apr 29 2018
"""
import numpy as np
import pickle
import time
import os
import pandas as pd
import sys
import pandas.core.indexes
sys.modules['pandas.indexes'] = pandas.core.indexes
from ... | code_fim | hard | {
"lang": "python",
"repo": "SaqibMamoon/multimodal-classification",
"path": "/code/utils/multimodal_prediction_helper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #def preprocess(self):
#feature_tr = preprocessing.StandardScaler().fit_transform(feature_tr)
#feature_val = preprocessing.StandardScaler().fit_transform(feature_val)
#feature_te = preprocessing.StandardScaler().fit_transform(feature_te)
#lass end_to_end_multimodal(model):
#... | code_fim | hard | {
"lang": "python",
"repo": "SaqibMamoon/multimodal-classification",
"path": "/code/utils/multimodal_prediction_helper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not root:
return 0
# 不含根节点
max_deep_l = max_deep(root.left)
max_deep_r = max_deep(root.right)
# 相等,说明左子树是满的
if max_deep_l == max_deep_r:
return 1 + 2 ** max_deep_l - 1 + self.countNodes(root.right)
# 左边大,说明右子树是满的
if... | code_fim | hard | {
"lang": "python",
"repo": "ParkinWu/leetcode",
"path": "/python/leetcode/222.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ParkinWu/leetcode path: /python/leetcode/222.py
# 给出一个完全二叉树,求出该树的节点个数。
#
# 说明:
#
# 完全二叉树的定义如下:在完全二叉树中,除了最底层节点可能没填满外,其余每层节点数都达到最大值,并且最下面一层的节点都集中在该层最左边的若干位置。若最底层为第 h 层,则该层包含 1~ 2h 个节点。
#
# 示例:
#
# 输入:
# 1
# / \
# 2 3
# / \ /
# 4 5 6
#
# 输出: 6
#
# 来源:力扣(LeetCode)
# 链接:https://leetcode-... | code_fim | medium | {
"lang": "python",
"repo": "ParkinWu/leetcode",
"path": "/python/leetcode/222.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not r:
return 0
ans = 1
while r.left:
ans += 1
r = r.left
return ans
if not root:
return 0
# 不含根节点
max_deep_l = max_deep(root.left)
max_deep_r = max_deep(root.rig... | code_fim | hard | {
"lang": "python",
"repo": "ParkinWu/leetcode",
"path": "/python/leetcode/222.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rossant/galry path: /galry/visuals/visual.py
texture information of a texture data.
Arguments:
* data: the texture data as an array.
Returns:
* texinfo: a dictionary with the information related to the texture data.
"""
assert data.ndim == 3
size =... | code_fim | hard | {
"lang": "python",
"repo": "rossant/galry",
"path": "/galry/visuals/visual.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.size = kwargs.pop('size', 0)
self.default_color = kwargs.pop('default_color', (1., 1., 0., 1.))
self.bounds = kwargs.pop('bounds', None)
self.is_static = kwargs.pop('is_static', False)
self.position_attribute_name = kwargs.pop('position_attribute_name', 'positi... | code_fim | hard | {
"lang": "python",
"repo": "rossant/galry",
"path": "/galry/visuals/visual.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_variable(self, name, visual=None):
"""Return a variable by its name, and for any given visual which
is specified by its name."""
# get the variables list
if visual is None:
variables = self.variables.values()
else:
variables = se... | code_fim | hard | {
"lang": "python",
"repo": "rossant/galry",
"path": "/galry/visuals/visual.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def show_attr_info(self):
for attr in ('cmd', 'mod', 'output', 'attty', 'max_width'):
self.output.write(' -> %s: %s\n' % (attr, getattr(self, attr)))
def __del__(self):
for fname in self._cache:
try:
os.remove(fname)
except Excep... | code_fim | hard | {
"lang": "python",
"repo": "shmilee/gdpy3",
"path": "/src/visplters/imgcat.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shmilee/gdpy3 path: /src/visplters/imgcat.py
Convert image *img* to outype and resize image if needed.
Parameters
----------
img: path, bytes or Figure objec
1. image path
2. entire image bytes
3. matplotlib.figure.Figure instance
typecandidates: tuple ... | code_fim | hard | {
"lang": "python",
"repo": "shmilee/gdpy3",
"path": "/src/visplters/imgcat.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shmilee/gdpy3 path: /src/visplters/imgcat.py
g-width-height
idx = 4
while True:
block_size = struct.unpack('>H', data[idx:idx+2])[0]
idx = idx + block_size
if data[idx:idx+2] == b'\xFF\xC0':
# found Start ... | code_fim | hard | {
"lang": "python",
"repo": "shmilee/gdpy3",
"path": "/src/visplters/imgcat.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def post(self, request, phonenumber_id, *args, **kwargs):
try:
confirm = PhoneNumberConfirmation.objects.get(
phone_number__id=phonenumber_id)
confirm.resend_confirmation()
except PhoneNumberConfirmation.DoesNotExist:
raise exceptions... | code_fim | hard | {
"lang": "python",
"repo": "thomas545/django-Rest-phonenumber-confirmation",
"path": "/phonenumber_confirmation/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: thomas545/django-Rest-phonenumber-confirmation path: /phonenumber_confirmation/views.py
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext_lazy as _
from rest_framework import generics, permissions, views, exceptions
from rest_framework.response import Re... | code_fim | hard | {
"lang": "python",
"repo": "thomas545/django-Rest-phonenumber-confirmation",
"path": "/phonenumber_confirmation/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
pin = serializer.validated_data.get('pin', None)
confirmation = self.get_object(serializer)
confirmation.confirmation(pin)
return Response({"detail": _("Phone numbe... | code_fim | hard | {
"lang": "python",
"repo": "thomas545/django-Rest-phonenumber-confirmation",
"path": "/phonenumber_confirmation/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _post_order(root):
if root:
_post_order(root.left)
_post_order(root.right)
print(root.data)
_post_order(self.root)
if __name__ == '__main__':
avl_tree = AVL_Tree()
avl_tree.insert(40)
avl_tree.insert(4)
... | code_fim | hard | {
"lang": "python",
"repo": "highgarden7/Data-Structures-Algorithms",
"path": "/Trees/AVLTree.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _pre_order(root):
if root:
print(root.data)
_pre_order(root.left)
_pre_order(root.right)
_pre_order(self.root)
def post_order(self):
def _post_order(root):
if root:
_post_orde... | code_fim | hard | {
"lang": "python",
"repo": "highgarden7/Data-Structures-Algorithms",
"path": "/Trees/AVLTree.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: highgarden7/Data-Structures-Algorithms path: /Trees/AVLTree.py
class Node(object):
def __init__(self, data, left = None, right = None):
self.data = data
self.left = left
self.right = right
self.BF = 0 #Balance Factor
class AVL_Tree(object)... | code_fim | hard | {
"lang": "python",
"repo": "highgarden7/Data-Structures-Algorithms",
"path": "/Trees/AVLTree.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DinoSaulo/Django-Ecommerce path: /checkout/urls.py
# coding=utf-8
from django.conf.urls import url
from . import views
<|fim_suffix|>urlpatterns = [
url(r'^carrinho/adicionar/(?P<slug>[\w_-]+)/$', views.create_cartitem, name='create_cartitem' ) ,
url(r'^carrinho/$', views.cart_item, na... | code_fim | easy | {
"lang": "python",
"repo": "DinoSaulo/Django-Ecommerce",
"path": "/checkout/urls.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>app_name = 'checkout'
urlpatterns = [
url(r'^carrinho/adicionar/(?P<slug>[\w_-]+)/$', views.create_cartitem, name='create_cartitem' ) ,
url(r'^carrinho/$', views.cart_item, name='cart_item'),
url(r'^finalizando/$', views.checkout, name='checkout')
]<|fim_prefix|># repo: DinoSaulo/Django-Ecomm... | code_fim | easy | {
"lang": "python",
"repo": "DinoSaulo/Django-Ecommerce",
"path": "/checkout/urls.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_time_knots(time_min: int,
time_max: int,
knots: np.ndarray) -> np.ndarray:
time_knots = np.hstack([time_min, [
k for k in knots
if k > time_min and k < time_max
], time_max])
return time_knots
def get_mortality_pattern_model(df: D... | code_fim | hard | {
"lang": "python",
"repo": "al00014/emmodel",
"path": "/examples/run_flu.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: al00014/emmodel path: /examples/run_flu.py
"""
Main running script
"""
from itertools import product
from typing import Dict, List
import matplotlib.pyplot as plt
import numpy as np
from emmodel.data import DataManager
from emmodel.model import (ExcessMortalityModel, plot_data, plot_model,
... | code_fim | hard | {
"lang": "python",
"repo": "al00014/emmodel",
"path": "/examples/run_flu.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def plot_models(dm: DataManager,
results: Dict[str, DataFrame]):
for name, df in results.items():
location = name.split("-")[0]
time_unit = dm.meta[location]["time_unit"]
col_year = dm.meta[location]["col_year"]
ax, axs = plot_data(df, time_unit, col_y... | code_fim | hard | {
"lang": "python",
"repo": "al00014/emmodel",
"path": "/examples/run_flu.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if feature_id not in FEATURES:
raise ValueError("Key not a valid feature")
return FEATURES[feature_id]<|fim_prefix|># repo: azharichenko/semester-progression path: /pidriver/feature.py
FEATURES = {"DEBUG_MODE": False}
<|fim_middle|>
def feature(feature_id: str) -> bool:
| code_fim | easy | {
"lang": "python",
"repo": "azharichenko/semester-progression",
"path": "/pidriver/feature.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: azharichenko/semester-progression path: /pidriver/feature.py
FEATURES = {"DEBUG_MODE": False}
<|fim_suffix|> if feature_id not in FEATURES:
raise ValueError("Key not a valid feature")
return FEATURES[feature_id]<|fim_middle|>def feature(feature_id: str) -> bool:
| code_fim | easy | {
"lang": "python",
"repo": "azharichenko/semester-progression",
"path": "/pidriver/feature.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Create a directory for the bug
path_to_bug_dir = os.path.join(path_to_soundness_folder, str(number_of_directories))
os.mkdir(path_to_bug_dir)
# copy the orig file and the mutant to the directory for the bug
shutil.copy2(seed_file_path, path_to_bug_dir)
shutil.copy2(buggy_mutant_... | code_fim | hard | {
"lang": "python",
"repo": "Practical-Formal-Methods/storm",
"path": "/storm/utils/file_operations.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Practical-Formal-Methods/storm path: /storm/utils/file_operations.py
"""
Copyright 2020 MPI-SWS
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/lice... | code_fim | hard | {
"lang": "python",
"repo": "Practical-Formal-Methods/storm",
"path": "/storm/utils/file_operations.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def pick_a_supported_theory(path_to_benchmark, solver, seed):
import random
random.seed(seed)
all_theories_in_benchamark_dir = os.listdir(path_to_benchmark)
while True:
theory = random.choice(all_theories_in_benchamark_dir)
if theory in get_supported_theories(solver):
... | code_fim | hard | {
"lang": "python",
"repo": "Practical-Formal-Methods/storm",
"path": "/storm/utils/file_operations.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_url(self):
url_url = "test url"
test_url = mixer.blend(Url, url=url_url, title="city")
assert str(test_url) == "city " + url_url<|fim_prefix|># repo: saeedmehr/Hotel-API path: /src/importCsv/tests/test_models.py
from mixer.backend.django import mixer
from importCsv.mo... | code_fim | hard | {
"lang": "python",
"repo": "saeedmehr/Hotel-API",
"path": "/src/importCsv/tests/test_models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> hotel_name = "test hotel"
hotel = mixer.blend(Hotel, name=hotel_name)
assert str(hotel) == hotel_name
def test_url(self):
url_url = "test url"
test_url = mixer.blend(Url, url=url_url, title="city")
assert str(test_url) == "city " + url_url<|fim_prefix|>... | code_fim | medium | {
"lang": "python",
"repo": "saeedmehr/Hotel-API",
"path": "/src/importCsv/tests/test_models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saeedmehr/Hotel-API path: /src/importCsv/tests/test_models.py
from mixer.backend.django import mixer
from importCsv.models import Hotel, City, Url
import pytest
<|fim_suffix|> def test_city(self):
city_name = "test city"
city = mixer.blend(City, name=city_name)
assert... | code_fim | medium | {
"lang": "python",
"repo": "saeedmehr/Hotel-API",
"path": "/src/importCsv/tests/test_models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Initialize SSH connection.
shell = mist.api.shell.Shell(machine.ctl.get_host())
key_id, ssh_user = shell.autoconfigure(self.script.owner,
machine.cloud.id,
machine.id)
sftp = she... | code_fim | hard | {
"lang": "python",
"repo": "mistio/mist.api",
"path": "/src/mist/api/scripts/controllers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mistio/mist.api path: /src/mist/api/scripts/controllers.py
import os
import re
import yaml
import random
import logging
from time import sleep
from io import StringIO
from yaml.parser import ParserError as YamlParserError
from yaml.scanner import ScannerError as YamlScannerError
import mist.ap... | code_fim | hard | {
"lang": "python",
"repo": "mistio/mist.api",
"path": "/src/mist/api/scripts/controllers.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # pylint: disable=unused-argument,no-self-use
def on_event(self, event, extension):
""" Handles the event """
data = event.get_data()
sessions_path = os.path.expanduser(
extension.preferences['sessions_dir'])
file_path = os.path.join(sessions_path, dat... | code_fim | hard | {
"lang": "python",
"repo": "brpaz/ulauncher-tilix",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brpaz/ulauncher-tilix path: /main.py
""" Main Module """
import logging
import os
import subprocess
# pylint: disable=import-error
from ulauncher.api.client.Extension import Extension
from ulauncher.api.client.EventListener import EventListener
from ulauncher.api.shared.event import KeywordQuery... | code_fim | hard | {
"lang": "python",
"repo": "brpaz/ulauncher-tilix",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sessions_path = os.path.expanduser(
extension.preferences['sessions_dir'])
file_path = os.path.join(sessions_path, data['session'])
subprocess.Popen(['tilix --session %s' % file_path], shell=True,
stdin=None, stdout=None, stderr=None, close_fds... | code_fim | hard | {
"lang": "python",
"repo": "brpaz/ulauncher-tilix",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aws/aws-sam-cli path: /samcli/commands/build/core/options.py
"""
Build Command Options related Datastructures for formatting.
"""
from typing import Dict, List
from samcli.cli.row_modifiers import RowDefinition
from samcli.cli.core.options import ALL_COMMON_OPTIONS, add_common_options_info
# NO... | code_fim | medium | {
"lang": "python",
"repo": "aws/aws-sam-cli",
"path": "/samcli/commands/build/core/options.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>EXTENSION_OPTIONS: List[str] = ["hook_name", "skip_prepare_infra"]
BUILD_STRATEGY_OPTIONS: List[str] = ["parallel", "exclude", "manifest", "cached"]
ARTIFACT_LOCATION_OPTIONS: List[str] = [
"build_dir",
"cache_dir",
"base_dir",
]
TEMPLATE_OPTIONS: List[str] = ["parameter_overrides"]
TERRAF... | code_fim | hard | {
"lang": "python",
"repo": "aws/aws-sam-cli",
"path": "/samcli/commands/build/core/options.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> HtoC_CH3_exchange_*00_lek_ILV
'''
reference = {'journal': 'Journal of Biomolecular NMR',
'year': 2007,
'volume': 38,
'pages': '79-88'
}<|fim_prefix|># repo: yinagu/chemex path: /chemex/experiments/cpmg/ch3_h2c/exp_help.py
"""
Created on Mar 14, 2012
@a... | code_fim | medium | {
"lang": "python",
"repo": "yinagu/chemex",
"path": "/chemex/experiments/cpmg/ch3_h2c/exp_help.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Off resonance effects are taken into account. The calculation is designed
explicitly for analyzing the Lewis Kay pulse sequence:
HtoC_CH3_exchange_*00_lek_ILV
'''
reference = {'journal': 'Journal of Biomolecular NMR',
'year': 2007,
'volume': 38,
... | code_fim | hard | {
"lang": "python",
"repo": "yinagu/chemex",
"path": "/chemex/experiments/cpmg/ch3_h2c/exp_help.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yinagu/chemex path: /chemex/experiments/cpmg/ch3_h2c/exp_help.py
"""
Created on Mar 14, 2012
@author: Mike Latham
"""
# local import
parse_line = "13C(methyl) - H to C CPMG "
description = \
''' Measures methyl carbon chemical exchange recorded on site-specifically
13CH3-labeled p... | code_fim | medium | {
"lang": "python",
"repo": "yinagu/chemex",
"path": "/chemex/experiments/cpmg/ch3_h2c/exp_help.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: templeblock/vq-vae-audio path: /vq-vae/vq-vae.py
from six.moves import xrange
import better_exceptions
import tensorflow as tf
from commons import masked
import numpy as np
from commons.ops import *
import os
import time
import json
from utils import mu_law
from audio_reader import AudioReader
d... | code_fim | hard | {
"lang": "python",
"repo": "templeblock/vq-vae-audio",
"path": "/vq-vae/vq-vae.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sess = tf.Session(config=tf.ConfigProto(log_device_placement=False))
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
reader.start_threads(sess)
try:
# 100K iterations
MAX_STEPS = int(1e5) # We can move this to another file if we want
log_dir = './log... | code_fim | hard | {
"lang": "python",
"repo": "templeblock/vq-vae-audio",
"path": "/vq-vae/vq-vae.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@staticmethod
def _condition(x, encoding):
"""Condition the input on the encoding.
Args:
x: The [mb, length, channels] float tensor input.
encoding: The [mb, encoding_length, channels] float tensor encoding.
Returns:
The output after broadcasting th... | code_fim | hard | {
"lang": "python",
"repo": "templeblock/vq-vae-audio",
"path": "/vq-vae/vq-vae.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bbrighttaer/jova_baselines path: /jova/data/__init__.py
# Author: bbrighttaer
# Project: jova
# Date: 6/23/19
# Time: 12:46 AM
# File: __init__.py.py
<|fim_suffix|>from jova.data.load_dataset import load_csv_dataset
from jova.data.data import Dataset, DtiDataset, load_prot_dict, load_dti_data, b... | code_fim | medium | {
"lang": "python",
"repo": "bbrighttaer/jova_baselines",
"path": "/jova/data/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>from jova.data.load_dataset import load_csv_dataset
from jova.data.data import Dataset, DtiDataset, load_prot_dict, load_dti_data, batch_collator, load_proteins, get_data
from jova.data.datasets import *
from jova.data.data_loader import *<|fim_prefix|># repo: bbrighttaer/jova_baselines path: /jova/data/... | code_fim | medium | {
"lang": "python",
"repo": "bbrighttaer/jova_baselines",
"path": "/jova/data/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print('You\'re swell!')
print('backslash at the end of a string: \\')
print('up\\down')
print('up\down')<|fim_prefix|># repo: ilonabudapesti/toolkitten path: /summer-of-code/week-01/calc.py
# calculator
# print(1+2)
# print(3)
# print(10%2)
# print(11%2)
# for i in range(0,9):
# print("bitshift ", i... | code_fim | hard | {
"lang": "python",
"repo": "ilonabudapesti/toolkitten",
"path": "/summer-of-code/week-01/calc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ilonabudapesti/toolkitten path: /summer-of-code/week-01/calc.py
# calculator
# print(1+2)
# print(3)
# print(10%2)
# print(11%2)
# for i in range(0,9):
# print("bitshift ", i, "times ", 1<<i)
# print('Hello, world!')
# print('')
# print('Good-bye.')
# print( 'I like' + 'chocolate cake.' )
... | code_fim | medium | {
"lang": "python",
"repo": "ilonabudapesti/toolkitten",
"path": "/summer-of-code/week-01/calc.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
('wbs_item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='wbs_item', to='dashboard.WBS_Item')),
],
),
migrations.CreateModel(
name='Comment',
fields=[
('id', models.AutoField(auto_created=T... | code_fim | hard | {
"lang": "python",
"repo": "surajsjain/interactive-wbs-management-tool",
"path": "/dashboard/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: surajsjain/interactive-wbs-management-tool path: /dashboard/migrations/0001_initial.py
# Generated by Django 2.2.5 on 2019-09-10 15:11
import datetime
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration... | code_fim | hard | {
"lang": "python",
"repo": "surajsjain/interactive-wbs-management-tool",
"path": "/dashboard/migrations/0001_initial.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>the historical values.
.. rubric:: Creation of an adaptive filter
If you want to create adaptive filter (for example NLMS), with size :code:`n=4`,
learning rate :code:`mu=0.1` and random initial parameters (weights), than use
following code
.. code-block:: python
f = pa.filters.AdaptiveFilter(mode... | code_fim | hard | {
"lang": "python",
"repo": "matousc89/padasip",
"path": "/padasip/filters/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matousc89/padasip path: /padasip/filters/__init__.py
"""
.. versionadded:: 0.1
.. versionchanged:: 1.2.2
An adaptive filter is a system that changes its adaptive parameteres
- adaptive weights :math:`\\textbf{w}(k)` - according to an optimization algorithm.
The an adaptive filter can be descri... | code_fim | hard | {
"lang": "python",
"repo": "matousc89/padasip",
"path": "/padasip/filters/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> * `e` : filter error for every sample (1 dimensional array).
The size corresponds with the desired value.
* `w` : history of all weights (2 dimensional array).
Every row is set of the weights for given sample.
"""
# overwrite n with correct size
kwargs["n"] = x.shape[1]
... | code_fim | hard | {
"lang": "python",
"repo": "matousc89/padasip",
"path": "/padasip/filters/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CSEA-IITB/WriteUps path: /2020/redpwn/crypto/pseudo-key/pseudo-key.py
#!/usr/bin/env python3
from string import ascii_lowercase
chr_to_num = {c: i for i, c in enumerate(ascii_lowercase)}
num_to_chr = {i: c for i, c in enumerate(ascii_lowercase)}
def encrypt(ptxt, key):
ptxt = ptxt.lower()
... | code_fim | medium | {
"lang": "python",
"repo": "CSEA-IITB/WriteUps",
"path": "/2020/redpwn/crypto/pseudo-key/pseudo-key.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ctxt = encrypt(ptxt,key)
pseudo_key = encrypt(key,key)
print('Ciphertext:',ctxt)
print('Pseudo-key:',pseudo_key)<|fim_prefix|># repo: CSEA-IITB/WriteUps path: /2020/redpwn/crypto/pseudo-key/pseudo-key.py
#!/usr/bin/env python3
from string import ascii_lowercase
chr_to_num = {c: i for i, c in enumerate... | code_fim | medium | {
"lang": "python",
"repo": "CSEA-IITB/WriteUps",
"path": "/2020/redpwn/crypto/pseudo-key/pseudo-key.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
with open(args.file_prefix, "r", encoding="utf8") as f:
data = f.readlines()
data_split = DataSplit()
train, valid = data_split.train_valid_split(data, size=args.valid_size, shuffle=args.shuffle)
with open(args.train_path, "w", encoding="utf8") as f:
... | code_fim | medium | {
"lang": "python",
"repo": "Felixgithub2017/t2t-learning",
"path": "/mytrain/my_split.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Felixgithub2017/t2t-learning path: /mytrain/my_split.py
from processutils.textfilter import DataSplit
import argparse
parser = argparse.ArgumentParser(description="my_split.py")
parser.add_argument('-f', "--file_prefix")
parser.add_argument('--train_name', default="train")
parser.add_argument('-... | code_fim | medium | {
"lang": "python",
"repo": "Felixgithub2017/t2t-learning",
"path": "/mytrain/my_split.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tyrylu/pyfmodex path: /tests/studio/test_system.py
import os
BANK_FILE = os.path.join(os.path.dirname(__file__), "..", "Vehicles.bank")
def test_initialize(studio_system):
studio_system.initialize()
def test_flush_commands(initialized_studio_system):
initialized_studio_system.flush_com... | code_fim | hard | {
"lang": "python",
"repo": "tyrylu/pyfmodex",
"path": "/tests/studio/test_system.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> bank = initialized_studio_system.load_bank_file(BANK_FILE)
assert bank.event_count == 1
def test_event(system_with_banks):
assert system_with_banks.get_event("event:/Vehicles/Car Engine").path == "event:/Vehicles/Car Engine"<|fim_prefix|># repo: tyrylu/pyfmodex path: /tests/studio/test_syste... | code_fim | hard | {
"lang": "python",
"repo": "tyrylu/pyfmodex",
"path": "/tests/studio/test_system.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fecgov/regulations-core path: /regcore/migrations/0010_auto_20160322_1704.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
<|fim_suffix|> operations = [
migrations.RunPython(forward, backward)
]<|fim_middle|>
def forward(... | code_fim | hard | {
"lang": "python",
"repo": "fecgov/regulations-core",
"path": "/regcore/migrations/0010_auto_20160322_1704.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('regcore', '0009_auto_20160322_1646'),
]
operations = [
migrations.RunPython(forward, backward)
]<|fim_prefix|># repo: fecgov/regulations-core path: /regcore/migrations/0010_auto_20160322_1704.py
# -*- coding: utf-8 -*-
from __future__ import unicode_lit... | code_fim | medium | {
"lang": "python",
"repo": "fecgov/regulations-core",
"path": "/regcore/migrations/0010_auto_20160322_1704.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@contextlib.contextmanager
def _in_testing_app_context(application):
with application.test_request_context():
with application.test_client() as client:
yield client
@pytest.yield_fixture
def server(sandbox):
with _patch_app_with_client(app):
with _in_testing_app_cont... | code_fim | hard | {
"lang": "python",
"repo": "vdt/git-code-debt",
"path": "/tests/server/conftest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vdt/git-code-debt path: /tests/server/conftest.py
from __future__ import absolute_import
from __future__ import unicode_literals
import contextlib
import mock
import pytest
from git_code_debt.generate import main
from git_code_debt.server.app import app
from git_code_debt.server.app import App... | code_fim | hard | {
"lang": "python",
"repo": "vdt/git-code-debt",
"path": "/tests/server/conftest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@pytest.yield_fixture
def server_with_data(server, cloneable_with_commits):
main([cloneable_with_commits.path, server.sandbox.db_path])
yield auto_namedtuple(
server=server,
cloneable_with_commits=cloneable_with_commits,
)<|fim_prefix|># repo: vdt/git-code-debt path: /tests/s... | code_fim | hard | {
"lang": "python",
"repo": "vdt/git-code-debt",
"path": "/tests/server/conftest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class BreezyMap(object):
'''
bitmap that may optionally be constructed by BreezySLAM
'''
def __init__(self, MAP_SIZE_PIXELS=500):
self.mapbytes = bytearray(MAP_SIZE_PIXELS * MAP_SIZE_PIXELS)
def run(self):
return self.mapbytes
def shutdown(self):
pass
c... | code_fim | hard | {
"lang": "python",
"repo": "qian5/Donkeycar",
"path": "/projects/donkeycar/donkeycar/parts/lidar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def plot_scan(self, img, distances, angles, max_dist, draw):
for dist, angle in zip(distances, angles):
self.plot_fn(img, dist, angle, max_dist, draw)
def run(self, distances, angles):
'''
takes two lists of equal length, one of distance values, the... | code_fim | hard | {
"lang": "python",
"repo": "qian5/Donkeycar",
"path": "/projects/donkeycar/donkeycar/parts/lidar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qian5/Donkeycar path: /projects/donkeycar/donkeycar/parts/lidar.py
"""
Lidar
"""
import time
import math
import pickle
import serial
import numpy as np
from donkeycar.utils import norm_deg, dist, deg2rad, arr_to_img
from PIL import Image, ImageDraw
class RPLidar(object):
'''
https://git... | code_fim | hard | {
"lang": "python",
"repo": "qian5/Donkeycar",
"path": "/projects/donkeycar/donkeycar/parts/lidar.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_speakerImage(self):
return "https://drive.google.com/uc?export=view&id={}".format(
str(self.speakerImage.split("/")[5])
)<|fim_prefix|># repo: kavin-create/oschub path: /dashboard/models.py
from django.db import models
class Speaker(models.Model):
<|fim_middle|> ... | code_fim | medium | {
"lang": "python",
"repo": "kavin-create/oschub",
"path": "/dashboard/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return "https://drive.google.com/uc?export=view&id={}".format(
str(self.speakerImage.split("/")[5])
)<|fim_prefix|># repo: kavin-create/oschub path: /dashboard/models.py
from django.db import models
class Speaker(models.Model):
speakerName = models.CharField(max_length=6... | code_fim | easy | {
"lang": "python",
"repo": "kavin-create/oschub",
"path": "/dashboard/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kavin-create/oschub path: /dashboard/models.py
from django.db import models
class Speaker(models.Model):
<|fim_suffix|> return "https://drive.google.com/uc?export=view&id={}".format(
str(self.speakerImage.split("/")[5])
)<|fim_middle|> speakerName = models.CharFiel... | code_fim | hard | {
"lang": "python",
"repo": "kavin-create/oschub",
"path": "/dashboard/models.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DASPRiD/DASBiT path: /dasbit/plugin/uptime.py
import os
import psutil
from time import time
import datetime
from dasbit.helper import timesince
class Uptime:
def __init__(self, manager):
self.client = manager.client
<|fim_suffix|> process = psutil.Process(os.getpid())
... | code_fim | medium | {
"lang": "python",
"repo": "DASPRiD/DASBiT",
"path": "/dasbit/plugin/uptime.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.client = manager.client
manager.registerCommand('uptime', 'uptime', 'uptime', None, self.getUptime)
def getUptime(self, source):
process = psutil.Process(os.getpid())
self.client.reply(source, 'Uptime: %s' % timesince(datetime.datetime.utcfromtimestamp(process.c... | code_fim | easy | {
"lang": "python",
"repo": "DASPRiD/DASBiT",
"path": "/dasbit/plugin/uptime.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def getUptime(self, source):
process = psutil.Process(os.getpid())
self.client.reply(source, 'Uptime: %s' % timesince(datetime.datetime.utcfromtimestamp(process.create_time()), ''))<|fim_prefix|># repo: DASPRiD/DASBiT path: /dasbit/plugin/uptime.py
import os
import psutil
from time i... | code_fim | medium | {
"lang": "python",
"repo": "DASPRiD/DASBiT",
"path": "/dasbit/plugin/uptime.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/verbs/_sabotage.py
#calss header
class _SABOTAGE():
def __init__(self,):
<|fim_suffix|> self.parents = []
self.childen = []
self.properties = []
self.jsondata = {}
self.specie = 'verbs'
def run(self, obj1 = [], obj2 = []):
return self.json... | code_fim | hard | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/verbs/_sabotage.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mindspore-ai/models path: /research/cv/psenet/src/dataset.py
# Copyright 2020-2022 Huawei Technologies Co., Ltd
#
# 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... | code_fim | hard | {
"lang": "python",
"repo": "mindspore-ai/models",
"path": "/research/cv/psenet/src/dataset.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self):
cv2.setNumThreads(2)
self.is_transform = True
self.img_size = config.TRAIN_LONG_SIZE
self.kernel_num = config.KERNEL_NUM
self.min_scale = config.TRAIN_MIN_SCALE
train_data_dir = config.TRAINDATA_IMG
train_gt_dir = config.TRAI... | code_fim | hard | {
"lang": "python",
"repo": "mindspore-ai/models",
"path": "/research/cv/psenet/src/dataset.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> gt_text = gt_text.astype(np.float32)
gt_kernels = gt_kernels.astype(np.float32)
training_mask = training_mask.astype(np.float32)
return img, gt_text, gt_kernels, training_mask
def __len__(self):
return len(self.all_img_paths)
def IC15_TEST_Generator():
i... | code_fim | hard | {
"lang": "python",
"repo": "mindspore-ai/models",
"path": "/research/cv/psenet/src/dataset.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: keotl/jivago path: /test/wsgi/request/test_headers.py
import unittest
from jivago.wsgi.request.headers import Headers
<|fim_suffix|> self.assertEqual("baz", headers['FOO_BAR'])
self.assertEqual("baz", headers['Foo-Bar'])
self.assertEqual("baz", headers['FOo-baR'])<|fim_m... | code_fim | medium | {
"lang": "python",
"repo": "keotl/jivago",
"path": "/test/wsgi/request/test_headers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_whenGettingHeaderValue_thenMatchRegardlessOfCase(self):
headers = Headers({"Foo-Bar": "baz"})
self.assertEqual("baz", headers['FOO_BAR'])
self.assertEqual("baz", headers['Foo-Bar'])
self.assertEqual("baz", headers['FOo-baR'])<|fim_prefix|># repo: keotl/jivago... | code_fim | easy | {
"lang": "python",
"repo": "keotl/jivago",
"path": "/test/wsgi/request/test_headers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
# Resample so that join works well
df_gps = get_gps_dataframe(gps_path).resample('60S').mean()
df_dust = get_dust_dataframe(dust_path).resample('60S').mean()
df = df_gps.join(df_dust)
# Slice for BM 2019 (remove test values)
df = df['2019-08-23':'2019-09-... | code_fim | hard | {
"lang": "python",
"repo": "ssuffian/hotlouddusty-data",
"path": "/combine_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ssuffian/hotlouddusty-data path: /combine_data.py
#!/usr/bin/env python
from bs4 import BeautifulSoup
from datetime import datetime
import json
import os
import pandas as pd
import pytz
data_dir = 'data'
gps_path = os.path.join(data_dir, 'gps/')
dust_path = os.path.join(data_dir, 'dust/dusty.cs... | code_fim | hard | {
"lang": "python",
"repo": "ssuffian/hotlouddusty-data",
"path": "/combine_data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: avsm/signpost path: /socialnet/twython/core_examples/public_timeline.py
from twython import Twython
<|fim_suffix|>for tweet in public_timeline:
print tweet["text"]<|fim_middle|># Getting the public timeline requires no authentication, huzzah
twitter = Twython()
public_timeline = twitter.getPubl... | code_fim | medium | {
"lang": "python",
"repo": "avsm/signpost",
"path": "/socialnet/twython/core_examples/public_timeline.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for tweet in public_timeline:
print tweet["text"]<|fim_prefix|># repo: avsm/signpost path: /socialnet/twython/core_examples/public_timeline.py
from twython import Twython
<|fim_middle|># Getting the public timeline requires no authentication, huzzah
twitter = Twython()
public_timeline = twitter.getPubl... | code_fim | medium | {
"lang": "python",
"repo": "avsm/signpost",
"path": "/socialnet/twython/core_examples/public_timeline.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>.TextureFormat import TextureFormat
from .Audio import AudioType, AudioCompressionFormat, AUDIO_TYPE_EXTEMSION<|fim_prefix|># repo: hydrargyrum/UnityPy path: /UnityPy/enums/__init__.py
from .BuildTarget import BuildTarget
from .ClassIDType <|fim_middle|>import ClassIDType
from .FileType import FileType
f... | code_fim | easy | {
"lang": "python",
"repo": "hydrargyrum/UnityPy",
"path": "/UnityPy/enums/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>AudioType, AudioCompressionFormat, AUDIO_TYPE_EXTEMSION<|fim_prefix|># repo: hydrargyrum/UnityPy path: /UnityPy/enums/__init__.py
from .BuildTarget import BuildTarget
from .ClassIDType <|fim_middle|>import ClassIDType
from .FileType import FileType
from .TextureFormat import TextureFormat
from .Audio imp... | code_fim | medium | {
"lang": "python",
"repo": "hydrargyrum/UnityPy",
"path": "/UnityPy/enums/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hydrargyrum/UnityPy path: /UnityPy/enums/__init__.py
from .BuildTarget import BuildTarget
from .ClassIDType import ClassIDType
from .FileType import FileType
from <|fim_suffix|>AudioType, AudioCompressionFormat, AUDIO_TYPE_EXTEMSION<|fim_middle|>.TextureFormat import TextureFormat
from .Audio imp... | code_fim | easy | {
"lang": "python",
"repo": "hydrargyrum/UnityPy",
"path": "/UnityPy/enums/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def transform(
self,
*,
df: pd.DataFrame,
destination: FieldModel,
source: list[FieldModel],
) -> pd.DataFrame:
if destination.name not in df.columns:
df[destination.name] = None
for field in source:
df[destination.nam... | code_fim | hard | {
"lang": "python",
"repo": "whythawk/whyqd",
"path": "/whyqd/crosswalk/actions/select.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: whythawk/whyqd path: /whyqd/crosswalk/actions/select.py
from __future__ import annotations
from typing import TYPE_CHECKING
import numpy as np
from whyqd.crosswalk.base import BaseSchemaAction
from whyqd.models import FieldModel
if TYPE_CHECKING:
import modin.pandas as pd
<|fim_suffix|> ... | code_fim | hard | {
"lang": "python",
"repo": "whythawk/whyqd",
"path": "/whyqd/crosswalk/actions/select.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().__init__()
self.name = "SELECT"
self.title = "Select"
self.description = "Use sparse data from a list of fields to populate a new field. Order is important, each successive field in the list have priority over the ones before it (e.g. for columns A, B & C, values in... | code_fim | hard | {
"lang": "python",
"repo": "whythawk/whyqd",
"path": "/whyqd/crosswalk/actions/select.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kumaya/dcp path: /37.py
# The power set of a set is the set of all its subsets.
# Write a function that, given a set, generates its power set.
# For example, given the set {1, 2, 3},
# it should return {{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}.
<|fim_suffix|>if __name__ == "__main__... | code_fim | hard | {
"lang": "python",
"repo": "kumaya/dcp",
"path": "/37.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
inp = [1, 2, 3]
print "Power set:", power_set(inp, len(inp))<|fim_prefix|># repo: kumaya/dcp path: /37.py
# The power set of a set is the set of all its subsets.
# Write a function that, given a set, generates its power set.
# For example, given the set {1, 2, 3},
# it... | code_fim | hard | {
"lang": "python",
"repo": "kumaya/dcp",
"path": "/37.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tuanquanghpvn/flask-intro path: /apps/core/views.py
from flask.ext.classy import FlaskView
from flask.ext.login import current_user, current_app
from functools import wraps
def login_required(func):
<|fim_suffix|>
def admin_required(func):
"""
Decorator check required login and hava... | code_fim | hard | {
"lang": "python",
"repo": "tuanquanghpvn/flask-intro",
"path": "/apps/core/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def admin_required(func):
"""
Decorator check required login and hava staff or superuser permission
:param func:
:return:
"""
@wraps(func)
def decorated_view(*args, **kwargs):
if current_app.login_manager._login_disabled:
return func(*args, **kw... | code_fim | hard | {
"lang": "python",
"repo": "tuanquanghpvn/flask-intro",
"path": "/apps/core/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if current_app.login_manager._login_disabled:
return func(*args, **kwargs)
elif not current_user.is_authenticated and not current_user.is_active:
return current_app.login_manager.unauthorized()
elif not current_user.is_staff and not current_user.is_superuser... | code_fim | hard | {
"lang": "python",
"repo": "tuanquanghpvn/flask-intro",
"path": "/apps/core/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
df.to_csv('Dataset02en.csv',index=False)<|fim_prefix|># repo: tanishqjha2298/Toxic-message-filtering-app path: /combineEnDataSets.py
import pandas as pd
df1 = pd.read_csv('Dataset11.csv')
df2 = pd.read_csv('Dataset22.csv')
df3 = pd.read_csv('Dataset33.csv')
<|fim_middle|>df = df1.append(df2)
df = ... | code_fim | medium | {
"lang": "python",
"repo": "tanishqjha2298/Toxic-message-filtering-app",
"path": "/combineEnDataSets.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tanishqjha2298/Toxic-message-filtering-app path: /combineEnDataSets.py
import pandas as pd
df1 = pd.read_csv('Dataset11.csv')
df2 = pd.read_csv('Dataset22.csv')
df3 = pd.read_csv('Dataset33.csv')
<|fim_suffix|>print(df.describe())
df.to_csv('Dataset02en.csv',index=False)<|fim_middle|>
df =... | code_fim | easy | {
"lang": "python",
"repo": "tanishqjha2298/Toxic-message-filtering-app",
"path": "/combineEnDataSets.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>df.to_csv('Dataset02en.csv',index=False)<|fim_prefix|># repo: tanishqjha2298/Toxic-message-filtering-app path: /combineEnDataSets.py
import pandas as pd
df1 = pd.read_csv('Dataset11.csv')
df2 = pd.read_csv('Dataset22.csv')
df3 = pd.read_csv('Dataset33.csv')
df = df1.append(df2)
df = df.append(df3)
... | code_fim | easy | {
"lang": "python",
"repo": "tanishqjha2298/Toxic-message-filtering-app",
"path": "/combineEnDataSets.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ip()
print 'time for %s = %.2f' % (fname, t1-t0)
return result
return f2<|fim_prefix|># repo: jmeyers314/DPMM path: /tests/test_utils.py
def timer(f):
import functools
@functools.wraps(f)
def f2(*args, **kwargs):
<|fim_middle|> import time
import inspect
... | code_fim | medium | {
"lang": "python",
"repo": "jmeyers314/DPMM",
"path": "/tests/test_utils.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jmeyers314/DPMM path: /tests/test_utils.py
def timer(f):
import functools
@functools.wraps(f)
def f2(*args, **kwargs):
import time
import inspect
t0 = time.time()
result = f(*args, *<|fim_suffix|>ip()
print 'time for %s = %.2f' % (fname, t1-t0)... | code_fim | medium | {
"lang": "python",
"repo": "jmeyers314/DPMM",
"path": "/tests/test_utils.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.