text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> # Combine the two samples into one, noting the samples the values came from
samples_x_y_instance.run(algorithm_instance)
combined_sample_instance = algorithm_instance.get_combined_sample()
distribution = TestStatisticDistribution(samples_x_y=samples_x_y_instance,
... | code_fim | hard | {
"lang": "python",
"repo": "max-ch9i/general-differences",
"path": "/index.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Example 2
# samples_x_y_instance = SamplesXY(sample_x=[5, 10], sample_y=[2, 2, 10])
# Example 3
samples_x_y_instance = SamplesXY(sample_x=[11, 12, 13, 14],
sample_y=[5, 6, 7])
# Combine the two samples into one, noting the samples the values cam... | code_fim | medium | {
"lang": "python",
"repo": "max-ch9i/general-differences",
"path": "/index.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: max-ch9i/general-differences path: /index.py
from SamplesXY import SamplesXY
from CombineAlgorithm import CombineAlgorithm
from TestStatisticDistribution import TestStatisticDistribution
if __name__ == '__main__':
algorithm_instance = CombineAlgorithm()
# Example 1
# samples_x_y_ins... | code_fim | medium | {
"lang": "python",
"repo": "max-ch9i/general-differences",
"path": "/index.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ussian/Game-Mechanics path: /Python/Collision/Collision.py
# libaries
import pygame
import random
# Constants
WIDTH = 800
HEIGHT = 800
FPS = 120
SPEEDX = 2
SPEEDY = 1
# Colors in RGB
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0... | code_fim | hard | {
"lang": "python",
"repo": "ussian/Game-Mechanics",
"path": "/Python/Collision/Collision.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Dont place "speedy = 8" in here because then every time the
# loop runs it will set the speed to 8
self.rect.x += self.speedx
self.rect.y += self.speedy
if self.rect.bottom == HEIGHT | self.rect.bottom > HEIGHT:
self.speedy *= -1
... | code_fim | hard | {
"lang": "python",
"repo": "ussian/Game-Mechanics",
"path": "/Python/Collision/Collision.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bentoml/BentoML path: /examples/custom_runner/nltk_pretrained_model/service.py
from __future__ import annotations
import time
import typing as t
from statistics import mean
from typing import TYPE_CHECKING
import nltk
from nltk.sentiment import SentimentIntensityAnalyzer
import bentoml
from be... | code_fim | hard | {
"lang": "python",
"repo": "bentoml/BentoML",
"path": "/examples/custom_runner/nltk_pretrained_model/service.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>nltk_runner = t.cast(
"RunnerImpl", bentoml.Runner(NLTKSentimentAnalysisRunnable, name="nltk_sentiment")
)
svc = bentoml.Service("sentiment_analyzer", runners=[nltk_runner])
@svc.api(input=Text(), output=JSON())
async def analysis(input_text: str) -> dict[str, bool]:
is_positive = await nltk_ru... | code_fim | hard | {
"lang": "python",
"repo": "bentoml/BentoML",
"path": "/examples/custom_runner/nltk_pretrained_model/service.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class NLTKSentimentAnalysisRunnable(bentoml.Runnable):
SUPPORTED_RESOURCES = ("cpu",)
SUPPORTS_CPU_MULTI_THREADING = False
def __init__(self):
self.sia = SentimentIntensityAnalyzer()
@bentoml.Runnable.method(batchable=False)
def is_positive(self, input_text: str) -> bool:
... | code_fim | hard | {
"lang": "python",
"repo": "bentoml/BentoML",
"path": "/examples/custom_runner/nltk_pretrained_model/service.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
targets: a [batch_size x time x (feat_dim*nrS)] tensor containing the binary targets
logits: a [batch_size x time x (feat_dim*emb_dim)] tensor containing the logits
usedbins: a [batch_size x time x feat_dim] tensor indicating the bins to use in the loss function
s... | code_fim | hard | {
"lang": "python",
"repo": "xiaohanghang/Nabu-MSSS",
"path": "/nabu/neuralnetworks/components/ops.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xiaohanghang/Nabu-MSSS path: /nabu/neuralnetworks/components/ops.py
2centervar_rat_loss'
with tf.name_scope('intravar2centervar_rat_loss'):
feat_dim = tf.shape(usedbins)[2]
output_dim = tf.shape(logits)[2]
emb_dim = output_dim/feat_dim
target_dim = tf.shape(targets)[2... | code_fim | hard | {
"lang": "python",
"repo": "xiaohanghang/Nabu-MSSS",
"path": "/nabu/neuralnetworks/components/ops.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
Compute the permutation invariant loss.
Remark: This is implementation is different from pit_loss as the last dimension of logits is
still feat_dim*nrS, but the first feat_dim entries correspond to the first speaker and the
second feat_dim entries correspond to the second speaker ... | code_fim | hard | {
"lang": "python",
"repo": "xiaohanghang/Nabu-MSSS",
"path": "/nabu/neuralnetworks/components/ops.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: scooter23/grins path: /mm/lib/motif/XButton.py
__version__ = "$Id$"
import Xlib
from XConstants import error, TRUE, FALSE, UNIT_PXL
from XTopLevel import toplevel
class _Button:
def __init__(self, dispobj, coordinates, z, times, sensitive):
self._coordinates = coordinates
se... | code_fim | hard | {
"lang": "python",
"repo": "scooter23/grins",
"path": "/mm/lib/motif/XButton.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class _ButtonCircle(_Button):
def __init__(self, dispobj, coordinates, z, times, sensitive):
_Button.__init__(self, dispobj, coordinates, z, times, sensitive)
# Returns true if the point is inside the box
def _inside(self, x, y):
if not self._sensitive:
return 0
... | code_fim | hard | {
"lang": "python",
"repo": "scooter23/grins",
"path": "/mm/lib/motif/XButton.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 2794608905/katago-server path: /katago_server/games/admin.py
from django.contrib import admin
from katago_server.games.models import Game
<|fim_suffix|> if not obj.pk: # Only set added_by during the first save.
obj.submitted_by = request.user
super().save_model(reque... | code_fim | hard | {
"lang": "python",
"repo": "2794608905/katago-server",
"path": "/katago_server/games/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> readonly_fields = ("created_at",)
list_display = ('uuid', 'result_text', 'created_at', 'submitted_by', 'white_network', 'black_network')
def save_model(self, request, obj, form, change):
if not obj.pk: # Only set added_by during the first save.
obj.submitted_by = request.... | code_fim | medium | {
"lang": "python",
"repo": "2794608905/katago-server",
"path": "/katago_server/games/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def save_model(self, request, obj, form, change):
if not obj.pk: # Only set added_by during the first save.
obj.submitted_by = request.user
super().save_model(request, obj, form, change)<|fim_prefix|># repo: 2794608905/katago-server path: /katago_server/games/admin.py
fro... | code_fim | hard | {
"lang": "python",
"repo": "2794608905/katago-server",
"path": "/katago_server/games/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def preprocessing(file):
print('Launch Processing of {}'.format(file))
output = file+'_processed.csv'
# By default, Pandas treats double quote as enclosing an entry so it includes all tabs and newlines in that entry
# until it reaches the next quote. To escape it we need to have the quot... | code_fim | hard | {
"lang": "python",
"repo": "superrichiesui/Text-Normalization-Demo",
"path": "/src/preprocessing.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # size of each row
row_size = df.memory_usage().sum() / len(df)
# maximum number of rows in each segment
row_limit = int(size // row_size)
# number of segments
seg_num = (len(df)+row_limit-1)//row_limit
# split df into segments
segments = [df.iloc[i*row_limit : (i+1)*row_li... | code_fim | hard | {
"lang": "python",
"repo": "superrichiesui/Text-Normalization-Demo",
"path": "/src/preprocessing.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: superrichiesui/Text-Normalization-Demo path: /src/preprocessing.py
# Copyright 2018 Cognibit Solutions LLP.
#
# 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... | code_fim | hard | {
"lang": "python",
"repo": "superrichiesui/Text-Normalization-Demo",
"path": "/src/preprocessing.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shnlmn/Rhino-Grasshopper-Scripts path: /IronPythonStubs/release/stubs.min/System/Windows/Forms/__init___parts/DataGridViewAutoSizeModeEventArgs.py
class DataGridViewAutoSizeModeEventArgs(EventArgs):
"""
Provides data for the System.Windows.Forms.DataGridViewSystem.Windows.Forms.DataGridView.Aut... | code_fim | hard | {
"lang": "python",
"repo": "shnlmn/Rhino-Grasshopper-Scripts",
"path": "/IronPythonStubs/release/stubs.min/System/Windows/Forms/__init___parts/DataGridViewAutoSizeModeEventArgs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ __new__(cls: type,previousModeAutoSized: bool) """
pass
PreviousModeAutoSized=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets a value specifying whether the System.Windows.Forms.DataGridView was previously set to automatically resize.
Get: PreviousModeAutoSized(s... | code_fim | medium | {
"lang": "python",
"repo": "shnlmn/Rhino-Grasshopper-Scripts",
"path": "/IronPythonStubs/release/stubs.min/System/Windows/Forms/__init___parts/DataGridViewAutoSizeModeEventArgs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aratz/pyABC path: /test/base/test_population.py
import numpy as np
import pytest
from pyabc import Population
from .test_storage import rand_pop_list
def rand_pop(m: int):
return Population(rand_pop_list(m))
<|fim_suffix|> # 1 sum stat per particle in this case
assert len(pop.get_... | code_fim | hard | {
"lang": "python",
"repo": "Aratz/pyABC",
"path": "/test/base/test_population.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> m = 53
pop = rand_pop(m)
# call methods
assert len(pop.get_list()) == len(pop)
weighted_distances = pop.get_weighted_distances()
weights, sumstats = pop.get_weighted_sum_stats()
vals = pop.get_for_keys(
keys=['weight', 'distance', 'parameter', 'sum_stat'])
assert... | code_fim | medium | {
"lang": "python",
"repo": "Aratz/pyABC",
"path": "/test/base/test_population.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> i=1
predict_frame = np.zeros(8000)
result = [torch.zeros(1300)]
detect_ = [True]
while(node100ms*i<len(test)):
result.append(torch.zeros(1300))
frame_now = test[node100ms*(i-1):node100ms*i]
#detect_.append( detect(frame_now) )
... | code_fim | hard | {
"lang": "python",
"repo": "ptomasz1/Si-Xun-Luo-Self-Supervised_Learning_for_Online_SpeakerDiarization",
"path": "/evaluation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
result.append(torch.zeros(1300))
frame_now = test[node100ms*(i-1):node100ms*i]
#detect_.append( detect(frame_now) )
predict_frame = np.concatenate((predict_frame[800:8000], frame_now), axis=None)
probability_distribution = model.predict(predict_frame)
... | code_fim | hard | {
"lang": "python",
"repo": "ptomasz1/Si-Xun-Luo-Self-Supervised_Learning_for_Online_SpeakerDiarization",
"path": "/evaluation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ptomasz1/Si-Xun-Luo-Self-Supervised_Learning_for_Online_SpeakerDiarization path: /evaluation.py
import webrtcvad
import numpy as np
import random
import torch
import torch.nn as nn
import time
import librosa
from tqdm import tqdm
import os
from scipy.io import wavfile
import pydub
from Layer impo... | code_fim | hard | {
"lang": "python",
"repo": "ptomasz1/Si-Xun-Luo-Self-Supervised_Learning_for_Online_SpeakerDiarization",
"path": "/evaluation.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> QApplication = QtWidgets.QApplication
QBuffer = QtCore.QBuffer
QIODevice = QtCore.QIODevice
QScreen = QtGui.QScreen
# QPixmap = self.PySide2.QtGui.QPixmap
global app
if not app:
app = QApplication([])
qbuffer = QBuffer()
... | code_fim | hard | {
"lang": "python",
"repo": "robocorp/rpaframework-screenshot",
"path": "/pyscreenshot/plugins/pyside2_grabwindow.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: robocorp/rpaframework-screenshot path: /pyscreenshot/plugins/pyside2_grabwindow.py
import logging
from PIL import Image
from pyscreenshot.plugins.backend import CBackend
from pyscreenshot.util import py2
if py2():
import StringIO
BytesIO = StringIO.StringIO
else:
import io
Byt... | code_fim | hard | {
"lang": "python",
"repo": "robocorp/rpaframework-screenshot",
"path": "/pyscreenshot/plugins/pyside2_grabwindow.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nikkkkhil/modelshare path: /src/nest/settings.py
import os
import yaml
from typing import Union, Dict, Any
SETTINGS_DIR = os.path.join(str(os.path.expanduser('~')), '.nest')
TEMPLATE_FILE = os.path.join(SETTINGS_DIR, 'template.yml')
SETTINGS_FILE = os.path.join(SETTINGS_DIR, 'settings.yml')
DE... | code_fim | hard | {
"lang": "python",
"repo": "nikkkkhil/modelshare",
"path": "/src/nest/settings.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self):
self.load()
def __getitem__(self, key: str):
return self.settings[key]
def __setitem__(self, key: str, val: str):
self.user_settings[key] = val
def __contains__(self, key):
return key in self.settings.keys()
def load(self):
... | code_fim | hard | {
"lang": "python",
"repo": "nikkkkhil/modelshare",
"path": "/src/nest/settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return settings, user_settings
def __init__(self):
self.load()
def __getitem__(self, key: str):
return self.settings[key]
def __setitem__(self, key: str, val: str):
self.user_settings[key] = val
def __contains__(self, key):
return key in self... | code_fim | hard | {
"lang": "python",
"repo": "nikkkkhil/modelshare",
"path": "/src/nest/settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: p768lwy3/torecsys path: /torecsys/inputs/base/multi_indices_emb.py
from typing import List, Optional, TypeVar
import numpy as np
import torch
import torch.nn as nn
from torecsys.inputs.base import BaseInput
class MultiIndicesEmbedding(BaseInput):
"""
Base Input class for embedding ind... | code_fim | hard | {
"lang": "python",
"repo": "p768lwy3/torecsys",
"path": "/torecsys/inputs/base/multi_indices_emb.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.offsets = self.offsets.cpu()
return self
def forward(self, inputs: torch.Tensor) -> torch.Tensor:
"""
Forward calculation of MultiIndicesEmbedding
Args:
inputs (T), shape = (B, N), data_type = torch.long: tensor of indices in inputs f... | code_fim | hard | {
"lang": "python",
"repo": "p768lwy3/torecsys",
"path": "/torecsys/inputs/base/multi_indices_emb.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shimizukawa/scrap2rst path: /scrap2rst/logging.py
import logging
def setup_logger(is_debug=False):
if is_debug:
logging.basicConfig(level=logging.DEBUG,<|fim_suffix|>gging.basicConfig(level=logging.INFO, format='%(message)s')<|fim_middle|> format='%(levelname)s: %(message)s')
el... | code_fim | easy | {
"lang": "python",
"repo": "shimizukawa/scrap2rst",
"path": "/scrap2rst/logging.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> format='%(levelname)s: %(message)s')
else:
logging.basicConfig(level=logging.INFO, format='%(message)s')<|fim_prefix|># repo: shimizukawa/scrap2rst path: /scrap2rst/logging.py
import logging
def setup_logger(is_debug=False):
if <|fim_middle|>is_debug:
logging.basicConfig(level=... | code_fim | easy | {
"lang": "python",
"repo": "shimizukawa/scrap2rst",
"path": "/scrap2rst/logging.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class DocumentSerializer(serializers.ModelSerializer):
"""Serializer for uploading documents/images"""
class Meta:
model = Documents
fields = ('sigh_number', 'image', 'req_time',
'parse_text', 'sig_in_image',)
read_only_fields = ('sigh_number', 'req_time'... | code_fim | medium | {
"lang": "python",
"repo": "atranscendence/H_task",
"path": "/H_dj_task/api_app/serializers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> class Meta:
model = Documents
fields = ('sigh_number', 'image', 'req_time',
'parse_text', 'sig_in_image',)
read_only_fields = ('sigh_number', 'req_time',
'parse_text', 'sig_in_image',)<|fim_prefix|># repo: atranscendence/H_task pat... | code_fim | medium | {
"lang": "python",
"repo": "atranscendence/H_task",
"path": "/H_dj_task/api_app/serializers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: atranscendence/H_task path: /H_dj_task/api_app/serializers.py
from django.contrib.auth import get_user_model, authenticate
from django.utils.translation import ugettext_lazy as gettext
from rest_framework import serializers
from main_app.models import Documents
<|fim_suffix|> class Meta:
... | code_fim | medium | {
"lang": "python",
"repo": "atranscendence/H_task",
"path": "/H_dj_task/api_app/serializers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def call_independent_functions_on_n_processors(function, arguments_lists, num_processors):
from multiprocessing import Pool
pool = Pool(int(num_processors))
results = pool.map(universal_worker, pool_args(function, *arguments_lists))
def universal_worker(input_pair):
function, args = inp... | code_fim | hard | {
"lang": "python",
"repo": "XingchengLin/RACER",
"path": "/molecular_demo/common_function.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: XingchengLin/RACER path: /molecular_demo/common_function.py
import math
import subprocess
import os
import time
import sys
import functools
import itertools
import numpy as np
import random
# For Biopython
from Bio.PDB import *
from Bio.PDB.Polypeptide import one_to_three, three_to_one
####... | code_fim | hard | {
"lang": "python",
"repo": "XingchengLin/RACER",
"path": "/molecular_demo/common_function.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: umair-abro/datahub path: /metadata-ingestion/src/datahub/metadata/schemas/__init__.py
# flake8: noqa
# This file is autogenerated by /metadata-ingestion/scripts/avro_codegen.py
# Do not modify manually!
# fmt: off
import functools
import pathlib
def _load_schema(schema_name: str) -> str:
... | code_fim | hard | {
"lang": "python",
"repo": "umair-abro/datahub",
"path": "/metadata-ingestion/src/datahub/metadata/schemas/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@functools.lru_cache(maxsize=None)
def getGlossaryRelatedTermsSchema() -> str:
return _load_schema("GlossaryRelatedTerms")
@functools.lru_cache(maxsize=None)
def getGlossaryTermInfoSchema() -> str:
return _load_schema("GlossaryTermInfo")
@functools.lru_cache(maxsize=None)
def getCorpGroupInfoSch... | code_fim | hard | {
"lang": "python",
"repo": "umair-abro/datahub",
"path": "/metadata-ingestion/src/datahub/metadata/schemas/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AppImageCrafters/appimage-builder path: /appimagebuilder/modules/setup/apprun_3/helpers/gstreamer.py
# Copyright 2020 Alexis Lopez Zubieta
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
#... | code_fim | hard | {
"lang": "python",
"repo": "AppImageCrafters/appimage-builder",
"path": "/appimagebuilder/modules/setup/apprun_3/helpers/gstreamer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._set_gst_plugins_path()
self._set_gst_plugins_scanner_path()
self._set_ptp_helper_path()
self._generate_gst_registry()
def _set_gst_plugins_path(self):
gst_1_lib = self.context.app_dir.find_one(["*/libgstreamer-1.0.so.0"])
if gst_1_lib:
... | code_fim | hard | {
"lang": "python",
"repo": "AppImageCrafters/appimage-builder",
"path": "/appimagebuilder/modules/setup/apprun_3/helpers/gstreamer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Parameters
----------
y_true, y_pred : list of list of tuples
minipatch : [row_min, row_max, col_min, col_max], optional
Bounds of the internal scoring patch (default is None)
Returns
-------
float: distance between input arrays
References
----------
http:... | code_fim | hard | {
"lang": "python",
"repo": "paris-saclay-cds/ramp-workflow",
"path": "/rampwf/score_types/detection/ospa.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: paris-saclay-cds/ramp-workflow path: /rampwf/score_types/detection/ospa.py
import numpy as np
from sklearn.utils import indices_to_mask
from .base import DetectionBaseScoreType
from .util import _select_minipatch_tuples, _match_tuples
class OSPA(DetectionBaseScoreType):
"""
Optimal Sub... | code_fim | hard | {
"lang": "python",
"repo": "paris-saclay-cds/ramp-workflow",
"path": "/rampwf/score_types/detection/ospa.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
n_true = len(y_true)
n_pred = len(y_pred)
# No craters and none found
if n_true == 0 and n_pred == 0:
return 0, 0, 0
# Mask of entries that lie within the minipatch
if minipatch is not None:
true_in_minipatch = _select_minipatch_tuples(y_true, minipatch)
... | code_fim | hard | {
"lang": "python",
"repo": "paris-saclay-cds/ramp-workflow",
"path": "/rampwf/score_types/detection/ospa.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vincentouma/Instagram path: /app/admin.py
from django.contrib import admin
from .models import Image,Comments,Profile
# Register your mo<|fim_suffix|>te.register(Image)
admin.site.register(Comments)<|fim_middle|>dels here.
admin.site.register(Profile)
admin.si | code_fim | easy | {
"lang": "python",
"repo": "vincentouma/Instagram",
"path": "/app/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>te.register(Image)
admin.site.register(Comments)<|fim_prefix|># repo: vincentouma/Instagram path: /app/admin.py
from django.contrib import admin
from .models import Image,Comments,Profile
# Register your mo<|fim_middle|>dels here.
admin.site.register(Profile)
admin.si | code_fim | easy | {
"lang": "python",
"repo": "vincentouma/Instagram",
"path": "/app/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kbd/setup path: /HOME/bin/lib/colors.py
# https://en.wikipedia.org/wiki/ANSI_escape_code
class D(dict):
__getattr__ = dict.__getitem__
<|fim_suffix|>e = D( # e = escapes for use within prompt, o=open, c=close
zsh=D(o='%{', c='%}'),
bash=D(o='\\[\x1b[', c='\\]'),
interactive=D(o... | code_fim | hard | {
"lang": "python",
"repo": "kbd/setup",
"path": "/HOME/bin/lib/colors.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>e = D( # e = escapes for use within prompt, o=open, c=close
zsh=D(o='%{', c='%}'),
bash=D(o='\\[\x1b[', c='\\]'),
interactive=D(o='', c=''),
)<|fim_prefix|># repo: kbd/setup path: /HOME/bin/lib/colors.py
# https://en.wikipedia.org/wiki/ANSI_escape_code
class D(dict):
__getattr__ = dict.... | code_fim | hard | {
"lang": "python",
"repo": "kbd/setup",
"path": "/HOME/bin/lib/colors.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_recent(self):
# pick a new action
s, t, a, r, sp = self.get_index(-1)
return sp.reshape((1, hp.INPUT_SIZE, hp.INPUT_SIZE, hp.NUM_CHANNELS))
def get_minibatch(self, frame_count):
# gradient update
size = hp.MINIBATCH_SIZE
s = np.zeros((size, hp.INPUT_SIZE, hp.INPUT_SIZE, hp.NUM_CHANN... | code_fim | hard | {
"lang": "python",
"repo": "xavi1989/cs231n",
"path": "/cs231n-project/transition_table.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # for i in range(hp.AGENT_HISTORY_LENGTH + 1):
# if i < hp.AGENT_HISTORY_LENGTH:
# sp[:, :, :, i] = current_transition.image
# if i > 0:
# s[:, :, :, i - 1] = current_transition.image
# if not current_transition.was_start:
# current_index -= 1
# current_transition = self.transit... | code_fim | hard | {
"lang": "python",
"repo": "xavi1989/cs231n",
"path": "/cs231n-project/transition_table.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xavi1989/cs231n path: /cs231n-project/transition_table.py
import numpy as np
import hyperparameters as hp
from action import Action
from collections import deque
import pdb
class Transition(object):
def __init__(self, image, terminal, action, reward, was_start, telemetry):
self.action = actio... | code_fim | hard | {
"lang": "python",
"repo": "xavi1989/cs231n",
"path": "/cs231n-project/transition_table.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: daviddexter/wrangle-mirror path: /wrangle/df/df_fill_empty.py
def df_fill_empty(data, fill_with):
'''Finds and replaces any value in dataframe that only consist of
whitespace. A common scenario is where you first fill empties
with np.nan and then handle nans as you would otherwise do... | code_fim | medium | {
"lang": "python",
"repo": "daviddexter/wrangle-mirror",
"path": "/wrangle/df/df_fill_empty.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data : Pandas Dataframe
The dataframe to be processed
fill_with: str
Fill the values with a string.
'''
return data.astype(str).apply(lambda x: x.str.strip().replace('', fill_with))<|fim_prefix|># repo: daviddexter/wrangle-mirror path: /wrangle/df/df_fill_empty.py
def df_f... | code_fim | medium | {
"lang": "python",
"repo": "daviddexter/wrangle-mirror",
"path": "/wrangle/df/df_fill_empty.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hailogon/Projects path: /Solutions/picalculator.py
def picalculator(dp):
pi = [3]
for x in range(2,1000000,4):
pi.append(4./(x*(x+1)*(x+2)))
pi.append(-4./((x+2)*(x+3)*(x+4)))
return round(sum(pi),dp)
<|fim_suffix|>if x > 11:
print "Sorry sir, this calculator is only capable of displayi... | code_fim | easy | {
"lang": "python",
"repo": "hailogon/Projects",
"path": "/Solutions/picalculator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if x > 11:
print "Sorry sir, this calculator is only capable of displaying 11 units of pi"
elif x < 1:
print "Nobody likes a smart-ass"
else:
print picalculator(x)<|fim_prefix|># repo: hailogon/Projects path: /Solutions/picalculator.py
def picalculator(dp):
pi = [3]
for x in range(2,1000000,4):
pi... | code_fim | easy | {
"lang": "python",
"repo": "hailogon/Projects",
"path": "/Solutions/picalculator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zzygyx9119/plastid path: /plastid/test/functional/test_crossmap.py
#!/usr/bin/env python
"""Test suite for :py:mod:`plastid.bin.crossmap`"""
import tempfile
import os
import subprocess
from nose.plugins.attrib import attr
from pkg_resources import resource_filename, cleanup_resources
from plasti... | code_fim | hard | {
"lang": "python",
"repo": "zzygyx9119/plastid",
"path": "/plastid/test/functional/test_crossmap.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#===============================================================================
# INDEX: Helper functions to run tests
#===============================================================================
@attr(test="functional")
@attr(speed="slow")
def do_test():
"""Perform functional test for plastid.b... | code_fim | hard | {
"lang": "python",
"repo": "zzygyx9119/plastid",
"path": "/plastid/test/functional/test_crossmap.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># see text for diagram, essentially
# Split - it breaks up DF by specified key into seperate entities
# Apply - performs (aggregation) function on the new individual groups
# Combine - merges results into an output array
# in reality, this computation generally runs in a single pass on the input
#... | code_fim | hard | {
"lang": "python",
"repo": "pgiardiniere/notes-PythonDataScienceHandbook",
"path": "/3.08-aggregGrouping.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pgiardiniere/notes-PythonDataScienceHandbook path: /3.08-aggregGrouping.py
### Aggregation and Grouping
# Now that we've fetched data in PD, time to explore the aggregation funcs
# sum(), mean(), median(), min(), max(), "groupby"s, etc.
import numpy as np
import pandas as pd
# omitting display ... | code_fim | hard | {
"lang": "python",
"repo": "pgiardiniere/notes-PythonDataScienceHandbook",
"path": "/3.08-aggregGrouping.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>## A list, array, series, or index w/ the grouping keys::
# The key can be any series or list, so long as LEN matches DF LEN
L = [0, 1, 0, 1, 2, 0]
df
df.groupby(L).sum()
# equivalent to the groupby('key') syntax used, but more verbose.
# i.e. for demonstration purposes only. This is what is abstrac... | code_fim | hard | {
"lang": "python",
"repo": "pgiardiniere/notes-PythonDataScienceHandbook",
"path": "/3.08-aggregGrouping.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ESMValGroup/ESMValCore path: /tests/unit/preprocessor/_derive/test_uajet.py
"""Test derivation of `uajet`."""
import iris
import numpy as np
import pytest
from esmvalcore.preprocessor._derive import uajet
TIME_COORD = iris.coords.DimCoord([1.0, 2.0, 3.0], standard_name='time')
LEV_COORD = iris.... | code_fim | hard | {
"lang": "python",
"repo": "ESMValGroup/ESMValCore",
"path": "/tests/unit/preprocessor/_derive/test_uajet.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.fixture
def cubes():
lat_array = np.array(
[-90.0, -80.0, -70.0, -60.0, -50.0, -40.0, -30.0, -20.0, -10.0, 0.0])
lat_coord = iris.coords.DimCoord(lat_array, standard_name='latitude')
# Produce data using Gaussian
y_40 = broadcast(gaussian(lat_array, -40.0))
y_50 = broa... | code_fim | hard | {
"lang": "python",
"repo": "ESMValGroup/ESMValCore",
"path": "/tests/unit/preprocessor/_derive/test_uajet.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>import scintillations.common
import scintillations.sequence
import scintillations.stream<|fim_prefix|># repo: FRidh/scintillations path: /scintillations/__init__.py
"""
==============
Scintillations
==============
<|fim_middle|>Atmospheric turbulence causes fluctuations in the sound speed which in effec... | code_fim | hard | {
"lang": "python",
"repo": "FRidh/scintillations",
"path": "/scintillations/__init__.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FRidh/scintillations path: /scintillations/__init__.py
"""
==============
Scintillations
==============
<|fim_suffix|>import scintillations.common
import scintillations.sequence
import scintillations.stream<|fim_middle|>Atmospheric turbulence causes fluctuations in the sound speed which in effec... | code_fim | hard | {
"lang": "python",
"repo": "FRidh/scintillations",
"path": "/scintillations/__init__.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def my_func(ab, mul=5):
al = [1] * (10 ** 6)
bl = [2] * (2 * 10 ** 7)
del bl
cl = ab * 123456 * mul
gl = al
del gl
del cl
def my_func2():
a = [1] * (10 ** 6)
b = [2] * (2 * 10 ** 7)
del b
del a
def example_argument_substitute_func(*args, **kwargs):
xl = args
yl ... | code_fim | medium | {
"lang": "python",
"repo": "peter1000/SpeedIT",
"path": "/Examples/Example4LineMemoryProfileI.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: peter1000/SpeedIT path: /Examples/Example4LineMemoryProfileI.py
""" Example implementation: <LineMemoryProfileIT>
"""
from inspect import (
currentframe,
getfile
)
from os.path import (
abspath,
dirname,
join
)
from sys import path as syspath
SCRIPT_PATH = dirname(abspath(getfile... | code_fim | hard | {
"lang": "python",
"repo": "peter1000/SpeedIT",
"path": "/Examples/Example4LineMemoryProfileI.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = speedit_line_memory(func_dict, use_func_name=True)
with open('result_output/Example4LineMemoryProfileIT2.txt', 'w') as file_:
file_.write('\n\n Example4LineMemoryProfileIT2.py output\n\n')
file_.write(result)
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++... | code_fim | hard | {
"lang": "python",
"repo": "peter1000/SpeedIT",
"path": "/Examples/Example4LineMemoryProfileI.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MisterXY89/parkhausAPI path: /parkhausAPI/api.py
from .wrapper import ParkhausWrapper
class API:
"""
Interface for the ParkhausWrapper
Attributes
----------
wrapper : ParkhausWrapper
used to perform the tasks
-> see wrapper.py for detailed doc
"""
d... | code_fim | hard | {
"lang": "python",
"repo": "MisterXY89/parkhausAPI",
"path": "/parkhausAPI/api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def getInfo(self, name, spots=True, content=True):
"""
calls getInfo on wrapper:
starts the process of getting the soup, parsing it
and creating the parkhaus object
Parameters
----------
name : str
name of the car park
| mayb... | code_fim | medium | {
"lang": "python",
"repo": "MisterXY89/parkhausAPI",
"path": "/parkhausAPI/api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return float
class MeanSquaredError(Loss):
def computeLoss(expected,outputs):
return (expected-outputs)**2
def computeGradients(expected,outputs):
return 2*(expected-outputs)<|fim_prefix|># repo: Ressnn/MiniMLCore path: /MiniMLCore/Losses.py
from abc import ABC, abs... | code_fim | medium | {
"lang": "python",
"repo": "Ressnn/MiniMLCore",
"path": "/MiniMLCore/Losses.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ressnn/MiniMLCore path: /MiniMLCore/Losses.py
from abc import ABC, abstractmethod
class Loss(ABC):
<|fim_suffix|>class MeanSquaredError(Loss):
def computeLoss(expected,outputs):
return (expected-outputs)**2
def computeGradients(expected,outputs):
return 2*(expected... | code_fim | medium | {
"lang": "python",
"repo": "Ressnn/MiniMLCore",
"path": "/MiniMLCore/Losses.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class MeanSquaredError(Loss):
def computeLoss(expected,outputs):
return (expected-outputs)**2
def computeGradients(expected,outputs):
return 2*(expected-outputs)<|fim_prefix|># repo: Ressnn/MiniMLCore path: /MiniMLCore/Losses.py
from abc import ABC, abstractmethod
class Los... | code_fim | medium | {
"lang": "python",
"repo": "Ressnn/MiniMLCore",
"path": "/MiniMLCore/Losses.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Assert that all resources of type 'ebs_block_device' that are inside a 'aws_instance' are encrypted
self.v.error_if_property_missing()
self.v.resources('aws_instance').property('ebs_block_device').property('encrypted').should_equal(True)
if __name__ == '__main__':
suite = un... | code_fim | medium | {
"lang": "python",
"repo": "UKHomeOffice/dq-aws-transition-testing",
"path": "/validate-terraform/launching-ec2-example/practise_spec.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: UKHomeOffice/dq-aws-transition-testing path: /validate-terraform/launching-ec2-example/practise_spec.py
import terraform_validate
class TestEncryptionAtRest(unittest.TestCase):
def setUp(self):
# Tell the module where to find your terraform configuration folder
self.path = o... | code_fim | hard | {
"lang": "python",
"repo": "UKHomeOffice/dq-aws-transition-testing",
"path": "/validate-terraform/launching-ec2-example/practise_spec.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_instance_ebs_block_device(self):
# Assert that all resources of type 'ebs_block_device' that are inside a 'aws_instance' are encrypted
self.v.error_if_property_missing()
self.v.resources('aws_instance').property('ebs_block_device').property('encrypted').should_equal(Tr... | code_fim | hard | {
"lang": "python",
"repo": "UKHomeOffice/dq-aws-transition-testing",
"path": "/validate-terraform/launching-ec2-example/practise_spec.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#print post3.body
#print post1.title
#print member1.age
#print member2.name<|fim_prefix|># repo: Akhidr1/forumworkshop path: /forums/main.py
import models
import stores
member1 = models.Member("Ahmed", 20)
member2 = models.Member("Nesma", 25)
post1 = models.Post("Hello!", "Happy to join your communi... | code_fim | hard | {
"lang": "python",
"repo": "Akhidr1/forumworkshop",
"path": "/forums/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(post1)
member_store = stores.MemberStore()
post_store = stores.PostStore()
member_store.add(member1)
member_store.add(member2)
print member_store.get_all()
post_store.add(post1)
post_store.add(post2)
print post_store.get_all()
#print post3.body
#print post1.title
#print member1.age
#pri... | code_fim | hard | {
"lang": "python",
"repo": "Akhidr1/forumworkshop",
"path": "/forums/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Akhidr1/forumworkshop path: /forums/main.py
import models
import stores
member1 = models.Member("Ahmed", 20)
member2 = models.Member("Nesma", 25)
post1 = models.Post("Hello!", "Happy to join your community!")
post2 = models.Post("Hi!", "First time for me here!")
post3 = models.Post("Howdy!",... | code_fim | medium | {
"lang": "python",
"repo": "Akhidr1/forumworkshop",
"path": "/forums/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return Response(state_response)
else:
# County and district scope will need to select multiple fields
# State code is needed for county/district aggregation
state_lookup = '{}_{}'.format(scope_field_name, loc_dict['state'])
fields_list.a... | code_fim | hard | {
"lang": "python",
"repo": "bsweger/usaspending-api",
"path": "/usaspending_api/search/v2/views/search.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bsweger/usaspending-api path: /usaspending_api/search/v2/views/search.py
eryset.annotate(month=ExtractMonth('action_date')) \
.values('fiscal_year', 'month')
month_set = sum_transaction_amount(month_set, filter_types=filter_types)
for trans in month_set:
... | code_fim | hard | {
"lang": "python",
"repo": "bsweger/usaspending-api",
"path": "/usaspending_api/search/v2/views/search.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif category == "cfda_programs":
if can_use_view(filters, 'SummaryCfdaNumbersView'):
queryset = get_view_queryset(filters, 'SummaryCfdaNumbersView')
queryset = queryset \
.filter(
federal_action_obligation__is... | code_fim | hard | {
"lang": "python",
"repo": "bsweger/usaspending-api",
"path": "/usaspending_api/search/v2/views/search.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __write_cache_getter__(self, code: Code, class_: Class, thread_safe_mode = False):
release_func_name = __get_c_func_name__(class_, Function('Release'))
func_head = 'std::shared_ptr<{}> {}::TryGetFromCache(void* native)'
with CodeBlock(code, func_head.format(class_.name, c... | code_fim | hard | {
"lang": "python",
"repo": "altseed/CppBindingGenerator",
"path": "/cbg/binding_generator_cplusplus/binding_generator_src.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if type_ in self.define.classes:
if type_.cache_mode != CacheMode.NoCache:
return '{}::TryGetFromCache({})'.format(type_.name, name)
else:
return 'std::shared_ptr<{}>({} != nullptr ? new {}({}) : nullptr)'.format(type_.name, name, type_.name,... | code_fim | hard | {
"lang": "python",
"repo": "altseed/CppBindingGenerator",
"path": "/cbg/binding_generator_cplusplus/binding_generator_src.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: altseed/CppBindingGenerator path: /cbg/binding_generator_cplusplus/binding_generator_src.py
def __get_cpp_type__(self, type_, is_return=False, called_by: ArgCalledBy = None) -> str:
is_ref = called_by == ArgCalledBy.Out or called_by == ArgCalledBy.Ref
if type_ == ctypes.c_b... | code_fim | hard | {
"lang": "python",
"repo": "altseed/CppBindingGenerator",
"path": "/cbg/binding_generator_cplusplus/binding_generator_src.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> locations = auto()
items = auto()
beatable = auto()
class Crystals(Enum):
# can't use IntEnum since there's also random
C0 = 0
C1 = 1
C2 = 2
C3 = 3
C4 = 4
C5 = 5
C6 = 6
C7 = 7
Random = -1
@staticmethod
def from_text(text: str) -> Crystals:
... | code_fim | hard | {
"lang": "python",
"repo": "TWest3D/MultiWorld-Utilities",
"path": "/Options.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TWest3D/MultiWorld-Utilities path: /Options.py
from __future__ import annotations
from enum import IntEnum, auto, Enum
class Toggle(IntEnum):
off = 0
on = 1
@classmethod
def from_text(cls, text: str) -> Toggle:
if text.lower() in {"off", "0", "false", "none", "null", "n... | code_fim | hard | {
"lang": "python",
"repo": "TWest3D/MultiWorld-Utilities",
"path": "/Options.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> vanilla = auto()
shuffled = auto()
chaos = auto()
mapshuffle = Toggle
compassshuffle = Toggle
keyshuffle = Toggle
bigkeyshuffle = Toggle
hints = Toggle
if __name__ == "__main__":
import argparse
test = argparse.Namespace()
test.logic = Logic.from_text("no_logic")
test.mapsh... | code_fim | hard | {
"lang": "python",
"repo": "TWest3D/MultiWorld-Utilities",
"path": "/Options.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: byung-u/ProjectEuler path: /Problem_100_199/euler_120.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Problem 120
Let r be the remainder when (a−1)^n + (a+1)^n is divided by a^2.
For example, if a = 7 and n = 3, then r = 42: 6^3 + 8^3 = 728 ≡ 42 mod 49. And as n varies, so too will r, but ... | code_fim | hard | {
"lang": "python",
"repo": "byung-u/ProjectEuler",
"path": "/Problem_100_199/euler_120.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def p120_nice():
# https://benpyeh.com/2013/06/23/project-euler-120/
L = 1000
print((L * (L + 1) * (2 * L + 1)) // 6 - 5 - (L - 2) * (L + 3) // 2 - (L // 2 - 1) * (L // 2 + 2))
def p120_nice2():
# https://blog.dreamshire.com/project-euler-120-solution/
# (a - 1) // 2 * 2 * a
pri... | code_fim | medium | {
"lang": "python",
"repo": "byung-u/ProjectEuler",
"path": "/Problem_100_199/euler_120.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pitt-cs-iot-lab/smart-pir-surveillance path: /camera_raw_record.py
from picamera import PiCamera
import time
class CameraRawRecord:
def __init__(self, duration, video_name, include_preview=False):
self.duration = duration
self.video_name = video_name
self.include_pr... | code_fim | medium | {
"lang": "python",
"repo": "pitt-cs-iot-lab/smart-pir-surveillance",
"path": "/camera_raw_record.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.include_preview is True:
self.camera.start_preview()
self.camera.start_recording(self.video_name)
time.sleep(self.duration)
self.camera.stop_recording()
self.camera.stop_preview()<|fim_prefix|># repo: pitt-cs-iot-lab/smart-pir-s... | code_fim | hard | {
"lang": "python",
"repo": "pitt-cs-iot-lab/smart-pir-surveillance",
"path": "/camera_raw_record.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Sandy4321/Ftrl-FFM path: /python/utils.py
import argparse
from collections import defaultdict
import random
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
def str2bool(v):
if isinstance(v, bool):
... | code_fim | hard | {
"lang": "python",
"repo": "Sandy4321/Ftrl-FFM",
"path": "/python/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> total_cols = cat_cols + num_cols
sample = list("0")
for field, col in enumerate(total_cols):
if col in cat_cols:
vals = cat_vals[str(col)+"_idx"]
n_unique_vals = cat_vals[str(col)+"_len"]
# i = random.randrange(n_unique_vals)
i = int(n_un... | code_fim | hard | {
"lang": "python",
"repo": "Sandy4321/Ftrl-FFM",
"path": "/python/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> total_cols = cat_cols + num_cols
label = data[label_col]
sample = list(str(label))
for field, col in enumerate(total_cols):
val = data[col]
if col in cat_cols:
idx_val_pair = (
"{}:{}:{}".format(field, cat_vals[col][val], 1)
if ff... | code_fim | hard | {
"lang": "python",
"repo": "Sandy4321/Ftrl-FFM",
"path": "/python/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> asm = opcodetools.assembler.assembler.Assembler(TEST_DIR + '/test8052.asm')
g, _i = cp.find_opcode_for_text(asm.code[3]['text'], asm)
self.assertTrue(g.mnemonic == 'MOV A,#b')
def test_6809_mode_1(self):
cp = opcodetools.cpu.cpu_manager.get_cpu_by_name('6809')
... | code_fim | hard | {
"lang": "python",
"repo": "topherCantrell/opcodetools",
"path": "/tests/test_asm/test_assembly.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: topherCantrell/opcodetools path: /tests/test_asm/test_assembly.py
import os
import unittest
import opcodetools.assembler.assembler
import opcodetools.cpu.cpu_manager
TEST_DIR = os.path.dirname(__file__)
class Test_Assembly(unittest.TestCase):
def test_6502_full(self):
asm = opco... | code_fim | hard | {
"lang": "python",
"repo": "topherCantrell/opcodetools",
"path": "/tests/test_asm/test_assembly.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> g, _i = cp.find_opcode_for_text(asm.code[2]['text'], asm)
self.assertTrue(g.mnemonic == 'JMP @A+DPTR')
def test_8052_simple_2(self):
cp = opcodetools.cpu.cpu_manager.get_cpu_by_name('8052')
cp.init_assembly()
asm = opcodetools.assembler.assembler.Assembler(TES... | code_fim | medium | {
"lang": "python",
"repo": "topherCantrell/opcodetools",
"path": "/tests/test_asm/test_assembly.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.