text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>+ str(b) + "\n")
else:
x = x - 1
print("%s %s" % (str(a),str(b)))
file.close()<|fim_prefix|># repo: enatheme/convex-hull path: /generate.py
# -*- coding: utf-8 -*-
import random, os, time
file = open("generate.out", "w")
for x in range(100):
a = random.randint(1, 100) % 100
b = random.randint(1, ... | code_fim | medium | {
"lang": "python",
"repo": "enatheme/convex-hull",
"path": "/generate.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> % 100
if ((a < 100) & (a > 0) & (b < 100) & (b > 0)):
file.write(str(a) + " " + str(b) + "\n")
else:
x = x - 1
print("%s %s" % (str(a),str(b)))
file.close()<|fim_prefix|># repo: enatheme/convex-hull path: /generate.py
# -*- coding: utf-8 -*-
import random, os, time
file = open("generate.out", "... | code_fim | medium | {
"lang": "python",
"repo": "enatheme/convex-hull",
"path": "/generate.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: enatheme/convex-hull path: /generate.py
# -*- coding: utf-8 -*-
import random, os, time
file = open("generate.out", "w")
<|fim_suffix|> % 100
if ((a < 100) & (a > 0) & (b < 100) & (b > 0)):
file.write(str(a) + " " + str(b) + "\n")
else:
x = x - 1
print("%s %s" % (str(a),str(b)))
file.clo... | code_fim | medium | {
"lang": "python",
"repo": "enatheme/convex-hull",
"path": "/generate.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def prepare_meta():
del this.args['account_url']
del this.args['erl']
del this.args['az_sec']
this.args = dict(this.args)
def emit(emit_data):
"""
used to emit data to the next node(s)
:param emit_data: dict | DecodeDict | list of dicts | list of DecodeDict
"""
if ty... | code_fim | hard | {
"lang": "python",
"repo": "heyoka/faxe",
"path": "/apps/faxe/priv/python/azblobstreampd.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: heyoka/faxe path: /apps/faxe/priv/python/azblobstreampd.py
from azure.storage.blob import BlobServiceClient
from azure.storage.blob import ContainerClient
import erlport
import erlport.erlang
import erlport.erlterms
import faxe
from decode_dict import DecodeDict
import json
import sys
from io imp... | code_fim | hard | {
"lang": "python",
"repo": "heyoka/faxe",
"path": "/apps/faxe/priv/python/azblobstreampd.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cuidi34/code2seq path: /code2seq/utils/vocabulary.py
import pickle
from dataclasses import dataclass
from os.path import exists
from typing import Dict, Optional
# vocabulary keys
TOKEN_TO_ID = "token_to_id"
NODE_TO_ID = "node_to_id"
LABEL_TO_ID = "label_to_id"
TYPE_TO_ID = "type_to_id"
<|fim_... | code_fim | medium | {
"lang": "python",
"repo": "cuidi34/code2seq",
"path": "/code2seq/utils/vocabulary.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def load_vocabulary(vocabulary_path: str) -> "Vocabulary":
if not exists(vocabulary_path):
raise ValueError(f"Can't find vocabulary in: {vocabulary_path}")
with open(vocabulary_path, "rb") as vocabulary_file:
vocabulary_dicts = pickle.load(voca... | code_fim | medium | {
"lang": "python",
"repo": "cuidi34/code2seq",
"path": "/code2seq/utils/vocabulary.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def set_bot_comment_id(self, record_id: int, bot_comment_id: int) -> None:
async def coro_fn() -> None:
async with self._engine.connect() as conn:
await conn.execute(update(record_table).where(record_table.c.id == record_id), {'bot_comment_id': bot_comment_id}... | code_fim | hard | {
"lang": "python",
"repo": "Pyprohly/powershell-bot",
"path": "/powershell_bot/dal/service.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Pyprohly/powershell-bot path: /powershell_bot/dal/service.py
from __future__ import annotations
from typing import TYPE_CHECKING, Optional, AsyncIterable
if TYPE_CHECKING:
import sqlalchemy.ext.asyncio
from ..models.record import Record
import asyncio
from sqlalchemy import select, ins... | code_fim | hard | {
"lang": "python",
"repo": "Pyprohly/powershell-bot",
"path": "/powershell_bot/dal/service.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maximmasiutin/pyre-check path: /client/commands/v2/server_event.py
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import dataclasses
import json
from pathlib import P... | code_fim | hard | {
"lang": "python",
"repo": "maximmasiutin/pyre-check",
"path": "/client/commands/v2/server_event.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.wait_on_initialization = wait_on_initialization
def wait_on(self, event_stream: IO[str]) -> None:
"""
Read from the given input channel, expecting server events there.
If `self.wait_on_initialization` is false, block until server socket
creation and return... | code_fim | hard | {
"lang": "python",
"repo": "maximmasiutin/pyre-check",
"path": "/client/commands/v2/server_event.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> code = list(
chain(
(choice(uppercase) for _ in range(upper)),
(choice(lowercase) for _ in range(lower)),
(choice(string.digits) for _ in range(digits)),
(choice(letters) for _ in range((length - digits - upper - lower)))
... | code_fim | hard | {
"lang": "python",
"repo": "rdboyett/urlshortener",
"path": "/urlshortener_project/urlshortener/serializers.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> lowercase = string.lowercase.translate(None, "o")
uppercase = string.uppercase.translate(None, "O")
letters = "{0:s}{1:s}".format(lowercase, uppercase)
code = list(
chain(
(choice(uppercase) for _ in range(upper)),
(choice(lowerc... | code_fim | hard | {
"lang": "python",
"repo": "rdboyett/urlshortener",
"path": "/urlshortener_project/urlshortener/serializers.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rdboyett/urlshortener path: /urlshortener_project/urlshortener/serializers.py
import string
from time import time
from itertools import chain
from random import seed, choice, sample
from rest_framework import serializers
from rest_framework.validators import UniqueValidator
from .models import ... | code_fim | hard | {
"lang": "python",
"repo": "rdboyett/urlshortener",
"path": "/urlshortener_project/urlshortener/serializers.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CheungXu/MagicMirror path: /DataCooker.py
import numpy as np
import cv2,random
import os
class DataCooker(object):
def __init__(self, image_size=256, batch_size = 1):
#Image&Label Path
self.image_path = os.path.join('.','data','images')
self.label_path = os.path.join... | code_fim | hard | {
"lang": "python",
"repo": "CheungXu/MagicMirror",
"path": "/DataCooker.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def show_label_dict(self, key='all'):
#Show Label Dictronary
if key == 'all':
return self.label_dict
else:
for k in self.label_dict.keys():
if key in k:
return self.label_dict[k]
return False
def s... | code_fim | hard | {
"lang": "python",
"repo": "CheungXu/MagicMirror",
"path": "/DataCooker.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: todorvelichkov/django-tabulate path: /tests/models.py
from django.db import models
from django_tabulate import TabulateQuerySet
<|fim_suffix|> objects = BookTabulateQuerySet.as_manager()<|fim_middle|>class BookTabulateQuerySet(TabulateQuerySet):
pass
class Book(models.Model):
name = models.Ch... | code_fim | medium | {
"lang": "python",
"repo": "todorvelichkov/django-tabulate",
"path": "/tests/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> name = models.CharField(max_length=255)
objects = BookTabulateQuerySet.as_manager()<|fim_prefix|># repo: todorvelichkov/django-tabulate path: /tests/models.py
from django.db import models
from django_tabulate import TabulateQuerySet
class BookTabulateQuerySet(TabulateQuerySet):
pass
<|fim_middle|>... | code_fim | easy | {
"lang": "python",
"repo": "todorvelichkov/django-tabulate",
"path": "/tests/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alxalx14/StayOnline path: /StayOnline/src/checkStatus.py
import threading
from time import sleep
from requests import get, exceptions
from src.fallback import cloudflare
from os import system, name
import socket
import json
import random
import sys
class checker():
def __init__(se... | code_fim | hard | {
"lang": "python",
"repo": "alxalx14/StayOnline",
"path": "/StayOnline/src/checkStatus.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return{
"1": self.levelOne,
"2": self.levelTwo,
"3": self.levelThree,
"4": self.levelFour,
}.get(level, lambda: None)(domain)
def domainHandler(self, domain, level):
sc = 200
while True:
try:
... | code_fim | hard | {
"lang": "python",
"repo": "alxalx14/StayOnline",
"path": "/StayOnline/src/checkStatus.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mcgreevy/chromium-build path: /scripts/slave/reboot_tools.py
# Copyright 2014 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.
""" Reboot the slave machine, unless it is run in a development
envirenme... | code_fim | hard | {
"lang": "python",
"repo": "mcgreevy/chromium-build",
"path": "/scripts/slave/reboot_tools.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def Reboot():
"""Reboot the buildbot slave machine.
This behavior is controlled by the reboot_on_step_timeout flag in
the active master configuration.
"""
# This envrionment is defined only when testing the slave on a dev machine.
is_testing = 'TESTING_MASTER' in os.environ
should_reboot =... | code_fim | hard | {
"lang": "python",
"repo": "mcgreevy/chromium-build",
"path": "/scripts/slave/reboot_tools.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def Reboot():
"""Reboot the buildbot slave machine.
This behavior is controlled by the reboot_on_step_timeout flag in
the active master configuration.
"""
# This envrionment is defined only when testing the slave on a dev machine.
is_testing = 'TESTING_MASTER' in os.environ
should_reboot ... | code_fim | hard | {
"lang": "python",
"repo": "mcgreevy/chromium-build",
"path": "/scripts/slave/reboot_tools.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LLNL/csld path: /csld/operations.py
stead to
generate a SymmOp from proper rotations and translation.
Args:
affine_transformation_matrix (4x4 array): Representing an
affine transformation.
tol (float): Tolerance for determining if matrices ... | code_fim | hard | {
"lang": "python",
"repo": "LLNL/csld",
"path": "/csld/operations.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def inversion(origin=(0, 0, 0)):
"""
Inversion symmetry operation about axis.
Args:
origin (3x1 array): Origin of the inversion operation. Defaults
to [0, 0, 0].
Returns:
SymmOp representing an inversion operat... | code_fim | hard | {
"lang": "python",
"repo": "LLNL/csld",
"path": "/csld/operations.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LLNL/csld path: /csld/operations.py
port numpy as np
from math import sin, cos, pi, sqrt
class SymmOp():
"""
A symmetry operation in cartesian OR fractional space. Consists of a rotation plus a
translation. Implementation is as an affine transformation matrix of rank 4
for effic... | code_fim | hard | {
"lang": "python",
"repo": "LLNL/csld",
"path": "/csld/operations.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def __init__(self, transport=None):
self.transport = engine.get_transport(transport)
self.engine = engine.EngineClient(self.transport)
def before(self, state):
state.request.context['engine'] = self.engine<|fim_prefix|># repo: lcostantino/mistral path: /mistral/api/hooks... | code_fim | medium | {
"lang": "python",
"repo": "lcostantino/mistral",
"path": "/mistral/api/hooks/engine.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class EngineHook(hooks.PecanHook):
def __init__(self, transport=None):
self.transport = engine.get_transport(transport)
self.engine = engine.EngineClient(self.transport)
def before(self, state):
state.request.context['engine'] = self.engine<|fim_prefix|># repo: lcostanti... | code_fim | medium | {
"lang": "python",
"repo": "lcostantino/mistral",
"path": "/mistral/api/hooks/engine.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lcostantino/mistral path: /mistral/api/hooks/engine.py
# -*- coding: utf-8 -*-
#
# 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... | code_fim | medium | {
"lang": "python",
"repo": "lcostantino/mistral",
"path": "/mistral/api/hooks/engine.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nyoungstudios/alphacam path: /yolo_backend/main.py
from util import *
import os
def main():
<|fim_suffix|>
if __name__ == "__main__":
main()<|fim_middle|> fb = FB()
while True:
clean()
fb.getAllLabImage()
predictAll(fb)
# fb.analyseResult()
| code_fim | medium | {
"lang": "python",
"repo": "nyoungstudios/alphacam",
"path": "/yolo_backend/main.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
main()<|fim_prefix|># repo: nyoungstudios/alphacam path: /yolo_backend/main.py
from util import *
import os
def main():
<|fim_middle|> fb = FB()
while True:
clean()
fb.getAllLabImage()
predictAll(fb)
# fb.analyseResult()
| code_fim | medium | {
"lang": "python",
"repo": "nyoungstudios/alphacam",
"path": "/yolo_backend/main.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #frame=cv2.imdecode(imgNp,-1)
FaceFileName = "test1.jpg" #Saving the current image from the webcam for testing.
cv2.imwrite(FaceFileName, frame)
try:
body=open(FaceFileName, "rb").read()
conn = http.client.HTTPSConnection('centralindia.api.cognitive.microsoft.... | code_fim | hard | {
"lang": "python",
"repo": "priyanshugandhi/Med-Help",
"path": "/api.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: priyanshugandhi/Med-Help path: /api.py
import http.client, urllib.request, urllib.parse, urllib.error, base64
import json
from PIL import Image
import requests
from io import BytesIO
import subprocess
from gtts import gTTS
from pydub import AudioSegment
import numpy as np
import time
import cv2
... | code_fim | hard | {
"lang": "python",
"repo": "priyanshugandhi/Med-Help",
"path": "/api.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def texttospeech(file_stream):
process_this_frame = True
file_format=file_stream.split(".")
file_names=os.listdir("uploads")
for file in file_names:
if file==file_stream:
destination = "/".join(["uploads", file])
video_capture = cv2.VideoCapture(destination)
while True:
# Grab a s... | code_fim | hard | {
"lang": "python",
"repo": "priyanshugandhi/Med-Help",
"path": "/api.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def criterion_kd(helper, outputs, targets, teacher_outputs):
"""
Compute the knowledge-distillation (KD) loss given outputs, labels.
"Hyperparameters": temperature and alpha
NOTE: the KL Divergence for PyTorch comparing the softmaxs of teacher
and student expects the input tensor to be... | code_fim | hard | {
"lang": "python",
"repo": "guobbin/federated_adaptation",
"path": "/utils/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: guobbin/federated_adaptation path: /utils/utils.py
import numpy as np
import random
import torch
import torch.nn.functional as F
from torch.autograd import Variable
from torch.utils.data.sampler import Sampler
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt
import re
... | code_fim | hard | {
"lang": "python",
"repo": "guobbin/federated_adaptation",
"path": "/utils/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NuM314/tf-keras-vis path: /tf_keras_vis/utils/losses.py
from abc import ABC, abstractmethod
import numpy as np
import tensorflow.keras.backend as K
from tf_keras_vis.utils import listify
<|fim_suffix|> raise NotImplementedError()
class SmoothedLoss(Loss):
def __init__(self, indice... | code_fim | medium | {
"lang": "python",
"repo": "NuM314/tf-keras-vis",
"path": "/tf_keras_vis/utils/losses.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, name):
self.name = name
@abstractmethod
def __call__(self, output):
raise NotImplementedError()
class SmoothedLoss(Loss):
def __init__(self, indices, epsilon=0.05):
super().__init__('SmoothedLoss')
self.indices = listify(indices)
... | code_fim | medium | {
"lang": "python",
"repo": "NuM314/tf-keras-vis",
"path": "/tf_keras_vis/utils/losses.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = self.prepare_network_chanal_last_reduced_size()
print(model.summary())
history = LossHistory()
for iter in range(2):
for fileCount in range(51):
'''
print('File: ' + ".\\npyXYFiles_size64\\X_data_" + str(fileCount)+ '.npy'... | code_fim | hard | {
"lang": "python",
"repo": "zeizeil/patternRecognitionCNNModel",
"path": "/trainShape.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zeizeil/patternRecognitionCNNModel path: /trainShape.py
):
return self.lossObj
#def get_dice_coeff(self):
# return self.dice_coef
def dice_coef_mod(y_true, y_pred, smooth=1):
y_true_f = K.flatten(y_true)
y_pred_f = K.flatten(y_pred)
y_pred_f = K.clip(y_pred_f... | code_fim | hard | {
"lang": "python",
"repo": "zeizeil/patternRecognitionCNNModel",
"path": "/trainShape.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zeizeil/patternRecognitionCNNModel path: /trainShape.py
3)(conv0)
conv0 = Activation('relu')(conv0)
pool0 = MaxPooling2D((2, 2), strides=(1, 1), padding='same', data_format='channels_last')(conv0)
conv01 = Conv2D(8, (2, 2), strides=(1, 1), padding='same', ... | code_fim | hard | {
"lang": "python",
"repo": "zeizeil/patternRecognitionCNNModel",
"path": "/trainShape.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._account = account
self._key = key
self._table = table
self.__client = client
self._client_factory = client_factory
for client in loads(getenv('LOKOLE_DEFAULT_CLIENTS', '[]')):
self.insert(client['id'], client['domain'])
@property
... | code_fim | hard | {
"lang": "python",
"repo": "NjengaSaruni/opwen-cloudserver",
"path": "/opwen_email_server/services/auth.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class AzureAuth(Auth, LogMixin):
def __init__(self, account: str, key: str, table: str,
client: TableService=None,
client_factory: Callable[..., TableService]=TableService
) -> None:
self._account = account
self._key = key
se... | code_fim | medium | {
"lang": "python",
"repo": "NjengaSaruni/opwen-cloudserver",
"path": "/opwen_email_server/services/auth.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NjengaSaruni/opwen-cloudserver path: /opwen_email_server/services/auth.py
from abc import ABCMeta
from abc import abstractmethod
from functools import lru_cache
from json import loads
from os import getenv
from typing import Callable
from typing import Optional
from azure.cosmosdb.table.tableser... | code_fim | hard | {
"lang": "python",
"repo": "NjengaSaruni/opwen-cloudserver",
"path": "/opwen_email_server/services/auth.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SchlossLab/Jenior_Metatranscriptomics_mSphere_2018 path: /code/python/slice_fasta.py
#!/bin/python
# slice_fasta.py raw.fasta 1000000000
import sys
output_fasta = str(sys.argv[1]).rstrip('fasta') + 'pick.fasta'
output_fasta = open(output_fasta, 'w')
max_seqs = int(sys.argv[2])
current_seqs = 0
... | code_fim | medium | {
"lang": "python",
"repo": "SchlossLab/Jenior_Metatranscriptomics_mSphere_2018",
"path": "/code/python/slice_fasta.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for line in input_fasta:
if line == '\n':
continue
elif line[0] == '>' and current_seqs < max_seqs:
output_fasta.write(line)
current_seqs += 1
continue
elif line[0] != '>' and current_seqs <= max_seqs:
output_fasta.write(line)
continue
else:
break
output_fasta.close()<|... | code_fim | medium | {
"lang": "python",
"repo": "SchlossLab/Jenior_Metatranscriptomics_mSphere_2018",
"path": "/code/python/slice_fasta.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif line[0] != '>' and current_seqs <= max_seqs:
output_fasta.write(line)
continue
else:
break
output_fasta.close()<|fim_prefix|># repo: SchlossLab/Jenior_Metatranscriptomics_mSphere_2018 path: /code/python/slice_fasta.py
#!/bin/python
# slice_fasta.py raw.fasta 1000000000
import sys
o... | code_fim | medium | {
"lang": "python",
"repo": "SchlossLab/Jenior_Metatranscriptomics_mSphere_2018",
"path": "/code/python/slice_fasta.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sorted_cols = sorted(d.keys(), key=lambda x: x.lower())
d_sorted = {}
for k in sorted_cols:
d_sorted[k] = d[k]
return d_sorted
def read_csv(file):
if not Path(file).exists():
raise FileNotFoundError('No such .csv file: ' + str(file))
else:
df = pd.read_cs... | code_fim | medium | {
"lang": "python",
"repo": "Xy1aR/Raspberry_Pi_monitoring_system",
"path": "/monitoring_system/utils/csv.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Xy1aR/Raspberry_Pi_monitoring_system path: /monitoring_system/utils/csv.py
import pandas as pd
from pathlib import Path
def write_csv(df, file, sort=True):
if 'DataFrame' not in str(type(df)):
try:
if sort:
df = _sort_dict(df)
df = _dict2df(df... | code_fim | medium | {
"lang": "python",
"repo": "Xy1aR/Raspberry_Pi_monitoring_system",
"path": "/monitoring_system/utils/csv.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#=============================
def runSpider(lines):
spifile = "currentSpiderScript.spi"
if os.path.isfile(spifile):
os.remove(spifile)
spi=open(spifile,'w')
spi.write("MD\n")
spi.write("TR OFF\n")
spi.write("MD\n")
spi.write("VB OFF\n")
... | code_fim | hard | {
"lang": "python",
"repo": "mcianfrocco/Optimal-cryoEM-imaging-of-Nanogold",
"path": "/makeStack.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mcianfrocco/Optimal-cryoEM-imaging-of-Nanogold path: /makeStack.py
#!/usr/bin/env python
import optparse
from sys import *
import os,sys,re
from optparse import OptionParser
import glob
import subprocess
from os import system
import linecache
import time
#=========================
def setupPar... | code_fim | hard | {
"lang": "python",
"repo": "mcianfrocco/Optimal-cryoEM-imaging-of-Nanogold",
"path": "/makeStack.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> spifile = "currentSpiderScript.spi"
if os.path.isfile(spifile):
os.remove(spifile)
spi=open(spifile,'w')
spi.write("MD\n")
spi.write("TR OFF\n")
spi.write("MD\n")
spi.write("VB OFF\n")
spi.write("MD\n")
spi.write("SET MP\n")
... | code_fim | hard | {
"lang": "python",
"repo": "mcianfrocco/Optimal-cryoEM-imaging-of-Nanogold",
"path": "/makeStack.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adam993/determined_stallman path: /train_model.py
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.externals import joblib
from sklearn.model_selection import train_test_split
from sklearn.metrics import roc_auc_score
from sklearn.model_selection import KFold
... | code_fim | hard | {
"lang": "python",
"repo": "adam993/determined_stallman",
"path": "/train_model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> oof_preds[val_idx] = clf.predict_proba(val_x, num_iteration=clf.best_iteration_)[:, 1]
sub_preds += clf.predict_proba(test_X[feats], num_iteration=clf.best_iteration_)[:, 1] / folds.n_splits
print('Fold %2d AUC : %.6f' % (n_fold + 1, roc_auc_score(val_y, oof_preds[val_idx])))
#del clf... | code_fim | hard | {
"lang": "python",
"repo": "adam993/determined_stallman",
"path": "/train_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> clf.fit(trn_x, trn_y,
eval_set= [(trn_x, trn_y), (val_x, val_y)],
eval_metric='auc', verbose=250, early_stopping_rounds=150
)
oof_preds[val_idx] = clf.predict_proba(val_x, num_iteration=clf.best_iteration_)[:, 1]
sub_preds += clf.predict_proba(test_X[f... | code_fim | hard | {
"lang": "python",
"repo": "adam993/determined_stallman",
"path": "/train_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def _class_to_inline_(self, attrs):
attrs_new = {attr:value for (attr, value) in attrs}
css_class = attrs_new.pop('class', '').strip()
css_classes = css_class.split(' ') if css_class else []
css_style = self._search_css_(css_classes... | code_fim | hard | {
"lang": "python",
"repo": "sky-music/sky-python-music-sheet-maker",
"path": "/src/skymusic/tools/merge_svg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sky-music/sky-python-music-sheet-maker path: /src/skymusic/tools/merge_svg.py
#!/usr/bin/env python3
"""
A script to import SVG files and convert them to background-images for HTML files
"""
if __name__ == '__main__':
#To find skymusic
import os, sys
project_path = os.path.normpath(o... | code_fim | hard | {
"lang": "python",
"repo": "sky-music/sky-python-music-sheet-maker",
"path": "/src/skymusic/tools/merge_svg.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if tag in self.drawing_tags: # tag must be recorded in extenso
if not self.css:
self.ascii += self._roundoff_(self.get_starttag_text().strip())
else:
if self.css: attrs = self._class_to_inline_(attrs)
... | code_fim | hard | {
"lang": "python",
"repo": "sky-music/sky-python-music-sheet-maker",
"path": "/src/skymusic/tools/merge_svg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("EVALUATING")
print("Train:", model.evaluate(X = dataset.train_x, Y = dataset.train_y))
print("Test:", model.evaluate(X = dataset.test_x, Y = dataset.test_y))
if not args.no_train:
print("TRAINING")
st = time()
model.fit(X = dataset.train_x, Y = dataset.train_y)
et = time()
print(f"Mod... | code_fim | medium | {
"lang": "python",
"repo": "varunranga/zorb",
"path": "/src/zorb.sh",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: varunranga/zorb path: /src/zorb.sh
#!/usr/local/bin/python3.8
import argparse
parser = argparse.ArgumentParser(description = 'Use ZORB to train a deep neural network using cli.')
parser.add_argument('-d', '--dataset', type = str, default = "MNIST", help = 'Dataset to train the network (see zorb.... | code_fim | hard | {
"lang": "python",
"repo": "varunranga/zorb",
"path": "/src/zorb.sh",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if args.load: network = zorb.models.load(args.load)
else:
network = [layer.replace('[', '(').replace(']', ')') if ('[' in layer) and (']' in layer) else (layer + "()") for layer in args.network]
network = [eval("zorb.layers."+layer) for layer in network]
model = zorb.models.Sequential(input_shape ... | code_fim | medium | {
"lang": "python",
"repo": "varunranga/zorb",
"path": "/src/zorb.sh",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JACflip55/telegram-scraping path: /Telegram_Crawler/Connector.py
# -*- coding:utf-8 -*-
import codecs
import datetime
import json
import sched
import optparse
import os
import time
import TelethonB
import threading
import sys
from telethon import TelegramClient
from telethon import errors
from t... | code_fim | hard | {
"lang": "python",
"repo": "JACflip55/telegram-scraping",
"path": "/Telegram_Crawler/Connector.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def read_leftout_groups(self):
if os.access("leftout_groups", os.F_OK):
with codecs.open("leftout_groups", "r", encoding="utf-8") as input:
groups = input.readlines()
return set(groups)
else:
return set()
def run(self, count... | code_fim | hard | {
"lang": "python",
"repo": "JACflip55/telegram-scraping",
"path": "/Telegram_Crawler/Connector.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ankit2001/trex-core path: /scripts/automation/trex_control_plane/interactive/trex/examples/astf/astf_path.py
import sys, os
cur_dir = os.path.dirname(__file__)
try: # example is being run as "python -m trex.examples.astf.<example>"
import trex.astf.api
except: # run as standalone script "p... | code_fim | hard | {
"lang": "python",
"repo": "ankit2001/trex-core",
"path": "/scripts/automation/trex_control_plane/interactive/trex/examples/astf/astf_path.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>assert os.path.isdir(ASTF_PROFILES_PATH), 'Could not determine ASTF profiles path'
assert os.path.isdir(EXT_LIBS_PATH), 'Could not determine external_libs path'<|fim_prefix|># repo: ankit2001/trex-core path: /scripts/automation/trex_control_plane/interactive/trex/examples/astf/astf_path.py
import sys, os... | code_fim | hard | {
"lang": "python",
"repo": "ankit2001/trex-core",
"path": "/scripts/automation/trex_control_plane/interactive/trex/examples/astf/astf_path.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SciLifeLab/genomics-status path: /status/sensorpush.py
"""Set of handlers related with Sensorpush data
"""
import json
import datetime
from status.util import SafeHandler
class SensorpushBaseHandler(SafeHandler):
def get_samples(self, start_days_ago=14):
# A reasonable start time
... | code_fim | hard | {
"lang": "python",
"repo": "SciLifeLab/genomics-status",
"path": "/status/sensorpush.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.write(json.dumps(sensors_with_warnings))
class SensorpushHandler(SensorpushBaseHandler):
"""Serves a page which lists all sensors with temperature info."""
def get(self):
sensor_data = self.get_samples(start_days_ago=28)
t = self.application.loader.load("sensorpush... | code_fim | hard | {
"lang": "python",
"repo": "SciLifeLab/genomics-status",
"path": "/status/sensorpush.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saishan27/Green path: /LanProcess.py
from nltk.tokenize import word_tokenize
def check_cmd(text):
<|fim_suffix|>out = (check_cmd("hello this what is saidharshan, pleased to meet you"))
# def
for i in range(1,len(out)):
if(i == "what"):
# & i+1 == "is"):
print("it knows"... | code_fim | easy | {
"lang": "python",
"repo": "saishan27/Green",
"path": "/LanProcess.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
out = (check_cmd("hello this what is saidharshan, pleased to meet you"))
# def
for i in range(1,len(out)):
if(i == "what"):
# & i+1 == "is"):
print("it knows")<|fim_prefix|># repo: saishan27/Green path: /LanProcess.py
from nltk.tokenize import word_tokenize
<|fim_middle|>def c... | code_fim | medium | {
"lang": "python",
"repo": "saishan27/Green",
"path": "/LanProcess.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> create_directory(paths.custom_configs_path)
create_directory(paths.custom_overrides_path)
create_directory(paths.custom_fallbacks_path)
create_directory(paths.custom_lockfile_path)
print('Finished mk_custom!')
if __name__ == "__main__":
main()<|fim_prefix|># repo: curtjen/clither path: /lib... | code_fim | hard | {
"lang": "python",
"repo": "curtjen/clither",
"path": "/lib/setup_custom.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: curtjen/clither path: /lib/setup_custom.py
#!/bin/env python
"""Backup current RC files in the HOME directory."""
import os
from helpers import create_directory, copy_file, paths, mk_clither_custom_dirs, clean_dir
def main():
<|fim_suffix|> # create_directory(paths.custom_default_addon_path)
... | code_fim | hard | {
"lang": "python",
"repo": "curtjen/clither",
"path": "/lib/setup_custom.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> create_directory(paths.custom_lib_path)
copy_file(paths.clither_run, paths.custom_path, write_over=True) # may want another lvl deep?
copy_file(paths.clither_pather, paths.custom_path, write_over=True)
copy_file(paths.clither_run_help, paths.custom_lib_path, write_over=True)
# create_directory(... | code_fim | medium | {
"lang": "python",
"repo": "curtjen/clither",
"path": "/lib/setup_custom.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> positive_data = data[data[target] == 1]
positive_ratio = len(positive_data) / len(data)
negative_data = data[data[target] == 0].sample(
frac=positive_ratio / (1 - positive_ratio), random_state=self.random_state
)
return positive_data.index.union(negative... | code_fim | medium | {
"lang": "python",
"repo": "upura/kaggle_utils",
"path": "/kaggle_utils/utils/sampling.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: upura/kaggle_utils path: /kaggle_utils/utils/sampling.py
class DownSampler(object):
def __init__(self, random_state):
self.random_state = random_state
<|fim_suffix|> positive_data = data[data[target] == 1]
positive_ratio = len(positive_data) / len(data)
negativ... | code_fim | easy | {
"lang": "python",
"repo": "upura/kaggle_utils",
"path": "/kaggle_utils/utils/sampling.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with use_credentials(self.creds):
return download(*args, **kwargs)
return download_cmd, dict(rpath=uri, lpath=local_path)
def _delete_command(self, uri: str) -> Tuple[Callable, Dict]:
def delete_cmd(*args, **kwargs):
with use_credentials(self.c... | code_fim | hard | {
"lang": "python",
"repo": "ludwig-ai/ludwig",
"path": "/ludwig/hyperopt/syncer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ludwig-ai/ludwig path: /ludwig/hyperopt/syncer.py
from typing import Any, Callable, Dict, List, Optional, Tuple
from ray.tune.syncer import _BackgroundSyncer
from ludwig.utils.data_utils import use_credentials
from ludwig.utils.fs_utils import delete, download, upload
class RemoteSyncer(_Back... | code_fim | hard | {
"lang": "python",
"repo": "ludwig-ai/ludwig",
"path": "/ludwig/hyperopt/syncer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _sync_up_command(self, local_path: str, uri: str, exclude: Optional[List] = None) -> Tuple[Callable, Dict]:
def upload_cmd(*args, **kwargs):
with use_credentials(self.creds):
return upload(*args, **kwargs)
return upload_cmd, dict(lpath=local_path, rpath... | code_fim | medium | {
"lang": "python",
"repo": "ludwig-ai/ludwig",
"path": "/ludwig/hyperopt/syncer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def make_mesh(vertices, cells, cell_type):
'''Mesh from data by MeshEditor'''
gdim = cell_type.geometric_dimension()
assert vertices.shape[1] == gdim
tdim = cell_type.topological_dimension()
mesh = Mesh()
editor = MeshEditor()
editor.open(mesh, str(cell_type), tdim, gdim) ... | code_fim | hard | {
"lang": "python",
"repo": "thw1021/fenics-calc",
"path": "/xcalc/function_read.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: thw1021/fenics-calc path: /xcalc/function_read.py
# This is the most fragile component of the package so be advised that
# these ARE NOT GENERAL PURPOSE READEDERS
from dolfin import Function, dof_to_vertex_map, warning, Mesh, MeshEditor
import xml.etree.ElementTree as ET
from itertools import ... | code_fim | hard | {
"lang": "python",
"repo": "thw1021/fenics-calc",
"path": "/xcalc/function_read.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def new_option_parser():
from amuse.units.optparse import OptionParser
result = OptionParser()
result.add_option("-N", dest="N", type="int",default = 100,
help="number of stars [%default]")
result.add_option("-n", dest="n_steps", type="int",default = 6,
... | code_fim | hard | {
"lang": "python",
"repo": "amusecode/amuse",
"path": "/examples/syllabus/hydro_simple.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amusecode/amuse path: /examples/syllabus/hydro_simple.py
"""
Simple routine for running a hydrodynamics solver
"""
from __future__ import print_function
from amuse.lab import *
def main(N=100, Mtot=1|units.MSun, Rvir=1|units.RSun,
t_end=1|units.day, n_steps=6):
converter=nbody_... | code_fim | hard | {
"lang": "python",
"repo": "amusecode/amuse",
"path": "/examples/syllabus/hydro_simple.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> from amuse.units.optparse import OptionParser
result = OptionParser()
result.add_option("-N", dest="N", type="int",default = 100,
help="number of stars [%default]")
result.add_option("-n", dest="n_steps", type="int",default = 6,
help="number of s... | code_fim | hard | {
"lang": "python",
"repo": "amusecode/amuse",
"path": "/examples/syllabus/hydro_simple.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
filters = ['g', 'r', 'i', 'z', 'y']
rep_all = glob.glob(os.path.join(rep_out, '*'))
lo = load_output(rep_all)
lo.load_data()
lo.save_output(os.path.join(rep_save, 'final_gp_outputs_all.pkl'))
for f in filters:
print(f)
rep_filters = glob.glob(os.path.join(rep_out... | code_fim | hard | {
"lang": "python",
"repo": "PFLeget/gastrometry",
"path": "/gastrometry/read_output.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PFLeget/gastrometry path: /gastrometry/read_output.py
import numpy as np
import copy
import pickle
import glob
import os
class gather_input(object):
def __init__(self, rep_output):
self.rep_output = rep_output
self.exp_id = []
self.u = []
self.v = []
... | code_fim | hard | {
"lang": "python",
"repo": "PFLeget/gastrometry",
"path": "/gastrometry/read_output.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
filters = ['g', 'r', 'i', 'z', 'y']
rep_all = glob.glob(os.path.join(rep_out, '*'))
lo = gather_input(rep_all)
lo.load_data()
lo.save_output(os.path.join(rep_save, 'inputs_all.pkl'))
for f in filters:
print(f)
rep_filters = glob.glob(os.path.join(rep_out, '*_%s*'... | code_fim | hard | {
"lang": "python",
"repo": "PFLeget/gastrometry",
"path": "/gastrometry/read_output.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for near in current.nearby:
# if not a wall
if near is not None:
node = self.get_node(near[0])
# and if not visited
if not visited[node.location]:
visited[node.location] = True
cy, cx =... | code_fim | hard | {
"lang": "python",
"repo": "Tinggaard/pathfinding",
"path": "/pathfinding/algs/breadthfirst.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tinggaard/pathfinding path: /pathfinding/algs/breadthfirst.py
import numpy as np
from _collections import deque as dq
def breadthfirst(self):
assert not self.solved
start = self.start
end = self.end
# set initial value
start.dist = 0
# bool array
visited = np.full(... | code_fim | hard | {
"lang": "python",
"repo": "Tinggaard/pathfinding",
"path": "/pathfinding/algs/breadthfirst.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Generates a random XYZ point inside the camera field of view
@type camera_info: sensor_msgs.CameraInfo
@param camera_info: Message with the meta information for a camera
@type maxdist: float
@param maxdist: distance from the camera ref frame in the z direction
@type mindist: ... | code_fim | hard | {
"lang": "python",
"repo": "crigroup/criros",
"path": "/src/criros/exploration.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: crigroup/criros path: /src/criros/exploration.py
#! /usr/bin/env python
import itertools
import numpy as np
import openravepy as orpy
# Image geometry
from sensor_msgs.msg import CameraInfo
from image_geometry import PinholeCameraModel
# Transformations
import tf.transformations as tr
def camer... | code_fim | hard | {
"lang": "python",
"repo": "crigroup/criros",
"path": "/src/criros/exploration.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MrSchnappi/ACL2021MF path: /dataset/EvalAI.py
from collections import defaultdict
import json
import re
import subprocess
import tempfile
import time
from typing import Any, Dict, List
from mypy_extensions import TypedDict
Prediction = TypedDict("Prediction", {"image_id": int, "caption": str})... | code_fim | hard | {
"lang": "python",
"repo": "MrSchnappi/ACL2021MF",
"path": "/dataset/EvalAI.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> submission_command_subprocess = subprocess.Popen(
submission_command.split(),
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
# This terminal output will have submission ID we need to check.
submiss... | code_fim | hard | {
"lang": "python",
"repo": "MrSchnappi/ACL2021MF",
"path": "/dataset/EvalAI.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> flipped_metrics: Dict[str, Any] = defaultdict(dict)
for key, val in metrics.items():
for subkey, subval in val.items():
flipped_metrics[subkey][key] = subval
# keys: {"B1", "B2", "B3", "B4", "METEOR", "ROUGE-L", "CIDEr", "SPICE"}
# In each of th... | code_fim | hard | {
"lang": "python",
"repo": "MrSchnappi/ACL2021MF",
"path": "/dataset/EvalAI.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ob, rew, terminated, truncated, info = super().step(action)
return ob, rew, False, truncated, info
# A simple wrapper that adds a is_success key which SB3 tracks
class SuccessInfoWrapper(gym.Wrapper):
def step(self, action):
ob, rew, terminated, truncated, info = super().step... | code_fim | hard | {
"lang": "python",
"repo": "haosulab/ManiSkill2",
"path": "/examples/tutorials/reinforcement-learning/sb3_ppo_liftcube_state.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: haosulab/ManiSkill2 path: /examples/tutorials/reinforcement-learning/sb3_ppo_liftcube_state.py
# Import required packages
import argparse
import os.path as osp
import gymnasium as gym
import numpy as np
from stable_baselines3 import PPO
from stable_baselines3.common.callbacks import CheckpointCa... | code_fim | hard | {
"lang": "python",
"repo": "haosulab/ManiSkill2",
"path": "/examples/tutorials/reinforcement-learning/sb3_ppo_liftcube_state.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return _init
# create eval environment
if args.eval:
record_dir = osp.join(log_dir, "videos/eval")
else:
record_dir = osp.join(log_dir, "videos")
eval_env = SubprocVecEnv(
[make_env(env_id, record_dir=record_dir) for _ in range(1)]
)
eval_env = VecM... | code_fim | hard | {
"lang": "python",
"repo": "haosulab/ManiSkill2",
"path": "/examples/tutorials/reinforcement-learning/sb3_ppo_liftcube_state.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_message_by_message_id(
self,
*,
db_chat: 'tg_models.Chat',
message_id: int,
) -> Optional['tg_models.Message']:
if db_chat is None or message_id is None:
return None
return self.tg_models.Message.objects.get_messa... | code_fim | medium | {
"lang": "python",
"repo": "appheap/social-media-analyzer",
"path": "/backend/telegram/methods/messages_and_media/get_message_by_message_id.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.tg_models.Message.objects.get_message_by_message_id(
db_chat=db_chat,
message_id=message_id,
)<|fim_prefix|># repo: appheap/social-media-analyzer path: /backend/telegram/methods/messages_and_media/get_message_by_message_id.py
from typing import Optional... | code_fim | hard | {
"lang": "python",
"repo": "appheap/social-media-analyzer",
"path": "/backend/telegram/methods/messages_and_media/get_message_by_message_id.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: appheap/social-media-analyzer path: /backend/telegram/methods/messages_and_media/get_message_by_message_id.py
from typing import Optional
from db.scaffold import Scaffold
from telegram import models as tg_models
<|fim_suffix|> def get_message_by_message_id(
self,
*,
... | code_fim | medium | {
"lang": "python",
"repo": "appheap/social-media-analyzer",
"path": "/backend/telegram/methods/messages_and_media/get_message_by_message_id.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>_STACK_TRACE_MAP = {
SanitizerLogParserOutputPrimaryKey('package1', 'data-race', 'key1',):
SanitizerSectionPartStackTrace((' #1 0x7f in key1 /ros2',)),
SanitizerLogParserOutputPrimaryKey('package2', 'lock-order-inversion', 'key2',):
SanitizerSectionPartStackTrace((' #2 0x7f in ke... | code_fim | hard | {
"lang": "python",
"repo": "colcon/colcon-sanitizer-reports",
"path": "/test/test_xml_output_generator.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: colcon/colcon-sanitizer-reports path: /test/test_xml_output_generator.py
# Copyright 2019 Amazon.com, Inc. or its affiliates. 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 obtai... | code_fim | medium | {
"lang": "python",
"repo": "colcon/colcon-sanitizer-reports",
"path": "/test/test_xml_output_generator.py",
"mode": "psm",
"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.