text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: Iapetus-11/photo-mosaic-generator path: /compiler.py
import numpy as np
import random
import base64
import json
import cv2
def im_from_64(b):
return cv2.imdecode(np.frombuffer(base64.b64decode(b), np.uint8), cv2.IMREAD_COLOR)
def draw_image(canvas, img, x, y):
for i, row in enumerate(im... | code_fim | hard | {
"lang": "python",
"repo": "Iapetus-11/photo-mosaic-generator",
"path": "/compiler.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def before_all(context):
context.driver = webdriver.Firefox()
context.home = HomeAdapter(context.driver)
def after_all(context):
"""Tear down hospital BDD test context."""
context.driver.quit()
def after_scenario(context, scenario):
"""Clean up after every test scenario."""
con... | code_fim | hard | {
"lang": "python",
"repo": "tysonclugg/selenium-page-adapter",
"path": "/tests/duckduckgo/features/environment.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> search_input = ElementDescriptor(By.ID, 'search_form_input_homepage')
search_reset = ElementDescriptor(By.ID, 'search_form_input_clear')
search_submit = ElementDescriptor(By.ID, 'search_button_homepage')
search_suggestions = AvailableElements(
lambda el: (
int(el.get_at... | code_fim | medium | {
"lang": "python",
"repo": "tysonclugg/selenium-page-adapter",
"path": "/tests/duckduckgo/features/environment.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tysonclugg/selenium-page-adapter path: /tests/duckduckgo/features/environment.py
"""DuckDuckGo BDD environment."""
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import ... | code_fim | medium | {
"lang": "python",
"repo": "tysonclugg/selenium-page-adapter",
"path": "/tests/duckduckgo/features/environment.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bytedance/TRTorch path: /tools/linter/cpplint.py
import os
import sys
import glob
import subprocess
import utils
import pwd
VALID_CPP_FILE_TYPES = [".cpp", ".cc", ".c", ".cu", ".hpp", ".h", ".cuh"]
<|fim_suffix|>
if __name__ == "__main__":
BAZEL_ROOT = utils.find_bazel_root()
USER = pwd... | code_fim | hard | {
"lang": "python",
"repo": "bytedance/TRTorch",
"path": "/tools/linter/cpplint.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> cmd = ['clang-format']
if change_file:
cmd.append("-i")
print(
"\033[93mWARNING:\033[0m This command is modifying your files with the recommended linting, you should review the changes before committing"
)
for f in target_files:
cmd.append(f)
... | code_fim | medium | {
"lang": "python",
"repo": "bytedance/TRTorch",
"path": "/tools/linter/cpplint.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
BAZEL_ROOT = utils.find_bazel_root()
USER = pwd.getpwuid(os.getuid())[0]
projects = utils.CHECK_PROJECTS(sys.argv[1:])
if "//..." in projects:
projects = [p.replace(BAZEL_ROOT, "/")[:-1] for p in glob.glob(BAZEL_ROOT + '/*/')]
projects = [p for p... | code_fim | hard | {
"lang": "python",
"repo": "bytedance/TRTorch",
"path": "/tools/linter/cpplint.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>totalSeconds1 = hour1 * 3600 + minute1 * 60 + second1
totalSeconds2 = hour2 * 3600 + minute2 * 60 + second2
days = day2 - day1
if (totalSeconds1 < totalSeconds2):
seconds = totalSeconds2 - totalSeconds1
else:
seconds = 86400 - totalSeconds1 + totalSeconds2
days -= 1
print("%d dia(s)" % days)
prin... | code_fim | medium | {
"lang": "python",
"repo": "MisaelAugusto/uri",
"path": "/python-3/beginner/1061.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MisaelAugusto/uri path: /python-3/beginner/1061.py
# -*- coding: utf-8 -*-
day1 = int(input().split()[1])
hour1, minute1, second1 = map(int, input().split(" : "))
<|fim_suffix|>totalSeconds1 = hour1 * 3600 + minute1 * 60 + second1
totalSeconds2 = hour2 * 3600 + minute2 * 60 + second2
days = da... | code_fim | medium | {
"lang": "python",
"repo": "MisaelAugusto/uri",
"path": "/python-3/beginner/1061.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mariaSerrabona/practica-IV path: /ej7.py
import math
import os
import random
import re
import sys
def gradingStudents(grades):
#creamos una nueva lista que almacena las notas finales ya redondeadas si fuese necesario
new_grades=[]
for grade in grades:
#si la calificación es menos a 4... | code_fim | medium | {
"lang": "python",
"repo": "mariaSerrabona/practica-IV",
"path": "/ej7.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
grades_count = int(input().strip())
grades = []
for _ in range(grades_count):
grades_item = int(input().strip())
grades.append(grades_item)
result = gradingStudents(grades)
fptr.write('\n'.join(map(str, resul... | code_fim | medium | {
"lang": "python",
"repo": "mariaSerrabona/practica-IV",
"path": "/ej7.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BlueJacket98/codesignal-challenges path: /challenges/differentRightmostBit/python3/differentRightmostBit.py
from math import log2
def differentRightmostBit(n, m):
return 2**log2((n^m)&-(n^m))
if __name__ == '__main__':
input0 = [11, 7, 1, 64, 1073741823, 42]
input1 = [13, 23, 0, 65, 107151359... | code_fim | hard | {
"lang": "python",
"repo": "BlueJacket98/codesignal-challenges",
"path": "/challenges/differentRightmostBit/python3/differentRightmostBit.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> expected, 'differentRightmostBit({}, {}) returned {}, but expected {}'.format(input0[i], input1[i], actual, expected)
print('PASSES {} out of {} tests'.format(len(expectedOutput), len(expectedOutput)))<|fim_prefix|># repo: BlueJacket98/codesignal-challenges path: /challenges/differentRightmostBit/pytho... | code_fim | hard | {
"lang": "python",
"repo": "BlueJacket98/codesignal-challenges",
"path": "/challenges/differentRightmostBit/python3/differentRightmostBit.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>, '# input1 = {}, # expectedOutput = {}'.format(len(input1), len(expectedOutput))
for i, expected in enumerate(expectedOutput):
actual = differentRightmostBit(input0[i], input1[i])
assert actual == expected, 'differentRightmostBit({}, {}) returned {}, but expected {}'.format(input0[i], input1[i], act... | code_fim | hard | {
"lang": "python",
"repo": "BlueJacket98/codesignal-challenges",
"path": "/challenges/differentRightmostBit/python3/differentRightmostBit.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/adjectives/_incautious.py
#calss header
class _INCAUTIOUS():
def __init__(self,):
<|fim_suffix|> self.jsondata[obj2] = {}
self.jsondata[obj2]['properties'] = self.name.lower()
return self.jsondata<|fim_middle|> self.name = "INCAUTIOUS"
self.defin... | code_fim | hard | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/adjectives/_incautious.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_middle_joint(joint_a: Joint2D, joint_b: Joint2D) -> Joint2D:
"""
Returns a joint which is in the middle of the two input joints. The visibility and score is estimated by the
visibility and score of the two surrounding joints.
:param joint_a: Surrounding joint one
:param joint_... | code_fim | hard | {
"lang": "python",
"repo": "noboevbo/nobos_commons",
"path": "/nobos_commons/utils/joint_helper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Returns a joint which is in the middle of the two input joints. The visibility and score is estimated by the
visibility and score of the two surrounding joints.
:param joint_a: Surrounding joint one
:param joint_b: Surrounding joint two
:return: Joint in the middle of joint_a a... | code_fim | hard | {
"lang": "python",
"repo": "noboevbo/nobos_commons",
"path": "/nobos_commons/utils/joint_helper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: noboevbo/nobos_commons path: /nobos_commons/utils/joint_helper.py
import math
from typing import List
from nobos_commons.data_structures.geometry import Triangle
from nobos_commons.data_structures.skeletons.joint_2d import Joint2D
from nobos_commons.data_structures.skeletons.joint_visibility imp... | code_fim | hard | {
"lang": "python",
"repo": "noboevbo/nobos_commons",
"path": "/nobos_commons/utils/joint_helper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tbvanderwoude/research-project path: /python/benchmarks/comparison/icts.py
from mapfmclient import Problem, Solution
import sys
import pathlib
from python.benchmarks.comparison.util import get_src_modules, solve_with_modules
this_dir = pathlib.Path(__file__).parent.absolute()
from python.algo... | code_fim | medium | {
"lang": "python",
"repo": "tbvanderwoude/research-project",
"path": "/python/benchmarks/comparison/icts.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>from python.algorithm import MapfAlgorithm
sys.path.insert(0, str("/home/tbvanderwoude/repos/rp"))
from src.ictsm .solver import Solver
from src.ictsm .solver_config import SolverConfig
sys.path.pop(0)
modules = get_src_modules()
class ICTS(MapfAlgorithm):
def solve(self, problem: Problem) -> Sol... | code_fim | medium | {
"lang": "python",
"repo": "tbvanderwoude/research-project",
"path": "/python/benchmarks/comparison/icts.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class ICTS(MapfAlgorithm):
def solve(self, problem: Problem) -> Solution:
def solve_icts():
config = SolverConfig(
name="Exh+E+B+O+ID",
combs=3,
prune=True,
enhanced=True,
pruned_child_gen=False,
... | code_fim | hard | {
"lang": "python",
"repo": "tbvanderwoude/research-project",
"path": "/python/benchmarks/comparison/icts.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(PROJECT_ROOT, 'prod.sqlite3'),
}
}<|fim_prefix|># repo: hotbaby/django-project-skeleton path: /project_name/settings/prod.py
# encoding: utf8
import os
from .base import * # NOQA
from .bas... | code_fim | easy | {
"lang": "python",
"repo": "hotbaby/django-project-skeleton",
"path": "/project_name/settings/prod.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hotbaby/django-project-skeleton path: /project_name/settings/prod.py
# encoding: utf8
import os
from .base import * # NOQA
from .base import DEFAULT_APPS, PROJECT_ROOT
DEBUG = False
<|fim_suffix|>DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME':... | code_fim | easy | {
"lang": "python",
"repo": "hotbaby/django-project-skeleton",
"path": "/project_name/settings/prod.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MYusha/video-classification-3d-cnn-pytorch path: /visualize_features.py
import numpy as np
import os
import json
import sys
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import manifold
from time import time
import pdb
from matplotlib import offsetbox
from sklearn.neighbors im... | code_fim | hard | {
"lang": "python",
"repo": "MYusha/video-classification-3d-cnn-pytorch",
"path": "/visualize_features.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # clfboost = GradientBoostingClassifier()
# acc = sklearn_predict(clfboost, X_train, y_train, X_test, y_test)
# print("accuracy of gradient boost classifiers is {}".format(acc))
X = np.vstack([X_train,X_test])
y = y_train+y_test
print('original feature of shape {}'.format(str(X.sh... | code_fim | hard | {
"lang": "python",
"repo": "MYusha/video-classification-3d-cnn-pytorch",
"path": "/visualize_features.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ggardiakos/Phaedra path: /backend/Phaedra/Notebook/Page.py
"""Page dataclass for Phaedra Notebook."""
from typing import Any, List, Dict, Optional, Union
import uuid
from wikipedia.wikipedia import page # type: ignore
from Phaedra.Notebook.Cell import Cell, CellJson
__all__ = ("Page", "Page... | code_fim | hard | {
"lang": "python",
"repo": "ggardiakos/Phaedra",
"path": "/backend/Phaedra/Notebook/Page.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
self.cells.insert(index, cell)
def add_cell(self, cell: Cell):
"""Adds a cell to the page.
:param cell: Cell to add.
:type cell: Cell
"""
self.cells.append(cell)
def get_cell(self, cell_id: str) -> Optional[Cell]:
"""Gets a ... | code_fim | hard | {
"lang": "python",
"repo": "ggardiakos/Phaedra",
"path": "/backend/Phaedra/Notebook/Page.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># revision identifiers, used by Alembic.
revision = '354de64ba129'
down_revision = 'b07673bb8654'
from alembic import op
import sqlalchemy as sa
def upgrade(active_plugins=None, options=None):
for table in ['devices', 'devicetemplates', 'vims', 'servicetypes']:
op.alter_column(table,
... | code_fim | medium | {
"lang": "python",
"repo": "openstack/tacker",
"path": "/tacker/db/migration/alembic_migrations/versions/354de64ba129_set_mandatory_columns_not_null.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstack/tacker path: /tacker/db/migration/alembic_migrations/versions/354de64ba129_set_mandatory_columns_not_null.py
# Copyright 2016 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.... | code_fim | medium | {
"lang": "python",
"repo": "openstack/tacker",
"path": "/tacker/db/migration/alembic_migrations/versions/354de64ba129_set_mandatory_columns_not_null.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>from alembic import op
import sqlalchemy as sa
def upgrade(active_plugins=None, options=None):
for table in ['devices', 'devicetemplates', 'vims', 'servicetypes']:
op.alter_column(table,
'tenant_id',
existing_type=sa.String(64),
... | code_fim | medium | {
"lang": "python",
"repo": "openstack/tacker",
"path": "/tacker/db/migration/alembic_migrations/versions/354de64ba129_set_mandatory_columns_not_null.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.port = port;
self.srvsock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
self.srvsock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 )
self.srvsock.bind( ("", port) )
self.srvsock.listen( 5 )
self.names=[]
self.password=[]
... | code_fim | hard | {
"lang": "python",
"repo": "Messaoud-Boudjada/PyChat",
"path": "/server.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Messaoud-Boudjada/PyChat path: /server.py
#The MIT License (MIT)
#Copyright (c) 2014 Boudjada Messaoud
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restrictio... | code_fim | hard | {
"lang": "python",
"repo": "Messaoud-Boudjada/PyChat",
"path": "/server.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__( self, port ):
self.port = port;
self.srvsock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
self.srvsock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 )
self.srvsock.bind( ("", port) )
self.srvsock.listen( 5 )
self.names=[]
... | code_fim | hard | {
"lang": "python",
"repo": "Messaoud-Boudjada/PyChat",
"path": "/server.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: claytonjwong/leetcode-py path: /389_find_the_difference.py
#
# 389. Find the Difference
#
# Q: https://leetcode.com/problems/find-the-difference/
# A: https://leetcode.com/problems/find-the-difference/discuss/862287/Javascript-Python3-C%2B%2B-Concise-solutions
#
from collections import Counter
... | code_fim | medium | {
"lang": "python",
"repo": "claytonjwong/leetcode-py",
"path": "/389_find_the_difference.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Solution:
def findTheDifference(self, s: str, t: str) -> str:
return [key for key in (Counter(t) - Counter(s))][0]<|fim_prefix|># repo: claytonjwong/leetcode-py path: /389_find_the_difference.py
#
# 389. Find the Difference
#
# Q: https://leetcode.com/problems/find-the-difference/
# A: ... | code_fim | medium | {
"lang": "python",
"repo": "claytonjwong/leetcode-py",
"path": "/389_find_the_difference.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ashwath92/MastersThesis path: /IndexingMAG/PythonPrograms/index_journals.py
import os
import pysolr
import requests
import csv
def insert_into_solr():
""" Inserts records into an empty solr index which has already been created."""
solr = pysolr.Solr('http://localhost:8983/solr/mag_journ... | code_fim | hard | {
"lang": "python",
"repo": "ashwath92/MastersThesis",
"path": "/IndexingMAG/PythonPrograms/index_journals.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>record['paper_count'] = paper_count
solr_record['citation_count'] = citation_count
solr_record['created_date'] = created_date
list_for_solr.append(solr_record)
# Upload to Solr: 48000-odd rows
solr.add(list_for_solr)
if __name__ == '__main__':
inser... | code_fim | hard | {
"lang": "python",
"repo": "ashwath92/MastersThesis",
"path": "/IndexingMAG/PythonPrograms/index_journals.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: firedot/loggy path: /command.py
#!/usr/bin/python
from sys import exit
from util.singleton import Singleton
class CommandManager(object):
__metaclass__ = Singleton
def __init__(self):
print '__init__'
if not hasattr(self, '_commands'):
self._commands = {}... | code_fim | medium | {
"lang": "python",
"repo": "firedot/loggy",
"path": "/command.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self):
super(ResumeCommand, self).__init__("resume")
def execute(self, **args):
return "PRINT"
class ExitCommand(Command):
def __init__(self):
super(ExitCommand, self).__init__("exit")
def execute(self, **args):
exit(0)
cm = CommandManager... | code_fim | hard | {
"lang": "python",
"repo": "firedot/loggy",
"path": "/command.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kiniamogh/navigator-api path: /navigator/auth/middlewares/troc.py
"""TROC Token Middleware.
Use RNC algorithm to create a token-based authentication/authorization
for Navigator.
Middleware Authorization.
"""
import sys
import json
from aiohttp import web
from navigator.libs.cypher import *
<|f... | code_fim | medium | {
"lang": "python",
"repo": "kiniamogh/navigator-api",
"path": "/navigator/auth/middlewares/troc.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>async def troctoken_middleware(app, handler):
async def middleware(request):
request.user = None
try:
troctoken = request.query.get("auth", request.headers.get("X-Token", None))
except KeyError as err:
troctoken = None
if troctoken:
t... | code_fim | medium | {
"lang": "python",
"repo": "kiniamogh/navigator-api",
"path": "/navigator/auth/middlewares/troc.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.code + ' ' + str(self.value)
class Meta:
app_label = 'PManager'<|fim_prefix|># repo: lenarhus/opengift.io path: /PManager/models/log.py
# -*- coding:utf-8 -*-
__author__ = 'Gvammer'
from django.db import models
from django.contrib.auth.models import User
class LogData(mo... | code_fim | hard | {
"lang": "python",
"repo": "lenarhus/opengift.io",
"path": "/PManager/models/log.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lenarhus/opengift.io path: /PManager/models/log.py
# -*- coding:utf-8 -*-
__author__ = 'Gvammer'
from django.db import models
from django.contrib.auth.models import User
class LogData(models.Model):
<|fim_suffix|> def __str__(self):
return self.code + ' ' + str(self.value)
class ... | code_fim | hard | {
"lang": "python",
"repo": "lenarhus/opengift.io",
"path": "/PManager/models/log.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __str__(self):
return self.code + ' ' + str(self.value)
class Meta:
app_label = 'PManager'<|fim_prefix|># repo: lenarhus/opengift.io path: /PManager/models/log.py
# -*- coding:utf-8 -*-
__author__ = 'Gvammer'
from django.db import models
from django.contrib.auth.models import... | code_fim | hard | {
"lang": "python",
"repo": "lenarhus/opengift.io",
"path": "/PManager/models/log.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Examples:
>>> x = ['This is a test file', 'This is second line', 'third line $1,000']
>>> mean_characters_per_word = MeanCharactersPerWord()
>>> mean_characters_per_word(x).tolist()
[3.0, 4.0, 5.0]
"""
name = "mean_characters_per_word"
input_types = [Text]
... | code_fim | hard | {
"lang": "python",
"repo": "mikewcasale/nlp_primitives",
"path": "/nlp_primitives/mean_characters_per_word.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> x = x.reset_index(drop=True).fillna('')
# replace end-of-sentence punctuation with space
p = re.escape('!,.:;?')
end_of_sentence_punct = re.compile('[%s]+$|[%s]+ |[%s]+\n' % (p, p, p))
x = x.str.replace(end_of_sentence_punct, ' ')
# b... | code_fim | medium | {
"lang": "python",
"repo": "mikewcasale/nlp_primitives",
"path": "/nlp_primitives/mean_characters_per_word.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mikewcasale/nlp_primitives path: /nlp_primitives/mean_characters_per_word.py
# -*- coding: utf-8 -*-
import re
from featuretools.primitives.base import TransformPrimitive
from featuretools.variable_types import Numeric, Text
class MeanCharactersPerWord(TransformPrimitive):
"""Determines t... | code_fim | hard | {
"lang": "python",
"repo": "mikewcasale/nlp_primitives",
"path": "/nlp_primitives/mean_characters_per_word.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def jurgen_dataset(avglen=800, seed=None):
trans_mat = np.array([[0.01,0.99,0.0,0.0],
[0.0,0.01,0.99,0.0],
[0.0,0.0,0.01,0.99],
[0.99,0.0,0.0,0.01]])
obs_mat = np.array([[0.0,0.5,0.5],
[2.0/3.0,1.0/6.0,1... | code_fim | hard | {
"lang": "python",
"repo": "jzf2101/hmm",
"path": "/microscopes/hmm/testutil.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jzf2101/hmm path: /microscopes/hmm/testutil.py
"""
Test helpers specific to HMM
"""
import numpy as np
from microscopes.common import validator
from microscopes.hmm.definition import model_definition
def toy_model(defn, states=5):
"""From a model definition, generate a random HMM transition
... | code_fim | hard | {
"lang": "python",
"repo": "jzf2101/hmm",
"path": "/microscopes/hmm/testutil.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Parameters
----------
defn: model definition
states: number of latent states
avlen: average length of one observation sequence
(actual length is sampled from a poisson distribution)
numobs: number of observation sequences
Output
------
data: the observations generated from the ... | code_fim | hard | {
"lang": "python",
"repo": "jzf2101/hmm",
"path": "/microscopes/hmm/testutil.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Hillssolo/keras path: /keras/wrappers/lime.py
from __future__ import absolute_import
import numpy as np
from ..models import Sequential
from ..layers import Dense
from ..callbacks import EarlyStopping
from ..utils.generic_utils import Progbar
from ..regularizers import l1
from ..optimizers impo... | code_fim | hard | {
"lang": "python",
"repo": "Hillssolo/keras",
"path": "/keras/wrappers/lime.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # masks & scores are now ordered by length; this does not matter since fit() will shuffle them
all_scores = np.concatenate(all_scores, axis = 0)
all_masks = np.concatenate(all_masks, axis = 0)
all_weights = []
if out is None: classes = list(range(numclasses))
... | code_fim | hard | {
"lang": "python",
"repo": "Hillssolo/keras",
"path": "/keras/wrappers/lime.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
all_masks = []
all_scores = []
for length in masks_by_length.keys():
input_original = np.stack([x[mask.nonzero()[0]] for mask in masks_by_length[length]], axis = 0)
masks = np.stack(masks_by_length[length], axis = 0)
scores = self.model.predict... | code_fim | hard | {
"lang": "python",
"repo": "Hillssolo/keras",
"path": "/keras/wrappers/lime.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> host_config = self.host_config()
fabric.api.sudo('apt-get install -y ' + ' '.join(host_config['apt_packages']))
fabric.api.sudo('python -m easy_install ' + ' '.join(host_config['pip_packages']))<|fim_prefix|># repo: popen2/django-giftcard path: /giftcard/management/commands/gc_ins... | code_fim | hard | {
"lang": "python",
"repo": "popen2/django-giftcard",
"path": "/giftcard/management/commands/gc_install_pkg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: popen2/django-giftcard path: /giftcard/management/commands/gc_install_pkg.py
from ..base_command import GiftcardCommand, CommandError
import fabric.api
class Command(GiftcardCommand):
def handle(self, *args, **kwargs):
for host in self.hosts(args):
with fabric.api.setting... | code_fim | medium | {
"lang": "python",
"repo": "popen2/django-giftcard",
"path": "/giftcard/management/commands/gc_install_pkg.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class admin(app.plugin.Action):
'''
插件的后台控制器
'''
def get(self):
pass
def post(self):
pass<|fim_prefix|># repo: qiuyukuhe/QcoreCMS path: /app/plugin/editor_kind/controller/__init__.py
#coding=utf-8
import app.plugin
import urllib2, urllib
class default(app.plugin.Actio... | code_fim | hard | {
"lang": "python",
"repo": "qiuyukuhe/QcoreCMS",
"path": "/app/plugin/editor_kind/controller/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qiuyukuhe/QcoreCMS path: /app/plugin/editor_kind/controller/__init__.py
#coding=utf-8
import app.plugin
import urllib2, urllib
class default(app.plugin.Action):
'''
插件的前台控制器(无权限控制)
'''
def get(self):
kw = self.get_argument('kw',False)
if kw :
api_url = ... | code_fim | hard | {
"lang": "python",
"repo": "qiuyukuhe/QcoreCMS",
"path": "/app/plugin/editor_kind/controller/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
The validated data.
"""
self.instance = self.instance or models.AppleReceipt()
self.instance.receipt_data = data["receipt_data"]
try:
self.instance.update_info()
except subscriptions.ReceiptException as e:
raise ... | code_fim | hard | {
"lang": "python",
"repo": "knowmetools/km-api",
"path": "/km_api/know_me/serializers/subscription_serializers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
data:
The data to validate.
Returns:
The validated data.
Raises:
serializers.ValidationError:
If the recipient is unable to receive a subscription
transfer.
"""
if not models... | code_fim | hard | {
"lang": "python",
"repo": "knowmetools/km-api",
"path": "/km_api/know_me/serializers/subscription_serializers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: knowmetools/km-api path: /km_api/know_me/serializers/subscription_serializers.py
import logging
from django.db import transaction
from django.utils import timezone
from django.utils.translation import ugettext, ugettext_lazy as _
from rest_email_auth.models import EmailAddress
from rest_framewor... | code_fim | hard | {
"lang": "python",
"repo": "knowmetools/km-api",
"path": "/km_api/know_me/serializers/subscription_serializers.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adwaitpande11/google-drive-file-reader-api path: /pydrive_api.py
import io
import googleapiclient.discovery
from googleapiclient.http import MediaIoBaseDownload
from authenticator import Authenticator
class PyDriveApi:
def __init__(self):
auth = Authenticator().authenticate()
... | code_fim | medium | {
"lang": "python",
"repo": "adwaitpande11/google-drive-file-reader-api",
"path": "/pydrive_api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> file = self.fetch_file_metadata_by_name(file_name)
return self.read_remote_file(file['id'])
def fetch_file_list(self, q=None):
return self.drive.files().list(q=q).execute()
def fetch_file_metadata_by_name(self, file_name):
file_list = self.fetch_file_list(q="name ... | code_fim | hard | {
"lang": "python",
"repo": "adwaitpande11/google-drive-file-reader-api",
"path": "/pydrive_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Zapix/mtpylon path: /mtpylon/messages/encrypted_message.py
# -*- coding: utf-8 -*-
import asyncio
import logging
from typing import Any
from random import randbytes
from tgcrypto import ige256_decrypt, ige256_encrypt # type: ignore
from mtpylon.schema import Schema
from mtpylon.crypto import (... | code_fim | hard | {
"lang": "python",
"repo": "Zapix/mtpylon",
"path": "/mtpylon/messages/encrypted_message.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>async def get_auth_key(
auth_manager: AuthKeyManager,
encrypted_message: bytes
) -> AuthKey:
"""
Returns actual auth_key value
Raises:
AuthKeyNotFound - if auth key not found in auth_manager
AuthKeyChangedException - if another key has been used
"""
income_auth... | code_fim | hard | {
"lang": "python",
"repo": "Zapix/mtpylon",
"path": "/mtpylon/messages/encrypted_message.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def pad_bytes(raw_data):
length_with_min_pad = len(raw_data) + MIN_PAD
round_pad = (16 - (length_with_min_pad % 16)) % 16
total_pad = round_pad + MIN_PAD
return randbytes(total_pad)
async def get_auth_key(
auth_manager: AuthKeyManager,
encrypted_message: bytes
) -> AuthKey:
... | code_fim | hard | {
"lang": "python",
"repo": "Zapix/mtpylon",
"path": "/mtpylon/messages/encrypted_message.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yz-/ut path: /pdict/manip.py
__author__ = 'thorwhalen'
def add_defaults(d, default_dict):
return dict(default_dict, **d)
def recursive_left_union(a, b):
b_copy = b.copy()
recursively_update_with(b_copy, a)
return b_copy
def recursively_update_with(a, b):
<|fim_suffix|>def me... | code_fim | hard | {
"lang": "python",
"repo": "yz-/ut",
"path": "/pdict/manip.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def merge(a, b, path=None):
"merges b into a"
a = a.copy()
if path is None: path = []
for key in b:
if key in a:
if isinstance(a[key], dict) and isinstance(b[key], dict):
merge(a[key], b[key], path + [str(key)])
elif a[key] == b[key]:
... | code_fim | hard | {
"lang": "python",
"repo": "yz-/ut",
"path": "/pdict/manip.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print ("ok, you would prefer to have %d more %s %s balls!" % (ballcount, ballcolor, ballsize))<|fim_prefix|># repo: jessehagberg/python-playground path: /ex13-1.py
from sys import argv
script, ballcolor, ballsize = argv
print "You have really %s %s balls!" % (ballcolor, ballsize)
<|fim_middle|>b... | code_fim | medium | {
"lang": "python",
"repo": "jessehagberg/python-playground",
"path": "/ex13-1.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jessehagberg/python-playground path: /ex13-1.py
from sys import argv
script, ballcolor, ballsize = argv
print "You have really %s %s balls!" % (ballcolor, ballsize)
<|fim_suffix|>print ("ok, you would prefer to have %d more %s %s balls!" % (ballcount, ballcolor, ballsize))<|fim_middle|>b... | code_fim | medium | {
"lang": "python",
"repo": "jessehagberg/python-playground",
"path": "/ex13-1.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>rom .renderer import *
from .utils import *<|fim_prefix|># repo: hiroharu-kato/nmr path: /nmr/__init__.py
from .backgrounds import *
from .cameras import *
from .meshes import *
from .obj_loa<|fim_middle|>der import *
from .rasterization import *
f | code_fim | easy | {
"lang": "python",
"repo": "hiroharu-kato/nmr",
"path": "/nmr/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hiroharu-kato/nmr path: /nmr/__init__.py
from .backgrounds import *
from .cameras import *
from .meshes import *
from .obj_loa<|fim_suffix|>rom .renderer import *
from .utils import *<|fim_middle|>der import *
from .rasterization import *
f | code_fim | easy | {
"lang": "python",
"repo": "hiroharu-kato/nmr",
"path": "/nmr/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: landlab/landlab path: /landlab/grid/unstructured/base.py
[0, 0, 1, 1], [0, 1, 0, 1]))
>>> ngrid.number_of_nodes
4
>>> ngrid.x_at_node
array([ 0., 1., 0., 1.])
>>> ngrid.x_at_node[2]
0.0
>>> ngrid.point_at_node[2]
array([ 1., 0.])
>>> ngrid.coord_at_node[:, ... | code_fim | hard | {
"lang": "python",
"repo": "landlab/landlab",
"path": "/landlab/grid/unstructured/base.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Distance between nodes.
Parameters
----------
node0 : array-like
Node ID of start
node1 : array-like
Node ID of end
Returns
-------
array :
Distances between nodes.
Examples
--------
... | code_fim | hard | {
"lang": "python",
"repo": "landlab/landlab",
"path": "/landlab/grid/unstructured/base.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Examples
--------
>>> from landlab.grid.unstructured.base import BaseGrid
>>> ngrid = BaseGrid(([0, 1, 0], [1, 1, 0]))
>>> ngrid.axis_units
('-', '-')
>>> ngrid = BaseGrid(([0, 1, 0], [1, 1, 0]),
... axis_units=['degrees_north', 'degrees... | code_fim | hard | {
"lang": "python",
"repo": "landlab/landlab",
"path": "/landlab/grid/unstructured/base.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def visit(inputs):
position = 0 + 0j
visited = {position}
for x in inputs:
position = position + move[x]
visited.add(position)
return visited
print(f"AoC 2015 Day 3, Part 1 answer is {len(visit(inputs))}")
print(f"AoC 2015 Day 3, Part 2 answer is {len(visit(inputs[0::2]) ... | code_fim | medium | {
"lang": "python",
"repo": "davidxbuck/adventofcode",
"path": "/2015/src/Advent2015_03.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: davidxbuck/adventofcode path: /2015/src/Advent2015_03.py
# Advent of Code 2015
#
# From https://adventofcode.com/2015/day/3
#
inputs = [data.strip() for data in open('../inputs/Advent2015_03.txt', 'r')][0]
move = {'^': 0 + 1j, ">": 1, "v": 0 - 1j, "<": -1}
def visit(inputs):
<|fim_suffix|>
pr... | code_fim | medium | {
"lang": "python",
"repo": "davidxbuck/adventofcode",
"path": "/2015/src/Advent2015_03.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> position = 0 + 0j
visited = {position}
for x in inputs:
position = position + move[x]
visited.add(position)
return visited
print(f"AoC 2015 Day 3, Part 1 answer is {len(visit(inputs))}")
print(f"AoC 2015 Day 3, Part 2 answer is {len(visit(inputs[0::2]) | visit(inputs[1::2... | code_fim | medium | {
"lang": "python",
"repo": "davidxbuck/adventofcode",
"path": "/2015/src/Advent2015_03.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> g = list_of_ggplots[0]
import plotnine as p9
from matplotlib import rc
rc('text', usetex=True)
g = (g + p9.xlab("$E_{tot}$") + p9.ylab("$[S^{**}]$") + p9.scale_color_manual(values=["red", "blue"], labels=["High [$S^{**}$]", "Low [$S^{**}$]"]))
g.save(filename=f"./Figure_7.png", fo... | code_fim | hard | {
"lang": "python",
"repo": "PNNL-Comp-Mass-Spec/CRNT4SBML",
"path": "/2021_BMC_Bioinformatics_paper_code/run_PrionDoublePhos.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#######################################################################################################################
#######################################################################################################################
# The code below produces the values for bistability (in parallel)... | code_fim | hard | {
"lang": "python",
"repo": "PNNL-Comp-Mass-Spec/CRNT4SBML",
"path": "/2021_BMC_Bioinformatics_paper_code/run_PrionDoublePhos.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PNNL-Comp-Mass-Spec/CRNT4SBML path: /2021_BMC_Bioinformatics_paper_code/run_PrionDoublePhos.py
########################################################################
########################################################################
# Please review the documentation provided at crnt4sbml.... | code_fim | medium | {
"lang": "python",
"repo": "PNNL-Comp-Mass-Spec/CRNT4SBML",
"path": "/2021_BMC_Bioinformatics_paper_code/run_PrionDoublePhos.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> s=self.scheduler()
random = RandomTable(10, rows=10000, scheduler=s)
cmp_ = CmpQueryLast(scheduler=s)
cst = Table("cmp_table", data={'_1': [0.5]})
value = Constant(cst, scheduler=s)
cmp_.input.cmp = value.output.table
cmp_.input.table = random.output... | code_fim | medium | {
"lang": "python",
"repo": "fagan2888/progressivis",
"path": "/tests/test_03_cmp_query.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fagan2888/progressivis path: /tests/test_03_cmp_query.py
from . import ProgressiveTest
from progressivis import Print
from progressivis.table import Table
from progressivis.table.cmp_query import CmpQueryLast
from progressivis.table.constant import Constant
from progressivis.stats import RandomT... | code_fim | medium | {
"lang": "python",
"repo": "fagan2888/progressivis",
"path": "/tests/test_03_cmp_query.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # read/compute node feature
if mini_data:
node_feat_path = './dataset/ogbn_proteins_node_feat_small.npy'
else:
node_feat_path = './dataset/ogbn_proteins_node_feat.npy'
new_node_feat = None
if os.path.exists(node_feat_path):
print("Begin: read node feature".cent... | code_fim | hard | {
"lang": "python",
"repo": "PaddlePaddle/PGL",
"path": "/legacy/examples/GaAN/preprocess.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Param:
d_name: name of dataset
mini_data: if mini_data==True, only use a small dataset (for test)
"""
# import ogb data
dataset = NodePropPredDataset(name = d_name)
num_tasks = dataset.num_tasks # obtaining the number of prediction tasks in a dataset... | code_fim | hard | {
"lang": "python",
"repo": "PaddlePaddle/PGL",
"path": "/legacy/examples/GaAN/preprocess.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PaddlePaddle/PGL path: /legacy/examples/GaAN/preprocess.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License a... | code_fim | hard | {
"lang": "python",
"repo": "PaddlePaddle/PGL",
"path": "/legacy/examples/GaAN/preprocess.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Path length regularization.
with tf.name_scope('PathReg'):
# Evaluate the regularization term using a smaller minibatch to conserve memory.
if pl_minibatch_shrink > 1:
pl_minibatch = minibatch_size // pl_minibatch_shrink
pl_latents = tf.random_normal([pl_... | code_fim | hard | {
"lang": "python",
"repo": "genforce/genforce",
"path": "/converters/stylegan2_official/training/loss.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: genforce/genforce path: /converters/stylegan2_official/training/loss.py
# Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html... | code_fim | hard | {
"lang": "python",
"repo": "genforce/genforce",
"path": "/converters/stylegan2_official/training/loss.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def log_inception_score(preds):
kl = preds * (tf.log(preds) - tf.log(tf.expand_dims(tf.reduce_mean(preds, 0), 0)))
return tf.reduce_mean(tf.reduce_sum(kl, 1), name='log_inception_score')
# Wasserstein losses from `Wasserstein GAN` (https://arxiv.org/abs/1701.07875).
def generator_loss(logits_ge... | code_fim | hard | {
"lang": "python",
"repo": "hitachi-rd-cv/influence-estimation-for-gans",
"path": "/modules/tf_ops.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hitachi-rd-cv/influence-estimation-for-gans path: /modules/tf_ops.py
import numpy as np
import tensorflow as tf
import tensorflow_probability as tfp
from tensorflow import gradients
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import math_ops
def clip_log_by_value(x, v... | code_fim | hard | {
"lang": "python",
"repo": "hitachi-rd-cv/influence-estimation-for-gans",
"path": "/modules/tf_ops.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif method == 'ls':
with tf.name_scope('ls_loss'):
loss_real = (logits_real - tf.ones_like(logits_real)) ** 2
elif method in ['minmax', 'modified_minmax']:
with tf.name_scope('minmax_loss'):
y_real = tf.ones_like(logits_real)
loss_real = tf.nn.... | code_fim | hard | {
"lang": "python",
"repo": "hitachi-rd-cv/influence-estimation-for-gans",
"path": "/modules/tf_ops.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def visit_MEDIUMBLOB(self, type_, **kw): ...
def visit_LONGBLOB(self, type_, **kw): ...
def visit_ENUM(self, type_, **kw): ...
def visit_SET(self, type_, **kw): ...
def visit_BOOLEAN(self, type, **kw): ...
class MySQLIdentifierPreparer(compiler.IdentifierPreparer):
reserved_words:... | code_fim | hard | {
"lang": "python",
"repo": "0xedward/sapp",
"path": "/stubs/sqlalchemy/dialects/mysql/base.pyi",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 0xedward/sapp path: /stubs/sqlalchemy/dialects/mysql/base.pyi
# Stubs for sqlalchemy.dialects.mysql.base (Python 3.6)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from array import array as _array
from typing import Any, Optional
from sqlalchemy.sql import compi... | code_fim | hard | {
"lang": "python",
"repo": "0xedward/sapp",
"path": "/stubs/sqlalchemy/dialects/mysql/base.pyi",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def visit_TEXT(self, type_, **kw): ...
def visit_TINYTEXT(self, type_, **kw): ...
def visit_MEDIUMTEXT(self, type_, **kw): ...
def visit_LONGTEXT(self, type_, **kw): ...
def visit_VARCHAR(self, type_, **kw): ...
def visit_CHAR(self, type_, **kw): ...
def visit_NVARCHAR(self, ty... | code_fim | hard | {
"lang": "python",
"repo": "0xedward/sapp",
"path": "/stubs/sqlalchemy/dialects/mysql/base.pyi",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mvantellingen/localshop path: /src/localshop/apps/packages/migrations/0008_auto_20171116_2112.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11.7 on 2017-11-16 21:12
from __future__ import unicode_literals
<|fim_suffix|>
dependencies = [
('packages', '0007_auto_20150909_2245'),
... | code_fim | medium | {
"lang": "python",
"repo": "mvantellingen/localshop",
"path": "/src/localshop/apps/packages/migrations/0008_auto_20171116_2112.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('packages', '0007_auto_20150909_2245'),
]
operations = [
migrations.AlterField(
model_name='releasefile',
name='filetype',
field=models.CharField(choices=[('sdist', 'Source'), ('bdist_egg', 'Egg'), ('bdist_msi', 'MSI'), ('b... | code_fim | medium | {
"lang": "python",
"repo": "mvantellingen/localshop",
"path": "/src/localshop/apps/packages/migrations/0008_auto_20171116_2112.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Migration(migrations.Migration):
dependencies = [
('packages', '0007_auto_20150909_2245'),
]
operations = [
migrations.AlterField(
model_name='releasefile',
name='filetype',
field=models.CharField(choices=[('sdist', 'Source'), ('bdis... | code_fim | medium | {
"lang": "python",
"repo": "mvantellingen/localshop",
"path": "/src/localshop/apps/packages/migrations/0008_auto_20171116_2112.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KOLANICH-GHActions/checkout path: /getRepoName.py
#!/usr/bin/env python3
import sys
from pathlib import Path
<|fim_suffix|>if __name__ == "__main__":
raw = sys.argv[1]
gitPrefix = "git@"
if raw.startswith(gitPrefix):
raw = "/".join(raw.split(":", 1))
res = parse_url(raw).path.strip("/").sp... | code_fim | easy | {
"lang": "python",
"repo": "KOLANICH-GHActions/checkout",
"path": "/getRepoName.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
raw = sys.argv[1]
gitPrefix = "git@"
if raw.startswith(gitPrefix):
raw = "/".join(raw.split(":", 1))
res = parse_url(raw).path.strip("/").split("/")[-1]
gitPostfix = ".git"
if res.endswith(gitPostfix):
res = res[: -len(gitPostfix)]
print(res)<|fim_prefix|># repo: KOLA... | code_fim | easy | {
"lang": "python",
"repo": "KOLANICH-GHActions/checkout",
"path": "/getRepoName.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 3ll3d00d/beqdesigner path: /src/main/python/ui/signal.py
self.verticalLayout = QtWidgets.QVBoxLayout(addSignalDialog)
self.verticalLayout.setObjectName("verticalLayout")
self.panesLayout = QtWidgets.QGridLayout()
self.panesLayout.setObjectName("panesLayout")
... | code_fim | hard | {
"lang": "python",
"repo": "3ll3d00d/beqdesigner",
"path": "/src/main/python/ui/signal.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 3ll3d00d/beqdesigner path: /src/main/python/ui/signal.py
esLayout.addLayout(self.filterSelectLayout, 2, 0, 1, 1)
self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setObjectName("gridLayout")
self.signalTypeTabs = QtWidgets.QTabWidget(addSignalDialog)
self.s... | code_fim | hard | {
"lang": "python",
"repo": "3ll3d00d/beqdesigner",
"path": "/src/main/python/ui/signal.py",
"mode": "psm",
"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.