text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: paigeco/VirtualGoniometer path: /src/Operators/RaycastSelect.py
""" [ raycast select module ] """
from bpy.types import Operator
import bpy
from bpy import ops as O
from .DoRaycast import do_raycast
from . import CallbackOptions
class PerformRaycastSelect(Operator):
"""Run a side different... | code_fim | hard | {
"lang": "python",
"repo": "paigeco/VirtualGoniometer",
"path": "/src/Operators/RaycastSelect.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if event.type in {'MIDDLEMOUSE', 'WHEELUPMOUSE', 'WHEELDOWNMOUSE'}:
# allow navigation
return {'PASS_THROUGH'}
elif event.type == 'MOUSEMOVE':
do_raycast(context, event, CallbackOptions.move_cursor, bn=self.break_number)
return {'RUNNING_MODA... | code_fim | hard | {
"lang": "python",
"repo": "paigeco/VirtualGoniometer",
"path": "/src/Operators/RaycastSelect.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def detect_marker(self):
if self.mode == "detect_marker":
self.ArucoTrigger.trigger = 1
self.trigger_aruco.publish(self.ArucoTrigger)
self.mode = "marker_waiting_position"
else:
pass
if self.mode == "marker_waiting_position":
... | code_fim | hard | {
"lang": "python",
"repo": "Jonsuff/AutoDeliverProject_Turtlebot3",
"path": "/controltower_py/src/control_0924.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.goal_status = data.status.status
def StartingCallback(self,data):
if data.trigger == 1:
self.mode = "return_to_base"
elif data.trigger == -1:
self.mode = "exit_program"
else :
pass
def MarkerIdCallback(self, data):
... | code_fim | hard | {
"lang": "python",
"repo": "Jonsuff/AutoDeliverProject_Turtlebot3",
"path": "/controltower_py/src/control_0924.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jonsuff/AutoDeliverProject_Turtlebot3 path: /controltower_py/src/control_0924.py
#!/usr/bin/env python
import rospy
from aruco_pkg.msg import ArucoTriggerMsg
from aruco_pkg.msg import ArucoMsg
from geometry_msgs.msg import PoseStamped
from std_msgs.msg import UInt16
from geometry_msgs.msg import ... | code_fim | hard | {
"lang": "python",
"repo": "Jonsuff/AutoDeliverProject_Turtlebot3",
"path": "/controltower_py/src/control_0924.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('--classifier', type=str, default='resnet18')
parser.add_argument('--data_dir', type=str, default='/data/huy/cifar10/')
parser.add_argument('--labels_dir', type=str, default='labels')
parser.add_argument('--target... | code_fim | hard | {
"lang": "python",
"repo": "File5/meta_neural_networks",
"path": "/mnn_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: File5/meta_neural_networks path: /mnn_test.py
import os, shutil
import torch
from argparse import ArgumentParser
from pytorch_lightning import Trainer
from mnn import CIFAR10_Module
def main(hparams):
<|fim_suffix|>if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argumen... | code_fim | hard | {
"lang": "python",
"repo": "File5/meta_neural_networks",
"path": "/mnn_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if(case == 0):
crop_img = im[0:int(h*percentage), 0:int(w*percentage)]
elif(case == 1):
crop_img = im[h-int(h*percentage):h, w-int(w*percentage):w]
elif(case == 2):
crop_img = im[0:int(h*percentage), w-int(w*percentage):w]
elif(case... | code_fim | medium | {
"lang": "python",
"repo": "MrEliptik/SudokuResolver",
"path": "/src/alterateImages.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MrEliptik/SudokuResolver path: /src/alterateImages.py
import cv2 as cv
from random import randint
def random_crop(im):
<|fim_suffix|> if(case == 0):
crop_img = im[0:int(h*percentage), 0:int(w*percentage)]
elif(case == 1):
crop_img = im[h-int(h*percen... | code_fim | medium | {
"lang": "python",
"repo": "MrEliptik/SudokuResolver",
"path": "/src/alterateImages.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DoubleGremlin181/Talk-To-Reddit path: /SQL_Convertor.py
import sqlite3
import json
from datetime import datetime
timeframe = ['2018-01', '2018-02','2018-03', '2018-04', '2018-05']
sql_transaction = []
connection = sqlite3.connect('Comment_Dataset.db')
c = connection.cursor()
cleanup = 1000000
... | code_fim | hard | {
"lang": "python",
"repo": "DoubleGremlin181/Talk-To-Reddit",
"path": "/SQL_Convertor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if score >= 2:
existing_comment_score = find_existing_score(parent_id)
if existing_comment_score:
if score > existing_comment_score:
if acceptable(body):
sql_insert_r... | code_fim | hard | {
"lang": "python",
"repo": "DoubleGremlin181/Talk-To-Reddit",
"path": "/SQL_Convertor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ``name`` is the column name.
``parent`` is an instance of TableSchema
.. note::
IndexSchema objects are automatically created for you by index_schema_builder
and loaded under ``schema.databases[name].tables[name].indexes``
Example
>>> schema.databases['sakila'].tables[... | code_fim | hard | {
"lang": "python",
"repo": "mmatuson/SchemaObject",
"path": "/schemaobject/index.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mmatuson/SchemaObject path: /schemaobject/index.py
from schemaobject.collections import OrderedDict
def index_schema_builder(table):
"""
Returns a dictionary loaded with all of the indexes available in the table.
``table`` must be an instance of TableSchema.
.. note::
Thi... | code_fim | hard | {
"lang": "python",
"repo": "mmatuson/SchemaObject",
"path": "/schemaobject/index.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def drop(self, alter_table=True):
"""
Generate the SQL to drop this index
>>> schema.databases['sakila'].tables['rental'].indexes['PRIMARY'].drop()
'DROP PRIMARY KEY'
>>> schema.databases['sakila'].tables['rental'].indexes['rental_date'].drop()
... | code_fim | hard | {
"lang": "python",
"repo": "mmatuson/SchemaObject",
"path": "/schemaobject/index.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(is_uniquechar_word('abc'))<|fim_prefix|># repo: skwongg/pyalgorithms path: /uniquechar_word.py
def is_uniquechar_word(word):
<|fim_middle|> charmap = {}
for char in word:
if char in charmap:
return False
else:
charmap[char] = 1
return True
| code_fim | medium | {
"lang": "python",
"repo": "skwongg/pyalgorithms",
"path": "/uniquechar_word.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: skwongg/pyalgorithms path: /uniquechar_word.py
def is_uniquechar_word(word):
<|fim_suffix|>print(is_uniquechar_word('abc'))<|fim_middle|> charmap = {}
for char in word:
if char in charmap:
return False
else:
charmap[char] = 1
return True
| code_fim | medium | {
"lang": "python",
"repo": "skwongg/pyalgorithms",
"path": "/uniquechar_word.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for movie in movies:
order = movie.xpath('.//@data-value').extract_first()
relative_page_url = movie.xpath('.//a/@href').extract_first()
absolute_page_url = 'www.imdb.com' + relative_page_url
title = movie.xpath('.//*[@class="titleColumn"]/a/text()')... | code_fim | hard | {
"lang": "python",
"repo": "david1707/top_rated_movies_imdb",
"path": "/top_rated_movies_imdb/spiders/get_movies.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: david1707/top_rated_movies_imdb path: /top_rated_movies_imdb/spiders/get_movies.py
# -*- coding: utf-8 -*-
import scrapy
class GetMoviesSpider(scrapy.Spider):
name = 'get_movies'
allowed_domains = ['www.imdb.com/chart/top?ref_=nv_mv_250']
start_urls = ['https://www.imdb.com/chart/to... | code_fim | hard | {
"lang": "python",
"repo": "david1707/top_rated_movies_imdb",
"path": "/top_rated_movies_imdb/spiders/get_movies.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: born2code4u/game path: /poll/pages.py
from otree.api import Currency as c, currency_range
from ._builtin import Page, WaitPage
from .models import Constants
from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect, HttpResponse
from django.urls import r... | code_fim | hard | {
"lang": "python",
"repo": "born2code4u/game",
"path": "/poll/pages.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class ResultsWaitPage(WaitPage):
def after_all_players_arrive(self):
pass
class Results(Page):
pass
page_sequence = [
MyPage,
ResultsWaitPage,
Results
]<|fim_prefix|># repo: born2code4u/game path: /poll/pages.py
from otree.api import Currency as c, currency_range
from ._... | code_fim | medium | {
"lang": "python",
"repo": "born2code4u/game",
"path": "/poll/pages.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> It can be executed in different modes, depending on the provided arguments:
* on an SDFG by only providing `sdfg`
* on a state by providing `sdfg` and `state`
* on a subgraph by providing `sdfg`, `state` and `graph`
:param sdfg: The SDFG to infer.
:param st... | code_fim | hard | {
"lang": "python",
"repo": "spcl/dace",
"path": "/dace/transformation/dataflow/sve/infer_types.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> scalar = (e.data.subset and e.data.subset.num_elements() == 1)
if e.data.data is not None:
allocated_as_scalar = (sdfg.arrays[e.data.data].storage is not dtypes.StorageType.GPU_Global)
else:
allocated_as_scalar = True
if inferred[(node, cname, True)... | code_fim | hard | {
"lang": "python",
"repo": "spcl/dace",
"path": "/dace/transformation/dataflow/sve/infer_types.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spcl/dace path: /dace/transformation/dataflow/sve/infer_types.py
# Copyright 2019-2021 ETH Zurich and the DaCe authors. All rights reserved.
"""
SVE Infer Types: This module is responsible for inferring connector types in the SDFG.
"""
from typing import *
from dace.sdfg.graph import MultiCon... | code_fim | hard | {
"lang": "python",
"repo": "spcl/dace",
"path": "/dace/transformation/dataflow/sve/infer_types.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return {
"statusCode": 200,
"body": {}
}<|fim_prefix|># repo: gavinz0228/pifetcher path: /src/aws_sqs_start_process.py
import json
import uuid
import boto3
import time
<|fim_middle|>def start_process(event, context):
sqs = boto3.resource('sqs')
queue = sqs.g... | code_fim | hard | {
"lang": "python",
"repo": "gavinz0228/pifetcher",
"path": "/src/aws_sqs_start_process.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gavinz0228/pifetcher path: /src/aws_sqs_start_process.py
import json
import uuid
import boto3
import time
<|fim_suffix|> return {
"statusCode": 200,
"body": {}
}<|fim_middle|>def start_process(event, context):
sqs = boto3.resource('sqs')
queue = sqs.g... | code_fim | hard | {
"lang": "python",
"repo": "gavinz0228/pifetcher",
"path": "/src/aws_sqs_start_process.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sgraham/nope path: /components/webui_generator/generator/view_model.py
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import datetime
import util
H_FILE_TEMPLATE = \
"""/... | code_fim | hard | {
"lang": "python",
"repo": "sgraham/nope",
"path": "/components/webui_generator/generator/view_model.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> lines = []
for event in events:
lines.append(DISPATCH_EVENT_TEMPLATE % {
'event_id': util.ToLowerCamelCase(event),
'method_name': EventIdToMethodName(event)
});
return '\n'.join(lines)
def GenCCFile(declaration):
subs = GetCommonSubis... | code_fim | hard | {
"lang": "python",
"repo": "sgraham/nope",
"path": "/components/webui_generator/generator/view_model.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>@receiver(user_logged_in, sender=apps.get_model(settings.AUTH_USER_MODEL))
def set_session_expiry(sender, request, user, **kwargs):
pass<|fim_prefix|># repo: vuonghv/brs path: /apps/users/signals.py
from django.dispatch import receiver
from django.db.models.signals import post_delete, post_save
from ... | code_fim | hard | {
"lang": "python",
"repo": "vuonghv/brs",
"path": "/apps/users/signals.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vuonghv/brs path: /apps/users/signals.py
from django.dispatch import receiver
from django.db.models.signals import post_delete, post_save
from django.contrib.auth.signals import user_logged_in
from django.conf import settings
from django.apps import apps
from apps.users.models import UserProfile... | code_fim | medium | {
"lang": "python",
"repo": "vuonghv/brs",
"path": "/apps/users/signals.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> API_ENDPOINT = _safe_load('API_ENDPOINT')<|fim_prefix|># repo: geospatial-jeff/cognition-stac-api path: /stac_api/config.py
import os
def _safe_load(var):
<|fim_middle|> if os.getenv(var):
return os.getenv(var)
else:
raise EnvironmentError(f"The `{var}` environment variable do... | code_fim | medium | {
"lang": "python",
"repo": "geospatial-jeff/cognition-stac-api",
"path": "/stac_api/config.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: geospatial-jeff/cognition-stac-api path: /stac_api/config.py
import os
def _safe_load(var):
<|fim_suffix|> API_ENDPOINT = _safe_load('API_ENDPOINT')<|fim_middle|> if os.getenv(var):
return os.getenv(var)
else:
raise EnvironmentError(f"The `{var}` environment variable do... | code_fim | medium | {
"lang": "python",
"repo": "geospatial-jeff/cognition-stac-api",
"path": "/stac_api/config.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
API_ENDPOINT = _safe_load('API_ENDPOINT')<|fim_prefix|># repo: geospatial-jeff/cognition-stac-api path: /stac_api/config.py
import os
def _safe_load(var):
<|fim_middle|> if os.getenv(var):
return os.getenv(var)
else:
raise EnvironmentError(f"The `{var}` environment variable d... | code_fim | medium | {
"lang": "python",
"repo": "geospatial-jeff/cognition-stac-api",
"path": "/stac_api/config.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PreferredAI/seer path: /local_search_contextualized_opinion.py
import argparse
import numpy as np
import pandas as pd
from tqdm import tqdm
from explanation_generation import (contextualize_candidate_sentences,
get_contextualizer, get_preference)
from sentenc... | code_fim | hard | {
"lang": "python",
"repo": "PreferredAI/seer",
"path": "/local_search_contextualized_opinion.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for aspect, sentence in zip(aspects, sentences):
represented_sentences = aspect_sentences_map.get(aspect)
if len(represented_sentences) > 0:
solution_sentences = solution[aspect].copy()
instance = candidates.loc["{}-{}-{}".format(item, aspect, sentence)]
... | code_fim | hard | {
"lang": "python",
"repo": "PreferredAI/seer",
"path": "/local_search_contextualized_opinion.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.add_query_param('RequestPath', RequestPath)
def get_ResultType(self): # String
return self.get_query_params().get('ResultType')
def set_ResultType(self, ResultType): # String
self.add_query_param('ResultType', ResultType)
def get_MockConfig(self): # String
return self.get_query_pa... | code_fim | hard | {
"lang": "python",
"repo": "aliyun/aliyun-openapi-python-sdk",
"path": "/aliyun-python-sdk-cloudapi/aliyunsdkcloudapi/request/v20160714/ModifyApiConfigurationRequest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aliyun/aliyun-openapi-python-sdk path: /aliyun-python-sdk-cloudapi/aliyunsdkcloudapi/request/v20160714/ModifyApiConfigurationRequest.py
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for addi... | code_fim | hard | {
"lang": "python",
"repo": "aliyun/aliyun-openapi-python-sdk",
"path": "/aliyun-python-sdk-cloudapi/aliyunsdkcloudapi/request/v20160714/ModifyApiConfigurationRequest.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def set_RequestHttpMethod(self, RequestHttpMethod): # String
self.add_query_param('RequestHttpMethod', RequestHttpMethod)
def get_ServiceParametersMap(self): # String
return self.get_query_params().get('ServiceParametersMap')
def set_ServiceParametersMap(self, ServiceParametersMap): # Strin... | code_fim | hard | {
"lang": "python",
"repo": "aliyun/aliyun-openapi-python-sdk",
"path": "/aliyun-python-sdk-cloudapi/aliyunsdkcloudapi/request/v20160714/ModifyApiConfigurationRequest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wayneparrott/ros2cli path: /ros2doctor/test/test_hello.py
# Copyright 2020 Open Source Robotics Foundation, 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
#
# ... | code_fim | medium | {
"lang": "python",
"repo": "wayneparrott/ros2cli",
"path": "/ros2doctor/test/test_hello.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_hello_single_host():
"""Run HelloVerb for one emit period on a single host."""
args = Namespace()
args.topic = '/canyouhearme'
args.emit_period = 0.1
args.print_period = 1.0
args.ttl = None
args.once = True
hello_verb = HelloVerb()
summary = hello_verb.main(arg... | code_fim | hard | {
"lang": "python",
"repo": "wayneparrott/ros2cli",
"path": "/ros2doctor/test/test_hello.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JieYang031/deepcpg path: /scripts/dcpg_filter_act.py
#!/usr/bin/env python
"""Compute filter activations of a DeepCpG model.
Computes the activation of the filters of the first convolutional layer for a
given DNA model. The resulting activations can be used to visualize and cluster
motifs, or c... | code_fim | hard | {
"lang": "python",
"repo": "JieYang031/deepcpg",
"path": "/scripts/dcpg_filter_act.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> g = p.add_argument_group('advanced arguments')
g.add_argument(
'--nb_sample',
help='Number of samples',
type=int)
g.add_argument(
'--shuffle',
help='Randomly sample inputs',
action='store_true')
g.add_a... | code_fim | hard | {
"lang": "python",
"repo": "JieYang031/deepcpg",
"path": "/scripts/dcpg_filter_act.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@app.route("/ping", methods=["GET"])
def ping():
return Response(response="\n", status=200)
@app.route("/invocations", methods=["POST"])
def predict():
if flask.request.content_type == 'text/csv':
data = flask.request.data.decode('utf-8')
s = StringIO(data)
print("input: "... | code_fim | medium | {
"lang": "python",
"repo": "amliuyong/Learn-Amazon-SageMaker-second-edition",
"path": "/Chapter 08/sklearn_custom/generic_estimator/sklearn-boston-housing-serve.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amliuyong/Learn-Amazon-SageMaker-second-edition path: /Chapter 08/sklearn_custom/generic_estimator/sklearn-boston-housing-serve.py
#!/usr/bin/env python
import joblib, os
import pandas as pd
from io import StringIO
import flask
from flask import Flask, Response
<|fim_suffix|>@app.route("/invoc... | code_fim | hard | {
"lang": "python",
"repo": "amliuyong/Learn-Amazon-SageMaker-second-edition",
"path": "/Chapter 08/sklearn_custom/generic_estimator/sklearn-boston-housing-serve.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: quay/appr path: /tests/conftest.py
from __future__ import absolute_import, division, print_function
import subprocess
import os.path
import base64
import json
import pytest
from appr.commands.cli import all_commands, get_parser
from appr.tests.conftest import (api_prefix, app, bad_package_dir, ... | code_fim | hard | {
"lang": "python",
"repo": "quay/appr",
"path": "/tests/conftest.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.fixture()
def subcall_cmd(monkeypatch):
def get_cmd(cmd, stderr="err"):
return " ".join(cmd)
monkeypatch.setattr("subprocess.check_output", get_cmd)
@pytest.fixture()
def subcall_cmd_error(monkeypatch):
def get_cmd(cmd, stderr="err"):
raise subprocess.CalledProcessErr... | code_fim | hard | {
"lang": "python",
"repo": "quay/appr",
"path": "/tests/conftest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>and
* or
* not
'''
print(1 < 2 < 3)
print(1 < 2 > 3)
print(1 < 2 and 2 < 3)
print(('h' == 'h') and (2 == 2))
print(4 == 1 or 2 == 2)
print("output ", not 1 == 1)
a = 12
b = a-10
print("a=", a, "\nb=", b, "\n", a > b)
print(2 < 3 > 10)
print(2 <= 3 >= 1)<|fim_prefix|># repo: swati12995/python-practice pat... | code_fim | medium | {
"lang": "python",
"repo": "swati12995/python-practice",
"path": "/src/basics/compare.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: swati12995/python-practice path: /src/basics/compare.py
print(2 == 2)
print('hello' == 'hello')
print('hello' == 'bye')
print('hello' == 'Hello')
print('2' == 2)
print(2.0 == 2)
prin<|fim_suffix|> == 2)
print("output ", not 1 == 1)
a = 12
b = a-10
print("a=", a, "\nb=", b, "\n", a > b)
print(2 < ... | code_fim | hard | {
"lang": "python",
"repo": "swati12995/python-practice",
"path": "/src/basics/compare.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.Model=GNM(self.calpha,gamma=1,dr=7.3,power=1)
self.assertTrue( self.Model.calculate_kirchhoff() )
self.assertTrue( self.Model.calculate_decomposition() )
self.assertIsNotNone( self.Model.get_eigenvalues() )
self.assertIsNotNone( self.Model.get_eigenvectors() )... | code_fim | medium | {
"lang": "python",
"repo": "Pranavkhade/PACKMAN",
"path": "/packman/tests/gnm/test_gnm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Pranavkhade/PACKMAN path: /packman/tests/gnm/test_gnm.py
from ... import molecule
from ...gnm import GNM
import unittest
import logging
from os import remove as rm
class TestMolecule(unittest.TestCase):
def setUp(self):
self.mol = molecule.load_structure('packman/tests/data/4hla.ci... | code_fim | hard | {
"lang": "python",
"repo": "Pranavkhade/PACKMAN",
"path": "/packman/tests/gnm/test_gnm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Beaver48/kaggle-vinbigdata path: /scripts/generate_submission.py
# %%
from collections import defaultdict
from itertools import groupby
from pathlib import Path
import cv2
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from IPython import get_ipython
from mmcv import Conf... | code_fim | hard | {
"lang": "python",
"repo": "Beaver48/kaggle-vinbigdata",
"path": "/scripts/generate_submission.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># %%
submit = []
for img_id, img_shape, bbox_data in result_supressed_final:
predict_str = ''
for bbox, score, label in zip(*bbox_data):
x_min, y_min, x_max, y_max = np.array(rel2abs(bbox, img_shape)).astype(np.int)
class_id = classname2classid[label]
predict_str += f' {cla... | code_fim | hard | {
"lang": "python",
"repo": "Beaver48/kaggle-vinbigdata",
"path": "/scripts/generate_submission.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #if audio is not detected
except speech_recognition.UnknownValueError:
print("Error: Sorry audio not detected by device microphone")
return None
#if there is connection issue or api issue
except speech_recognition.RequestError:
p... | code_fim | hard | {
"lang": "python",
"repo": "cssoumyade/en_audio2text",
"path": "/src/en_audio2text/aud2text.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cssoumyade/en_audio2text path: /src/en_audio2text/aud2text.py
import speech_recognition
import os
from en_audio2text.text_rules import TextConvRules
class SpeechRecognizer:
"""
Speech Recognition module developed using the speech_recognition package and it uses
google's speech_to_te... | code_fim | hard | {
"lang": "python",
"repo": "cssoumyade/en_audio2text",
"path": "/src/en_audio2text/aud2text.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = deep_rl.algorithm.model_based.DeterministicWorldModel(dynamics_model=dynamics_model, optimizer=optimizer,
cost_fn_batch=env.cost_fn_batch)
planner = deep_rl.algorithm.model_based.planner.BestRandomActionPlanner(model=model,... | code_fim | hard | {
"lang": "python",
"repo": "vermouth1992/torchlib",
"path": "/examples/deep_rl/model_based/plan.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vermouth1992/torchlib path: /examples/deep_rl/model_based/plan.py
"""
Test Vanilla model-based RL
"""
def make_parser():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('env_name', type=str)
parser.add_argument('--nn_size', '-s', type=int, default=64)
... | code_fim | hard | {
"lang": "python",
"repo": "vermouth1992/torchlib",
"path": "/examples/deep_rl/model_based/plan.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JulianConneely/multiParadigm path: /Assignment2/10.py
# Verify the parentheses Given a string, return true if it is a nesting of zero or more
# pairs of parenthesis, like “(())” or “((()))”.
# The only characters in the input will be parentheses, nothing else
# For them to be balanced each ope... | code_fim | hard | {
"lang": "python",
"repo": "JulianConneely/multiParadigm",
"path": "/Assignment2/10.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Driver code
string = "{[]{()}}"
# The zero means that "" is an input which would return true i.e. the empty string
print(string, "-", "True"
# It's false anytime the braces don't balance for example "((", "(()", or "((())))".
if check(string) else "False")<|fim_prefix|># repo: JulianConneel... | code_fim | hard | {
"lang": "python",
"repo": "JulianConneely/multiParadigm",
"path": "/Assignment2/10.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @patch(JSON_SEND_FUNC)
def test_delete_dhcp_bulk(self, mock_send_api_req):
self.drv.delete_dhcp_bulk('t1', ['dhcp1', 'dhcp2'])
calls = [
('region/RegionOne/dhcp', 'DELETE',
[{'id': 'dhcp1'}, {'id': 'dhcp2'}])
]
self._verify_send_api_request_... | code_fim | hard | {
"lang": "python",
"repo": "sapcc/networking-arista",
"path": "/networking_arista/tests/unit/ml2/test_arista_mechanism_driver.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sapcc/networking-arista path: /networking_arista/tests/unit/ml2/test_arista_mechanism_driver.py
cmd2.append('instance id %s type router' % device_id)
cmd2.append('port id %s network-id %s hostid %s' % (
port_id, network_id, host))
... | code_fim | hard | {
"lang": "python",
"repo": "sapcc/networking-arista",
"path": "/networking_arista/tests/unit/ml2/test_arista_mechanism_driver.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sapcc/networking-arista path: /networking_arista/tests/unit/ml2/test_arista_mechanism_driver.py
%
(expected_num_nets, num_nets_provisioned))
# Now test the delete networks
for net_id in nets:
network_context = self._get_network_context(tenant... | code_fim | hard | {
"lang": "python",
"repo": "sapcc/networking-arista",
"path": "/networking_arista/tests/unit/ml2/test_arista_mechanism_driver.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>rules = [
policy.DocumentedRuleDefault(
name='instance:extension:database:create',
check_str='rule:admin_or_owner',
description='Create a set of Schemas',
operations=[
{
'path': PATH_DATABASES,
'method': 'POST'
},
... | code_fim | medium | {
"lang": "python",
"repo": "openstack/trove",
"path": "/trove/common/policies/databases.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstack/trove path: /trove/common/policies/databases.py
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
... | code_fim | medium | {
"lang": "python",
"repo": "openstack/trove",
"path": "/trove/common/policies/databases.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zedrian/shkoma path: /shkoma/peptide_record.py
class PeptideRecord:
def __init__(self, peptide, matches=[]):
self.peptide = peptide
self.peptide_parameters = None
self.matches = matches
def __str__(self):
if len(self.matches) != 0:
return recei... | code_fim | hard | {
"lang": "python",
"repo": "zedrian/shkoma",
"path": "/shkoma/peptide_record.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def received_peptide_record_to_string(record):
# received peptide record interpretation = missed peptide record interpretation + matches
result = missed_peptide_record_to_string(record)
result += ' Matches: {0}\n'.format(len(record.matches))
if len(record.matches) != 0:
index = 1... | code_fim | medium | {
"lang": "python",
"repo": "zedrian/shkoma",
"path": "/shkoma/peptide_record.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>urlpatterns = [
url(r'',
authenticated_home,
name='auth_home'),
]<|fim_prefix|># repo: Peterdaniel24/vmi path: /apps/home/urls.py
from django.conf.urls import url
from django.contrib import admin
from .views import authenticated_home
<|fim_middle|>
__author__ = "Alan Viars"
admin.a... | code_fim | easy | {
"lang": "python",
"repo": "Peterdaniel24/vmi",
"path": "/apps/home/urls.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>admin.autodiscover()
urlpatterns = [
url(r'',
authenticated_home,
name='auth_home'),
]<|fim_prefix|># repo: Peterdaniel24/vmi path: /apps/home/urls.py
from django.conf.urls import url
from django.contrib import admin
from .views import authenticated_home
<|fim_middle|>__author__ =... | code_fim | easy | {
"lang": "python",
"repo": "Peterdaniel24/vmi",
"path": "/apps/home/urls.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Peterdaniel24/vmi path: /apps/home/urls.py
from django.conf.urls import url
from django.contrib import admin
from .views import authenticated_home
<|fim_suffix|>urlpatterns = [
url(r'',
authenticated_home,
name='auth_home'),
]<|fim_middle|>__author__ = "Alan Viars"
admin.a... | code_fim | easy | {
"lang": "python",
"repo": "Peterdaniel24/vmi",
"path": "/apps/home/urls.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(dados[:, 1:3][0] / (2019 - dados[:, 1:3][1]))
print(contador[contador > 5])
print(dados[:, dados[1] > 2000])<|fim_prefix|># repo: alifoliveira/rep-estudos path: /python/Alura/data science/numpy/fatiamento.py
import numpy as np
import pandas as pa
contador = np.arange(10)
<|fim_middle|>km2 = np.... | code_fim | hard | {
"lang": "python",
"repo": "alifoliveira/rep-estudos",
"path": "/python/Alura/data science/numpy/fatiamento.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alifoliveira/rep-estudos path: /python/Alura/data science/numpy/fatiamento.py
import numpy as np
import pandas as pa
contador = np.arange(10)
km2 = np.array([44410., 5712., 37123., 0., 25757.])
anos2 = np.array([2003, 1991, 1990, 2019, 2006])
dados = np.array([km2, anos2])
<|fim_suffix|># prin... | code_fim | easy | {
"lang": "python",
"repo": "alifoliveira/rep-estudos",
"path": "/python/Alura/data science/numpy/fatiamento.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># print(contador[::2]) # indice pares
print(dados[:, 1:3][0] / (2019 - dados[:, 1:3][1]))
print(contador[contador > 5])
print(dados[:, dados[1] > 2000])<|fim_prefix|># repo: alifoliveira/rep-estudos path: /python/Alura/data science/numpy/fatiamento.py
import numpy as np
import pandas as pa
contador =... | code_fim | easy | {
"lang": "python",
"repo": "alifoliveira/rep-estudos",
"path": "/python/Alura/data science/numpy/fatiamento.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def clear(self):
with tf.device(self._device):
self._current_size.assign(tf.zeros_like(self._current_size))
self._current_pos.assign(tf.zeros_like(self._current_pos))
def gather_all(self):
"""Returns all the items in buffer.
Returns:
Re... | code_fim | hard | {
"lang": "python",
"repo": "Haichao-Zhang/alf",
"path": "/alf/experience_replayers/replay_buffer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Haichao-Zhang/alf path: /alf/experience_replayers/replay_buffer.py
# Copyright (c) 2019 Horizon Robotics. 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 Lice... | code_fim | hard | {
"lang": "python",
"repo": "Haichao-Zhang/alf",
"path": "/alf/experience_replayers/replay_buffer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''Type of a school's MUN program.'''
CLUB = 1
CLASS = 2
class PaymentTypes(Constants):
'''Type of a payment method'''
CARD = 1
CHECK = 2<|fim_prefix|># repo: bmun/huxley path: /huxley/core/constants.py
# Copyright (c) 2011-2022 Berkeley Model United Nations. All rights reserved... | code_fim | hard | {
"lang": "python",
"repo": "bmun/huxley",
"path": "/huxley/core/constants.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''Whether a school's primary/secondary contact is a student or faculty.'''
STUDENT = 1
FACULTY = 2
class ProgramTypes(Constants):
'''Type of a school's MUN program.'''
CLUB = 1
CLASS = 2
class PaymentTypes(Constants):
'''Type of a payment method'''
CARD = 1
CHECK =... | code_fim | hard | {
"lang": "python",
"repo": "bmun/huxley",
"path": "/huxley/core/constants.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bmun/huxley path: /huxley/core/constants.py
# Copyright (c) 2011-2022 Berkeley Model United Nations. All rights reserved.
# Use of this source code is governed by a BSD License (see LICENSE).
import json
<|fim_suffix|> @classmethod
def to_json(cls):
return json.dumps(cls.to_dict... | code_fim | hard | {
"lang": "python",
"repo": "bmun/huxley",
"path": "/huxley/core/constants.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> mult = utils.get_mult_rigidity(3.0e9)
assert isinstance(mult, types.FunctionType)
numpy.testing.assert_almost_equal(mult(numpy.pi), 31437675.329275224)
numpy.testing.assert_almost_equal(mult(1.0e-8), 0.10006922855944561)<|fim_prefix|># repo: T-Nicholls/pytac path: /test/test_utils.py
impo... | code_fim | hard | {
"lang": "python",
"repo": "T-Nicholls/pytac",
"path": "/test/test_utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: T-Nicholls/pytac path: /test/test_utils.py
import types
import numpy
from pytac import utils
def test_rigidity():
numpy.testing.assert_almost_equal(utils.get_rigidity(3.0e9), 10006922.85594456)
def test_get_div_rigidity():
<|fim_suffix|> mult = utils.get_mult_rigidity(3.0e9)
asse... | code_fim | hard | {
"lang": "python",
"repo": "T-Nicholls/pytac",
"path": "/test/test_utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mljar/mljar-supervised path: /supervised/utils/metric.py
import logging
log = logging.getLogger(__name__)
import numpy as np
import pandas as pd
import scipy as sp
from sklearn.metrics import log_loss
from sklearn.metrics import roc_auc_score
from sklearn.metrics import mean_squared_error
from ... | code_fim | hard | {
"lang": "python",
"repo": "mljar/mljar-supervised",
"path": "/supervised/utils/metric.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return "f1", -negative_f1(target, preds, weight), True
def lightgbm_eval_metric_average_precision(preds, dtrain):
target = dtrain.get_label()
weight = dtrain.get_weight()
return "average_precision", -negative_average_precision(target, preds, weight), True
def lightgbm_eval_metric_accu... | code_fim | hard | {
"lang": "python",
"repo": "mljar/mljar-supervised",
"path": "/supervised/utils/metric.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def evaluate(self, approxes, target, weight):
assert len(approxes) == 1
assert len(target) == len(approxes[0])
preds = np.array(approxes[0])
target = np.array(target)
if weight is not None:
weight = np.array(weight)
metric = UserDefinedEval... | code_fim | hard | {
"lang": "python",
"repo": "mljar/mljar-supervised",
"path": "/supervised/utils/metric.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Set up the Python variables
M = 1
R = 0.1
I = M*R**2/2
m = 0.1
w0 = 10
The yoyos P and Q will remain anti-symmetric if released at the same time, so
$\mathbf{r}_{P/G} = -\mathbf{r}_{Q/G},~|\mathbf{r}_{P/G}| =
|\mathbf{r}_{Q/G}|$
and
$\mathbf{v}_{P/G} = -\mathbf{v}_{Q/G},~v_P = v_Q.$
The equations... | code_fim | hard | {
"lang": "python",
"repo": "EMM18012/engineering-dynamics",
"path": "/_build/jupyter_execute/module_04/yoyo-despin_02.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>The angular momentum is constant because $\sum \mathbf{M}_G = 0 =
\frac{d}{dt}\mathbf{h}_G$. The total angular momentum is as such
$\mathbf{h}_G = I_G \omega_B \hat{k} + m_P \mathbf{r}_{P/G} \times
\mathbf{r}_{P/G}+
m_Q \mathbf{r}_{Q/G} \times \mathbf{r}_{Q/G}$
where $m_P = m_Q = m$
$\mathbf{h}_G = I_... | code_fim | hard | {
"lang": "python",
"repo": "EMM18012/engineering-dynamics",
"path": "/_build/jupyter_execute/module_04/yoyo-despin_02.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EMM18012/engineering-dynamics path: /_build/jupyter_execute/module_04/yoyo-despin_02.py
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
plt.style.use('fivethirtyeight')
# Yoyo despin revisited (cord constraint)
from IPython.core.display import SVG
SVG(fi... | code_fim | hard | {
"lang": "python",
"repo": "EMM18012/engineering-dynamics",
"path": "/_build/jupyter_execute/module_04/yoyo-despin_02.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Hell13Cat/termux-BeautifulLaunch path: /termux-br.py
import os
import shutil
import platform
def dels(text):
for num in range(len(text)):
char = text[num]
if char == " ":
pass
else:
break
readytext = text[num:(len(text))]
return readytext
try:
import configparser
except ImportE... | code_fim | hard | {
"lang": "python",
"repo": "Hell13Cat/termux-BeautifulLaunch",
"path": "/termux-br.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>width = shutil.get_terminal_size().columns
position = (width - max(map(len, stats))) // 2
for line in stats: # left justtified
if ("+" in line) or ("|" in line) or ("/" in line):
print(line.center(width))
else:
print(' '*position + line)<|fim_prefix|># repo: Hell13Cat/termux-BeautifulLaunch path: ... | code_fim | hard | {
"lang": "python",
"repo": "Hell13Cat/termux-BeautifulLaunch",
"path": "/termux-br.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jeongkiwon/nomadgram path: /nomadgram/images/serializers.py
from rest_framework import serializers
from . import models
from taggit_serializer.serializers import (TagListSerializerField, TaggitSerializer)
from nomadgram.users import models as user_models
class SmallImagesSerializer(serializers.M... | code_fim | hard | {
"lang": "python",
"repo": "Jeongkiwon/nomadgram",
"path": "/nomadgram/images/serializers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
comments=CommentSerializer(many=True)
creator=FeedUserSerializer()
tags=TagListSerializerField()
class Meta:
model=models.Image
fields= (
'id',
'file',
'location',
'caption',
'comments',
'like_count',... | code_fim | hard | {
"lang": "python",
"repo": "Jeongkiwon/nomadgram",
"path": "/nomadgram/images/serializers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WhiteBlackGoose/HI19 path: /hypo2/dataset.py
from hypo2.base.basef import BaseHIObj
import numpy as np
from hypo2.base.cache import Cache
from IPython.display import clear_output
from hypo2.preprocessor import Preprocessor
from hypo2.addit.functions import Functional as F
<|fim_suffix|> ... | code_fim | hard | {
"lang": "python",
"repo": "WhiteBlackGoose/HI19",
"path": "/hypo2/dataset.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert len(paths) == self.cfg.CLASS_COUNT, "Paths count must be equal to CLASS_COUNT (check cfg param)"
words = [[] for i in range(len(paths))]
cache = Cache(self.cfg)
try:
for class_id in range(self.cfg.CLASS_COUNT):
fff = 0
... | code_fim | hard | {
"lang": "python",
"repo": "WhiteBlackGoose/HI19",
"path": "/hypo2/dataset.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_add_remove_hook(hooks):
def func_a():
print("Does something")
def func_b():
print("Doesn't do anything")
def func_c(arg_a, arg_b):
print(arg_a, arg_b)
pf = partial(func_c, "a", "b")
hooks.create_hook("hook_a", [])
hooks.create_hook("hook_b")
... | code_fim | hard | {
"lang": "python",
"repo": "akshaybadola/simple_trainer",
"path": "/tests/test_pipeline.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pf = partial(func_c, "a", "b")
hooks.create_hook("hook_a", [])
hooks.create_hook("hook_b")
hooks.add_hook("hook_a", func_a)
hooks.add_hook("hook_a", func_b)
assert hooks.describe_hook("hook_a") == ["func_b", "func_a"]
hooks.add_hook("hook_b", func_a)
hooks.add_hook_after("h... | code_fim | medium | {
"lang": "python",
"repo": "akshaybadola/simple_trainer",
"path": "/tests/test_pipeline.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: akshaybadola/simple_trainer path: /tests/test_pipeline.py
import pytest
from functools import partial
def test_create_hook(hooks):
hooks.create_hook("hook_a", [])
hooks.create_hook("hook_b")
assert "hook_a" in hooks
assert "hook_b" in hooks
with pytest.raises(AttributeError)... | code_fim | hard | {
"lang": "python",
"repo": "akshaybadola/simple_trainer",
"path": "/tests/test_pipeline.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _parser_options():
"""Parses the options and arguments from the command line."""
#We have two options: get some of the details from the config file,
import argparse
from pydft import base
pdescr = "Numerical DFT code."
parser = argparse.ArgumentParser(parents=[base.bparser], de... | code_fim | hard | {
"lang": "python",
"repo": "wsmorgan/py_dft",
"path": "/pydft/dft.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> msg.example(script, explain, contents, required, output, outputfmt, details)
script_options = {
"a": dict(default=1., type=float,
help=("The lattice parameter for the crystal structure.")),
"-crystal": dict(default="sc", type=str,
help=("The type of primitiv... | code_fim | hard | {
"lang": "python",
"repo": "wsmorgan/py_dft",
"path": "/pydft/dft.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wsmorgan/py_dft path: /pydft/dft.py
#!/usr/bin/python
from pydft import msg
import numpy as np
import csv
def RepresentInt(s):
"""Determines if a string can be represented as an integer. code take
from
http://stackoverflow.com/questions/1265665/python-check-if-a-string-represents-an... | code_fim | hard | {
"lang": "python",
"repo": "wsmorgan/py_dft",
"path": "/pydft/dft.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: benathi/nntools path: /examples/lstm_short.py
import os
#os.environ["CUDA_LAUNCH_BLOCKING"] = "1" # for profiling to sync gpu calls disable for full run
import os.path
#import scipy.io
import lasagne # nn packages for layers nn layers + lstm
import theano
import scipy.io
theano.config.allow... | code_fim | hard | {
"lang": "python",
"repo": "benathi/nntools",
"path": "/examples/lstm_short.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># These lists specify that sym_input should take the value of sh_input and etc.
# Note the cast: T.cast(sh_target, 'int32'). This is nessesary because Theano
# does only support shared varibles with type float32. We cast the shared
# value to an integer before it is used in the graph.
givens = [(sym_input... | code_fim | hard | {
"lang": "python",
"repo": "benathi/nntools",
"path": "/examples/lstm_short.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># create cost entropy costfunctions.
# We use the get_output method to get the output from the network.
# When you use dropout layers you shuld set deterministic to false during
# training and to true during testing. In theano this requires two different
# graphs.
# When we use backwards LSTM's a symbolic... | code_fim | hard | {
"lang": "python",
"repo": "benathi/nntools",
"path": "/examples/lstm_short.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: googlefonts/noto-emoji path: /add_glyphs.py
#!/usr/bin/env python3
"""Extend a ttx file with additional data.
Takes a ttx file and one or more directories containing image files named
after sequences of codepoints, extends the cmap, hmtx, GSUB, and GlyphOrder
tables in the source ttx file based... | code_fim | hard | {
"lang": "python",
"repo": "googlefonts/noto-emoji",
"path": "/add_glyphs.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Format 4 only has unicode values 0x0000 to 0xFFFF
newtable.cmap = {cp: name for cp, name in cmap.items() if cp <= 0xFFFF}
font['cmap'].tables.append(newtable)
def update_font_data(font, seq_to_advance, vadvance, aliases, add_cmap4, add_glyf):
"""Update the font's cmap, hmtx, GSUB, and GlyphOrd... | code_fim | hard | {
"lang": "python",
"repo": "googlefonts/noto-emoji",
"path": "/add_glyphs.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.