text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> plt.figure(figsize=(3.5, 0.5))
mmax = max(kg.values())
gradient = np.linspace(0, mmax, 100)
gradient = np.vstack((gradient, gradient))
plt.imshow(gradient, aspect='auto', cmap=plt.get_cmap('Purples'),
vmax=mmax)
plt.xticks((0, 50, 100),
[str(x) for ... | code_fim | hard | {
"lang": "python",
"repo": "mgalardini/2018_ecoli_pathogenicity",
"path": "/src/plot_tree",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mgalardini/2018_ecoli_pathogenicity path: /src/plot_tree
#!/usr/bin/env python
def get_options():
import argparse
# create the top-level parser
description = "Generate annotated tree"
parser = argparse.ArgumentParser(description=description)
parser.add_argument('tree', acti... | code_fim | hard | {
"lang": "python",
"repo": "mgalardini/2018_ecoli_pathogenicity",
"path": "/src/plot_tree",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # got anything to do?
if not layers:
return
for revvers, revmeth in self.revs:
todo = [lyr for lyr in layers if await lyr.getModelVers() < revvers]
if not todo:
continue
logger.warning(f'beginning model migration ->... | code_fim | hard | {
"lang": "python",
"repo": "cmd-not-found/synapse",
"path": "/synapse/lib/modelrev.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cmd-not-found/synapse path: /synapse/lib/modelrev.py
import logging
import synapse.exc as s_exc
logger = logging.getLogger(__name__)
maxvers = (0, 2, 0)
class ModelRev:
def __init__(self, core):
self.core = core
self.revs = (
# ((0, 0, 0), self._addModelVers),... | code_fim | hard | {
"lang": "python",
"repo": "cmd-not-found/synapse",
"path": "/synapse/lib/modelrev.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lorioux/donatecare path: /backend/tests/test_dbase.py
import pytest
@pytest.mark.run(order=2)
def test_db_init_commands(runner):
<|fim_suffix|> result = runner.invoke(args=['populate'])
assert "Populating" in result.output
pass<|fim_middle|> result = runner.invoke(args=['delete'])
... | code_fim | medium | {
"lang": "python",
"repo": "Lorioux/donatecare",
"path": "/backend/tests/test_dbase.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = runner.invoke(args=['populate'])
assert "Populating" in result.output
pass<|fim_prefix|># repo: Lorioux/donatecare path: /backend/tests/test_dbase.py
import pytest
@pytest.mark.run(order=2)
def test_db_init_commands(runner):
<|fim_middle|> result = runner.invoke(args=['delete'])
... | code_fim | medium | {
"lang": "python",
"repo": "Lorioux/donatecare",
"path": "/backend/tests/test_dbase.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jalabort/alabortcvpr2015 path: /alabortcvpr2015/clm/classifier.py
from __future__ import division
import numpy as np
from numpy.fft import fft2, ifft2, fftshift
from sklearn import svm
from sklearn import linear_model
class MCF(object):
r"""
Multi-channel Correlation Filter
"""
... | code_fim | hard | {
"lang": "python",
"repo": "jalabort/alabortcvpr2015",
"path": "/alabortcvpr2015/clm/classifier.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def invert_filters(self):
return np.real(fftshift(ifft2(self.F), axes=(-2, -1)))
class LinearSVMLR(object):
r"""
Binary classifier that combines Linear Support Vector Machines and
Logistic Regression.
"""
def __init__(self, samples, mask, threshold=0.05, **kwarg):
... | code_fim | hard | {
"lang": "python",
"repo": "jalabort/alabortcvpr2015",
"path": "/alabortcvpr2015/clm/classifier.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: csm10495/errgrep path: /errgrep/non_blocking_read_thread.py
import queue
import sys
import threading
import time
class NonBlockingReadThread(threading.Thread):
'''
A thread that continually reads lines from a file object and places each read line in
.lines_queue
Th... | code_fim | medium | {
"lang": "python",
"repo": "csm10495/errgrep",
"path": "/errgrep/non_blocking_read_thread.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def start_if_not_started_yet(self):
try:
NonBlockingReadThread.start(self)
except RuntimeError:
pass
stdin_read_thread = StdinReadThread()<|fim_prefix|># repo: csm10495/errgrep path: /errgrep/non_blocking_read_thread.py
import queue
import sys
import t... | code_fim | hard | {
"lang": "python",
"repo": "csm10495/errgrep",
"path": "/errgrep/non_blocking_read_thread.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RobMurray98/BribeNet path: /test/BribeNet/bribery/temporal/action/test_briberyAction.py
from unittest import TestCase
from unittest.mock import MagicMock
from BribeNet.bribery.temporal.action.briberyAction import BriberyActionTimeNotCorrectException, \
BriberyActionExecutedMultipleTimesExcep... | code_fim | hard | {
"lang": "python",
"repo": "RobMurray98/BribeNet",
"path": "/test/BribeNet/bribery/temporal/action/test_briberyAction.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_perform_action_fails_if_already_executed(self):
try:
self.action.add_bribe(0, 0.01)
self.action.perform_action()
self.action.perform_action()
except BriberyActionExecutedMultipleTimesException:
return
self.fail()<|fim_pre... | code_fim | hard | {
"lang": "python",
"repo": "RobMurray98/BribeNet",
"path": "/test/BribeNet/bribery/temporal/action/test_briberyAction.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_perform_action_fails_if_at_different_times(self):
try:
self.graph.get_time_step = MagicMock(return_value=self.action.get_time_step()+1)
self.action.perform_action()
except BriberyActionTimeNotCorrectException:
return
self.fail()
... | code_fim | medium | {
"lang": "python",
"repo": "RobMurray98/BribeNet",
"path": "/test/BribeNet/bribery/temporal/action/test_briberyAction.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def create_model_explainer(self):
self.explainer = LimeTabularExplainer(
self.train,
feature_names=self.feature_names,
training_labels=self.labels_train,
class_names=self.class_names,
... | code_fim | hard | {
"lang": "python",
"repo": "chreman/explaining_algorithms",
"path": "/creditscoring.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_custom_explanation(self, instance):
exp = self.explainer.explain_instance(instance,
self.classifier.predict_proba,
num_features=3, top_labels=1)
return exp.as_html(show_table=True, show_... | code_fim | hard | {
"lang": "python",
"repo": "chreman/explaining_algorithms",
"path": "/creditscoring.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chreman/explaining_algorithms path: /creditscoring.py
import os
import pandas as pd
import matplotlib
matplotlib.use('Agg')
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
from... | code_fim | hard | {
"lang": "python",
"repo": "chreman/explaining_algorithms",
"path": "/creditscoring.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return ContextualParserApproach() \
.setInputCols(["sentence", "token"]) \
.setOutputCol("context_entity") \
.setCaseSensitive(False) \
.setContextMatch(False) \
.setPrefixAndSuffixMatch(False)<|fim_prefix|># repo: prakashcinna/nlu path:... | code_fim | hard | {
"lang": "python",
"repo": "prakashcinna/nlu",
"path": "/nlu/components/matchers/context_parser/context_parser.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: prakashcinna/nlu path: /nlu/components/matchers/context_parser/context_parser.py
from sparknlp_jsl.annotator import ContextualParserApproach,ContextualParserModel
class ContextParser:
<|fim_suffix|> return ContextualParserApproach() \
.setInputCols(["sentence", "token"]) \
... | code_fim | hard | {
"lang": "python",
"repo": "prakashcinna/nlu",
"path": "/nlu/components/matchers/context_parser/context_parser.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def wndProc(self, hwnd, msg, wparam, lparam):
if msg == 0x240:
self.handleTouchMessage(wparam, lparam)
return 0 # handled
return win32gui.CallWindowProc(self.oldWndProc, hwnd, msg, wparam, lparam)<|fim_prefix|># repo: rbreaves/pywmtouchhook path: /touchhook.py
... | code_fim | hard | {
"lang": "python",
"repo": "rbreaves/pywmtouchhook",
"path": "/touchhook.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rbreaves/pywmtouchhook path: /touchhook.py
import win32gui
import win32con
import ctypes
RegisterTouchWindow = ctypes.windll.user32.RegisterTouchWindow
GetTouchInputInfo = ctypes.windll.user32.GetTouchInputInfo
from ctypes import c_long, c_uint32, c_void_p
from ctypes import pointer, sizeof
imp... | code_fim | hard | {
"lang": "python",
"repo": "rbreaves/pywmtouchhook",
"path": "/touchhook.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gugarosa/opytimizer path: /opytimizer/optimizers/swarm/fso.py
"""Flying Squirrel Optimizer.
"""
import copy
from typing import Any, Dict, Optional
import numpy as np
import opytimizer.math.distribution as d
import opytimizer.math.random as r
import opytimizer.utils.exception as e
from opytimiz... | code_fim | hard | {
"lang": "python",
"repo": "gugarosa/opytimizer",
"path": "/opytimizer/optimizers/swarm/fso.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> mean_position = np.mean([agent.position for agent in space.agents], axis=0)
# Calculates the Sigma Reduction Factor (eq. 5)
SRF = (-np.log(1 - (1 / np.sqrt(iteration + 2)))) ** 2
# Calculates the Beta Expansion Factor
BEF = self.beta + (2 - self.beta) * ((iteratio... | code_fim | hard | {
"lang": "python",
"repo": "gugarosa/opytimizer",
"path": "/opytimizer/optimizers/swarm/fso.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Calculates the Sigma Reduction Factor (eq. 5)
SRF = (-np.log(1 - (1 / np.sqrt(iteration + 2)))) ** 2
# Calculates the Beta Expansion Factor
BEF = self.beta + (2 - self.beta) * ((iteration + 1) / n_iterations)
for agent in space.agents:
a = copy.deepc... | code_fim | hard | {
"lang": "python",
"repo": "gugarosa/opytimizer",
"path": "/opytimizer/optimizers/swarm/fso.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gabemery/gammapy path: /gammapy/image/tests/test_catalog.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import absolute_import, division, print_function, unicode_literals
from numpy.testing import assert_allclose
from astropy import units as u
from ...utils.tes... | code_fim | hard | {
"lang": "python",
"repo": "gabemery/gammapy",
"path": "/gammapy/image/tests/test_catalog.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> reference = SkyImage.empty(xref=18.0, yref=-0.6, nypix=81,
nxpix=81, binsz=0.1)
filename = '$GAMMAPY_EXTRA/datasets/catalogs/hgps_catalog_v1.fits.gz'
catalog = SourceCatalogHGPS(filename)
estimator = CatalogImageEstimator(reference=refere... | code_fim | hard | {
"lang": "python",
"repo": "gabemery/gammapy",
"path": "/gammapy/image/tests/test_catalog.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> sha3_object = hashlib.sha3_256(password.encode('UTF-8'))
hashed = sha3_object.hexdigest()
return hashed
def verify_password(password, password_hash):
""" Check if the password entered is correct or not """
password_entered = hash_password(password)
return secrets.compare_digest(... | code_fim | medium | {
"lang": "python",
"repo": "Rohan-Great/Python-Hand-Cricket",
"path": "/src/modules/hashfunc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def verify_password(password, password_hash):
""" Check if the password entered is correct or not """
password_entered = hash_password(password)
return secrets.compare_digest(password_entered, password_hash)<|fim_prefix|># repo: Rohan-Great/Python-Hand-Cricket path: /src/modules/hashfunc.py
... | code_fim | medium | {
"lang": "python",
"repo": "Rohan-Great/Python-Hand-Cricket",
"path": "/src/modules/hashfunc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Rohan-Great/Python-Hand-Cricket path: /src/modules/hashfunc.py
import hashlib
import secrets
# This file simply describes the hashing algorithm.
def hash_password(password):
""" Simply describe the algorithm used for password hashing: SHA3-256 """
sha3_object = hashlib.sha3_256(passwor... | code_fim | medium | {
"lang": "python",
"repo": "Rohan-Great/Python-Hand-Cricket",
"path": "/src/modules/hashfunc.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> y_true = test[:, query_config["targ_idx"]]
y_pred = classifier.predict(fn_test, **query_config, **predict_config)
q_inf_time = classifier.s["model_data"].get("inf_time")
f1_micro = f1_score(y_true, y_pred, average="micro")
f1_macro = f1_score(y_true, y_pred, average="macro")
retu... | code_fim | hard | {
"lang": "python",
"repo": "eliavw/aaai20",
"path": "/cli/predict/run_pxs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eliavw/aaai20 path: /cli/predict/run_pxs.py
import argparse
import json
import os
import sys
import warnings
from pathlib import Path
import dill as pkl
import numpy as np
import pandas as pd
from sklearn.exceptions import UndefinedMetricWarning
from sklearn.metrics import f1_score
import mercs... | code_fim | hard | {
"lang": "python",
"repo": "eliavw/aaai20",
"path": "/cli/predict/run_pxs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Load queries
fn_qry = filename_query(dataset, suffix="default")
q_codes = np.load(fn_qry)
# Load data
suffix = "test-pxs"
fn_test = filename_dataset(dataset, step=2, suffix=suffix, extension="csv")
df = pd.read_csv(fn_test, index_col=None)
test = df.values
test = tes... | code_fim | hard | {
"lang": "python",
"repo": "eliavw/aaai20",
"path": "/cli/predict/run_pxs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wenk-silvan/pren-robo-cube-ipcv path: /src/pren_course_complete.py
#!/bin/python3
import sys
import cv2
import logging
sys.path.append('/home/pi/pren/pren-robo-cube-ipcv/')
from configparser import ConfigParser
from src.common.movement.drive import Drive
from src.common.movement.climb import Cli... | code_fim | hard | {
"lang": "python",
"repo": "wenk-silvan/pren-robo-cube-ipcv",
"path": "/src/pren_course_complete.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> climb.head_up_slow(10) # tilt slightly forward to see pictogram on ground
pictogram = course_detect_pictogram.run(camera=camera)
climb.head_down_fast(10)
snapshot = course_find_stair_center.run(conf=conf_parser["B_FIND_STAIR_CENTER"], camera=camera, drive=drive)
path: Path = cour... | code_fim | medium | {
"lang": "python",
"repo": "wenk-silvan/pren-robo-cube-ipcv",
"path": "/src/pren_course_complete.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AlexKuhnle/ShapeWorld path: /shapeworld/captions/entity_type.py
from shapeworld.captions import Predicate, Attribute
class EntityType(Predicate):
predtypes = {'type'}
def __init__(self, attributes=None):
if attributes is None:
attributes = list()
elif isins... | code_fim | hard | {
"lang": "python",
"repo": "AlexKuhnle/ShapeWorld",
"path": "/shapeworld/captions/entity_type.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def polish_notation(self, reverse=False):
if reverse:
return [rpn_symbol for attribute in self.value for rpn_symbol in attribute.polish_notation(reverse=reverse)] + \
[str(self) + str(len(self.value))]
else:
return [str(self) + str(len(self.value... | code_fim | hard | {
"lang": "python",
"repo": "AlexKuhnle/ShapeWorld",
"path": "/shapeworld/captions/entity_type.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: projectcalico/calico-nova path: /nova/virt/netutils.py
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
# Copyright (c) 2010 Citrix Systems, Inc.
# Copyright 2013 IBM Corp.
#
# Licensed ... | code_fim | hard | {
"lang": "python",
"repo": "projectcalico/calico-nova",
"path": "/nova/virt/netutils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not (network_info and template):
return
nets = []
ifc_num = -1
ipv6_is_available = False
for vif in network_info:
if not vif['network'] or not vif['network']['subnets']:
continue
network = vif['network']
# NOTE(bnemec): The template onl... | code_fim | hard | {
"lang": "python",
"repo": "projectcalico/calico-nova",
"path": "/nova/virt/netutils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vivekfantain/CoutnMinSketch path: /count_min_sketch/count_min_sketch.py
from numpy import zeros, int32, int16, arange, array
from math import log, e, ceil
class CountMinSketch(object):
def __init__(self, w=None, d=None, delta=None, epsilon=None, bits=256):
"""
CountMinSketch is an imp... | code_fim | hard | {
"lang": "python",
"repo": "vivekfantain/CoutnMinSketch",
"path": "/count_min_sketch/count_min_sketch.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if 2**bits < w:
raise Exception("Too few bits for w")
#Values taken from http://www.isthe.com/chongo/tech/comp/fnv/
if bits == 32:
self.prime = 0x1000193
self.offset = 0x811c9dc5
elif bits == 64:
self.prime = 0x100000001b3
self.offset = 0xcbf29ce484222325L
elif bits =... | code_fim | hard | {
"lang": "python",
"repo": "vivekfantain/CoutnMinSketch",
"path": "/count_min_sketch/count_min_sketch.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cwlseu/RustPython path: /tests/benchmarks/perf_fib.py
def fib(n):
# a, b = 1, 1
a = 1
b = 1
for _ in range(n-1):
temp = b
b = a+b
a = temp
<|fim_suffix|>print(fib(1))
print(fib(2))
print(fib(3))
print(fib(4))
print(fib(5))<|fim_middle|> #a, b = b, a+b
r... | code_fim | easy | {
"lang": "python",
"repo": "cwlseu/RustPython",
"path": "/tests/benchmarks/perf_fib.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(fib(1))
print(fib(2))
print(fib(3))
print(fib(4))
print(fib(5))<|fim_prefix|># repo: cwlseu/RustPython path: /tests/benchmarks/perf_fib.py
def fib(n):
# a, b = 1, 1
a = 1
b = 1
for _ in range(n-1):
temp = b
b = a+b
a = temp
<|fim_middle|> #a, b = b, a+b
r... | code_fim | easy | {
"lang": "python",
"repo": "cwlseu/RustPython",
"path": "/tests/benchmarks/perf_fib.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if sidebar != "Conclusion":
st.write("") # Blank line
st.markdown(
"Made by [Michael Nasello](https://ca.linkedin.com/in/michael-nasello) and "
"[Sheen Thusoo](https://ca.linkedin.com/in/sheenthusoo): Applied Machine Learning Interns, Summer 2021"
)<|fim_prefix|># repo: TinaAB... | code_fim | hard | {
"lang": "python",
"repo": "TinaABB/projectpensive",
"path": "/demo/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TinaABB/projectpensive path: /demo/main.py
import streamlit as st
from problem_framing import problem_framing
from demo import demo
from design import design
from evaluation import evaluation
from failed_attempts import failed_attempts
from next_steps import next_steps
from conclusion import con... | code_fim | medium | {
"lang": "python",
"repo": "TinaABB/projectpensive",
"path": "/demo/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Sidebar
st.sidebar.header("Vector Institute: AI Engineering and Technology")
st.sidebar.image("images/vector_logo.jpeg", width=300)
sidebar = st.sidebar.selectbox(
"Demo Section",
("Problem Framing", "Design", "Demo", "Evaluation", "Failed Attempts", "Next Steps", "Conclusion")
)
if sidebar == ... | code_fim | hard | {
"lang": "python",
"repo": "TinaABB/projectpensive",
"path": "/demo/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> cost_all_list.append(cost_all)
print("epoch:", episode+1)
print("The number of cycles in this epoch:", sum)
print("The reward list:", reward_list)
print("The best reward in this epoch:", max(reward_list))
print("The final reward in this epoch:", reward)
... | code_fim | hard | {
"lang": "python",
"repo": "papercodeFXY/Reinforcement-learning-with-tensorflow-master",
"path": "/contents/MyExperiment/Exp3_zxq/run_this.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: papercodeFXY/Reinforcement-learning-with-tensorflow-master path: /contents/MyExperiment/Exp3_zxq/run_this.py
from cluster_env import Cluster
from RL_brain import QLearningTable
import datetime
import numpy as np
import matplotlib.pyplot as plt
import pylab as pl
import random
import pandas as pd
... | code_fim | hard | {
"lang": "python",
"repo": "papercodeFXY/Reinforcement-learning-with-tensorflow-master",
"path": "/contents/MyExperiment/Exp3_zxq/run_this.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qinshuang/ITINFO-api path: /src/app/commons/DatasMixin.py
#!usr/bin/env python
# -*- coding:utf-8 -*-
"""
@author:sqin
@file: DatasMixin.py
@time: 2019/01/02
"""
from app import db
from app.commons.errors import RequestParmsError, DuplicateDataError
from sqlalchemy.exc import IntegrityError
cl... | code_fim | hard | {
"lang": "python",
"repo": "qinshuang/ITINFO-api",
"path": "/src/app/commons/DatasMixin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not data:
raise RequestParmsError
try:
new_t = self.T(**data)
db.session.add(new_t)
db.session.commit()
except IntegrityError:
raise DuplicateDataError
except BaseException as e:
raise RequestParmsEr... | code_fim | hard | {
"lang": "python",
"repo": "qinshuang/ITINFO-api",
"path": "/src/app/commons/DatasMixin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sjenni/LearningToSpotArtifacts path: /train_autoencoder_stl10.py
from Preprocessor import Preprocessor
from train.AETrainer import AETrainer
from datasets.STL10 import STL10
from models.AutoEncoder import AutoEncoder
target_shape = [96, 96, 3]
model = AutoEncoder(num_layers=4, batch_size=128, ta... | code_fim | medium | {
"lang": "python",
"repo": "sjenni/LearningToSpotArtifacts",
"path": "/train_autoencoder_stl10.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>10()
preprocessor = Preprocessor(target_shape=target_shape, augment_color=True)
trainer = AETrainer(model=model, dataset=data, pre_processor=preprocessor, num_epochs=500, lr_policy='linear',
optimizer='adam', init_lr=0.0003, num_gpus=2)
trainer.train_model(None)<|fim_prefix|># repo: sj... | code_fim | medium | {
"lang": "python",
"repo": "sjenni/LearningToSpotArtifacts",
"path": "/train_autoencoder_stl10.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: freebsd/freebsd-ports path: /cad/cura/files/patch-cura__app.py
--- cura_app.py.orig 2020-02-28 16:06:57 UTC
+++ cura_app.<|fim_suffix|># Cura is released under the terms of the LGPLv3 or higher.<|fim_middle|>py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3.8
+#!/usr/bin/env %%PYTHON_CMD%%
# Copyrigh... | code_fim | medium | {
"lang": "python",
"repo": "freebsd/freebsd-ports",
"path": "/cad/cura/files/patch-cura__app.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># Cura is released under the terms of the LGPLv3 or higher.<|fim_prefix|># repo: freebsd/freebsd-ports path: /cad/cura/files/patch-cura__app.py
--- cura_app.py.orig 2020-02-28 16:06:57 UTC
+++ cura_app.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3.8
+#!/usr/bin/e<|fim_middle|>nv %%PYTHON_CMD%%
# Copyrigh... | code_fim | easy | {
"lang": "python",
"repo": "freebsd/freebsd-ports",
"path": "/cad/cura/files/patch-cura__app.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for agent_i in range(self.num_agents):
# print(observations[agent_i].shape)
self.obs_buffs[agent_i][self.curr_i:self.curr_i +
nentries] = observations[agent_i]
# actions are already batched by agent, so they are indexed differ... | code_fim | hard | {
"lang": "python",
"repo": "WeiChengTseng/DL_final_project",
"path": "/maac_team/utils/buffer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if accumulate:
done_thread = np.argwhere(dones[0]).flatten()
if len(done_thread) > 0:
# print(done_thread)
pass
for thread in done_thread:
accum_rwd, thd = np.zeros(self.num_agents), 16 - thread
tmp... | code_fim | hard | {
"lang": "python",
"repo": "WeiChengTseng/DL_final_project",
"path": "/maac_team/utils/buffer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WeiChengTseng/DL_final_project path: /maac_team/utils/buffer.py
import numpy as np
from torch import Tensor
from torch.autograd import Variable
class ReplayBuffer(object):
"""
Replay Buffer for multi-agent RL with parallel rollouts
"""
def __init__(self,
max_st... | code_fim | hard | {
"lang": "python",
"repo": "WeiChengTseng/DL_final_project",
"path": "/maac_team/utils/buffer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(ChatworkAlerter, self).__init__(rule)
self.chatwork_apikey = self.rule.get('chatwork_apikey', None)
self.chatwork_room_id = self.rule.get('chatwork_room_id', None)
self.url = 'https://api.chatwork.com/v2/rooms/%s/messages' % (self.chatwork_room_id)
self.chatwo... | code_fim | medium | {
"lang": "python",
"repo": "fwalloe/elastalert2",
"path": "/elastalert/alerters/chatwork.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
response = requests.post(self.url, params=params, headers=headers, proxies=proxies, auth=auth)
response.raise_for_status()
except RequestException as e:
raise EAException("Error posting to Chattwork: %s. Details: %s" % (e, "" if e.response is None e... | code_fim | hard | {
"lang": "python",
"repo": "fwalloe/elastalert2",
"path": "/elastalert/alerters/chatwork.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fwalloe/elastalert2 path: /elastalert/alerters/chatwork.py
import warnings
import requests
from requests import RequestException
from requests.auth import HTTPProxyAuth
from elastalert.alerts import Alerter, BasicMatchString
from elastalert.util import EAException, elastalert_logger
<|fim_suff... | code_fim | medium | {
"lang": "python",
"repo": "fwalloe/elastalert2",
"path": "/elastalert/alerters/chatwork.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> prefix_pkg = prefix_pkg_type + f".{package_name}"
for subpackage_init_file in dir_.rglob("__init__.py"):
parent_dir = subpackage_init_file.parent
relative_parent_dir = parent_dir.relative_to(dir_)
if relative_parent_dir == Path("."):
# this handles the case whe... | code_fim | hard | {
"lang": "python",
"repo": "fetchai/agents-aea",
"path": "/aea/components/base.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fetchai/agents-aea path: /aea/components/base.py
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2018-2023 Fetch.AI Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file ... | code_fim | hard | {
"lang": "python",
"repo": "fetchai/agents-aea",
"path": "/aea/components/base.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SteveKueng/mwa2_scripts path: /payload/usr/local/munki/mwa2/utils.py
#!/usr/bin/env python
""" munkiwebadmin utils.py """
import subprocess
import urllib
import urllib2
from Foundation import *
BUNDLE_ID = 'com.github.stevekueng.munkiwebadmin'
class GurlError(Exception):
pass
class HTTPE... | code_fim | hard | {
"lang": "python",
"repo": "SteveKueng/mwa2_scripts",
"path": "/payload/usr/local/munki/mwa2/utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = urllib.urlencode(data)
req = urllib2.Request(pref('ServerURL') + url, data)
req.add_header("Authorization", "%s" % pref('authKey'))
try:
resp = urllib2.urlopen(req)
except urllib2.HTTPError as e:
print e
except urllib2.URLError as e:
print e
else... | code_fim | hard | {
"lang": "python",
"repo": "SteveKueng/mwa2_scripts",
"path": "/payload/usr/local/munki/mwa2/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: generaljun/JavPy path: /JavPy/embed/youav_com.py
from JavPy.embed.BaseEmbed import BaseEmbed
import requests
from JavPy.utils.config import proxy
import re
# according to https://www.youav.com/css/object.js
_button2server = {
1: 7,
2: 8,
3: 2,
101: 2,
7: 4
}
class youav_com... | code_fim | hard | {
"lang": "python",
"repo": "generaljun/JavPy",
"path": "/JavPy/embed/youav_com.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
# print(youav_com.decode("https://www.youav.com/video/15022/tokyo-hot-n1338-%E6%9D%B1%E7%86%B1%E6%BF%80%E6%83%85-%E5%B1%88%E8%BE%B1%E7%BE%9E%E6%81%A5%E3%82%AF%E3%82%B9%E3%82%B3-%E7%89%B9%E9%9B%86-part7"))
# print(requests.get("https://www.youav.com/ajax/hls.php?server=80... | code_fim | medium | {
"lang": "python",
"repo": "generaljun/JavPy",
"path": "/JavPy/embed/youav_com.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not os.path.exists(f'/tmp/gosat{year}{month}.tsv'):
if verbose:
print("Cache not found, downloading data...")
try:
with open(f'/tmp/gosat{year}{month}.tsv', 'w') as data:
r = requests.get(f'https://www.eorc.jaxa.jp/GOSA... | code_fim | hard | {
"lang": "python",
"repo": "lusmoura/Nasa-space-apps",
"path": "/build/lib/pyspace/jaxa/gosat.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lusmoura/Nasa-space-apps path: /build/lib/pyspace/jaxa/gosat.py
import os
import requests
import pandas as pd
class Gosat:
"""Contains the GOSAT greenhouse gases concentration data
Atributes
---------
df: pandas.DataFrame
Dataframe with gosat data
M... | code_fim | hard | {
"lang": "python",
"repo": "lusmoura/Nasa-space-apps",
"path": "/build/lib/pyspace/jaxa/gosat.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> df = pd.read_csv(f'/tmp/gosat{year}{month}.tsv', '\t')
if verbose:
print("Dataset loaded")
self.df = df
def summarize(self):
"""Returns summary statistics of the dataset"""
return self.df.describe()
if __name__ == '__main__':
GS = Gosat(su... | code_fim | hard | {
"lang": "python",
"repo": "lusmoura/Nasa-space-apps",
"path": "/build/lib/pyspace/jaxa/gosat.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bluecatlabs/gateway-workflows path: /Community/ServiceNow CMDB/cmdb_switches/cmdb_switches_page.py
# Copyright 2020 BlueCat Networks. All rights reserved.
# Various Flask framework items.
import os
import sys
import codecs
from flask import url_for, redirect, render_template, flash, g
<|fim_su... | code_fim | hard | {
"lang": "python",
"repo": "bluecatlabs/gateway-workflows",
"path": "/Community/ServiceNow CMDB/cmdb_switches/cmdb_switches_page.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> form = GenericFormTemplate()
# Remove this line if your workflow does not need to select a configuration
if form.validate_on_submit():
g.user.logger.info('SUCCESS')
flash('success', 'succeed')
return redirect(url_for('cmdb_switchescmdb_switches_cmdb_switches_page'))
... | code_fim | hard | {
"lang": "python",
"repo": "bluecatlabs/gateway-workflows",
"path": "/Community/ServiceNow CMDB/cmdb_switches/cmdb_switches_page.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EPCCed/wee_archie path: /framework/client/servercomm.py
import requests
import shutil
import json
#class which describes the ways that the program can interact with the server.
class servercomm:
#input is the name of the simulation (as known to the server)
def __init__(self,simname,serv... | code_fim | hard | {
"lang": "python",
"repo": "EPCCed/wee_archie",
"path": "/framework/client/servercomm.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # delete the file 'file' from the server
def DeleteFile(self,file):
if self.started:
deletefilerequest=requests.delete(self.data_base+file)
print("Deleted file: '"+file+"'")
else:
print("Error: No simulation is running")
#delete all the simu... | code_fim | hard | {
"lang": "python",
"repo": "EPCCed/wee_archie",
"path": "/framework/client/servercomm.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.started:
deletefilerequest=requests.delete(self.base)
print("Deleted Simulation")
self.started=False
else:
print("Error: No simulation to be deleted")
#returns whether the server class object has started a simulation
def IsSt... | code_fim | hard | {
"lang": "python",
"repo": "EPCCed/wee_archie",
"path": "/framework/client/servercomm.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aws-samples/aws-open-data-satellite-lidar-tutorial path: /libs/apls/skeletonize.py
aphs:", len([z.nodes for z in sub_graphs]))
bad_nodes = []
if verbose:
print(" len(G_.nodes()):", len(G_.nodes()) )
print(" len(G_.edges()):", len(G_.edges()) )
if super_verbose... | code_fim | hard | {
"lang": "python",
"repo": "aws-samples/aws-open-data-satellite-lidar-tutorial",
"path": "/libs/apls/skeletonize.py",
"mode": "psm",
"license": "MIT-0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aws-samples/aws-open-data-satellite-lidar-tutorial path: /libs/apls/skeletonize.py
nes = []
edges = list(G.edges())
if len(edges) < 1:
return []
prev_e = edges[0][1]
current_line = list(edges[0])
added_edges = {edges[0]}
for s, e in edges[1:]:
if (s, e) in ... | code_fim | hard | {
"lang": "python",
"repo": "aws-samples/aws-open-data-satellite-lidar-tutorial",
"path": "/libs/apls/skeletonize.py",
"mode": "psm",
"license": "MIT-0",
"source": "the-stack-v2"
} |
<|fim_suffix|>################################################################################
def make_skeleton(img_loc, thresh, debug, fix_borders, replicate=5,
clip=2, img_shape=(1300, 1300), img_mult=255, hole_size=300,
cv2_kernel_close=7, cv2_kernel_open=7,
use... | code_fim | hard | {
"lang": "python",
"repo": "aws-samples/aws-open-data-satellite-lidar-tutorial",
"path": "/libs/apls/skeletonize.py",
"mode": "spm",
"license": "MIT-0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Augmented Chebyshev scalarization:
objective(y) = min(w * y) + alpha * sum(w * y)
Note: this assumes maximization.
See [Knowles2005]_ for details.
This scalarization can be used with qExpectedImprovement to implement q-ParEGO
as proposed in [Daulton2020]_.
Args:
... | code_fim | hard | {
"lang": "python",
"repo": "leelasd/botorch",
"path": "/botorch/utils/multi_objective/scalarization.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: leelasd/botorch path: /botorch/utils/multi_objective/scalarization.py
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
r"""
Helper utilities for ... | code_fim | medium | {
"lang": "python",
"repo": "leelasd/botorch",
"path": "/botorch/utils/multi_objective/scalarization.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
Transform function using the objective weights.
Example:
>>> weights = torch.tensor([0.75, 0.25])
>>> transform = get_aug_chebyshev_scalarization(weights, Y)
"""
if weights.shape != Y.shape[-1:]:
raise BotorchTensorDimensionError(
"weig... | code_fim | hard | {
"lang": "python",
"repo": "leelasd/botorch",
"path": "/botorch/utils/multi_objective/scalarization.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ChaunceyXCX/e_gate path: /gpio.py
from machine import Pin,Timer
import time
import machine
button_key = 0
led_key = 2
open_gate_key = 14
stop_key = 12
close_gate_key = 13
led = Pin(led_key,Pin.OUT,0)
open_pin = Pin(open_gate_key,Pin.OUT,0)
stop_pin = Pin(stop_key,Pin.OUT,1)
close_pin = Pin(clos... | code_fim | hard | {
"lang": "python",
"repo": "ChaunceyXCX/e_gate",
"path": "/gpio.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def close_gate():
pin = Pin(close_gate_key,Pin.OUT)
pin.value(1)
time.sleep(0.05)
pin.value(0)
blink(3)
print("gpio ok")<|fim_prefix|># repo: ChaunceyXCX/e_gate path: /gpio.py
from machine import Pin,Timer
import time
import machine
button_key = 0
led_key = 2
open_gate_key = 14
... | code_fim | medium | {
"lang": "python",
"repo": "ChaunceyXCX/e_gate",
"path": "/gpio.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: John-zf/VGCN path: /variational_gcn/vgcn.py
t_conditional_likelihood,
get_conditional_likelihood_kronecker,
predict,
get_predictive_distribution
)
from variational_gcn.losses import get_losses
from variational_gcn.metrics import evaluate_accuracy, evaluate_mnlp
from variational_gcn... | code_fim | hard | {
"lang": "python",
"repo": "John-zf/VGCN",
"path": "/variational_gcn/vgcn.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> no_op = tf.no_op()
metrics_list = [self.loss_train, self.loss_val, self.loss_test,
self.accuracy_train, self.accuracy_val, self.accuracy_test,
self.kl, self.ell_train, self.reg,
self.mnlp_train, self.mnlp_val, self.mn... | code_fim | hard | {
"lang": "python",
"repo": "John-zf/VGCN",
"path": "/variational_gcn/vgcn.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: John-zf/VGCN path: /variational_gcn/vgcn.py
.graph_priors import get_prior
from variational_gcn.graph_posteriors import (
get_variational_posterior,
sample_posterior,
)
from variational_gcn.likelihood import (
get_conditional_likelihood,
get_conditional_likelihood_kronecker,
... | code_fim | hard | {
"lang": "python",
"repo": "John-zf/VGCN",
"path": "/variational_gcn/vgcn.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ppsekhar/CS224W path: /socialScore/socialScore.py
reqTime = datetime.fromtimestamp(req)
#
# Look for response time from the destinaton to ths source
#
for resp in temporalMap[dst].get(src, list()):
resp... | code_fim | hard | {
"lang": "python",
"repo": "ppsekhar/CS224W",
"path": "/socialScore/socialScore.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def getAvgResponseScore(nodeAdj, nodeResponseTuple):
avgNodeResponse = list()
for src, destinations in nodeAdj.iteritems():
totalRequests = 0.0
totalPriorityResponse = 0.0
#print "Processing %r" % src
for dst, reqTimestamps in destinations.iteritems():
... | code_fim | hard | {
"lang": "python",
"repo": "ppsekhar/CS224W",
"path": "/socialScore/socialScore.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> minWeightedCliqueScore = weightedCliqueList[-1][1]
maxWeightedCliqueScore = weightedCliqueList[0][1]
for node, score in nodeCliqueList:
if not NodeAttributes.get(node, None):
NodeAttributes[node] = dict()
NodeAttributes[node]['nodeClique'] = score
NodeA... | code_fim | hard | {
"lang": "python",
"repo": "ppsekhar/CS224W",
"path": "/socialScore/socialScore.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mcf-yuichi/cotoba-agent-oss path: /dialogue-engine/test/programytest/aiml_tests/space_tests/test_space_aiml.py
"""
Copyright (c) 2020 COTOBA DESIGN, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Softwar... | code_fim | hard | {
"lang": "python",
"repo": "mcf-yuichi/cotoba-agent-oss",
"path": "/dialogue-engine/test/programytest/aiml_tests/space_tests/test_space_aiml.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_jp_space_en(self):
response = self._client_context.bot.ask_question(self._client_context, "jp SPACE en")
self.assertEqual(response, '日本語 test.')
def test_tag_en_space_jp(self):
response = self._client_context.bot.ask_question(self._client_context, "TAG en jp")
... | code_fim | hard | {
"lang": "python",
"repo": "mcf-yuichi/cotoba-agent-oss",
"path": "/dialogue-engine/test/programytest/aiml_tests/space_tests/test_space_aiml.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class GhostUnit(ArmyUnit, Cloakable):
def __init__(self, unit: Unit, model: GhostModel):
super().__init__(unit)
self.model = model<|fim_prefix|># repo: ljuti/raynors-rangers path: /bot/units/terran/ghost.py
from bot.units.terran.army_unit import ArmyUnit
from bot.units.terran.abilities.cloakabl... | code_fim | easy | {
"lang": "python",
"repo": "ljuti/raynors-rangers",
"path": "/bot/units/terran/ghost.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().__init__(unit)
self.model = model<|fim_prefix|># repo: ljuti/raynors-rangers path: /bot/units/terran/ghost.py
from bot.units.terran.army_unit import ArmyUnit
from bot.units.terran.abilities.cloakable import Cloakable
from bot.units.models.terran.ghost import GhostModel
from sc2.unit impo... | code_fim | medium | {
"lang": "python",
"repo": "ljuti/raynors-rangers",
"path": "/bot/units/terran/ghost.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ljuti/raynors-rangers path: /bot/units/terran/ghost.py
from bot.units.terran.army_unit import ArmyUnit
from bot.units.terran.abilities.cloakable import Cloakable
from bot.units.models.terran.ghost import GhostModel
<|fim_suffix|> super().__init__(unit)
self.model = model<|fim_middle|>from... | code_fim | medium | {
"lang": "python",
"repo": "ljuti/raynors-rangers",
"path": "/bot/units/terran/ghost.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hellstein/codegen-statemachine path: /smgen/parser.py
import json
from jinja2 import Environment, Template, FileSystemLoader
class Parser:
"""
parse the state, transition and init configuration
"""
def __init__(self, stateConf, initConf):
<|fim_suffix|> with open(self.initC... | code_fim | hard | {
"lang": "python",
"repo": "hellstein/codegen-statemachine",
"path": "/smgen/parser.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> content = {}
with open(self.stateConf, 'r') as f:
data = json.load(f)
self.info['statenames'] = list(data.keys())
self.info['transitionnames'] = list(set([x for y in [d['transitions'].keys() for s, d in data.items()] for x in y]))
self.info['... | code_fim | hard | {
"lang": "python",
"repo": "hellstein/codegen-statemachine",
"path": "/smgen/parser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with open(self.initConf, 'r') as f:
data = json.load(f)
self.info['initstate'], self.info['initaction'] = data['state'], data['action']
self.info['statenames'].remove(self.info['initstate'])
self.info['statenames'].insert(0, self.info['initstate'])<|fim_pref... | code_fim | hard | {
"lang": "python",
"repo": "hellstein/codegen-statemachine",
"path": "/smgen/parser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jxhangithub/lintcode path: /Tree/619.Binary Tree Longest Consecutive Sequence III/Solution.py
"""
Definition for a multi tree node.
class MultiTreeNode(object):
def __init__(self, x):
self.val = x
children = [] # children is a list of MultiTreeNode
"""
<|fim_suffix|> i... | code_fim | hard | {
"lang": "python",
"repo": "jxhangithub/lintcode",
"path": "/Tree/619.Binary Tree Longest Consecutive Sequence III/Solution.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _find_path(self, root):
if root is None:
return 0
up, down = 0, 0
for child in root.children:
child_up, child_down = self._find_path(child)
if child.val - 1 == root.val:
up = max(up, child_up + 1)
elif child.... | code_fim | hard | {
"lang": "python",
"repo": "jxhangithub/lintcode",
"path": "/Tree/619.Binary Tree Longest Consecutive Sequence III/Solution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>C[i]
C[i]+=(C[i-1]-C[i])
print('Output:',k)<|fim_prefix|># repo: Codechef-SRM-NCR-Chapter/30-DaysOfCode-March-2021 path: /answers/AkshajV1309/Day26/D26Q2.py
N=int(input('Enter Size: '))
C,k=[int(x) for x in input('Enter Array: ').split()][:N],0
for i in rang<|fim_middle|>e(1,len(C)):
if C[i-1... | code_fim | easy | {
"lang": "python",
"repo": "Codechef-SRM-NCR-Chapter/30-DaysOfCode-March-2021",
"path": "/answers/AkshajV1309/Day26/D26Q2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Codechef-SRM-NCR-Chapter/30-DaysOfCode-March-2021 path: /answers/AkshajV1309/Day26/D26Q2.py
N=int(input('Enter Size: '))
C,k=[int(x) for x in <|fim_suffix|>e(1,len(C)):
if C[i-1]>C[i]:
k+=C[i-1]-C[i]
C[i]+=(C[i-1]-C[i])
print('Output:',k)<|fim_middle|>input('Enter Array: ').sp... | code_fim | easy | {
"lang": "python",
"repo": "Codechef-SRM-NCR-Chapter/30-DaysOfCode-March-2021",
"path": "/answers/AkshajV1309/Day26/D26Q2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: exosite-garage/utility_scripts path: /rpc_list_portal_clients.py
#==============================================================================
# rpc_list_portal_clients.py
# Python script that uses Portal account CIK and lists all owned device clients
# and description information.
#
# Uses JSO... | code_fim | hard | {
"lang": "python",
"repo": "exosite-garage/utility_scripts",
"path": "/rpc_list_portal_clients.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.send('POST /api:v1/rpc/process HTTP/1.1\r\n')
s.send('Host: m2.exosite.com\r\n')
s.send('Content-Type: application/json; charset=utf-8\r\n')
body = json_rpc
s.send('Content-Length: '+ str(len(body))... | code_fim | hard | {
"lang": "python",
"repo": "exosite-garage/utility_scripts",
"path": "/rpc_list_portal_clients.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.