text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> componentType = self._componentType
if componentType:
if idx >= len(componentType):
raise PyAsn1Error(
'Component type error out of range'
)
t = componentType[idx].getType()
if not t.getTagSet().isS... | code_fim | hard | {
"lang": "python",
"repo": "scalyr/scalyr-agent-2",
"path": "/scalyr_agent/third_party/pysnmp/proto/rfc1155.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: scalyr/scalyr-agent-2 path: /scalyr_agent/third_party/pysnmp/proto/rfc1155.py
from pyasn1.type import univ, tag, constraint, namedtype
from pyasn1.error import PyAsn1Error
from pysnmp.proto import error
__all__ = ['Opaque', 'NetworkAddress', 'ObjectName', 'TimeTicks',
'Counter', 'Gaug... | code_fim | hard | {
"lang": "python",
"repo": "scalyr/scalyr-agent-2",
"path": "/scalyr_agent/third_party/pysnmp/proto/rfc1155.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> filename = os.path.join("tests", "testdata", "odense_rough.mesh")
m = Mesh(filename)
with pytest.raises(Exception):
nc = m.get_node_coords(code="foo")
def test_plot_mesh():
filename = os.path.join("tests", "testdata", "odense_rough.mesh")
m = Mesh(filename)
m.plot()
... | code_fim | hard | {
"lang": "python",
"repo": "ecomodeller/mikeio",
"path": "/tests/test_mesh.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert nc.shape == (134, 3)
def test_get_bad_node_coordinates():
filename = os.path.join("tests", "testdata", "odense_rough.mesh")
m = Mesh(filename)
with pytest.raises(Exception):
nc = m.get_node_coords(code="foo")
def test_plot_mesh():
filename = os.path.join("tests", "t... | code_fim | medium | {
"lang": "python",
"repo": "ecomodeller/mikeio",
"path": "/tests/test_mesh.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ecomodeller/mikeio path: /tests/test_mesh.py
import os
import pytest
from mikeio.mesh import Mesh
def test_get_number_of_elements():
filename = os.path.join("tests", "testdata", "odense_rough.mesh")
m = Mesh(filename)
assert m.get_number_of_elements() == 654
def test_get_element_... | code_fim | hard | {
"lang": "python",
"repo": "ecomodeller/mikeio",
"path": "/tests/test_mesh.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM,socket.IPPROTO_UDP)
sock.setsockopt(socket.IPPROTO_IP,socket.IP_MULTICAST_TTL,MULTICAST_TTL)
sock.sendto("robot",(MCAST_GRP,MCAST_PORT))<|fim_prefix|># repo: vianaernesto/ServidorUDP path: /app/app.py
import socket
MCAST_GRP = '224.1.1.1'
MCAST_PORT ... | code_fim | easy | {
"lang": "python",
"repo": "vianaernesto/ServidorUDP",
"path": "/app/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vianaernesto/ServidorUDP path: /app/app.py
import socket
MCAST_GRP = '224.1.1.1'
MCAST_PORT = 5007
<|fim_suffix|>sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM,socket.IPPROTO_UDP)
sock.setsockopt(socket.IPPROTO_IP,socket.IP_MULTICAST_TTL,MULTICAST_TTL)
sock.sendto("robot",(MCAST_GRP,MCAS... | code_fim | easy | {
"lang": "python",
"repo": "vianaernesto/ServidorUDP",
"path": "/app/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dry-python/returns path: /returns/interfaces/unwrappable.py
from abc import abstractmethod
from typing import Generic, TypeVar
_FirstType = TypeVar('_FirstType')
_SecondType = TypeVar('_SecondType')
_UnwrappableType = TypeVar('_UnwrappableType', bound='Unwrappable')
class Unwrappable(Generic[... | code_fim | hard | {
"lang": "python",
"repo": "dry-python/returns",
"path": "/returns/interfaces/unwrappable.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Not all types can be ``Unwrappable`` because we do require
to raise ``UnwrapFailedError`` if unwrap is not possible.
"""
__slots__ = ()
@abstractmethod
def unwrap(self: _UnwrappableType) -> _FirstType:
"""
Custom magic method to unwrap inner value from container.
... | code_fim | hard | {
"lang": "python",
"repo": "dry-python/returns",
"path": "/returns/interfaces/unwrappable.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: abdullahthabit/MAIA-projects path: /Summer internship - Uncertainty Estimation in Deep Learning Glioma Segmentation as a Measure for Active Learning/Code/glassimaging/training/standardTrainer.py
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
import tor... | code_fim | hard | {
"lang": "python",
"repo": "abdullahthabit/MAIA-projects",
"path": "/Summer internship - Uncertainty Estimation in Deep Learning Glioma Segmentation as a Measure for Active Learning/Code/glassimaging/training/standardTrainer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def initFromDesc(desc):
net = createModel(desc)
optimizer = optim.Adam(net.parameters(), lr=StandardTrainer.lr)
scheduler = optim.lr_scheduler.ReduceLROnPlateau(optimizer)
return StandardTrainer(net, optimizer, scheduler=scheduler)
def saveModel(s... | code_fim | hard | {
"lang": "python",
"repo": "abdullahthabit/MAIA-projects",
"path": "/Summer internship - Uncertainty Estimation in Deep Learning Glioma Segmentation as a Measure for Active Learning/Code/glassimaging/training/standardTrainer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def trainWithBatch(self, imagebatch, targetbatch):
self.net = self.net.train()
targetbatch = targetbatch.long()
targetbatch = targetbatch[:,:,:,:]
imagebatch = imagebatch.float()
targetbatch = targetbatch.to(self.device)
imagebatch = imagebatch.to(self.d... | code_fim | hard | {
"lang": "python",
"repo": "abdullahthabit/MAIA-projects",
"path": "/Summer internship - Uncertainty Estimation in Deep Learning Glioma Segmentation as a Measure for Active Learning/Code/glassimaging/training/standardTrainer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self):
self.x_data = [[73, 80, 75],
[93, 88, 93],
[89, 91, 90],
[96, 98, 100],
[73, 66, 70]]
self.y_data = [[152], [185], [180], [196], [142]]
def __len__(self):
return... | code_fim | medium | {
"lang": "python",
"repo": "HyundongHwang/PyTorchDeepLearningStart",
"path": "/0307_custom_dataset.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HyundongHwang/PyTorchDeepLearningStart path: /0307_custom_dataset.py
import myutil as mu
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.utils.data import TensorDataset # 텐서데이터셋
from torch.utils.data import DataLoader # 데이터로더
from torch.... | code_fim | hard | {
"lang": "python",
"repo": "HyundongHwang/PyTorchDeepLearningStart",
"path": "/0307_custom_dataset.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Train the model with only train data and best parameters of random search
estimator = DummyRegressor(**grid_search.best_params_)
estimator.fit(X_train, y_train)
results_searchcv(grid_search, estimator, X_val, y_val)<|fim_prefix|># repo: Albert-GM/TFM path: /src/models/dummy_regressor.py
# allows to im... | code_fim | hard | {
"lang": "python",
"repo": "Albert-GM/TFM",
"path": "/src/models/dummy_regressor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Albert-GM/TFM path: /src/models/dummy_regressor.py
# allows to import own functions
import sys
import os
import re
root_project = re.findall(r'(^\S*TFM)', os.getcwd())[0]
sys.path.append(root_project)
from src.utils.help_func import results_searchcv,plot_predictions,\
errors_distribution, pl... | code_fim | hard | {
"lang": "python",
"repo": "Albert-GM/TFM",
"path": "/src/models/dummy_regressor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return "%s, Value: %s" % (self.type, self.value)<|fim_prefix|># repo: OtavioHenrique/yalul path: /yalul/lex/token.py
class Token:
"""
A lex Token of the yalul language
"""
def __init__(self, type, value):
"""
Construct a new Token object.
:params type: Typ... | code_fim | easy | {
"lang": "python",
"repo": "OtavioHenrique/yalul",
"path": "/yalul/lex/token.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OtavioHenrique/yalul path: /yalul/lex/token.py
class Token:
"""
A lex Token of the yalul language
"""
def __init__(self, type, value):
<|fim_suffix|> :params type: Type of the token, this type must be a TokenType
:param value: The literal value of the token
... | code_fim | easy | {
"lang": "python",
"repo": "OtavioHenrique/yalul",
"path": "/yalul/lex/token.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ristani/Codewars-Katas path: /kyu-06/delete-repeating-elements.py
"""
Given a list lst and a number N, create a new list that contains each
number of lst at most N times without reordering. For example if N = 2,
and the input is [1,2,3,1,2,1,2,3], you take [1,2,3,1,2], drop the next
[1,2] since t... | code_fim | medium | {
"lang": "python",
"repo": "Ristani/Codewars-Katas",
"path": "/kyu-06/delete-repeating-elements.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Get a new list that we will return.
result = []
# Get a dictionary to count the occurrences.
occurrences = {}
# Loop through all provided numbers.
for n in order:
# Get the count of the current number, or assign it to 0.
count = occurrences.setdefault(n, 0)
... | code_fim | medium | {
"lang": "python",
"repo": "Ristani/Codewars-Katas",
"path": "/kyu-06/delete-repeating-elements.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dade-ai/sflow path: /sflow/core/icore.py
# -*- coding: utf-8 -*-
# from __future__ import absolute_import
from contextlib import contextmanager
import collections
import tensorflow as tf
from .iconst import const
from .defaults import Dic
from snipy.basic import (patchmethod, patchproperty, tupl... | code_fim | hard | {
"lang": "python",
"repo": "dade-ai/sflow",
"path": "/sflow/core/icore.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# noinspection PyShadowingNames
@patchmethod(tf.Tensor, name='eval')
def _tensor_eval(t, feed_dict=None, session=None):
# noinspection PyProtectedMember
return t._eval(feed_dict=feed_dict, session=session or t.session) # tf.get_default_session()) # ,t.session)
# noinspection PyShadowingNames
... | code_fim | hard | {
"lang": "python",
"repo": "dade-ai/sflow",
"path": "/sflow/core/icore.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BabyYodaFanclub/RoboRepair path: /BotProject/BotBase.py
from abc import ABCMeta, abstractmethod
from telegram import ChatAction
class BotBase(metaclass=ABCMeta):
@abstractmethod
def send_text(self, chat_id: str, text: str):
pass
@abstractmethod
def send_image(self, cha... | code_fim | hard | {
"lang": "python",
"repo": "BabyYodaFanclub/RoboRepair",
"path": "/BotProject/BotBase.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass
@abstractmethod
def delayed_type_message(self, chat_id: str, text: str, callback):
pass
@abstractmethod
def send_iteratively_edited_message(self, chat_id: str, texts: list):
pass<|fim_prefix|># repo: BabyYodaFanclub/RoboRepair path: /BotProject/BotBase.py
fr... | code_fim | medium | {
"lang": "python",
"repo": "BabyYodaFanclub/RoboRepair",
"path": "/BotProject/BotBase.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lehduong/NPTM path: /hrank/models/googlenet_cifar.py
'''GoogLeNet with PyTorch.'''
import torch
import torch.nn as nn
norm_mean, norm_var = 0.0, 1.0
cov_cfg=[(22*i+2) for i in range(1+2+5+2)]
class Inception(nn.Module):
def __init__(self, in_planes, n1x1, n3x3red, n3x3, n5x5red, n5x5, p... | code_fim | hard | {
"lang": "python",
"repo": "lehduong/NPTM",
"path": "/hrank/models/googlenet_cifar.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 256 x 32 x 32
out = self.inception_b3(out)
# 480 x 32 x 32
out = self.maxpool1(out)
# 480 x 16 x 16
out = self.inception_a4(out)
# 512 x 16 x 16
out = self.inception_b4(out)
# 512 x 16 x 16
out = self.inception_c4(out)
... | code_fim | hard | {
"lang": "python",
"repo": "lehduong/NPTM",
"path": "/hrank/models/googlenet_cifar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shkarupa-alex/ruconlluconv path: /ruconlluconv/space/dataset.py
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import csv
import os
import random
from conllu import parse
def create_dataset(src_files, dest_path):
... | code_fim | hard | {
"lang": "python",
"repo": "shkarupa-alex/ruconlluconv",
"path": "/ruconlluconv/space/dataset.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> curr_id = 0
while len(train_data):
curr_data, train_data = train_data[:10000], train_data[10000:]
curr_id += 1
with open(os.path.join(dest_path, 'train-{}.txt'.format(curr_id)), 'w', newline='') as f:
csvwriter = csv.writer(f, quoting=csv.QUOTE_ALL)
... | code_fim | hard | {
"lang": "python",
"repo": "shkarupa-alex/ruconlluconv",
"path": "/ruconlluconv/space/dataset.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mike03052000/python path: /Training/2014-0110-training/Code_python/TextAndFiles/Solutions/filter2.py
#!/usr/bin/env python
"""
Filters using generator functions.
Use generator functions to write filters.
Each filter function takes the following arguments:
1. An iterable
2. A function that ... | code_fim | hard | {
"lang": "python",
"repo": "mike03052000/python",
"path": "/Training/2014-0110-training/Code_python/TextAndFiles/Solutions/filter2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def filter(iterable, filter_func):
"""Filter the strings in iterable using filter_func.
Return a generator function.
"""
for item in iterable:
item = filter_func(item)
if item is not None:
yield item
def add_double_mash(line):
"""Add comment characters (... | code_fim | hard | {
"lang": "python",
"repo": "mike03052000/python",
"path": "/Training/2014-0110-training/Code_python/TextAndFiles/Solutions/filter2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_get_bytes_from_pem(self):
content = ("-----BEGIN CERTIFICATE-----\n"
"certificate\n"
"-----END CERTIFICATE----\n")
base64_bytes = textutil.get_bytes_from_pem(content)
self.assertEquals("certificate", base64_bytes)
content... | code_fim | hard | {
"lang": "python",
"repo": "clearlinux/WALinuxAgent",
"path": "/tests/utils/test_text_util.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> content = ("-----BEGIN PRIVATE KEY-----\n"
"private key\n"
"-----END PRIVATE Key-----\n")
base64_bytes = textutil.get_bytes_from_pem(content)
self.assertEquals("private key", base64_bytes)
if __name__ == '__main__':
unittest.main()... | code_fim | hard | {
"lang": "python",
"repo": "clearlinux/WALinuxAgent",
"path": "/tests/utils/test_text_util.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: clearlinux/WALinuxAgent path: /tests/utils/test_text_util.py
# Copyright 2014 Microsoft Corporation
#
# 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.a... | code_fim | hard | {
"lang": "python",
"repo": "clearlinux/WALinuxAgent",
"path": "/tests/utils/test_text_util.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Fabriceibols/API-Wars path: /modules/constants.py
# ---------------------------------------------------------------------------------------------------------------------
# API Wars
# constan... | code_fim | hard | {
"lang": "python",
"repo": "Fabriceibols/API-Wars",
"path": "/modules/constants.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
HEADERS = _Headers()
# --------------------------------------------------- webside logic ---------------------------------------------------
# The names of the columns that contain the button data.
class _ColumnWithButton:
PLANETS = (
KEY.PLANETS.RESIDENTS,
)
STARSHIPS = (
... | code_fim | hard | {
"lang": "python",
"repo": "Fabriceibols/API-Wars",
"path": "/modules/constants.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>GET', expected_status=200):
sys.exit(0)
sys.exit(1)<|fim_prefix|># repo: BioinformaticsArchive/phylesystem-api path: /ws-tests/test_api_root.py
#!/usr/bin/env python
import sys, os
from opentreetest<|fim_middle|>ing import test_http_json_method, config
DOMAIN = config('host', 'apihost')
if test_http_... | code_fim | medium | {
"lang": "python",
"repo": "BioinformaticsArchive/phylesystem-api",
"path": "/ws-tests/test_api_root.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BioinformaticsArchive/phylesystem-api path: /ws-tests/test_api_root.py
#!/usr/bin/env python
import sys, os
from opentreetest<|fim_suffix|>g('host', 'apihost')
if test_http_json_method(DOMAIN, 'GET', expected_status=200):
sys.exit(0)
sys.exit(1)<|fim_middle|>ing import test_http_json_method, ... | code_fim | easy | {
"lang": "python",
"repo": "BioinformaticsArchive/phylesystem-api",
"path": "/ws-tests/test_api_root.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 5G-del/python-phoenixdb path: /phoenixdb/tests/test_connection.py
import unittest
import phoenixdb
from phoenixdb.tests import TEST_DB_URL
@unittest.skipIf(TEST_DB_URL is None, "these tests require the PHOENIXDB_TEST_DB_URL environment variable set to a clean database")
class PhoenixConnectionT... | code_fim | hard | {
"lang": "python",
"repo": "5G-del/python-phoenixdb",
"path": "/phoenixdb/tests/test_connection.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
r = phoenixdb.connect(TEST_DB_URL, **connect_kw_args)
except AttributeError:
self.fail("Failed to connect")
return r
def test_connection_credentials(self):
connect_kw_args = {'user': 'SCOTT', 'password': 'TIGER', 'readonly': 'True'}
... | code_fim | hard | {
"lang": "python",
"repo": "5G-del/python-phoenixdb",
"path": "/phoenixdb/tests/test_connection.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_connection_credentials(self):
connect_kw_args = {'user': 'SCOTT', 'password': 'TIGER', 'readonly': 'True'}
con = self._connect(connect_kw_args)
try:
self.assertEqual(
con._connection_args, {'user': 'SCOTT', 'password': 'TIGER'},
... | code_fim | hard | {
"lang": "python",
"repo": "5G-del/python-phoenixdb",
"path": "/phoenixdb/tests/test_connection.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> mdl.setObjective(gu.quicksum(buy[f] * c["Cost"] for f,c in dat.foods.items()),
sense=gu.GRB.MINIMIZE)
mdl.optimize()
if mdl.status == gu.GRB.OPTIMAL:
sln = solution_schema.TicDat()
for f,x in buy.items():
if x.x > 0:
sln.buy_foo... | code_fim | hard | {
"lang": "python",
"repo": "ticdat/ticdat",
"path": "/examples/expert_section/diet_simple_package/solve_code.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Create decision variables for the foods to buy
buy = {f:mdl.addVar(name=f) for f in dat.foods}
# Nutrition constraints
for c in dat.categories:
mdl.addConstr(gu.quicksum(dat.nutrition_quantities[f,c]["Quantity"] * buy[f]
for f in dat.foods) == nutrition[c]... | code_fim | hard | {
"lang": "python",
"repo": "ticdat/ticdat",
"path": "/examples/expert_section/diet_simple_package/solve_code.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ticdat/ticdat path: /examples/expert_section/diet_simple_package/solve_code.py
from diet_simple_package.schemas import input_schema, solution_schema
try: # if you don't have gurobipy installed, the code will still load and then fail on solve
import gurobipy as gu
except:
gu = None
# ----... | code_fim | hard | {
"lang": "python",
"repo": "ticdat/ticdat",
"path": "/examples/expert_section/diet_simple_package/solve_code.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Onac8/X-Serv-14.2-Variaciones path: /servidor-http-simple.py
#!/usr/bin/python3
"""
Simple HTTP Server
Jesus M. Gonzalez-Barahona and Gregorio Robles
{jgb, grex} @ gsyc.es
TSAI, SAT and SARO subjects (Universidad Rey Juan Carlos)
"""
import socket
# Create a TCP objet socket and bind it to a p... | code_fim | hard | {
"lang": "python",
"repo": "Onac8/X-Serv-14.2-Variaciones",
"path": "/servidor-http-simple.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>mySocket.listen(5)
# Accept connections, read incoming data, and answer back an HTML page
# (in an infinite loop)
try:
while True:
print('Waiting for connections')
(recvSocket, address) = mySocket.accept()
print('HTTP request received:')
print(recvSocket.recv(2048))
... | code_fim | hard | {
"lang": "python",
"repo": "Onac8/X-Serv-14.2-Variaciones",
"path": "/servidor-http-simple.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># Queue a maximum of 5 TCP connection requests
mySocket.listen(5)
# Accept connections, read incoming data, and answer back an HTML page
# (in an infinite loop)
try:
while True:
print('Waiting for connections')
(recvSocket, address) = mySocket.accept()
print('HTTP request re... | code_fim | hard | {
"lang": "python",
"repo": "Onac8/X-Serv-14.2-Variaciones",
"path": "/servidor-http-simple.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lonsofore/InvertedIndex path: /invertedindexproto/invertedindex_pb2.py
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: invertedindex.proto
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descrip... | code_fim | hard | {
"lang": "python",
"repo": "Lonsofore/InvertedIndex",
"path": "/invertedindexproto/invertedindex_pb2.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>IdArray = _reflection.GeneratedProtocolMessageType('IdArray', (_message.Message,), dict(
DESCRIPTOR = _IDARRAY,
__module__ = 'invertedindex_pb2'
# @@protoc_insertion_point(class_scope:invertedindex.IdArray)
))
_sym_db.RegisterMessage(IdArray)
Text = _reflection.GeneratedProtocolMessageType('Text'... | code_fim | hard | {
"lang": "python",
"repo": "Lonsofore/InvertedIndex",
"path": "/invertedindexproto/invertedindex_pb2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>DESCRIPTOR.message_types_by_name['Id'] = _ID
DESCRIPTOR.message_types_by_name['IdArray'] = _IDARRAY
DESCRIPTOR.message_types_by_name['Text'] = _TEXT
DESCRIPTOR.message_types_by_name['Status'] = _STATUS
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
Id = _reflection.GeneratedProtocolMessageType('Id', (_messag... | code_fim | hard | {
"lang": "python",
"repo": "Lonsofore/InvertedIndex",
"path": "/invertedindexproto/invertedindex_pb2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: T4rk1n/dazzler path: /tests/test_page_parts.py
import pytest
@pytest.mark.async_test
async def test_page_parts(browser, start_visit):
from tests.apps.page_parts.page_parts import app
await start_visit(app, pages_directory='tests/apps/page_parts/pages')
await browser.get('http://lo... | code_fim | medium | {
"lang": "python",
"repo": "T4rk1n/dazzler",
"path": "/tests/test_page_parts.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for selector in ('header', 'first', 'footer'):
await browser.click(f'#bind-{selector}-clicker')
await browser.wait_for_text_to_equal(f'#bind-{selector}-output', '1')
await browser.get('http://localhost:8150/second')
await browser.wait_for_text_to_equal('#second', 'second')
... | code_fim | medium | {
"lang": "python",
"repo": "T4rk1n/dazzler",
"path": "/tests/test_page_parts.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gnarph/DIRT path: /models/document.py
from collections import defaultdict
from functools import wraps
from utilities import file_ops
class InvalidDocumentException(BaseException):
pass
def error_handler(fn):
@wraps(fn)
def wrapped(*args, **kwargs):
try:
val = ... | code_fim | hard | {
"lang": "python",
"repo": "gnarph/DIRT",
"path": "/models/document.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Get the preprocessed body of the file
"""
return file_ops.read_utf8(self.pre_file_name)
def clone(self):
"""
Make a copy
:return: return a copy of the document object
"""
return Document(file_name=self.file_name,
... | code_fim | hard | {
"lang": "python",
"repo": "gnarph/DIRT",
"path": "/models/document.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.n_frame_len = int(frame_len * sample_rate)
self.buffer = np.zeros(
shape=2*int(frame_overlap * sample_rate) + self.n_frame_len,
dtype=np.float32)
self.reset()
def _decode(self, frame, merge):
assert len(frame)==self.n_frame_len
... | code_fim | hard | {
"lang": "python",
"repo": "Leofltt/rg_speech_to_text",
"path": "/TheSoundOfAIOSR/stt/nemo/audio_framer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Leofltt/rg_speech_to_text path: /TheSoundOfAIOSR/stt/nemo/audio_framer.py
import numpy as np
import torch
# class for streaming frame-based ASR
# 1) use reset() method to reset FrameASR's state
# 2) call transcribe(frame) to do ASR on
# contiguous signal's frames
class FrameASR:
def ... | code_fim | hard | {
"lang": "python",
"repo": "Leofltt/rg_speech_to_text",
"path": "/TheSoundOfAIOSR/stt/nemo/audio_framer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nitely/http-lazy-headers path: /http_lazy_headers/shared/common/language_tags.py
# -*- coding: utf-8 -*-
from ..utils import constraints
from ..utils import checkers
from ..utils import assertions
from ..utils import ascii_tools
from ... import exceptions
# A-Z / a-z
_ALPHA = frozenset(
as... | code_fim | hard | {
"lang": "python",
"repo": "nitely/http-lazy-headers",
"path": "/http_lazy_headers/shared/common/language_tags.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if sub_tag_len == 4 and is_alpha(sub_tag):
lang_tag[SCRIPT] = sub_tag
continue
if curr == REGION:
curr = VARIANT
if sub_tag_len == 2 and is_alpha(sub_tag):
lang_tag[REGION] = sub_tag
continue
... | code_fim | hard | {
"lang": "python",
"repo": "nitely/http-lazy-headers",
"path": "/http_lazy_headers/shared/common/language_tags.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if sub_tag_len == 4 and checkers.is_number(sub_tag[0]):
variants.append(sub_tag)
continue
curr = EXTENSION
# https://tools.ietf.org/html/rfc5646#section-2.2.6
if curr == EXTENSION:
if sub_tag_len == 1 and sub_tag[0] != '... | code_fim | hard | {
"lang": "python",
"repo": "nitely/http-lazy-headers",
"path": "/http_lazy_headers/shared/common/language_tags.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># add a steps renderer
p.step([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2, mode="center")
show(p)<|fim_prefix|># repo: bokeh/bokeh path: /examples/basic/lines/line_steps.py
from bokeh.plotting import figure, show
<|fim_middle|>p = figure(width=400, height=400)
| code_fim | easy | {
"lang": "python",
"repo": "bokeh/bokeh",
"path": "/examples/basic/lines/line_steps.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bokeh/bokeh path: /examples/basic/lines/line_steps.py
from bokeh.plotting import figure, show
<|fim_suffix|># add a steps renderer
p.step([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2, mode="center")
show(p)<|fim_middle|>p = figure(width=400, height=400)
| code_fim | easy | {
"lang": "python",
"repo": "bokeh/bokeh",
"path": "/examples/basic/lines/line_steps.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> ft = flawed_ft(puzzle_input)
for _ in range(99):
next(ft)
signal_output = next(ft)[0:8]
print("output signal is {}".format(''.join([str(j) for j in signal_output])))
def puzzle_part_b(puzzle_input):
n_repetitions = 10000
input_length = puzzle_input.shape[0] * n_repetition... | code_fim | hard | {
"lang": "python",
"repo": "rfrazier716/advent_of_code_2019",
"path": "/advent_of_code/day16.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rfrazier716/advent_of_code_2019 path: /advent_of_code/day16.py
import numpy as np
from pathlib import Path
from math import ceil
def get_base_pattern(phase_step):
return np.roll(np.repeat(np.array([0, 1, 0, -1]), phase_step + 1), -1)
def flawed_ft(ft_input=np.array([])):
# generator to ... | code_fim | hard | {
"lang": "python",
"repo": "rfrazier716/advent_of_code_2019",
"path": "/advent_of_code/day16.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def puzzle_tests():
test_input_string="12345678"
puzzle_input=np.array([int(x) for x in test_input_string])
ft = flawed_ft(puzzle_input)
for _ in range(4):
print(next(ft))
signal_output = next(ft)[0:8]
print("output signal is {}".format(''.join([str(j) for j in signal_outpu... | code_fim | hard | {
"lang": "python",
"repo": "rfrazier716/advent_of_code_2019",
"path": "/advent_of_code/day16.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def check(expected, output):
global test_case_number
expected_size = len(expected)
output_size = len(output)
result = True
if expected_size != output_size:
result = False
for i in range(min(expected_size, output_size)):
result &= (output[i] == expected[i])
right... | code_fim | hard | {
"lang": "python",
"repo": "DeerFreckles/training-largest-triple-products",
"path": "/largest_triple_products.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DeerFreckles/training-largest-triple-products path: /largest_triple_products.py
import math
def findMaxProduct(arr):
out = []
for i in range(len(arr)):
if i < 2:
out.append(-1)
else:
tmp = arr[0:i+1]
tmp.sort(reverse=True)
o... | code_fim | hard | {
"lang": "python",
"repo": "DeerFreckles/training-largest-triple-products",
"path": "/largest_triple_products.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yukkikou/taco path: /taco/test/test_cluster_genes.py
'''
TACO: Multi-sample transcriptome assembly from RNA-Seq
'''
from operator import itemgetter
from taco.lib.assemble import Cluster
<|fim_suffix|> clusters, filtered = Cluster.build([a1, a2, b1, rt1], min_frac=0.01)
assert len(cluster... | code_fim | hard | {
"lang": "python",
"repo": "yukkikou/taco",
"path": "/taco/test/test_cluster_genes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> a1 = ((1, 2, 3, 4), 1000)
a2 = ((4, 5, 6), 1000)
b1 = ((7, 8, 9), 100)
rt1 = ((6, 7), 1)
clusters, filtered = Cluster.build([a1, a2, b1, rt1], min_frac=0.0)
assert len(clusters) == 1
assert len(filtered) == 0
clusters, filtered = Cluster.build([a1, a2, b1, rt1], min_frac=... | code_fim | medium | {
"lang": "python",
"repo": "yukkikou/taco",
"path": "/taco/test/test_cluster_genes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> clusters, filtered = Cluster.build([a1, a2, b1, rt1], min_frac=0.0)
assert len(clusters) == 1
assert len(filtered) == 0
clusters, filtered = Cluster.build([a1, a2, b1, rt1], min_frac=0.01)
assert len(clusters) == 2
assert len(filtered) == 1
# print 'clusters', len(clusters)
... | code_fim | medium | {
"lang": "python",
"repo": "yukkikou/taco",
"path": "/taco/test/test_cluster_genes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().__init__()
# Получение автодополнений, где
# con - соединение
# tokens (list) - список лексем
# content (str) - содержимое файла
# line (int) - строка
# position (int) - позиция в строке
# chatId (str) - ID чата
# branchId (str) - ID ветки
def getAutoc... | code_fim | medium | {
"lang": "python",
"repo": "reviewgramweb/reviewgram",
"path": "/backend/pythonautocompleter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: reviewgramweb/reviewgram path: /backend/pythonautocompleter.py
from abc import ABC, abstractmethod
from reviewgramdb import *
from repoutils import *
import pymysql
import jedi
# Делает автодополнение через jedi, используя даннные папки и содержимое
def jedi_try_autocomplete_with_folder(conten... | code_fim | hard | {
"lang": "python",
"repo": "reviewgramweb/reviewgram",
"path": "/backend/pythonautocompleter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> otree = octree.OcTree(np.ones([210, 3]))
otree.grow()
if __name__ == '__main__':
unittest.main()<|fim_prefix|># repo: nejcd/pointcloud path: /tests/test_octree.py
import unittest
from pointcloud.utils import octree
import numpy as np
<|fim_middle|>
class TestOcTree(unittest.TestCase... | code_fim | medium | {
"lang": "python",
"repo": "nejcd/pointcloud",
"path": "/tests/test_octree.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nejcd/pointcloud path: /tests/test_octree.py
import unittest
from pointcloud.utils import octree
import numpy as np
class TestOcTree(unittest.TestCase):
<|fim_suffix|>if __name__ == '__main__':
unittest.main()<|fim_middle|> def test_create_tree(self):
otree = octree.OcTree(np.on... | code_fim | medium | {
"lang": "python",
"repo": "nejcd/pointcloud",
"path": "/tests/test_octree.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JoseALermaIII/python-tutorials path: /pythontutorials/books/AutomateTheBoringStuff/Ch10/P4_podBayDoor.py
"""Pod Bay Door
This program raises an :py:class:`AssertionError`.
<|fim_suffix|>def main():
podBayDoorStatus = "open"
assert podBayDoorStatus == "open", "The pod bay doors need to b... | code_fim | easy | {
"lang": "python",
"repo": "JoseALermaIII/python-tutorials",
"path": "/pythontutorials/books/AutomateTheBoringStuff/Ch10/P4_podBayDoor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> podBayDoorStatus = "open"
assert podBayDoorStatus == "open", "The pod bay doors need to be 'open'."
podBayDoorStatus = 'I\'m sorry, Dave. I\'m afraid I can\'t do that.'
assert podBayDoorStatus == "open", "The pod bay doors need to be 'open'."
if __name__ == '__main__':
main()<|fim_pr... | code_fim | easy | {
"lang": "python",
"repo": "JoseALermaIII/python-tutorials",
"path": "/pythontutorials/books/AutomateTheBoringStuff/Ch10/P4_podBayDoor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> settings = frappe.get_single("Extraesia Settings")
if not settings.sales_order_items_validation:
return
for item in doc.items:
item_data = get_data(item.item_code)
for data in item_data:
if data["warehouse"] == item.warehouse:
if data["projec... | code_fim | medium | {
"lang": "python",
"repo": "exar888/extraesia",
"path": "/extraesia/slaes_order.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: exar888/extraesia path: /extraesia/slaes_order.py
from __future__ import unicode_literals
import frappe
from frappe import _
from erpnext.stock.dashboard.item_dashboard import get_data
<|fim_suffix|> settings = frappe.get_single("Extraesia Settings")
if not settings.sales_order_items_vali... | code_fim | medium | {
"lang": "python",
"repo": "exar888/extraesia",
"path": "/extraesia/slaes_order.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zain-zafar/University-CS-Exercises path: /CSCA08 - Introduction to CS 1/ex2 - Course Mark Calculator.py
# Global variables. Feel free to play around with these
# but please return them to their original values before you submit.
a0_weight = 5
a1_weight = 7
a2_weight = 8
term_tests_weight = 20
exa... | code_fim | hard | {
"lang": "python",
"repo": "zain-zafar/University-CS-Exercises",
"path": "/CSCA08 - Introduction to CS 1/ex2 - Course Mark Calculator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#-----------------------------------------------------------------------------
#The function final_mark generates the term mark of the student by adding up
#the percentage received by the student on assignments,tests,quizzes
#tests, and also final exam
def final_mark(a0_mark,a1_mark,a2_mark,exercises_m... | code_fim | hard | {
"lang": "python",
"repo": "zain-zafar/University-CS-Exercises",
"path": "/CSCA08 - Introduction to CS 1/ex2 - Course Mark Calculator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # template2 = Image.open('C:/Users/ojaash/Desktop/images_and_sample-code/test-images/template2.png')
template2 = ht.resizeTemplate(template2, space*3)
template2 = np.array(template2)
template2 = ko.rgb2gray(template2)
print('Template 2 Shape', template2.shape)
# template3 = Image.... | code_fim | hard | {
"lang": "python",
"repo": "robin1221/Optical_Music_Recognition",
"path": "/omr.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: robin1221/Optical_Music_Recognition path: /omr.py
import numpy as np
import sys
from PIL import Image
from PIL import ImageFilter
import random
from PIL import ImageDraw
from Kernel_Operations import kernelOperations
from Template_Matching import templateMatching
from Hough_Transform import houg... | code_fim | hard | {
"lang": "python",
"repo": "robin1221/Optical_Music_Recognition",
"path": "/omr.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pavanrao/bitesofpy path: /pybites_bite55/steam.py
from collections import namedtuple
import feedparser
# cached version to have predictable results for testing
FEED_URL = "https://bites-data.s3.us-east-2.amazonaws.com/steam_gaming.xml"
Game = namedtuple('Game', 'title link')
<|fim_... | code_fim | medium | {
"lang": "python",
"repo": "pavanrao/bitesofpy",
"path": "/pybites_bite55/steam.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Parses Steam's RSS feed and returns a list of Game namedtuples"""
feed = feedparser.parse(FEED_URL)
games = []
for entry in feed.entries:
games.append(Game(title = entry['title']
, link = entry['link']
))
return games<|f... | code_fim | medium | {
"lang": "python",
"repo": "pavanrao/bitesofpy",
"path": "/pybites_bite55/steam.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dimagi/commcare-hq path: /corehq/motech/dhis2/migrations/0005_delete_jsonapilog.py
# Generated by Django 1.11.14 on 2018-07-13 11:26
from django.db import migrations
class Migration(migrations.Migration):
<|fim_suffix|> state_operations = [
migrations.DeleteModel(
name=... | code_fim | medium | {
"lang": "python",
"repo": "dimagi/commcare-hq",
"path": "/corehq/motech/dhis2/migrations/0005_delete_jsonapilog.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> state_operations = [
migrations.DeleteModel(
name='JsonApiLog',
),
]
operations = [
migrations.SeparateDatabaseAndState(
# The corehq.motech.dhis2.JsonApiLog model moved to
# corehq.motech.RequestLog and uses the original table. So th... | code_fim | medium | {
"lang": "python",
"repo": "dimagi/commcare-hq",
"path": "/corehq/motech/dhis2/migrations/0005_delete_jsonapilog.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return T2TDocModel.it_fits_into_the_limit(current_block_len, len(sentences[block_end + 1]), self.USE_CHARS)
def it_fits_pre_chars_limit():
return T2TDocModel.it_fits_into_the_limit(pre_context_len, len(sentences[pre_context_start - 1]), self.PRE_CHARS)
def pre_con... | code_fim | hard | {
"lang": "python",
"repo": "ufal/lindat-translation",
"path": "/app/models/t2t_model.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> block_start = 0
block_end = -1
current_block_len = 0
pre_context_len = 0
pre_context_start = block_start
# helpers to make the while loops more readable #
def has_next_sent(index=None):
if index is None:
return T2TDocMode... | code_fim | hard | {
"lang": "python",
"repo": "ufal/lindat-translation",
"path": "/app/models/t2t_model.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ufal/lindat-translation path: /app/models/t2t_model.py
from math import ceil
from pprint import pformat
import numpy as np
from flask import current_app, session
from tensor2tensor.serving import serving_utils
from tensor2tensor.utils import registry
import app.models as models
from app.text_ut... | code_fim | hard | {
"lang": "python",
"repo": "ufal/lindat-translation",
"path": "/app/models/t2t_model.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: steff456/spyder-screencast path: /spyder_screencast/container.py
# -*- coding: utf-8 -*-
# Third party imports
from qtpy.QtCore import QSize, QPoint, Signal
from spyder.api.translations import get_translation
from spyder.api.widgets.main_container import PluginMainContainer
<|fim_suffix|> ... | code_fim | hard | {
"lang": "python",
"repo": "steff456/spyder-screencast",
"path": "/spyder_screencast/container.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def on_option_update(self, option, value):
pass
def update_actions(self):
pass
# --- Public API
# ------------------------------------------------------------------------
def start_recording(self):
pass
def stop_recording(self):
pass
def upda... | code_fim | hard | {
"lang": "python",
"repo": "steff456/spyder-screencast",
"path": "/spyder_screencast/container.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class PositionalEncoding(nn.Module):
""" Implement the PE function. Taken from https://nlp.seas.harvard.edu/2018/04/03/attention.html."""
def __init__(self, hidden_dim, max_len=5000):
super(PositionalEncoding, self).__init__()
# Compute the positional encodings once in log space.
... | code_fim | hard | {
"lang": "python",
"repo": "mleszczy/bootleg",
"path": "/bootleg/layers/layers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mleszczy/bootleg path: /bootleg/layers/layers.py
"""Simple model building blocks"""
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from bootleg.utils.classes.dotted_dict import DottedDict
from torch.nn import Parameter
from torc... | code_fim | hard | {
"lang": "python",
"repo": "mleszczy/bootleg",
"path": "/bootleg/layers/layers.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> right_dense_dim = tensorizers["right_dense"].dim
left_dense_dim = tensorizers["left_dense"].dim
decoder = create_module(
config.decoder,
right_dim=right_encoder.representation_dim + right_dense_dim,
left_dim=left_encoder.representation_dim + lef... | code_fim | hard | {
"lang": "python",
"repo": "thomascherickal/pytext",
"path": "/pytext/models/two_tower_classification_model.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: thomascherickal/pytext path: /pytext/models/two_tower_classification_model.py
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Dict, List, Optional, Tuple
import torch
from pytext.common.constants import Stage
from pytext.config im... | code_fim | hard | {
"lang": "python",
"repo": "thomascherickal/pytext",
"path": "/pytext/models/two_tower_classification_model.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def trace(self, inputs):
return torch.jit.trace(self, inputs)
def torchscriptify(self, tensorizers, traced_model):
"""Using the traced model, create a ScriptModule which has a nicer API that
includes generating tensors from simple data types, and returns classified
... | code_fim | hard | {
"lang": "python",
"repo": "thomascherickal/pytext",
"path": "/pytext/models/two_tower_classification_model.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>(abs(lit))
if status is None:
return None
is_conjugated = lit < 0
return is_conjugated is not status<|fim_prefix|># repo: pombredanne/sat-solver-2 path: /simplesat/sat/utils.py
def value(lit, assignments):
""" Value of a literal give<|fim_middle|>n variable assignments.
"""
... | code_fim | medium | {
"lang": "python",
"repo": "pombredanne/sat-solver-2",
"path": "/simplesat/sat/utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>_conjugated = lit < 0
return is_conjugated is not status<|fim_prefix|># repo: pombredanne/sat-solver-2 path: /simplesat/sat/utils.py
def value(lit, assignments):
""" Value of a literal give<|fim_middle|>n variable assignments.
"""
status = assignments.get(abs(lit))
if status is None:
... | code_fim | medium | {
"lang": "python",
"repo": "pombredanne/sat-solver-2",
"path": "/simplesat/sat/utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pombredanne/sat-solver-2 path: /simplesat/sat/utils.py
def value(lit, assignments):
""" Value of a literal give<|fim_suffix|>_conjugated = lit < 0
return is_conjugated is not status<|fim_middle|>n variable assignments.
"""
status = assignments.get(abs(lit))
if status is None:
... | code_fim | medium | {
"lang": "python",
"repo": "pombredanne/sat-solver-2",
"path": "/simplesat/sat/utils.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># adapted from django.contrib.auth.views.PasswordResetConfirmView
def complete_login(request, uidb64=None, token=None):
redirect_url = '/'
if request.user.is_authenticated:
return HttpResponseRedirect(redirect_url)
user = get_user(uidb64)
if user and default_token_generator.check_... | code_fim | hard | {
"lang": "python",
"repo": "chriscauley/django-unrest",
"path": "/unrest/nopass/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chriscauley/django-unrest path: /unrest/nopass/views.py
from django.http import JsonResponse, HttpResponseRedirect, HttpResponse
from django.contrib.auth import login, get_user_model
from django.contrib.auth.forms import PasswordResetForm
from django.contrib.auth.tokens import default_token_gener... | code_fim | hard | {
"lang": "python",
"repo": "chriscauley/django-unrest",
"path": "/unrest/nopass/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not root:
return []
res = []
queue = []
depth = 0
queue.append(root)
while queue:
depth += 1
tmp = []
for i in range(len(queue)):
node = queue.pop(0)
tmp.append(node.val)
... | code_fim | hard | {
"lang": "python",
"repo": "hscspring/The-DataStructure-and-Algorithms",
"path": "/LeetCode/103-Binary-Tree-Zigzag-Level-Order-Traversal/Binary-Tree-Zigzag-Level-Order-Traversal.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.