text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: nshm99/serializer path: /koala_serializer/code_generators/__init__.py
# -*- coding: utf-8 -*-
# python imports
import os
# project imports
from .python import PythonCodeGenerator
from .cpp import CppCodeGenerator
<|fim_suffix|>
def generate(self, parse_tree):
code, filename = self.... | code_fim | hard | {
"lang": "python",
"repo": "nshm99/serializer",
"path": "/koala_serializer/code_generators/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> code, filename = self._generators[self._programming_language].generate(parse_tree, self._module_name)
with open(os.path.join(self._destination_dir, filename), 'w') as f:
f.write(code)<|fim_prefix|># repo: nshm99/serializer path: /koala_serializer/code_generators/__init__.py
# ... | code_fim | hard | {
"lang": "python",
"repo": "nshm99/serializer",
"path": "/koala_serializer/code_generators/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sjkingo/ticketus path: /ticketus/urls.py
from django.conf import settings
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.views.generic.base import RedirectView
<|fim_suffix|>if settings.DEBUG:
# Serve media files in development. Note Django a... | code_fim | hard | {
"lang": "python",
"repo": "sjkingo/ticketus",
"path": "/ticketus/urls.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>if settings.DEBUG:
# Serve media files in development. Note Django automatically serves
# static files as the staticfiles app is active in settings.py.
from django.conf.urls.static import static
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)<|fim_prefix|># rep... | code_fim | hard | {
"lang": "python",
"repo": "sjkingo/ticketus",
"path": "/ticketus/urls.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> out_cls, out_regr = model.forward(imgs)
loss_cls, loss_regr = LOSS_CLS.forward(input=out_cls, target=clss), LOSS_REGR.forward(
input=out_regr, target=regrs)
# print(loss_cls,loss_regr)
... | code_fim | hard | {
"lang": "python",
"repo": "ustczhouyu/VTD",
"path": "/Detection/CTPN_vertical/train_pytorch.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ustczhouyu/VTD path: /Detection/CTPN_vertical/train_pytorch.py
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
import torch
from torch.utils.data import DataLoader
from torch import optim
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from torch.utils.data.sampler imp... | code_fim | hard | {
"lang": "python",
"repo": "ustczhouyu/VTD",
"path": "/Detection/CTPN_vertical/train_pytorch.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: leith-bartrich/fiepipe path: /fiepipelib/localuser/routines/localuser.py
import os.path
from fiepipelib.localplatform.routines.localplatform import AbstractLocalPlatformBaseRoutines, \
get_local_platform_routines
class LocalUserRoutines(object):
"""represents the local user. Often req... | code_fim | hard | {
"lang": "python",
"repo": "leith-bartrich/fiepipe",
"path": "/fiepipelib/localuser/routines/localuser.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self._local_platform
def __init__(self, platform: AbstractLocalPlatformBaseRoutines):
self._local_platform = platform
def get_home_dir(self) -> str:
"""Gets the user's home directory. Similar to '~'"""
ret = os.path.expanduser("~")
if not os.path.e... | code_fim | hard | {
"lang": "python",
"repo": "leith-bartrich/fiepipe",
"path": "/fiepipelib/localuser/routines/localuser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: npdoty/citeproc-py path: /tests/citeproc-test.py
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from citeproc.py2compat import *
import glob
import io
import json
import os
import sys
import traceback
from codecs import utf_8_encod... | code_fim | hard | {
"lang": "python",
"repo": "npdoty/citeproc-py",
"path": "/tests/citeproc-test.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not args:
destination.write('\n')
else:
print(*args, file=destination)
try:
glob_pattern = args[0]
filter_tests = False
except IndexError:
glob_pattern = '*'
filter_tests = True
total_count = {}
passed_count = {}
... | code_fim | hard | {
"lang": "python",
"repo": "npdoty/citeproc-py",
"path": "/tests/citeproc-test.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> destination.write(str(s))
sys.stderr = UnicodeWriter()
except TypeError:
destination = sys.stdout
def out(*args):
if not args:
destination.write('\n')
else:
print(*args, file=destination)
try:
glob_pattern = args[... | code_fim | hard | {
"lang": "python",
"repo": "npdoty/citeproc-py",
"path": "/tests/citeproc-test.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Goes through each cells and display them
def display(n, baseBoard):
for y in range(n):
for x in range(n):
print(baseBoard[y][x], end=' ')
graphic.printCell(baseBoard[y][x], y, x)
if(x == n - 1):
print("")<|fim_prefix|># repo: akileine13/Ju... | code_fim | hard | {
"lang": "python",
"repo": "akileine13/JustGetTen",
"path": "/bases.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: akileine13/JustGetTen path: /bases.py
import random
import possibles
import merge
import graphic
from graphic import *
import pygame
from pygame.locals import *
<|fim_suffix|> randomNum = random.random()
if(randomNum < proba[0]):
return 4
elif(proba[0] < randomNum < proba[1]):... | code_fim | medium | {
"lang": "python",
"repo": "akileine13/JustGetTen",
"path": "/bases.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class GrandChallengeGame(Game):
ALL = []
round_number = 0
def __init__(self, *args, **kwargs):
# Set parent's fields
self._meta.get_field('verbose_name').default = "GrandChallenges"
self._meta.get_field('short_name').default = ""
# the url field takes as value ... | code_fim | hard | {
"lang": "python",
"repo": "rosedu/wouso",
"path": "/wouso/games/grandchallenge/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rosedu/wouso path: /wouso/games/grandchallenge/models.py
from django.db import models
from django.db.models import Q, Max
import logging
from wouso.core.config.models import IntegerSetting
from wouso.core.game.models import Game
from wouso.core.user.models import Player
from wouso.games.challenge... | code_fim | hard | {
"lang": "python",
"repo": "rosedu/wouso",
"path": "/wouso/games/grandchallenge/models.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GregoryBrown/gNMI-API path: /key-plugin.py
import optparse
import sys
from json import dumps
from pyang.plugin import PyangPlugin, plugins, register_plugin, init
from pyang.repository import FileRepository
from pyang.context import Context
from pyang.error import error_codes, allow_warning
from p... | code_fim | hard | {
"lang": "python",
"repo": "GregoryBrown/gNMI-API",
"path": "/key-plugin.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self):
PyangPlugin.__init__(self, "keys")
def add_output_format(self, fmts):
self.multiple_modules = True
fmts["keys"] = self
def add_opts(self, optparser):
optlist: List[Any] = [
optparse.make_option(
"--keys-help", de... | code_fim | hard | {
"lang": "python",
"repo": "GregoryBrown/gNMI-API",
"path": "/key-plugin.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carrier-io/dusty path: /dusty/reporters/engagement/reporter.py
#!/usr/bin/python3
# coding=utf-8
# pylint: disable=I0011,E0401
# Copyright 2019 getcarrier.io
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Licens... | code_fim | hard | {
"lang": "python",
"repo": "carrier-io/dusty",
"path": "/dusty/reporters/engagement/reporter.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_hash_code(self, title):
return hashlib.sha256(title.strip().encode('utf-8')).hexdigest()
def get_title(self, title):
return f"{title}. {self.test_type} SCAN: {self.get_target()}"
def get_target(self):
if self.test_type in ("SAST", "DEPENDENCY"):
... | code_fim | hard | {
"lang": "python",
"repo": "carrier-io/dusty",
"path": "/dusty/reporters/engagement/reporter.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Reporter(DependentModuleModel, ReporterModel):
""" Report findings from scanners """
def __init__(self, context):
""" Initialize reporter instance """
super().__init__()
self.context = context
self.test_type = self.context.config['settings']['testing_type']
... | code_fim | hard | {
"lang": "python",
"repo": "carrier-io/dusty",
"path": "/dusty/reporters/engagement/reporter.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>env.Program(join(BASE, "bin", EXENAME.format(name="lisp.parser")), Glob("*.c"), LIBPATH=LIBPATH, LIBS=LIBS)<|fim_prefix|># repo: hacatu/Praser path: /src/demos/lisp_parser/SConstruct
import os
import os.path
<|fim_middle|>join = os.path.join
Import("env BASE LIBS LIBPATH EXENAME")
| code_fim | medium | {
"lang": "python",
"repo": "hacatu/Praser",
"path": "/src/demos/lisp_parser/SConstruct",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hacatu/Praser path: /src/demos/lisp_parser/SConstruct
import os
import os.path
join = os.path.join
<|fim_suffix|>env.Program(join(BASE, "bin", EXENAME.format(name="lisp.parser")), Glob("*.c"), LIBPATH=LIBPATH, LIBS=LIBS)<|fim_middle|>Import("env BASE LIBS LIBPATH EXENAME")
| code_fim | easy | {
"lang": "python",
"repo": "hacatu/Praser",
"path": "/src/demos/lisp_parser/SConstruct",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hacatu/Praser path: /src/demos/lisp_parser/SConstruct
import os
import os.path
<|fim_suffix|>env.Program(join(BASE, "bin", EXENAME.format(name="lisp.parser")), Glob("*.c"), LIBPATH=LIBPATH, LIBS=LIBS)<|fim_middle|>join = os.path.join
Import("env BASE LIBS LIBPATH EXENAME")
| code_fim | medium | {
"lang": "python",
"repo": "hacatu/Praser",
"path": "/src/demos/lisp_parser/SConstruct",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Falcons-Robocup/code path: /packages/worldModel/tst/testWmRDLsuite.py
# Copyright 2020-2021 Jan Feitsma (Falcons)
# SPDX-License-Identifier: Apache-2.0
#!/usr/bin/env python3
import sys, os
import shutil, glob
import argparse
import yaml, uuid
import traceback
import subprocess
import unittest
u... | code_fim | hard | {
"lang": "python",
"repo": "Falcons-Robocup/code",
"path": "/packages/worldModel/tst/testWmRDLsuite.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class WorldModelRDLTestSuite(unittest.TestSuite):
"""
Setup the test suite, consisting of a sequence of tests. Also setup tmp directory, since it is referred to in test case definition (arguments).
"""
def __init__(self, args = None):
unittest.TestSuite.__init__(self)
# de... | code_fim | hard | {
"lang": "python",
"repo": "Falcons-Robocup/code",
"path": "/packages/worldModel/tst/testWmRDLsuite.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class WorldModelTracingRateTestCase(unittest.TestCase):
def __init__(self, rdl):
unittest.TestCase.__init__(self, methodName='test_tracing_rate')
self.rdl = rdl
def test_tracing_rate(self):
# use rdlinfo utility to determine the duration of the RDL
command = "frun ... | code_fim | hard | {
"lang": "python",
"repo": "Falcons-Robocup/code",
"path": "/packages/worldModel/tst/testWmRDLsuite.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>rule count:
input:
sortbam='outdir/{sample}_output/Aligned.sortedByCoord.out.bam.sort'
params:
outdir ='outdir/{sample}_output'
output:
outdir ='outdir/{sample}_output/Aligned.sortedByCoord.out.bam.sort.count'
conda:
"mapping.yaml"
shell:
'featureCoun... | code_fim | hard | {
"lang": "python",
"repo": "foocheung/hsv_study_2017",
"path": "/Snakefile",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: foocheung/hsv_study_2017 path: /Snakefile
from os import listdir
import glob
import os
configfile: "config.yaml.single"
(config['samples'])
print (config['samples'])
rule all:
input:
expand("outdir/{sample}_output/Aligned.sortedByCoord.out.bam", sample = config['samples']),
expan... | code_fim | hard | {
"lang": "python",
"repo": "foocheung/hsv_study_2017",
"path": "/Snakefile",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> 50.00 and valor <= 75.00:
print('Intervalo (50,75]')
elif valor > 75.00 and valor <= 100.00:
print('Intervalo (75,100]')
else:
print('Fora de intervalo')<|fim_prefix|># repo: carloshenrique051994/Uri path: /Python/1037 - Intervalo.py
valor = float(input())
if valor >= 0 and valor <= 25.00:
... | code_fim | medium | {
"lang": "python",
"repo": "carloshenrique051994/Uri",
"path": "/Python/1037 - Intervalo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carloshenrique051994/Uri path: /Python/1037 - Intervalo.py
valor = float(input())
if valor >= 0 and valor <= 25.00:
print('Intervalo [0,25<|fim_suffix|>lor <= 100.00:
print('Intervalo (75,100]')
else:
print('Fora de intervalo')<|fim_middle|>]')
elif valor > 25 and valor <= 50.00:
... | code_fim | medium | {
"lang": "python",
"repo": "carloshenrique051994/Uri",
"path": "/Python/1037 - Intervalo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>EXAMPLES_DIR = os.path.join(os.path.dirname(os.getcwd()),"fasttrips","Examples","test_scenario")
Run.run_fasttrips(
input_network_dir= os.path.join(EXAMPLES_DIR,"network"),
input_demand_dir = os.path.join(EXAMPLES_DIR,"demand_reg"),
run_config = os.path.join(EXAMPLES_DIR,"demand_reg",... | code_fim | medium | {
"lang": "python",
"repo": "pedrocamargo/fast-trips",
"path": "/scripts/run_trace.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pedrocamargo/fast-trips path: /scripts/run_trace.py
"""
This script shows how to run a Fast-Trips trace for a single person-trip by adding two keywords to the call to run_fasttrips():
- trace_ids = list of tuples identifying which trips to trace ("<person_id>","<trip_id>")
- debug_trace_only = ... | code_fim | medium | {
"lang": "python",
"repo": "pedrocamargo/fast-trips",
"path": "/scripts/run_trace.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>import os
from fasttrips import Run
EXAMPLES_DIR = os.path.join(os.path.dirname(os.getcwd()),"fasttrips","Examples","test_scenario")
Run.run_fasttrips(
input_network_dir= os.path.join(EXAMPLES_DIR,"network"),
input_demand_dir = os.path.join(EXAMPLES_DIR,"demand_reg"),
run_config = o... | code_fim | hard | {
"lang": "python",
"repo": "pedrocamargo/fast-trips",
"path": "/scripts/run_trace.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wangbailin/kuzhanggui path: /microsite/forms.py
import ModelForm
from models import *
from django.contrib.contenttypes.models import ContentType
from ajax_upload.widgets import AjaxClearableFileInput
from utils import get_wx_access_token
from widgets import LongTextInput
from widgets import Long... | code_fim | hard | {
"lang": "python",
"repo": "wangbailin/kuzhanggui",
"path": "/microsite/forms.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wangbailin/kuzhanggui path: /microsite/forms.py
elds = ('contact_item', 'name', 'email', 'phone', 'qq', 'id', 'tab_id')
class HomePageForm(ModelForm):
pic1 = forms.ImageField(label=u'焦点图1', widget=AjaxClearableFileInput(), help_text=u"建议焦点图的尺寸相同以保证焦点图的最佳显示效果")
pic2 = forms.ImageField(lab... | code_fim | hard | {
"lang": "python",
"repo": "wangbailin/kuzhanggui",
"path": "/microsite/forms.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class AddProductClassForm(forms.Form):
name = forms.CharField()
tab_id = forms.IntegerField()
def clean_name(self):
try:
ProductClass.objects.get(name=self.cleaned_data['name'])
except ProductClass.DoesNotExist:
return self.cleaned_data['name']
... | code_fim | hard | {
"lang": "python",
"repo": "wangbailin/kuzhanggui",
"path": "/microsite/forms.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class TestGeoMapping(TestCase):
def test_mapping(self):
pytest.skip("TODO")<|fim_prefix|># repo: kamotos/django-rest-framework-mongoengine path: /tests/test_2geo.py
import pytest
from django.test import TestCase
from mongoengine import Document, fields
<|fim_middle|>class GeoModel(Document... | code_fim | hard | {
"lang": "python",
"repo": "kamotos/django-rest-framework-mongoengine",
"path": "/tests/test_2geo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kamotos/django-rest-framework-mongoengine path: /tests/test_2geo.py
import pytest
from django.test import TestCase
from mongoengine import Document, fields
<|fim_suffix|> geo_point_field = fields.PointField()
geo_line_field = fields.LineStringField()
geo_polygon_field = fields.Polyg... | code_fim | medium | {
"lang": "python",
"repo": "kamotos/django-rest-framework-mongoengine",
"path": "/tests/test_2geo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: intel/intel-cmt-cat path: /appqos/tests/test_stats.py
################################################################################
# BSD LICENSE
#
# Copyright(c) 2018-2023 Intel Corporation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modifica... | code_fim | hard | {
"lang": "python",
"repo": "intel/intel-cmt-cat",
"path": "/appqos/tests/test_stats.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> stats_invalid_access = 4
for _ in range(stats_invalid_access):
stats_store.general_stats_inc_num_invalid_access()
gen_stats = stats_store.general_stats_get()
assert gen_stats['num_invalid_access_attempts'] == stats_invalid_access
gen_stats_invalid_acc... | code_fim | hard | {
"lang": "python",
"repo": "intel/intel-cmt-cat",
"path": "/appqos/tests/test_stats.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> stats_err = 2
for _ in range(stats_err):
stats_store.general_stats_inc_num_err()
gen_stats = stats_store.general_stats_get()
assert gen_stats['num_err'] == stats_err
gen_stats_err = stats_store.general_stats_get(StatsStore.General.NUM_ERR)
ass... | code_fim | hard | {
"lang": "python",
"repo": "intel/intel-cmt-cat",
"path": "/appqos/tests/test_stats.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mkaywong/NNSolver path: /NNSolver/Pool.py
#!/usr/bin/env python
# coding: utf-8
import numpy as np
from Layer import Layer
from PassThrough import PassThrough
class Pool(PassThrough):
poolTypes = ['max','ave']
def __init__(self, para):
PassThrough.__init__(self, para)
... | code_fim | hard | {
"lang": "python",
"repo": "mkaywong/NNSolver",
"path": "/NNSolver/Pool.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> inp = self.bottom.getOutput()[:Layer.currentBatchSize]
dA = self.top.getInputDerivative()[:Layer.currentBatchSize]
for i in range(Layer.currentBatchSize):
jj = 0
for j in range(self.kernelShape[0],self.inpShape[1]+1,self.stride):
jSt = j - se... | code_fim | hard | {
"lang": "python",
"repo": "mkaywong/NNSolver",
"path": "/NNSolver/Pool.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class CachableQueryingSystem:
def __init__(self, cache):
self.local_cache = {}
self.cache = cache
def read_cache(self, query):
filename = to_filename(query)
if filename in self.local_cache:
return self.local_cache[filename], True
else:
... | code_fim | hard | {
"lang": "python",
"repo": "darkinka/CSK",
"path": "/quasimodo/cache/cachable_querying_system.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: darkinka/CSK path: /quasimodo/cache/cachable_querying_system.py
from quasimodo.parameters_reader import ParametersReader
parameters_reader = ParametersReader()
PATTERN_FIRST = (parameters_reader.get_parameter("pattern-first") or "true") == "true"
possible_second_word_question = ["is", "are", "do... | code_fim | hard | {
"lang": "python",
"repo": "darkinka/CSK",
"path": "/quasimodo/cache/cachable_querying_system.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_regex_from_query_by_pattern(filename):
filename_split = filename.split("-")
if len(filename_split) <= 1:
filename_regex = filename
else:
if filename_split[0] in ["why", "how"]:
if filename_split[1] in possible_second_word_question:
filename_r... | code_fim | hard | {
"lang": "python",
"repo": "darkinka/CSK",
"path": "/quasimodo/cache/cachable_querying_system.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertArgIsBlock(
NetworkExtension.NEAppProxyUDPFlow.readDatagramsWithCompletionHandler_,
0,
b"v@@@",
)
self.assertArgIsBlock(
NetworkExtension.NEAppProxyUDPFlow.writeDatagrams_sentByEndpoints_completionHandler_,
2,
... | code_fim | medium | {
"lang": "python",
"repo": "ronaldoussoren/pyobjc",
"path": "/pyobjc-framework-NetworkExtension/PyObjCTest/test_neappproxyudpflow.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ronaldoussoren/pyobjc path: /pyobjc-framework-NetworkExtension/PyObjCTest/test_neappproxyudpflow.py
from PyObjCTools.TestSupport import TestCase, min_os_level
import NetworkExtension
<|fim_suffix|> self.assertArgIsBlock(
NetworkExtension.NEAppProxyUDPFlow.readDatagramsWithCom... | code_fim | medium | {
"lang": "python",
"repo": "ronaldoussoren/pyobjc",
"path": "/pyobjc-framework-NetworkExtension/PyObjCTest/test_neappproxyudpflow.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_epinions(self):
self._test_dataset(self, 'Epinions')
def test_slashdotzoo(self):
self._test_dataset(self, 'SlashdotZoo')
def test_wikisigned(self):
self._test_dataset(self, 'WikiSigned')
if __name__ == '__main__':
unittest.main()<|fim_prefix|># repo: dr... | code_fim | hard | {
"lang": "python",
"repo": "drzazi/SignedNetZoo",
"path": "/tests/test_datasets.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: drzazi/SignedNetZoo path: /tests/test_datasets.py
"""
Smoke test for datasets in SignedNetZoo. Only testing on small datasets.
"""
import SignedNetZoo
import shutil
import unittest
import networkx as nx
class TestDataset(unittest.TestCase):
@staticmethod
def _test_dataset(self, dataset... | code_fim | hard | {
"lang": "python",
"repo": "drzazi/SignedNetZoo",
"path": "/tests/test_datasets.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_slashdotzoo(self):
self._test_dataset(self, 'SlashdotZoo')
def test_wikisigned(self):
self._test_dataset(self, 'WikiSigned')
if __name__ == '__main__':
unittest.main()<|fim_prefix|># repo: drzazi/SignedNetZoo path: /tests/test_datasets.py
"""
Smoke test for dataset... | code_fim | medium | {
"lang": "python",
"repo": "drzazi/SignedNetZoo",
"path": "/tests/test_datasets.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SpartaHack/SpartaHackVI-Website path: /data/transform.py
import os, sys, json
# for i in range(1, len(sys.argv)):
# src = json.load(open(sys.argv[i]))
<|fim_suffix|>json.dump(out1, open('majors-set.json', 'w'))
json.dump(out2, open('majors-dict.json', 'w'))<|fim_middle|># out = {}
# ... | code_fim | hard | {
"lang": "python",
"repo": "SpartaHack/SpartaHackVI-Website",
"path": "/data/transform.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> out1.append(src[1])
out2[src[1]] = src
json.dump(out1, open('majors-set.json', 'w'))
json.dump(out2, open('majors-dict.json', 'w'))<|fim_prefix|># repo: SpartaHack/SpartaHackVI-Website path: /data/transform.py
import os, sys, json
# for i in range(1, len(sys.argv)):
# src = json.load(open(... | code_fim | hard | {
"lang": "python",
"repo": "SpartaHack/SpartaHackVI-Website",
"path": "/data/transform.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # tests for convert_model()
ov_model = convert_model(model, extensions=ext_path1)
flag, msg = compare_functions(ov_model, create_ref_model_1(), False)
assert flag, msg
ov_model = convert_model(model, extensions=[ext_path1, ext_path2])
... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/openvino",
"path": "/tests/layer_tests/mo_python_api_tests/mo_convert_legacy_extensions_test_actual.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openvinotoolkit/openvino path: /tests/layer_tests/mo_python_api_tests/mo_convert_legacy_extensions_test_actual.py
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import openvino.runtime as ov
import os
import tempfile
import tensorflow as tf
i... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/openvino",
"path": "/tests/layer_tests/mo_python_api_tests/mo_convert_legacy_extensions_test_actual.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> exit_code, stderr = generate_ir(coverage=False, **{"input_model": model,
"extensions": ','.join([ext_path1, ext_path2]),
"output_dir": tmpdir})
assert not e... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/openvino",
"path": "/tests/layer_tests/mo_python_api_tests/mo_convert_legacy_extensions_test_actual.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def for_page(self, page, per_page=15):
return self.skip((page - 1) * per_page).take(per_page)
def union(self, query, all=False):
"""
Add a union statement to the query
:param query: A QueryBuilder instance
:type query: QueryBuilder
:param all: Whe... | code_fim | hard | {
"lang": "python",
"repo": "MakarenaLabs/Orator-Google-App-Engine",
"path": "/orator/query/builder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MakarenaLabs/Orator-Google-App-Engine path: /orator/query/builder.py
return self.where_exists(callback, 'or', negate)
def where_not_exists(self, callback, boolean='and'):
return self.where_exists(callback, boolean, True)
def or_where_not_exists(self, callback):
se... | code_fim | hard | {
"lang": "python",
"repo": "MakarenaLabs/Orator-Google-App-Engine",
"path": "/orator/query/builder.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param columns: The columns to group by
:type columns: tuple
:return: The current QueryBuilder instance
:rtype: QueryBuilder
"""
for column in columns:
self.groups.append(column)
return self
def having(self, column, operator=None, ... | code_fim | hard | {
"lang": "python",
"repo": "MakarenaLabs/Orator-Google-App-Engine",
"path": "/orator/query/builder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstack/ec2-api path: /ec2api/exception.py
# Copyright 2014
# The Cloudscaling Group, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/lic... | code_fim | hard | {
"lang": "python",
"repo": "openstack/ec2-api",
"path": "/ec2api/exception.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class InvalidInternetGatewayIDNotFound(EC2NotFoundException):
ec2_code = 'InvalidInternetGatewayID.NotFound'
msg_fmt = _("The internetGateway ID '%(id)s' does not exist")
class InvalidSubnetIDNotFound(EC2NotFoundException):
ec2_code = 'InvalidSubnetID.NotFound'
msg_fmt = _("The subnet I... | code_fim | hard | {
"lang": "python",
"repo": "openstack/ec2-api",
"path": "/ec2api/exception.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class InvalidBlockDeviceMapping(EC2InvalidException):
pass
class IncorrectState(EC2IncorrectStateException):
msg_fmt = _("The resource is in incorrect state for the request - reason: "
"'%(reason)s'")
class DependencyViolation(EC2IncorrectStateException):
msg_fmt = _('Obje... | code_fim | hard | {
"lang": "python",
"repo": "openstack/ec2-api",
"path": "/ec2api/exception.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
dt: May be a string or datetime to allow automatic conversion
"""
return int(str_to_datetime(dt).timestamp())
def epoch_to_str(epoch: int) -> str:
"""Convert epoch seconds to indy-standard datetime string.
Args:
epoch: epoch seconds
"""
return datetim... | code_fim | hard | {
"lang": "python",
"repo": "blockpass-identity-lab/aries-fl-demo",
"path": "/aries_cloudagent/messaging/util.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: blockpass-identity-lab/aries-fl-demo path: /aries_cloudagent/messaging/util.py
"""Utils for messages."""
from datetime import datetime, timedelta, timezone
import logging
from math import floor
import re
from typing import Union
LOGGER = logging.getLogger(__name__)
def datetime_to_str(dt: Uni... | code_fim | hard | {
"lang": "python",
"repo": "blockpass-identity-lab/aries-fl-demo",
"path": "/aries_cloudagent/messaging/util.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def canon(raw_attr_name: str) -> str:
"""
Canonicalize input attribute name for indy proofs and credential offers.
Args:
raw_attr_name: raw attribute name
Returns:
canonicalized attribute name
"""
if raw_attr_name: # do not dereference None, and "" is already c... | code_fim | hard | {
"lang": "python",
"repo": "blockpass-identity-lab/aries-fl-demo",
"path": "/aries_cloudagent/messaging/util.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: github/codeql path: /python/ql/src/Lexical/OldOctalLiteral.py
#Easily misread as x = 15
x = 015
#The extra 'o' alerts the reader that this is an octal literal
y = 0o15
<|fim_suffix|>#Or if it is a bit pattern then a binary value might be clearer
y = 0b1101<|fim_middle|>#If this is a byte sized... | code_fim | medium | {
"lang": "python",
"repo": "github/codeql",
"path": "/python/ql/src/Lexical/OldOctalLiteral.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#Or if it is a bit pattern then a binary value might be clearer
y = 0b1101<|fim_prefix|># repo: github/codeql path: /python/ql/src/Lexical/OldOctalLiteral.py
#Easily misread as x = 15
x = 015
<|fim_middle|>#The extra 'o' alerts the reader that this is an octal literal
y = 0o15
#If this is a byte sized... | code_fim | medium | {
"lang": "python",
"repo": "github/codeql",
"path": "/python/ql/src/Lexical/OldOctalLiteral.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: enterstudio/jsontableschema-bigquery-py path: /jsontableschema_bigquery/mappers.py
# -*- coding: utf-8 -*-
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import
from __future__ import unicode_literals
import re
from slugify import slugify
... | code_fim | hard | {
"lang": "python",
"repo": "enterstudio/jsontableschema-bigquery-py",
"path": "/jsontableschema_bigquery/mappers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Convert
fields = []
for field in nativedesc['fields']:
try:
ftype = mapping[field['type']]
except KeyError:
message = 'Type %s is not supported' % field['type']
raise TypeError(message)
resfield = {
'name': field['name']... | code_fim | hard | {
"lang": "python",
"repo": "enterstudio/jsontableschema-bigquery-py",
"path": "/jsontableschema_bigquery/mappers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Mapping
mapping = {
'STRING': 'string',
'INTEGER': 'integer',
'FLOAT': 'number',
'BOOLEAN': 'boolean',
'TIMESTAMP': 'datetime',
}
# Convert
fields = []
for field in nativedesc['fields']:
try:
ftype = mapping[field['type... | code_fim | hard | {
"lang": "python",
"repo": "enterstudio/jsontableschema-bigquery-py",
"path": "/jsontableschema_bigquery/mappers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: factset/quart-openapi path: /quart_openapi/utils.py
"""utils.py
Helper functions for use in other modules
"""
from copy import deepcopy
from itertools import filterfalse
from inspect import getdoc
import re
from typing import Dict, Union, List, Callable, Any, Type
#: regex for finding ':raises... | code_fim | hard | {
"lang": "python",
"repo": "factset/quart-openapi",
"path": "/quart_openapi/utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __get__(self, obj: Type[object], cls: object) -> Any:
if obj is None:
return self
value = obj.__dict__[self.func.__name__] = self.func(obj)
return value
def not_none(data: Dict[Any, Any]) -> Dict[Any, Any]:
"""Return the passed in dictionary after removing ... | code_fim | hard | {
"lang": "python",
"repo": "factset/quart-openapi",
"path": "/quart_openapi/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: static-analysis-engineering/CodeHawk-Java path: /chj/index/MethodSignature.py
# ------------------------------------------------------------------------------
# CodeHawk Java Analyzer
# Author: Henny Sipma
# ------------------------------------------------------------------------------
# The MIT ... | code_fim | hard | {
"lang": "python",
"repo": "static-analysis-engineering/CodeHawk-Java",
"path": "/chj/index/MethodSignature.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class ClassMethodSignature(JavaTypesBase):
def __init__(self,
tpd: "JTypeDictionary",
index: int,
tags: List[str],
args: List[int]):
JavaTypesBase.__init__(self,tpd,index,tags,args)
self.cnix = int(self.args[0])
self.msix = int... | code_fim | hard | {
"lang": "python",
"repo": "static-analysis-engineering/CodeHawk-Java",
"path": "/chj/index/MethodSignature.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> add_group_to_inbox(self.group, GroupInboxReason.NEW)
assert GroupInbox.objects.filter(
group=self.group, reason=GroupInboxReason.NEW.value
).exists()
assert not inbox_in.called
add_group_to_inbox(self.group, GroupInboxReason.REGRESSION)
assert Gr... | code_fim | medium | {
"lang": "python",
"repo": "nagyist/sentry",
"path": "/tests/sentry/models/test_groupinbox.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nagyist/sentry path: /tests/sentry/models/test_groupinbox.py
from unittest.mock import patch
from sentry.models import (
Activity,
GroupInbox,
GroupInboxReason,
GroupInboxRemoveAction,
add_group_to_inbox,
remove_group_from_inbox,
)
from sentry.testutils import TestCase
fr... | code_fim | medium | {
"lang": "python",
"repo": "nagyist/sentry",
"path": "/tests/sentry/models/test_groupinbox.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> reason_details = {"meow": 123}
add_group_to_inbox(self.group, GroupInboxReason.NEW, reason_details)
assert GroupInbox.objects.get(group=self.group.id).reason_details is None<|fim_prefix|># repo: nagyist/sentry path: /tests/sentry/models/test_groupinbox.py
from unittest.mock import... | code_fim | hard | {
"lang": "python",
"repo": "nagyist/sentry",
"path": "/tests/sentry/models/test_groupinbox.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gammapy/gammapy path: /docs/user-guide/datasets/plot_stack.py
"""Example plot showing stacking of two datasets."""
from astropy import units as u
from astropy.coordinates import SkyCoord
import matplotlib.pyplot as plt
from gammapy.data import Observation, observatory_locations
from gammapy.data... | code_fim | hard | {
"lang": "python",
"repo": "gammapy/gammapy",
"path": "/docs/user-guide/datasets/plot_stack.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>stacked = dataset_1.copy(name="stacked")
stacked.stack(dataset_2)
stacked.models = model
npred_stacked = stacked.npred()
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(10, 4))
axes[0].set_title("Stacked Energy Dispersion Matrix")
axes[1].set_title("Predicted Counts")
stacked.edisp.get_edisp_kernel... | code_fim | hard | {
"lang": "python",
"repo": "gammapy/gammapy",
"path": "/docs/user-guide/datasets/plot_stack.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>dataset_1 = maker.run(stacked.copy(), observation=observation)
dataset_2 = maker.run(stacked.copy(), observation=observation)
pwl = PowerLawSpectralModel()
model = SkyModel(spectral_model=pwl, name="test-source")
dataset_1.mask_safe = geom.energy_mask(energy_min=2 * u.TeV)
dataset_2.mask_safe = geom.ene... | code_fim | hard | {
"lang": "python",
"repo": "gammapy/gammapy",
"path": "/docs/user-guide/datasets/plot_stack.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: project-callisto/django-decorator-include path: /tests/included.py
from __future__ import unicode_literals
from django.conf.urls import include, url
from django.http import HttpResponse
<|fim_suffix|>
urlpatterns = [
url(r'^included/', include('tests.included2')),
url(r'^test/$', testif... | code_fim | medium | {
"lang": "python",
"repo": "project-callisto/django-decorator-include",
"path": "/tests/included.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return HttpResponse('testify!')
urlpatterns = [
url(r'^included/', include('tests.included2')),
url(r'^test/$', testify, name='testify'),
]<|fim_prefix|># repo: project-callisto/django-decorator-include path: /tests/included.py
from __future__ import unicode_literals
from django.conf.urls ... | code_fim | easy | {
"lang": "python",
"repo": "project-callisto/django-decorator-include",
"path": "/tests/included.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>gui = ti.GUI('SDF 2D')
frame = 1
light_pos[None] = [0.5, 0.85]
while True:
while gui.get_event(ti.GUI.PRESS):
if gui.event.key == ti.GUI.LMB:
light_pos[None] = [gui.event.pos[0], gui.event.pos[1]]
frame = 1
img.fill(0)
elif gui.event.key == ti.GUI.ES... | code_fim | hard | {
"lang": "python",
"repo": "new-TonyWang/taichi",
"path": "/examples/sdf2d.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: new-TonyWang/taichi path: /examples/sdf2d.py
import taichi as ti
from math import tau
from renderer_utils import reflect, refract
ti.init(arch=ti.opengl)
N = 512
img = ti.field(dtype=ti.f32, shape=(N, N))
light_pos = ti.Vector.field(2, dtype=ti.f32, shape=())
@ti.func
def vres(distance, emissi... | code_fim | hard | {
"lang": "python",
"repo": "new-TonyWang/taichi",
"path": "/examples/sdf2d.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
return a list of all nested files
'''
if not hasattr(yml, 'items'):
return []
invalid_nesting = []
p = re.compile('^[A-z]*::[A-z]*::[A-z]*$')
for k, v in yml.items():
if isinstance(v, dict) and "type" in v:
t = v["type"]
if t.ends... | code_fim | hard | {
"lang": "python",
"repo": "onap/archive-vnfsdk-ice",
"path": "/validation-scripts/ice_validator/tests/utils/nested_files.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> nested_files = []
for k, v in yml.items():
if isinstance(v, dict) and "type" in v:
t = v["type"]
if t.endswith(".yml") or t.endswith(".yaml"):
filepath = path.join(dirpath, t)
with open(filepath) as fh:
t_yml = ya... | code_fim | hard | {
"lang": "python",
"repo": "onap/archive-vnfsdk-ice",
"path": "/validation-scripts/ice_validator/tests/utils/nested_files.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: onap/archive-vnfsdk-ice path: /validation-scripts/ice_validator/tests/utils/nested_files.py
# -*- coding: utf8 -*-
# ============LICENSE_START=======================================================
# org.onap.vvp/validation-scripts
# ===============================================================... | code_fim | hard | {
"lang": "python",
"repo": "onap/archive-vnfsdk-ice",
"path": "/validation-scripts/ice_validator/tests/utils/nested_files.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: voutilad/tangle path: /tangle/events.py
"""
File Events
"""
from pickle import loads, dumps
from collections import namedtuple
from enum import Enum
from time import time
class EventType(Enum):
"""
Definition of supported file system events:
``EventType.write``: a write occurred
... | code_fim | hard | {
"lang": "python",
"repo": "voutilad/tangle",
"path": "/tangle/events.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def dump_event(event):
return dumps(event._asdict())
def load_event(event_str):
return LocalEvent._make(loads(event_str).values())
def StartEv(): return LocalEvent(STARTED, -1, time(), '', None)
def StopEv(): return LocalEvent(STOPPED, -1, time(), '', None)
def CreateFileEv(inode, name, fd)... | code_fim | medium | {
"lang": "python",
"repo": "voutilad/tangle",
"path": "/tangle/events.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Transkribus/PyLaia path: /laia/meters/sequence_error_meter_test.py
from __future__ import absolute_import
from __future__ import division
import unittest
from laia.meters import SequenceErrorMeter
class SequenceErrorMeterTest(unittest.TestCase):
def testSingleString(self):
err = S... | code_fim | hard | {
"lang": "python",
"repo": "Transkribus/PyLaia",
"path": "/laia/meters/sequence_error_meter_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> err = SequenceErrorMeter()
ref = [[1, 2, 3, 4]]
hyp = [[1, 2, 5, 6, 4]]
err.add(ref, hyp)
err2 = SequenceErrorMeter()
err2.load_state_dict(err.state_dict())
self.assertEqual(err.value, err2.value)
if __name__ == "__main__":
unittest.main()<|fim... | code_fim | hard | {
"lang": "python",
"repo": "Transkribus/PyLaia",
"path": "/laia/meters/sequence_error_meter_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def testMultiple(self):
err = SequenceErrorMeter()
ref = [["the", "house", "is", "blue"], ["my", "dog", "is", "black"]]
hyp = [["the", "home", "is", "white"], ["my", "dog", "is", "not", "black"]]
err.add(ref, hyp)
self.assertEqual(err.value, (2 + 1) / (4 + 4))
... | code_fim | hard | {
"lang": "python",
"repo": "Transkribus/PyLaia",
"path": "/laia/meters/sequence_error_meter_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pzharrington/vissl path: /extra_scripts/convert_caffe2_to_torchvision_resnet.py
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Convert the ResNet-50 models from IC... | code_fim | hard | {
"lang": "python",
"repo": "pzharrington/vissl",
"path": "/extra_scripts/convert_caffe2_to_torchvision_resnet.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> logger.info("Remapping C2 weights")
max_c2_key_size = max(len(k) for k in original_keys if "_momentum" not in k)
new_weights = OrderedDict()
for k in original_keys:
v = weights[k]
if "_momentum" in k:
continue
if "pred" in k:
continue
... | code_fim | hard | {
"lang": "python",
"repo": "pzharrington/vissl",
"path": "/extra_scripts/convert_caffe2_to_torchvision_resnet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> path('cadastroTelefone/', views.CadastroTelefone, name='cadastroTelefone'),
path('meusTelefones/', views.TelefonesList, name='listaTelefones'),
path('meusTelefones/editar/<int:idTelefone>', views.atualizarMeusTelefones,name='telefone_atualizar'),
path('meusTelefones/excluir/<int:pk>', view... | code_fim | hard | {
"lang": "python",
"repo": "deyviddalbem/TrabalhoDeConclusaoDeCurso",
"path": "/sistemaDeGestaoDeServicosPublicos/Usuario/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: deyviddalbem/TrabalhoDeConclusaoDeCurso path: /sistemaDeGestaoDeServicosPublicos/Usuario/urls.py
from django.contrib import admin
from django.urls import include, path
from django.contrib.auth import views as auth_views
from django.views.generic.base import TemplateView
from . import views
<|f... | code_fim | hard | {
"lang": "python",
"repo": "deyviddalbem/TrabalhoDeConclusaoDeCurso",
"path": "/sistemaDeGestaoDeServicosPublicos/Usuario/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> path('cadastroEndereco/', views.cadastroEndereco, name='cadastroEndereco'),
path('meusEnderecos/', views.enderecosList, name='listaEnderecos'),
path('enderecos/listar/<int:pk>',views.ListarEnderecos.as_view(), name='listar_enderecos'),
#path('enderecos/listar/',views.enderecosList, name='e... | code_fim | hard | {
"lang": "python",
"repo": "deyviddalbem/TrabalhoDeConclusaoDeCurso",
"path": "/sistemaDeGestaoDeServicosPublicos/Usuario/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for eff in action.effects:
name = ' '.join([eff.literal.predicate] + map(lambda x: mapping[x], eff.literal.args))
if eff.literal.__class__ == NegatedAtom:
DEL.add(Fluent(name))
elif eff.literal.__class__ == Atom:
ADD.add(Fluent(name))
else:
... | code_fim | hard | {
"lang": "python",
"repo": "vishalbelsare/krtoolkit",
"path": "/krrt/planning/strips/representation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vishalbelsare/krtoolkit path: /krrt/planning/strips/representation.py
from krrt.utils import read_file
from krrt.planning.pddl import open as parsePDDL
from krrt.planning.pddl import Assign, Atom, Conjunction, NegatedAtom
from krrt.planning.pddl.instantiate import explore
from krrt.planning impo... | code_fim | hard | {
"lang": "python",
"repo": "vishalbelsare/krtoolkit",
"path": "/krrt/planning/strips/representation.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Lift the initial state
inits = set([])
for init in t.init:
# We don't want to keep around the trivial equality constraints
if Assign == init.__class__:
continue
if Atom != init.__class__:
print ("Error: Init condition not an Atom -- " + str(in... | code_fim | hard | {
"lang": "python",
"repo": "vishalbelsare/krtoolkit",
"path": "/krrt/planning/strips/representation.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.