text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>
total += num
print("Total:", total)
main()<|fim_prefix|># repo: lfamarantine/Baruch-CIS-2300 path: /classwork/10_28_2020 (classwork).py
# In-class exercise
# input a number, iterate 5 times, and get running total;
def main():
total = 0
for _ in ran<|fim_middle|>ge(5):
nu... | code_fim | medium | {
"lang": "python",
"repo": "lfamarantine/Baruch-CIS-2300",
"path": "/classwork/10_28_2020 (classwork).py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
try:
fname = sys.argv[1]
except:
exit(1)
fd = open(fname)
stix_pkg = STIXPackage.from_xml(fd)
parse_stix(stix_pkg)<|fim_prefix|># repo: STIXProject/stixproject.github.io path: /documentation/idioms/simple-incident/simple-incident_consumer.py... | code_fim | hard | {
"lang": "python",
"repo": "STIXProject/stixproject.github.io",
"path": "/documentation/idioms/simple-incident/simple-incident_consumer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("Initial Compromise: " + str(inc.time.initial_compromise.value))
print("Incident Discovery: " + str(inc.time.incident_discovery.value))
print("Restoration Achieved: " + str(inc.time.restoration_achieved.value))
print("Incident Reported: " + str(inc.time.incident_repor... | code_fim | hard | {
"lang": "python",
"repo": "STIXProject/stixproject.github.io",
"path": "/documentation/idioms/simple-incident/simple-incident_consumer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: STIXProject/stixproject.github.io path: /documentation/idioms/simple-incident/simple-incident_consumer.py
#!/usr/bin/env python
# Copyright (c) 2014, The MITRE Corporation. All rights reserved.
# See LICENSE.txt for complete terms.
import sys
from stix.core import STIXPackage
def parse_stix(pk... | code_fim | hard | {
"lang": "python",
"repo": "STIXProject/stixproject.github.io",
"path": "/documentation/idioms/simple-incident/simple-incident_consumer.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return suggested_regexes
def suggest_tags(content):
"""
Suggest tags based on text content
"""
suggested_keywords = _suggest_keywords(content)
suggested_regexes = _suggest_regexes(content)
suggested_tag_ids = suggested_keywords | suggested_regexes
return Tag.objects.fil... | code_fim | hard | {
"lang": "python",
"repo": "SBillion/django-taggit-suggest",
"path": "/taggit_suggest/utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def suggest_tags(content):
"""
Suggest tags based on text content
"""
suggested_keywords = _suggest_keywords(content)
suggested_regexes = _suggest_regexes(content)
suggested_tag_ids = suggested_keywords | suggested_regexes
return Tag.objects.filter(id__in=suggested_tag_ids)<... | code_fim | medium | {
"lang": "python",
"repo": "SBillion/django-taggit-suggest",
"path": "/taggit_suggest/utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SBillion/django-taggit-suggest path: /taggit_suggest/utils.py
import re
from taggit_suggest.models import TagKeyword, TagRegex
from taggit.models import Tag
def _suggest_keywords(content):
"""
Suggest by keywords
"""
suggested_keywords = set()
keywords = TagKeyword.objects.... | code_fim | medium | {
"lang": "python",
"repo": "SBillion/django-taggit-suggest",
"path": "/taggit_suggest/utils.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># Python code to demonstrate addition of tuple to a set.
# s = set()
# t = ('f', 'o')
#
# # adding tuple t to set s.
# s.add(t)
#
# print(s)
power = []
for i in range(-10, -90, -5):
power.append(i)
print(power)
print("Power in ra")<|fim_prefix|># repo: WishmaL/Mobile-Network-Simulation path: /Tests/... | code_fim | hard | {
"lang": "python",
"repo": "WishmaL/Mobile-Network-Simulation",
"path": "/Tests/try2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WishmaL/Mobile-Network-Simulation path: /Tests/try2.py
# import math
# # import Ba
# import random
#
# list1 = []
# list2 = []
# list3 = []
#
# for i in range(1,30,2):
#
# list1.append(i)
# for i in range(31, 60, 2):
#
# list2.append(i)
# for i in range(61, 90, 2):
#
# list3.append(i)... | code_fim | hard | {
"lang": "python",
"repo": "WishmaL/Mobile-Network-Simulation",
"path": "/Tests/try2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: threewisemonkeys-as/genrl path: /tests/test_bandit/test_cb_agents.py
import shutil
from genrl.agents import (
BernoulliMAB,
BootstrapNeuralAgent,
FixedAgent,
LinearPosteriorAgent,
NeuralGreedyAgent,
NeuralLinearPosteriorAgent,
NeuralNoiseSamplingAgent,
Variational... | code_fim | hard | {
"lang": "python",
"repo": "threewisemonkeys-as/genrl",
"path": "/tests/test_bandit/test_cb_agents.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_bootstrap_neural_agent(self) -> None:
self._test_fn(BootstrapNeuralAgent)
def test_neural_noise_sampling_agent(self) -> None:
self._test_fn(NeuralNoiseSamplingAgent)
def test_fixed_agent(self) -> None:
self._test_fn(FixedAgent)<|fim_prefix|># repo: threewisem... | code_fim | hard | {
"lang": "python",
"repo": "threewisemonkeys-as/genrl",
"path": "/tests/test_bandit/test_cb_agents.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_neural_greedy_agent(self) -> None:
self._test_fn(NeuralGreedyAgent)
def test_variational_agent(self) -> None:
self._test_fn(VariationalAgent)
def test_bootstrap_neural_agent(self) -> None:
self._test_fn(BootstrapNeuralAgent)
def test_neural_noise_samplin... | code_fim | hard | {
"lang": "python",
"repo": "threewisemonkeys-as/genrl",
"path": "/tests/test_bandit/test_cb_agents.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jm-huang/StratiPy path: /stratipy/nbs.py
#!/usr/bin/env python
# coding: utf-8
import sys
import os
sys.path.append(os.path.abspath('../../stratipy'))
from stratipy import (load_data, formatting_data, filtering_diffusion,
nmf_bootstrap, consensus_clustering,
... | code_fim | hard | {
"lang": "python",
"repo": "jm-huang/StratiPy",
"path": "/stratipy/nbs.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> nmf_bootstrap.bootstrap(
result_folder, mut_type, mut_propag, ppi_final,
influence_weight, simplification, alpha, tol, keep_singletons,
ngh_max, min_mutation, max_mutation, n_components,
n_permutations, run_bootstrap, lambd, tol_nmf,
compute_gene_clustering, sub... | code_fim | hard | {
"lang": "python",
"repo": "jm-huang/StratiPy",
"path": "/stratipy/nbs.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: raybellwaves/xclim path: /xclim/core/cfchecks.py
# noqa: D205,D400
"""
CF-Convention checking
======================
Utilities designed to verify the compliance of metadata with the CF-Convention.
"""
import fnmatch
from typing import Sequence, Union
from .formatting import parse_cell_methods
f... | code_fim | hard | {
"lang": "python",
"repo": "raybellwaves/xclim",
"path": "/xclim/core/cfchecks.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def check_valid_temperature(var, units):
r"""Check that variable is air temperature."""
check_valid(var, "standard_name", "air_temperature")
check_valid(var, "units", units)
def check_valid_discharge(var):
r"""Check that the variable is a discharge."""
check_valid(var, "standard_nam... | code_fim | hard | {
"lang": "python",
"repo": "raybellwaves/xclim",
"path": "/xclim/core/cfchecks.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def check_valid_mean_temperature(var, units="K"):
r"""Check that a variable is a valid daily mean temperature."""
check_valid_temperature(var, units)
check_valid(var, "cell_methods", "time: mean within days")
def check_valid_max_temperature(var, units="K"):
r"""Check that a variable is ... | code_fim | hard | {
"lang": "python",
"repo": "raybellwaves/xclim",
"path": "/xclim/core/cfchecks.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> sum_total = 0
sum_current = 0
print("initially",U.size())
#print(torch.matmul(U,U.t()))
for i in range(20):
sum_total += sigma[i][i]
index = -1
#print("total1",sum_total)
for i in range(20):
sum_current += sigma[i][i]
x = (sum_current*100.0)/sum_total
if(x>95):
index = i
break
inde... | code_fim | medium | {
"lang": "python",
"repo": "davidrmh/Riemannian_Geometry_of_Deep_Generative_Models",
"path": "/MNIST/PCA.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: davidrmh/Riemannian_Geometry_of_Deep_Generative_Models path: /MNIST/PCA.py
import torch
import torchvision
from torch import nn
from torch import optim
import torch.nn.functional as F
from torch.autograd import Variable
import random
import numpy as np
def reduction1(U, sigma, vh, x1):
y = 0
z... | code_fim | medium | {
"lang": "python",
"repo": "davidrmh/Riemannian_Geometry_of_Deep_Generative_Models",
"path": "/MNIST/PCA.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def reduction(U, sigma, vh, x1):
sum_total = 0
sum_current = 0
print("initially",U.size())
#print(torch.matmul(U,U.t()))
for i in range(20):
sum_total += sigma[i][i]
index = -1
#print("total1",sum_total)
for i in range(20):
sum_current += sigma[i][i]
x = (sum_current*100.0)/sum_total
if(x... | code_fim | hard | {
"lang": "python",
"repo": "davidrmh/Riemannian_Geometry_of_Deep_Generative_Models",
"path": "/MNIST/PCA.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>x = [14, 27, 1, 4, 2, 50, 3, 1]
y = [2, 4, -4, 3, 1, 1, 14, 27, 50]
answer(x,y)
print('---> -4')<|fim_prefix|># repo: kevinpz/google-foobar path: /previous_code_1/level1/prison_labor_dodgers.py
#!/usr/bin/env python2
def answer(x, y):
#check in which list we have the moved worker
if len(x) > le... | code_fim | medium | {
"lang": "python",
"repo": "kevinpz/google-foobar",
"path": "/previous_code_1/level1/prison_labor_dodgers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kevinpz/google-foobar path: /previous_code_1/level1/prison_labor_dodgers.py
#!/usr/bin/env python2
def answer(x, y):
#check in which list we have the moved worker
if len(x) > len(y):
moved_list = [i for i in x if i not in y]
else:
moved_list = [i for i in y if i not i... | code_fim | medium | {
"lang": "python",
"repo": "kevinpz/google-foobar",
"path": "/previous_code_1/level1/prison_labor_dodgers.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>answer(x,y)
print('---> 6')
x = [14, 27, 1, 4, 2, 50, 3, 1]
y = [2, 4, -4, 3, 1, 1, 14, 27, 50]
answer(x,y)
print('---> -4')<|fim_prefix|># repo: kevinpz/google-foobar path: /previous_code_1/level1/prison_labor_dodgers.py
#!/usr/bin/env python2
def answer(x, y):
#check in which list we have the mo... | code_fim | medium | {
"lang": "python",
"repo": "kevinpz/google-foobar",
"path": "/previous_code_1/level1/prison_labor_dodgers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # write trace files
for conf_name, conf_traces in traces.items():
conf_traces.write(os.path.join(self.result_path, conf_name, 'trace.trc'))
def _duration(self):
return time.time() - self.time_start
def _run_thread(self, thread_id, max_duration):
whil... | code_fim | hard | {
"lang": "python",
"repo": "renkekuhlmann/gams-benchmark",
"path": "/src/benchmark/scheduler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: renkekuhlmann/gams-benchmark path: /src/benchmark/scheduler.py
#!/usr/bin/env python3
""" Scheduler """
import os
import glob
import time
import queue
import threading
from job import Job
from trace_dict import TraceDict
from trace_record import TraceRecord
from result import Result
class Sche... | code_fim | hard | {
"lang": "python",
"repo": "renkekuhlmann/gams-benchmark",
"path": "/src/benchmark/scheduler.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.kwargs['view_instance'].filter_queryset = lambda x: x.filter(pk__in=[])
response = ListModelKeyBit().get_data(**self.kwargs)
self.assertEqual(response, None)
class RetrieveSqlQueryKeyBitTest(TestCase):
def setUp(self):
self.kwargs = {
'params': None,
... | code_fim | hard | {
"lang": "python",
"repo": "chibisov/drf-extensions",
"path": "/tests_app/tests/unit/key_constructor/bits/tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chibisov/drf-extensions path: /tests_app/tests/unit/key_constructor/bits/tests.py
return {
'id': 1,
'geobase_id': 123,
'name': 'London',
}
self.kwargs['params'] = ['name', 'geobase_id']
expect... | code_fim | hard | {
"lang": "python",
"repo": "chibisov/drf-extensions",
"path": "/tests_app/tests/unit/key_constructor/bits/tests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class UserKeyBitTest(TestCase):
def setUp(self):
self.kwargs = {
'params': None,
'view_instance': None,
'view_method': None,
'request': factory.get(''),
'args': None,
'kwargs': None
}
self.user = Mock()
... | code_fim | hard | {
"lang": "python",
"repo": "chibisov/drf-extensions",
"path": "/tests_app/tests/unit/key_constructor/bits/tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wilseypa/lhf path: /python_tests/DataScripts/tdaPlots.py
import numpy as np
from ripser import ripser
from persim import plot_diagrams
from sklearn import metrics
import argparse
import matplotlib as mpl
import pylab
from palettable.colorbrewer.qualitative import Set1_9
from palettable.tableau im... | code_fim | hard | {
"lang": "python",
"repo": "wilseypa/lhf",
"path": "/python_tests/DataScripts/tdaPlots.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ax1 = fig.add_subplot(1,2,1)
ax2 = fig.add_subplot(1,2,2)
######BARCODES########
indexNaN = np.isinf(data)
if(args.inf):
print("test")
data[indexNaN] = float(args.inf)
else:
data[indexNaN] = 1
# select our color map
colorPalette = Set1_9.mpl_colors
# set the markers for the scatter plotting of the p... | code_fim | hard | {
"lang": "python",
"repo": "wilseypa/lhf",
"path": "/python_tests/DataScripts/tdaPlots.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bhollis/reviewboard path: /reviewboard/extensions/base.py
from djblets.extensions.base import Extension, ExtensionManager
<|fim_suffix|> return _extension_manager<|fim_middle|>
_extension_manager = None
def get_extension_manager():
global _extension_manager
if not _extension_manager... | code_fim | medium | {
"lang": "python",
"repo": "bhollis/reviewboard",
"path": "/reviewboard/extensions/base.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not _extension_manager:
_extension_manager = ExtensionManager("reviewboard.extensions")
return _extension_manager<|fim_prefix|># repo: bhollis/reviewboard path: /reviewboard/extensions/base.py
from djblets.extensions.base import Extension, ExtensionManager
<|fim_middle|>
_extension_m... | code_fim | medium | {
"lang": "python",
"repo": "bhollis/reviewboard",
"path": "/reviewboard/extensions/base.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> global _extension_manager
if not _extension_manager:
_extension_manager = ExtensionManager("reviewboard.extensions")
return _extension_manager<|fim_prefix|># repo: bhollis/reviewboard path: /reviewboard/extensions/base.py
from djblets.extensions.base import Extension, ExtensionManag... | code_fim | easy | {
"lang": "python",
"repo": "bhollis/reviewboard",
"path": "/reviewboard/extensions/base.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: triton-inference-server/server path: /qa/L0_query/query_e2e.py
#!/usr/bin/env python
# Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following co... | code_fim | hard | {
"lang": "python",
"repo": "triton-inference-server/server",
"path": "/qa/L0_query/query_e2e.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Set up too small CUDA shared memory for outputs, expect query
# returns default value
triton_client.unregister_system_shared_memory()
triton_client.unregister_cuda_shared_memory()
shm_op0_handle = cudashm.create_shared_memory_region("output0_data", 1, 0)
s... | code_fim | hard | {
"lang": "python",
"repo": "triton-inference-server/server",
"path": "/qa/L0_query/query_e2e.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
triton_client.infer(model_name="query", inputs=inputs, outputs=outputs)
self.assertTrue(False, "expect error with query information")
except InferenceServerException as ex:
self.assertTrue("OUTPUT0 GPU 0" in ex.message())
self.assertTrue... | code_fim | hard | {
"lang": "python",
"repo": "triton-inference-server/server",
"path": "/qa/L0_query/query_e2e.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> _, max_val, _, max_loc = cv2.minMaxLoc(match)
# max_loc is best match when using TM_CCOEFF method
#bottom_right = (max_loc[0] + self._cursor_width,
# max_loc[1] + self._cursor_height)
if max_val > self._cursor_threshold:
frame_set[self._cursor_stream_... | code_fim | hard | {
"lang": "python",
"repo": "reubenjacob/video-vectorization",
"path": "/video_processing/processors/cursor_tracker.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def process(self, frame_set):
if (frame_set.get(self._background_stream_name, False) and
self._background_image is None):
self._background_image = cv2.cvtColor(
frame_set[self._background_stream_name].data, cv2.COLOR_BGR2GRAY)
if frame_set.get(self._video_stream_name, Fal... | code_fim | hard | {
"lang": "python",
"repo": "reubenjacob/video-vectorization",
"path": "/video_processing/processors/cursor_tracker.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: reubenjacob/video-vectorization path: /video_processing/processors/cursor_tracker.py
# Copyright 2019 Google LLC.
"""Tracks the cursor in a video.
Given a template image for a cursor, adds a stream containing coordinates of the
cursor in the video.
"""
from __future__ import absolute_import
fro... | code_fim | hard | {
"lang": "python",
"repo": "reubenjacob/video-vectorization",
"path": "/video_processing/processors/cursor_tracker.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>figure.suptitle("Euler angles, internal states, and flags")
axes[0].plot(timestamp, euler[:, 0], "tab:red", label="Roll")
axes[0].plot(timestamp, euler[:, 1], "tab:green", label="Pitch")
axes[0].plot(timestamp, euler[:, 2], "tab:blue", label="Yaw")
axes[0].set_ylabel("Degrees")
axes[0].grid()
axes[0].leg... | code_fim | hard | {
"lang": "python",
"repo": "xioTechnologies/Fusion",
"path": "/Python/advanced_example.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xioTechnologies/Fusion path: /Python/advanced_example.py
import imufusion
import matplotlib.pyplot as pyplot
import numpy
import sys
# Import sensor data
data = numpy.genfromtxt("sensor_data.csv", delimiter=",", skip_header=1)
sample_rate = 100 # 100 Hz
timestamp = data[:, 0]
gyroscope = data... | code_fim | hard | {
"lang": "python",
"repo": "xioTechnologies/Fusion",
"path": "/Python/advanced_example.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def plot_bool(axis, x, y, label):
axis.plot(x, y, "tab:cyan", label=label)
pyplot.sca(axis)
pyplot.yticks([0, 1], ["False", "True"])
axis.grid()
axis.legend()
# Plot Euler angles
figure, axes = pyplot.subplots(nrows=10, sharex=True, gridspec_kw={"height_ratios": [6, 1, 2, 1, 1, 1, 2... | code_fim | hard | {
"lang": "python",
"repo": "xioTechnologies/Fusion",
"path": "/Python/advanced_example.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SAP/project-kb path: /prospector/service/main.py
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import HTMLResponse, RedirectResponse
# from .dependencies import oauth2_scheme
from api.routers import jobs, nvd, preprocessed, u... | code_fim | hard | {
"lang": "python",
"repo": "SAP/project-kb",
"path": "/prospector/service/main.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
config = parse_config_file()
logger.setLevel(config.log_level)
uvicorn.run(
app,
host="0.0.0.0",
port=8000,
)<|fim_prefix|># repo: SAP/project-kb path: /prospector/service/main.py
import uvicorn
from fastapi import FastAPI
from fastapi.m... | code_fim | medium | {
"lang": "python",
"repo": "SAP/project-kb",
"path": "/prospector/service/main.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>app = FastAPI(openapi_tags=api_metadata)
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:3000", "localhost:3000"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(users.router)
app.include_router(nvd.router)
app.include_rout... | code_fim | hard | {
"lang": "python",
"repo": "SAP/project-kb",
"path": "/prospector/service/main.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def tag_objs(db, count, project, tags):
by_tag = defaultdict(list)
for i in range(count):
cls = sqldb._tagged[i % len(sqldb._tagged)]
obj = cls()
by_tag[tags[i % len(tags)]].append(obj)
db.session.add(obj)
db.session.commit()
for tag, objs in by_tag.items()... | code_fim | hard | {
"lang": "python",
"repo": "balabin/mlrun",
"path": "/tests/test_sqldb.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: balabin/mlrun path: /tests/test_sqldb.py
# Copyright 2019 Iguazio
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# U... | code_fim | hard | {
"lang": "python",
"repo": "balabin/mlrun",
"path": "/tests/test_sqldb.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> response_mock = MagicMock()
response_mock.status_code = http_status
assert stream.should_retry(response_mock) == should_retry
def test_backoff_time(stream):
response_mock = MagicMock()
expected_backoff_time = 60
assert stream.backoff_time(response_mock) == expected_backoff_time<|... | code_fim | hard | {
"lang": "python",
"repo": "alldatacenter/alldata",
"path": "/dts/airbyte/airbyte-integrations/connectors/source-onesignal/unit_tests/test_streams.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alldatacenter/alldata path: /dts/airbyte/airbyte-integrations/connectors/source-onesignal/unit_tests/test_streams.py
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
from http import HTTPStatus
from unittest.mock import MagicMock
import pytest
import requests
from source_onesignal.s... | code_fim | hard | {
"lang": "python",
"repo": "alldatacenter/alldata",
"path": "/dts/airbyte/airbyte-integrations/connectors/source-onesignal/unit_tests/test_streams.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.mark.parametrize(
("http_status", "should_retry"),
[
(HTTPStatus.OK, False),
(HTTPStatus.BAD_REQUEST, False),
(HTTPStatus.TOO_MANY_REQUESTS, True),
(HTTPStatus.INTERNAL_SERVER_ERROR, True),
],
)
def test_should_retry(stream, http_status, should_retry):
... | code_fim | hard | {
"lang": "python",
"repo": "alldatacenter/alldata",
"path": "/dts/airbyte/airbyte-integrations/connectors/source-onesignal/unit_tests/test_streams.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: buptbf/IIP_Salient360_2018 path: /Test_images_Demo.py
from __future__ import division
import os, cv2, sys, re
import numpy as np
import keras.backend as K
from keras.optimizers import SGD
from keras.callbacks import EarlyStopping, ModelCheckpoint, TensorBoard, ReduceLROnPlateau
import tensorfl... | code_fim | hard | {
"lang": "python",
"repo": "buptbf/IIP_Salient360_2018",
"path": "/Test_images_Demo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> res = postprocess_predictions(predimg, height, width)
cv2.imwrite(output_folder + name + '_woCB.png', res.astype(int))
if with_CB:
res = addCB(res,cmap)
cv2.imwrite(output_folder + name + '.png', res.astype(int))
with open(output_folder + name + '.bin',... | code_fim | hard | {
"lang": "python",
"repo": "buptbf/IIP_Salient360_2018",
"path": "/Test_images_Demo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: databill86/HyperFoods path: /venv/lib/python3.6/site-packages/jupyterlab_server/servertest.py
# Shim for notebook server or jupyter_server
#
# Provides:
# - ServerTestBase
# - assert_http_error
#
try:
from notebook.tests.launchnotebook import (
assert_http_error,
NotebookTe... | code_fim | medium | {
"lang": "python",
"repo": "databill86/HyperFoods",
"path": "/venv/lib/python3.6/site-packages/jupyterlab_server/servertest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Base as ServerTestBase
)
except ImportError:
from jupyter_server.tests.launchnotebook import assert_http_error # noqa
from jupyter_server.tests.launchserver import ServerTestBase # noqa<|fim_prefix|># repo: databill86/HyperFoods path: /venv/lib/python3.6/site-packages/jupyterlab_serv... | code_fim | medium | {
"lang": "python",
"repo": "databill86/HyperFoods",
"path": "/venv/lib/python3.6/site-packages/jupyterlab_server/servertest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>sert_http_error # noqa
from jupyter_server.tests.launchserver import ServerTestBase # noqa<|fim_prefix|># repo: databill86/HyperFoods path: /venv/lib/python3.6/site-packages/jupyterlab_server/servertest.py
# Shim for notebook server or jupyter_server
#
# Provides:
# - ServerTestBase
# - as... | code_fim | medium | {
"lang": "python",
"repo": "databill86/HyperFoods",
"path": "/venv/lib/python3.6/site-packages/jupyterlab_server/servertest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aaornsc/OpenPNM path: /scripts/example_multiphase_diffusion.py
r"""
Example: Multiphase diffusion with heterogeneous reaction
2D network, consists of air and water. Air occupies the middle of the
network and is surrounded by two film-like regions of water at the top
and the bottom. T... | code_fim | hard | {
"lang": "python",
"repo": "aaornsc/OpenPNM",
"path": "/scripts/example_multiphase_diffusion.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Define physics
phys = op.physics.Standard(network=net, phase=mphase, geometry=geom)
# Assign a partition coefficient (concentration ratio)
K_water_air = 0.5 # c @ water / c @ air
const = op.models.misc.constant
mphase.set_binary_partition_coef(propname="throat.partition_coef",
... | code_fim | hard | {
"lang": "python",
"repo": "aaornsc/OpenPNM",
"path": "/scripts/example_multiphase_diffusion.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Fickian diffusion
fd = op.algorithms.FickianDiffusion(network=net, phase=mphase)
# Set source term
phys["pore.A1"] = -1e-8 * geom["pore.area"]
phys["pore.A2"] = 0.0
linear = op.models.physics.generic_source_term.linear
phys.add_model(propname="pore.rxn", model=linear, X="pore.concentration",
... | code_fim | hard | {
"lang": "python",
"repo": "aaornsc/OpenPNM",
"path": "/scripts/example_multiphase_diffusion.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>") if isfile(join(".", f))]
print(onlyfiles)<|fim_prefix|># repo: prewittdavon/TEDVis path: /TEDx/Titles_starting_0_to_9/names.py
from os import listdir
from os.path import isfile, join
from operator import itemgetter, a<|fim_middle|>ttrgetter
onlyfiles = [f for f in listdir(". | code_fim | easy | {
"lang": "python",
"repo": "prewittdavon/TEDVis",
"path": "/TEDx/Titles_starting_0_to_9/names.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: prewittdavon/TEDVis path: /TEDx/Titles_starting_0_to_9/names.py
from os import listdir
from os.path import is<|fim_suffix|>") if isfile(join(".", f))]
print(onlyfiles)<|fim_middle|>file, join
from operator import itemgetter, attrgetter
onlyfiles = [f for f in listdir(". | code_fim | medium | {
"lang": "python",
"repo": "prewittdavon/TEDVis",
"path": "/TEDx/Titles_starting_0_to_9/names.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: infobeisel/mbnwcModSys path: /module_game_menus.py
r",12), #Player troops' morale x1.2
(start_presentation, "prsnt_singleplayer_campain_map"),
#(jump_to_menu, "mnu_start_game_1"),
#(assign,"$g_finished_missions",2),
]
),
("start_normal",[],"Normal",... | code_fim | hard | {
"lang": "python",
"repo": "infobeisel/mbnwcModSys",
"path": "/module_game_menus.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> ("continue",[],"Yes, please.",
[
(stop_all_sounds,1),
(modify_visitors_at_site,"scn_tutorial"),
(reset_visitors, 0),
(set_player_troop, "trp_player"),
(assign, "$g_player_troop", "trp_player"),
(troop_raise_attribute, "$g_player_troop", ca_streng... | code_fim | hard | {
"lang": "python",
"repo": "infobeisel/mbnwcModSys",
"path": "/module_game_menus.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: infobeisel/mbnwcModSys path: /module_game_menus.py
n_banner, "mesh_banner_kingdom_b"),
(faction_set_slot, "fac_prussia", slot_faction_banner, "mesh_banner_kingdom_c"),
(faction_set_slot, "fac_russia", slot_faction_banner, "mesh_banner_kingdom_a"),
(faction_set_slot, "fac_austria... | code_fim | hard | {
"lang": "python",
"repo": "infobeisel/mbnwcModSys",
"path": "/module_game_menus.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: josephkirk/cross3d path: /cross3d/abstract/mixer/clip.py
##
# \namespace cross3d.abstract.clip
#
# \remarks The AbstractClip class provides a base implementation of a
# cross-application interface to a clip.
#
# \author willc
# \author Blur Studio
# \date 10/15/15
#
import cross... | code_fim | hard | {
"lang": "python",
"repo": "josephkirk/cross3d",
"path": "/cross3d/abstract/mixer/clip.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def sourceStart(self):
return None
@property
def scale(self):
return None
@property
def track(self):
"""The Track instance for the Clip's parent Track."""
return self._track
@track.setter
def track(self, value):
self._track = value
@property
def trimEnd(se... | code_fim | hard | {
"lang": "python",
"repo": "josephkirk/cross3d",
"path": "/cross3d/abstract/mixer/clip.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mbark/messaging-service path: /tests/conftest.py
import os
import pytest
import redis
from falcon import testing
from msgr.app import create
from msgr.db import DbClient
def is_responsive(client):
try:
return client.ping()
except redis.ConnectionError:
return False
@... | code_fim | hard | {
"lang": "python",
"repo": "mbark/messaging-service",
"path": "/tests/conftest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass
def add(self, key, value):
return True
def get_range(self, key, start, stop):
return []
def get_unread(self, key):
return []
def remove(self, key, elements):
return [0, 0]<|fim_prefix|># repo: mbark/messaging-service path: /tests/conftest.p... | code_fim | medium | {
"lang": "python",
"repo": "mbark/messaging-service",
"path": "/tests/conftest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i_epoch_pi in range(self.epochs):
#mb_advantages = b_advantages
newlogproba, entropy = self.evaluate(b_obs, b_actions)
_,state_v = self.policy(b_obs)
state_v = state_v.reshape(-1,1)
e_advantages = returns - state_v.detach()
... | code_fim | hard | {
"lang": "python",
"repo": "Sopitta/RL-Pong",
"path": "/cartpole_test/agent.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> v_loss_unclipped = self.MseLoss(new_values,b_returns[minibatch_ind])
#v_loss_unclipped = ((new_values - b_returns[minibatch_ind]) ** 2)
v_clipped = b_values[minibatch_ind] + torch.clamp(new_values - b_values[minibatch_ind],
... | code_fim | hard | {
"lang": "python",
"repo": "Sopitta/RL-Pong",
"path": "/cartpole_test/agent.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Sopitta/RL-Pong path: /cartpole_test/agent.py
import torch
import torch.nn.functional as F
from torch.distributions import Normal
import numpy as np
class Policy(torch.nn.Module):
def __init__(self, state_space, action_space):
super().__init__()
self.state_space = state_spac... | code_fim | hard | {
"lang": "python",
"repo": "Sopitta/RL-Pong",
"path": "/cartpole_test/agent.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: terryhahm/ARAM path: /dataAnalysis.py
#%%
import pandas as pd
import matplotlib.pyplot as plt
import riotConstant
# Language / Region / Champion / Tier
# will be passed as parameter from user's selection
# Read Data
def readData( language, region, championName, tier ):
RIOTConstant = riot... | code_fim | hard | {
"lang": "python",
"repo": "terryhahm/ARAM",
"path": "/dataAnalysis.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print( data.groupby(["win", "spell1Id", "spell2Id"]).size() )
print( data.groupby(["spell1Id", "spell2Id"]).size() )
def runeByWinRate( language, region, championName, tier ):
data = readData( language, region, championName, tier)
# print( data[['win', 'spell1Id', 'spell2Id']].head(5) )
... | code_fim | hard | {
"lang": "python",
"repo": "terryhahm/ARAM",
"path": "/dataAnalysis.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> championId = RIOTConstant.getChampionId(championName)
data = readData( language, region, championName, tier)
# Changin the combination of spells in ascending order to check frequency
print( data[['spell1Id', 'spell2Id']].head(5) )
spell_combination = data[['spell1Id', 'spell2Id']]
... | code_fim | hard | {
"lang": "python",
"repo": "terryhahm/ARAM",
"path": "/dataAnalysis.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mwinding/connectome_analysis path: /scripts/identify_neuron_classes/plot_LNs-PNs_supplemental.py
#%%
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from pymaid_creds import url, name, password, token
from data_settings import pairs_path
import pymaid... | code_fim | hard | {
"lang": "python",
"repo": "mwinding/connectome_analysis",
"path": "/scripts/identify_neuron_classes/plot_LNs-PNs_supplemental.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>LN_ipsi = np.intersect1d(LN, ipsi)
LN_bilat = np.intersect1d(LN, bilateral)
LN_contra = np.intersect1d(LN, contra)
# create dataframes with left/right neuron pairs; nonpaired neurons had duplicated skids in left/right column
LN_ipsi = Promat.load_pairs_from_annotation(annot='', pairList=pairs, return_typ... | code_fim | hard | {
"lang": "python",
"repo": "mwinding/connectome_analysis",
"path": "/scripts/identify_neuron_classes/plot_LNs-PNs_supplemental.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># sort LN_ipsi with published neurons first
pub = [7941652, 7941642, 7939979, 8311264, 7939890, 5291791, 8102935, 8877971, 8274021, 10555409, 7394271, 8273369, 17414715, 8700125, 8480418, 15571194]
pub_names = ['Broad D1', 'Broad D2', 'Broad T1', 'Broad T2', 'Broad T3', 'picky 0', 'picky 1', 'picky 2', 'p... | code_fim | hard | {
"lang": "python",
"repo": "mwinding/connectome_analysis",
"path": "/scripts/identify_neuron_classes/plot_LNs-PNs_supplemental.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bsb808/python-algorithms path: /examples/astar_ex.py
import algorithms.a_star_path_finding as pf
import astar_utils as autils
reload(autils)
<|fim_suffix|>fig=figure(1)
clf()
autils.plotAstar(a,path)
show()<|fim_middle|>a = pf.AStar()
walls = ((0, 5), (1, 0), (1, 1), (1, 5), (2, 3),
(3,... | code_fim | hard | {
"lang": "python",
"repo": "bsb808/python-algorithms",
"path": "/examples/astar_ex.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fig=figure(1)
clf()
autils.plotAstar(a,path)
show()<|fim_prefix|># repo: bsb808/python-algorithms path: /examples/astar_ex.py
import algorithms.a_star_path_finding as pf
import astar_utils as autils
reload(autils)
<|fim_middle|>a = pf.AStar()
walls = ((0, 5), (1, 0), (1, 1), (1, 5), (2, 3),
(3,... | code_fim | hard | {
"lang": "python",
"repo": "bsb808/python-algorithms",
"path": "/examples/astar_ex.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return False
def has_attacked_trusted(life, life_id):
return _has_attacked(life, life_id, judgement.get_trusted(life))
def has_attacked_self(life, life_id):
return len(lfe.get_memory(life, matches={'text': 'shot_by', 'target': life_id}))>0
def react_to_attack(life, life_id):
_knows = brain.knows_al... | code_fim | hard | {
"lang": "python",
"repo": "jeason1997/Reactor-3",
"path": "/alife/stats.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _has_attacked(life, life_id, target_list):
for memory in lfe.get_memory(life, matches={'text': 'heard about attack', 'attacker': life_id}):
if memory['target'] in target_list:
return True
return False
def has_attacked_trusted(life, life_id):
return _has_attacked(life, life_id, judgement.get... | code_fim | hard | {
"lang": "python",
"repo": "jeason1997/Reactor-3",
"path": "/alife/stats.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jeason1997/Reactor-3 path: /alife/stats.py
dint(1, MAX_CHARISMA)
def desires_job(life):
#TODO: We recalculate this, but the answer is always the same.
_wont = brain.get_flag(life, 'wont_work')
if life['job'] or _wont:
if _wont:
_wont = brain.flag(life, 'wont_work', value=_wont-1)
... | code_fim | hard | {
"lang": "python",
"repo": "jeason1997/Reactor-3",
"path": "/alife/stats.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>setattr(judge,'target',['OSCNrequest'])<|fim_prefix|># repo: julia-codes/oscn path: /oscn/parse/judge.py
import re
def judge(oscn_html):
<|fim_middle|> judge_re = r'Judge:\s*([\w\s\,]*)'
find_judge = re.compile(judge_re, re.M)
judge_search = find_judge.search(oscn_html)
if judge_search.g... | code_fim | hard | {
"lang": "python",
"repo": "julia-codes/oscn",
"path": "/oscn/parse/judge.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: julia-codes/oscn path: /oscn/parse/judge.py
import re
def judge(oscn_html):
<|fim_suffix|>setattr(judge,'target',['OSCNrequest'])<|fim_middle|> judge_re = r'Judge:\s*([\w\s\,]*)'
find_judge = re.compile(judge_re, re.M)
judge_search = find_judge.search(oscn_html)
if judge_search.g... | code_fim | hard | {
"lang": "python",
"repo": "julia-codes/oscn",
"path": "/oscn/parse/judge.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stepheku/cerner-domain-powerplan-compare path: /domain_pathway_compare.py
# -*- coding: ISO-8859-1 -*-
from pathlib import Path
import csv
STRING_ENCODING = "utf_8_sig"
def get_columns_from_csv(file_path: Path) -> list:
with open(file_path, "r", ) as f:
reader = csv.DictReader(f)
... | code_fim | hard | {
"lang": "python",
"repo": "stepheku/cerner-domain-powerplan-compare",
"path": "/domain_pathway_compare.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return output
def main():
script_path = Path(__file__).parent
b0783 = csv_to_json(Path(script_path, "data", "b0783_pathway.csv"))
p0783 = csv_to_json(Path(script_path, "data", "p0783_pathway.csv"))
output = []
for plan_desc, plan_dict in b0783.items():
b0783_plan_dict =... | code_fim | hard | {
"lang": "python",
"repo": "stepheku/cerner-domain-powerplan-compare",
"path": "/domain_pathway_compare.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
script_path = Path(__file__).parent
b0783 = csv_to_json(Path(script_path, "data", "b0783_pathway.csv"))
p0783 = csv_to_json(Path(script_path, "data", "p0783_pathway.csv"))
output = []
for plan_desc, plan_dict in b0783.items():
b0783_plan_dict = plan_dict
p... | code_fim | hard | {
"lang": "python",
"repo": "stepheku/cerner-domain-powerplan-compare",
"path": "/domain_pathway_compare.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if run_in_parallel == False: thread_no = 1
self._pool = Pool(thread_no)
return self._pool
def close_pool(self, pool, force_process_respawn=False):
if pool is not None:
if (self._thread_technique != 'multiprocessing' and
self._multiprocessi... | code_fim | hard | {
"lang": "python",
"repo": "vishalbelsare/findatapy",
"path": "/findatapy/util/swimpool.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vishalbelsare/findatapy path: /findatapy/util/swimpool.py
__author__ = "saeedamen" # Saeed Amen
#
# Copyright 2016 Cuemacro
#
# 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 Licen... | code_fim | hard | {
"lang": "python",
"repo": "vishalbelsare/findatapy",
"path": "/findatapy/util/swimpool.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: evd995/face_recognition_toolbox path: /face_recognition_toolbox/methods/SqueezeNetManager.py
"""
WARNING: OpenFace requires Python 2.7
Module for managing the SqueezeNet recognition method.
Obtained from https://github.com/kgrm/face-recog-eval
"""
import os
import cv2
import numpy as np
from ke... | code_fim | hard | {
"lang": "python",
"repo": "evd995/face_recognition_toolbox",
"path": "/face_recognition_toolbox/methods/SqueezeNetManager.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> K.set_image_dim_ordering('th')
def predict(self, image, normalize=True):
"""
Get encoding of the face.
Image will be resized to 299x299 using bicubic interpolation
:param np.array image: Face image
:param bool normalize: Return normalized vector
... | code_fim | hard | {
"lang": "python",
"repo": "evd995/face_recognition_toolbox",
"path": "/face_recognition_toolbox/methods/SqueezeNetManager.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def setUp(self):
self.obsmode="acs,sbc,pr130l"
self.spectrum="rn(icat(k93models,5770,0.0,4.5),band(johnson,v),20,vegamag)"
self.subset=False
self.etcid="ACS.SBC.SPEC.010"
self.setglobal(__file__)
self.runpy()
class SpecSourcerateSpecCase15(basecase.SpecS... | code_fim | hard | {
"lang": "python",
"repo": "spacetelescope/pysynphot",
"path": "/commissioning/acs_etc_cases.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spacetelescope/pysynphot path: /commissioning/acs_etc_cases.py
class countrateCase154(basecase.countrateCase):
def setUp(self):
self.obsmode="acs,hrc,f550m"
self.spectrum="spec(earthshine.fits)*0.5+rn(spec(Zodi.fits),band(johnson,v),22.7,vegamag)+(spec(el1215a.fits)+spec(el13... | code_fim | hard | {
"lang": "python",
"repo": "spacetelescope/pysynphot",
"path": "/commissioning/acs_etc_cases.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def setUp(self):
self.obsmode="acs,wfc1,fr647m#6470"
self.spectrum="spec(earthshine.fits)*0.5+rn(spec(Zodi.fits),band(johnson,v),22.7,vegamag)"
self.subset=False
self.etcid="ACS.WFC.PT.RAMP.014"
self.setglobal(__file__)
self.runpy()
class countrateCase13... | code_fim | hard | {
"lang": "python",
"repo": "spacetelescope/pysynphot",
"path": "/commissioning/acs_etc_cases.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>@api.route("/form-input-dns-info")
async def form_input_dns_info(req, resp):
"""Form input endpoint for dns info"""
domain = req.params['domain']
if 'nameserver' in req.params.keys():
nameserver = req.params['nameserver']
else:
nameserver = None
dns_info_A=_g... | code_fim | hard | {
"lang": "python",
"repo": "tatianajiselle/dinghy-ping",
"path": "/dinghy_ping/services/api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tatianajiselle/dinghy-ping path: /dinghy_ping/services/api.py
import responder
import requests
from prometheus_client import Counter, Summary, start_http_server
import time
import asyncio
import os
import json
import data
import dinghy_dns
import dns.rdatatype
import socket
import logging
from ur... | code_fim | hard | {
"lang": "python",
"repo": "tatianajiselle/dinghy-ping",
"path": "/dinghy_ping/services/api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: isabella232/digitalbuildings path: /tools/validators/instance_validator/instance_validator.py
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the License);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
... | code_fim | hard | {
"lang": "python",
"repo": "isabella232/digitalbuildings",
"path": "/tools/validators/instance_validator/instance_validator.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> parsed = dict(raw_parse)
entity_instances = {}
entity_names = list(parsed.keys())
# first build all the entity instances
for entity_name in entity_names:
entity = dict(parsed[entity_name])
instance = entity_instance.EntityInstance(entity,
uni... | code_fim | hard | {
"lang": "python",
"repo": "isabella232/digitalbuildings",
"path": "/tools/validators/instance_validator/instance_validator.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(k):
m[i] = np.dot(g[i], X) / np.sum(g[i])
xmm = X - m[i]
s[i] = np.dot(g[i] * xmm.T, xmm) / np.sum(g[i])
pi[i] = np.sum(g[i]) / n
return pi, m, s<|fim_prefix|># repo: kyeeh/holbertonschool-machine_learning path: /unsupervised_learning/0x01-clustering... | code_fim | hard | {
"lang": "python",
"repo": "kyeeh/holbertonschool-machine_learning",
"path": "/unsupervised_learning/0x01-clustering/7-maximization.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kyeeh/holbertonschool-machine_learning path: /unsupervised_learning/0x01-clustering/7-maximization.py
#!/usr/bin/env python3
"""
Clustering Module
"""
import numpy as np
def maximization(X, g):
"""
Calculates the maximization step in the EM algorithm for a GMM:
X is a numpy.ndarray... | code_fim | hard | {
"lang": "python",
"repo": "kyeeh/holbertonschool-machine_learning",
"path": "/unsupervised_learning/0x01-clustering/7-maximization.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not np.isclose(np.sum(g, axis=0), np.ones((n, ))).all():
return None, None, None
pi, m, s = np.zeros((k,)), np.zeros((k, d)), np.zeros((k, d, d))
for i in range(k):
m[i] = np.dot(g[i], X) / np.sum(g[i])
xmm = X - m[i]
s[i] = np.dot(g[i] * xmm.T, xmm) / np.su... | code_fim | hard | {
"lang": "python",
"repo": "kyeeh/holbertonschool-machine_learning",
"path": "/unsupervised_learning/0x01-clustering/7-maximization.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.