text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> See `wrap.base.Scatter` for a description of how matplotlib is wrapped to make this plot. """<|fim_prefix|># repo: Jammy2211/PyAutoArray path: /autoarray/plot/wrap/two_d/parallel_overscan_plot.py from autoarray.plot.wrap.two_d.grid_plot import GridPlot <|fim_middle|> class ParallelOverscanPl...
code_fim
medium
{ "lang": "python", "repo": "Jammy2211/PyAutoArray", "path": "/autoarray/plot/wrap/two_d/parallel_overscan_plot.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @staticmethod def construct_capture_obj(captureds): captures = [] for location, piece in captureds.items(): captures.append({'location': location, 'name': piece.kind, 'color': piece.color, 'moves': piece.moves}) return captures @staticmethod def constru...
code_fim
hard
{ "lang": "python", "repo": "theovoss/Chess", "path": "/chess/board/history.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> captures = [] for location, piece in captureds.items(): captures.append({'location': location, 'name': piece.kind, 'color': piece.color, 'moves': piece.moves}) return captures @staticmethod def construct_side_effect(method, **kwargs): start = kwargs['st...
code_fim
hard
{ "lang": "python", "repo": "theovoss/Chess", "path": "/chess/board/history.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: theovoss/Chess path: /chess/board/history.py import copy class History(): def __init__(self, json=None): self._index = -1 self._history = [] self._initial_board = {} if json: if 'history' in json: self._history = json['history'] ...
code_fim
hard
{ "lang": "python", "repo": "theovoss/Chess", "path": "/chess/board/history.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: iampakos/moai-0.1.0a2 path: /moai/data/datasets/human_pose/HUMAN4D/importers/image.py import cv2 import torch import numpy import io #NOTE: extract these to common loading funcs def load_image(filename: str, data_type=torch.float32): color_img = numpy.array(cv2.imread(filename, cv2.IMREAD_A...
code_fim
hard
{ "lang": "python", "repo": "iampakos/moai-0.1.0a2", "path": "/moai/data/datasets/human_pose/HUMAN4D/importers/image.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def load_depth_pgm(filename: str, data_type=torch.float32, scale = 1): depth_img = readpgm(filename) depth_img = depth_img.astype(numpy.float32) * scale h, w = depth_img.shape depth_data = depth_img.astype(numpy.float32) return torch.from_numpy( depth_data.reshape(1, 1, h, w) ...
code_fim
hard
{ "lang": "python", "repo": "iampakos/moai-0.1.0a2", "path": "/moai/data/datasets/human_pose/HUMAN4D/importers/image.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> return QPushButton("PyQt5 button")<|fim_prefix|># repo: sweersr/pandas-profiling-1 path: /src/pandas_profiling/report/presentation/flavours/qt/dataset.py from PyQt5.QtWidgets import QPushButton from pandas_profiling.report.presentation.core import Dataset <|fim_middle|> class QtDataset(Dataset)...
code_fim
easy
{ "lang": "python", "repo": "sweersr/pandas-profiling-1", "path": "/src/pandas_profiling/report/presentation/flavours/qt/dataset.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sweersr/pandas-profiling-1 path: /src/pandas_profiling/report/presentation/flavours/qt/dataset.py from PyQt5.QtWidgets import QPushButton from pandas_profiling.report.presentation.core import Dataset <|fim_suffix|> def render(self): return QPushButton("PyQt5 button")<|fim_middle|>cl...
code_fim
easy
{ "lang": "python", "repo": "sweersr/pandas-profiling-1", "path": "/src/pandas_profiling/report/presentation/flavours/qt/dataset.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: thorsteinson/board-vector-proto path: /lib/cmdlet.py import argparse import sys from typing import Callable, List, Dict, Any ArgsType = Dict[str, Any] class Cmdlet: def __init__(self, name: str, helpmsg: str, runner: Callable): self.name = name self.helpmsg = helpmsg ...
code_fim
hard
{ "lang": "python", "repo": "thorsteinson/board-vector-proto", "path": "/lib/cmdlet.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for cmd in self.cmdlets: cmd.add_command(subparsers) args = main_parser.parse_args() command = sys.argv[1] for cmd in self.cmdlets: if command == cmd.name: cmd.runner(args)<|fim_prefix|># repo: thorsteinson/board-vector-proto path:...
code_fim
hard
{ "lang": "python", "repo": "thorsteinson/board-vector-proto", "path": "/lib/cmdlet.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: dr-guangtou/asap path: /asap/scripts/um_precompute_pairs.py #!/usr/bin/env python """ Precompute lensing pairs using UniverseMachine SMDPL catalog. """ import os import argparse import numpy as np from astropy.table import Table from asap import vagc def main(um_file, ptl_file, wl_min_r=0.0...
code_fim
hard
{ "lang": "python", "repo": "dr-guangtou/asap", "path": "/asap/scripts/um_precompute_pairs.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> parser.add_argument( 'ptl_file', type=str, help=('Simulation particle table in .npy format')) parser.add_argument( '-l', '--r_low', dest='wl_min_r', help='Lower limit of the radial bin', type=float, default=0.08) parser.add_argument( '-u', '--r...
code_fim
hard
{ "lang": "python", "repo": "dr-guangtou/asap", "path": "/asap/scripts/um_precompute_pairs.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> parser.add_argument( '-n', '--n_bins', dest='wl_n_bins', help='Number of the radial bin', type=int, default=22) args = parser.parse_args() main(args.um_file, args.ptl_file, wl_min_r=args.wl_min_r, wl_max_r=args.wl_max_r, wl_n_bins=args.wl_n_bins)<|fi...
code_fim
hard
{ "lang": "python", "repo": "dr-guangtou/asap", "path": "/asap/scripts/um_precompute_pairs.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: frankygtd/connector-x path: /connectorx-python/connectorx/tests/test_oracle.py import os import pandas as pd import pytest from pandas.testing import assert_frame_equal from .. import read_sql @pytest.fixture(scope="module") # type: ignore def oracle_url() -> str: conn = os.environ["ORAC...
code_fim
hard
{ "lang": "python", "repo": "frankygtd/connector-x", "path": "/connectorx-python/connectorx/tests/test_oracle.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@pytest.mark.skipif(not os.environ.get("ORACLE_URL"), reason="Test oracle until we deploy oracle database") def test_empty_result(oracle_url: str) -> None: query = "select * from test_partition where TEST_INT < -100" df = read_sql( oracle_url, query ) expected = pd.DataFram...
code_fim
hard
{ "lang": "python", "repo": "frankygtd/connector-x", "path": "/connectorx-python/connectorx/tests/test_oracle.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: CFGIndia20/team-25 path: /API/app.py import json from googletrans import Translator from classification.categorize import pred from flask import Flask, render_template,request, redirect, url_for app = Flask(__name__) translator = Translator() @app.route('/complaints', methods=['POST']) def get_...
code_fim
hard
{ "lang": "python", "repo": "CFGIndia20/team-25", "path": "/API/app.py", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> @app.errorhandler(404) def not_found(e): """Simple error handler if there are calls to any other endpoint""" return json.dumps({"error": "Endpoint not found"}) if __name__ == '__main__': app.run(debug=True, port=5000)<|fim_prefix|># repo: CFGIndia20/team-25 path: /API/app.py import json...
code_fim
hard
{ "lang": "python", "repo": "CFGIndia20/team-25", "path": "/API/app.py", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> """Simple error handler if there are calls to any other endpoint""" return json.dumps({"error": "Endpoint not found"}) if __name__ == '__main__': app.run(debug=True, port=5000)<|fim_prefix|># repo: CFGIndia20/team-25 path: /API/app.py import json from googletrans import Translator from cla...
code_fim
hard
{ "lang": "python", "repo": "CFGIndia20/team-25", "path": "/API/app.py", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|># repo: Computational-Chemistry-Research/nanome-lib path: /nanome/_internal/_network/_commands/_serialization/_stream/_create_stream.py from nanome._internal._util._serializers import _ArraySerializer, _LongSerializer from nanome._internal._util._serializers import _TypeSerializer from nanome.util.enums ...
code_fim
medium
{ "lang": "python", "repo": "Computational-Chemistry-Research/nanome-lib", "path": "/nanome/_internal/_network/_commands/_serialization/_stream/_create_stream.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def name(self): return "StreamCreation" def serialize(self, version, value, context): stream_type = value[0] if version > 0: context.write_byte(stream_type) if version >= 2: context.write_byte(value[2]) if stream_type == SType.shape...
code_fim
medium
{ "lang": "python", "repo": "Computational-Chemistry-Research/nanome-lib", "path": "/nanome/_internal/_network/_commands/_serialization/_stream/_create_stream.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> class MessageRecvError(Exception): pass class RoutineStop(Exception): pass<|fim_prefix|># repo: pmdz/smite path: /smite/exceptions.py class ConnectionError(Exception): pass class ClientTimeout(Exception): pass class ServantBindError(Exception): pass <|fim_middle|> class ProxyB...
code_fim
hard
{ "lang": "python", "repo": "pmdz/smite", "path": "/smite/exceptions.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: pmdz/smite path: /smite/exceptions.py class ConnectionError(Exception): pass class ClientTimeout(Exception): pass <|fim_suffix|> super(MessageException, self).__init__(message) self.traceback = traceback class MessageRecvError(Exception): pass class RoutineStop(E...
code_fim
medium
{ "lang": "python", "repo": "pmdz/smite", "path": "/smite/exceptions.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>class ProxyBindError(Exception): pass class MessageException(Exception): def __init__(self, message, traceback): super(MessageException, self).__init__(message) self.traceback = traceback class MessageRecvError(Exception): pass class RoutineStop(Exception): pass<|fim...
code_fim
medium
{ "lang": "python", "repo": "pmdz/smite", "path": "/smite/exceptions.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: thanhtu19392/SmileML path: /src/smileml/pipeline.py from sklearn.base import BaseEstimator, TransformerMixin from sklearn import clone import pandas as pd import numpy as np from scipy import stats from sklearn.preprocessing import MinMaxScaler from sklearn.model_selection import cross_val_predic...
code_fim
hard
{ "lang": "python", "repo": "thanhtu19392/SmileML", "path": "/src/smileml/pipeline.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> class CountFrequencyEncoder(BaseEstimator, TransformerMixin): """ Encode the value by their frequency observed in the training set """ def __init__(self, min_card=5, count_na=False): self.min_card = min_card self.count_na = count_na self.vc = None def fit(sel...
code_fim
hard
{ "lang": "python", "repo": "thanhtu19392/SmileML", "path": "/src/smileml/pipeline.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.conn.execute("SELECT * FROM avc where class='Taboo' and attribute='name' and value='test_Taboo'") result = self.conn.fetchall() self.assertTrue(result > 0, "successful in adding Taboo") self.assertTrue(result[0][1] == "test_Taboo", "value didnot match for the added Tab...
code_fim
hard
{ "lang": "python", "repo": "mrlesmithjr/acitoolkit", "path": "/applications/search/aciSearch_update_local_database_test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: mrlesmithjr/acitoolkit path: /applications/search/aciSearch_update_local_database_test.py from acitoolkit.acisession import Session import unittest import sys import time import sqlite3 from acitoolkit.acitoolkit import * from acitoolkit.aciphysobject import * class TestTenantUpdateInDatabase(...
code_fim
hard
{ "lang": "python", "repo": "mrlesmithjr/acitoolkit", "path": "/applications/search/aciSearch_update_local_database_test.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>@pytest.mark.parametrize( 'exc,type_', ( (TypeError(), 'type_error'), (ValueError(), 'value_error'), (AssertionError(), 'assertion_error'), (errors.DecimalIsNotFiniteError(), 'value_error.decimal.not_finite'), ), ) def test_get_exc_type(exc, type_): if isins...
code_fim
hard
{ "lang": "python", "repo": "collerek/pydantic", "path": "/tests/test_errors.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: collerek/pydantic path: /tests/test_errors.py import pickle import sys from typing import Dict, List, Optional, Union from uuid import UUID, uuid4 import pytest from pydantic import UUID1, BaseConfig, BaseModel, PydanticTypeError, ValidationError, conint, errors, validator from pydantic.error_w...
code_fim
hard
{ "lang": "python", "repo": "collerek/pydantic", "path": "/tests/test_errors.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def test_single_error(): class Model(BaseModel): x: int with pytest.raises(ValidationError) as exc_info: Model(x='x') expected = """\ 1 validation error for Model x value is not a valid integer (type=type_error.integer)""" assert str(exc_info.value) == expected asse...
code_fim
hard
{ "lang": "python", "repo": "collerek/pydantic", "path": "/tests/test_errors.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """Concatenation model.""" def __init__(self, opt, texts): super(Concat, self).__init__(opt, texts) embed_dim = opt.embed_dim class Composer(torch.nn.Module): """Inner composer class.""" def __init__(self, opt): super(Composer, sel...
code_fim
hard
{ "lang": "python", "repo": "huynhtruc0309/maaf", "path": "/models/third_party/tirg.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> dots = torch.mm(mod_img1, img2.transpose(0, 1)) labels = torch.tensor(range(dots.shape[0])).long() labels = torch.autograd.Variable(labels).cuda() losses = F.cross_entropy(dots, labels, reduction='none') if self.opt.drop_worst_flag: losses, idx = torch.t...
code_fim
hard
{ "lang": "python", "repo": "huynhtruc0309/maaf", "path": "/models/third_party/tirg.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: huynhtruc0309/maaf path: /models/third_party/tirg.py # Copyright 2019 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.ap...
code_fim
hard
{ "lang": "python", "repo": "huynhtruc0309/maaf", "path": "/models/third_party/tirg.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: 50183816/lineregression path: /HMM/whiteblackball.py # _*_ codig utf8 _*_ import numpy as np # HMM前向算法 # def hmm_forward(pi, A, B, s): ''' :param pi: :param A: :param B: :param s: :return: ''' alpha = pi * B[:, s[0]] print(alpha) for index in np.arange(...
code_fim
hard
{ "lang": "python", "repo": "50183816/lineregression", "path": "/HMM/whiteblackball.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>if __name__ == '__main__': pi = np.array([0.2, 0.5, 0.3]) A = np.array([ [0.5, 0.4, 0.1], [0.2, 0.2, 0.6], [0.2, 0.5, 0.3] ]) B = np.array([ [0.4, 0.6], [0.8, 0.2], [0.5, 0.5] ]) s = [0, 1, 0, 0, 1] final, p = hmm_viterbi(pi, A, ...
code_fim
hard
{ "lang": "python", "repo": "50183816/lineregression", "path": "/HMM/whiteblackball.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>0\x00\x00\x00\x00J\x00\x13\x00\x01\x00L\x00e\x00g\x00a\x00l\x00C\x00o\x00p\x00y\x00r\x00i\x00g\x00h\x00t\x00\x00\x00C\x00o\x00p\x00y\x00r\x00i\x00g\x00h\x00t\x00 \x00\xa9\x00 \x00.\x00 \x002\x000\x002\x000\x00\x00\x00\x00\x00*\x00\x01\x00\x01\x00L\x00e\x00g\x00a\x00l\x00T\x00r\x00a\x00d\x00e\x00m\x00a\x00...
code_fim
hard
{ "lang": "python", "repo": "target/strelka", "path": "/src/python/strelka/tests/test_scan_png_eof.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: target/strelka path: /src/python/strelka/tests/test_scan_png_eof.py from pathlib import Path from unittest import TestCase, mock from strelka.scanners.scan_png_eof import ScanPngEof as ScanUnderTest from strelka.tests import run_test_scan def test_scan_png_eof(mocker): """ Pass: Sample...
code_fim
hard
{ "lang": "python", "repo": "target/strelka", "path": "/src/python/strelka/tests/test_scan_png_eof.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: haowu666/pytext path: /pytext/data/tokenizers/tokenizer.py #!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import re from typing import List, NamedTuple from pytext.config.component import Component, ComponentType class Token(NamedTuple): valu...
code_fim
hard
{ "lang": "python", "repo": "haowu666/pytext", "path": "/pytext/data/tokenizers/tokenizer.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> @classmethod def from_config(cls, config: Config): return cls() def __init__(self): super().__init__(None) def tokenize(self, input: List[str]) -> List[Token]: tokens = [Token(token_text, -1, -1) for token_text in input if token_text] return tokens<|fim_pr...
code_fim
hard
{ "lang": "python", "repo": "haowu666/pytext", "path": "/pytext/data/tokenizers/tokenizer.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> @classmethod def from_config(cls, config: Config): return cls(config.split_regex, config.lowercase) def __init__(self, split_regex=r"\s+", lowercase=True): super().__init__(None) self.split_regex = split_regex self.lowercase = lowercase def tokenize(self, ...
code_fim
hard
{ "lang": "python", "repo": "haowu666/pytext", "path": "/pytext/data/tokenizers/tokenizer.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: torfinnnome-test/usegalaxy-no-tools-1 path: /scripts/write_report_from_log.py import csv import sys import argparse default_tool_shed = 'toolshed.g2.bx.psu.edu' log_file = 'automated_tool_installation_log.tsv' """ Generate a report of weekly installations and updates on usegalaxy.no Because thi...
code_fim
hard
{ "lang": "python", "repo": "torfinnnome-test/usegalaxy-no-tools-1", "path": "/scripts/write_report_from_log.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> rows = [ row_num for (row_num, row) in enumerate(table) if row['Category'] == build_category.title() and row['Build Num.'] == str(build_number) ] return (rows[0], rows[-1]) def tool_table(tool_dict): content = '| Section | Tool |\n|---------|-----|\n' for section in sorted(to...
code_fim
hard
{ "lang": "python", "repo": "torfinnnome-test/usegalaxy-no-tools-1", "path": "/scripts/write_report_from_log.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return line_y, line_x def plotting_tip(diff_min_x, diff_min_y): tip_x = int(round(diff_min_x/rescale_factor)) tip_y = int(round(diff_min_y/rescale_factor)) circle_y, circle_x = disk([tip_y, tip_x], 12) frame_raw[circle_y, circle_x] = 1 return #def plot_lines():<|f...
code_fim
hard
{ "lang": "python", "repo": "janwolzenburg/us-detection-biopsy-needle", "path": "/needle_detection/plotting.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: janwolzenburg/us-detection-biopsy-needle path: /needle_detection/plotting.py import numpy as np import astropy.convolution as ascon from scipy import ndimage, signal from skimage import draw """ description gets the x- and y-values representing the line to be drawn in the raw frame ...
code_fim
hard
{ "lang": "python", "repo": "janwolzenburg/us-detection-biopsy-needle", "path": "/needle_detection/plotting.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def plotting_tip(diff_min_x, diff_min_y): tip_x = int(round(diff_min_x/rescale_factor)) tip_y = int(round(diff_min_y/rescale_factor)) circle_y, circle_x = disk([tip_y, tip_x], 12) frame_raw[circle_y, circle_x] = 1 return #def plot_lines():<|fim_prefix|># repo: janwolzenbur...
code_fim
hard
{ "lang": "python", "repo": "janwolzenburg/us-detection-biopsy-needle", "path": "/needle_detection/plotting.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: g0e/ccd3 path: /dist/server/echo_csv.py #!/usr/bin/python3 # coding:utf-8 <|fim_suffix|>params = cgi.FieldStorage() print("Content-Disposition: attachment; filename=" + params.getfirst("file_name","data.csv")) print("Content-Type: text/csv;\n") print(params.getfirst("file_contents",""))<|fim_mid...
code_fim
easy
{ "lang": "python", "repo": "g0e/ccd3", "path": "/dist/server/echo_csv.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>params = cgi.FieldStorage() print("Content-Disposition: attachment; filename=" + params.getfirst("file_name","data.csv")) print("Content-Type: text/csv;\n") print(params.getfirst("file_contents",""))<|fim_prefix|># repo: g0e/ccd3 path: /dist/server/echo_csv.py #!/usr/bin/python3 # coding:utf-8 <|fim_mid...
code_fim
easy
{ "lang": "python", "repo": "g0e/ccd3", "path": "/dist/server/echo_csv.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> serializer_class = webSerializers.PracticeAttackDefenseTaskSerializer queryset = PracticeAttackDefenseTask.objects.filter(is_copy=False, event__public=True).order_by('lock', '-id', ) cms_serializer = cmsSerializers.PracticeAttackDefenseTaskSerializer web_serializer = webSerializers.Practic...
code_fim
medium
{ "lang": "python", "repo": "g842995907/guops-know", "path": "/test-xooj/practice_attack_defense/api.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: g842995907/guops-know path: /test-xooj/practice_attack_defense/api.py # -*- coding: utf-8 -*- from practice.api import Practice from practice_attack_defense.cms import serializers as cmsSerializers from practice_attack_defense.models import PracticeAttackDefenseTask, PracticeAttackDefenseCategor...
code_fim
medium
{ "lang": "python", "repo": "g842995907/guops-know", "path": "/test-xooj/practice_attack_defense/api.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> backend_uri = None tmp_path = None try: if example_utils.SQLALCHEMY_AVAILABLE: tmp_path = tempfile.mktemp(prefix='tf-resume-example') backend_uri = "sqlite:///%s" % (tmp_path) else: tmp_path = tempfile.mkdtemp(prefix='tf-resume-example') ...
code_fim
hard
{ "lang": "python", "repo": "openstack/taskflow", "path": "/taskflow/examples/resume_many_flows.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: openstack/taskflow path: /taskflow/examples/resume_many_flows.py # -*- coding: utf-8 -*- # Copyright (C) 2013 Yahoo! Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may o...
code_fim
hard
{ "lang": "python", "repo": "openstack/taskflow", "path": "/taskflow/examples/resume_many_flows.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> stdout, _stderr = proc.communicate() rc = proc.returncode if rc != 0: raise RuntimeError("Could not run %s [%s]", cmd, rc) print(stdout.decode()) def _path_to(name): return os.path.abspath(os.path.join(os.path.dirname(__file__), 'resume...
code_fim
hard
{ "lang": "python", "repo": "openstack/taskflow", "path": "/taskflow/examples/resume_many_flows.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: CloudVE/galaxycloudrunner path: /galaxycloudrunner/__init__.py """GalaxyCloudRunner library setup.""" # Current version of the library __version__ = "0.3.0+dev" <|fim_suffix|> :rtype: ``string`` :return: Library version (e.g., "0.1.0"). """ return __version__<|fim_middle|>def g...
code_fim
medium
{ "lang": "python", "repo": "CloudVE/galaxycloudrunner", "path": "/galaxycloudrunner/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Return a string with the current version of the library. :rtype: ``string`` :return: Library version (e.g., "0.1.0"). """ return __version__<|fim_prefix|># repo: CloudVE/galaxycloudrunner path: /galaxycloudrunner/__init__.py """GalaxyCloudRunner library setup.""" <|fim_midd...
code_fim
medium
{ "lang": "python", "repo": "CloudVE/galaxycloudrunner", "path": "/galaxycloudrunner/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def get_version(): """ Return a string with the current version of the library. :rtype: ``string`` :return: Library version (e.g., "0.1.0"). """ return __version__<|fim_prefix|># repo: CloudVE/galaxycloudrunner path: /galaxycloudrunner/__init__.py """GalaxyCloudRunner library se...
code_fim
medium
{ "lang": "python", "repo": "CloudVE/galaxycloudrunner", "path": "/galaxycloudrunner/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: F5Networks/f5-common-python path: /f5/bigip/tm/sys/sflow.py # coding=utf-8 # # Copyright 2017 F5 Networks Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # ht...
code_fim
hard
{ "lang": "python", "repo": "F5Networks/f5-common-python", "path": "/f5/bigip/tm/sys/sflow.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> super(Receivers, self).__init__(sflow) self._meta_data['allowed_lazy_attributes'] = [Receiver] self._meta_data['attribute_registry'] =\ {'tm:sys:sflow:receiver:receiverstate': Receiver} class Receiver(Resource): def __init__(self, receivers): super(Receive...
code_fim
hard
{ "lang": "python", "repo": "F5Networks/f5-common-python", "path": "/f5/bigip/tm/sys/sflow.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def test_unique(self): # A job can not be created without a jobtype, create one first jobtype = JobType() jobtype.name = "foo" jobtype.description = "this is a job type" jobtype.classname = "Foobar" jobtype.code = dedent(""" class Foobar(JobType)...
code_fim
hard
{ "lang": "python", "repo": "pyfarm/pyfarm-master", "path": "/tests/test_models/test_model_job.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: pyfarm/pyfarm-master path: /tests/test_models/test_model_job.py # No shebang line, this module is meant to be imported # # Copyright 2013 Oliver Palmer # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may ...
code_fim
hard
{ "lang": "python", "repo": "pyfarm/pyfarm-master", "path": "/tests/test_models/test_model_job.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: pitzer42/opbk-br-quickstart path: /validate.py from opbk_br_quickstart.client_factory import create_client, ApiFamily, AdminApiFamily,CommonApiFamily, ChannelsApiFamily, ProductsServicesApiFamily from participant_endpoints import get_endpoints <|fim_suffix|>def validate_client(client): for m...
code_fim
hard
{ "lang": "python", "repo": "pitzer42/opbk-br-quickstart", "path": "/validate.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return methods def validate_participant(participant, host): print(header) print(participant) print(header) validate_client(create_client( host, ApiFamily.ADMIN, AdminApiFamily.METRICS)) validate_client(create_client( host, ApiFamily....
code_fim
hard
{ "lang": "python", "repo": "pitzer42/opbk-br-quickstart", "path": "/validate.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: lpieri/api_slack path: /clean_channel.py import requests from error import * def clean_channel(channel2clean, token): print ('Your token is: {token}'.format(token=token)) chan_to_find = channel2clean response = requests.get('https://slack.com/api/channels.list?limit=100&token={token}'.format(...
code_fim
hard
{ "lang": "python", "repo": "lpieri/api_slack", "path": "/clean_channel.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> doesn\'t exist !') confirmation = input('Really want to delete all messages from this channel ? [y/n]') if confirmation == 'y': response = requests.get('https://slack.com/api/channels.history?count=1000&channel={id}&token={token}'.format(id=chan_id, token=token)).json() if response['ok'] == False: ...
code_fim
hard
{ "lang": "python", "repo": "lpieri/api_slack", "path": "/clean_channel.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """"Takes in a list of images and returns the activation dictionary.""" if auto_resize: images_ = [imresize(im, (224, 224)) for im in images] else: images_ = images feed_dict = {self.input_images: images_} return sess.run(vgg.activations, fee...
code_fim
hard
{ "lang": "python", "repo": "HangJie720/Classifiers2LearnWith", "path": "/experiments/vgg16_pre-trained/vgg16_pre-trained-alt.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: HangJie720/Classifiers2LearnWith path: /experiments/vgg16_pre-trained/vgg16_pre-trained-alt.py """A pre-trained implimentation of VGG16 with weights trained on ImageNet. NOTE: It's not a great idea to use tf.constant to take in large arrays that will not change, better to use a non-trainable var...
code_fim
hard
{ "lang": "python", "repo": "HangJie720/Classifiers2LearnWith", "path": "/experiments/vgg16_pre-trained/vgg16_pre-trained-alt.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> parameters = [] # storage for trainable parameters # pooling arguments _ksize = [1, 2, 2, 1] _strides = [1, 2, 2, 1] # center the input images with tf.name_scope('preprocess_centering'): mean = tf.constant([123.68, 116.779, 103.939], dtype=tf...
code_fim
hard
{ "lang": "python", "repo": "HangJie720/Classifiers2LearnWith", "path": "/experiments/vgg16_pre-trained/vgg16_pre-trained-alt.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def generate_credential(s): '''basic_auth_header will return a base64 encoded header object to :param username: the username ''' if sys.version_info[0] >= 3: s = bytes(s, 'utf-8') credentials = base64.b64encode(s).decode('utf-8') else: credentials = base64.b64en...
code_fim
hard
{ "lang": "python", "repo": "mconcas/singularity-python", "path": "/singularity/registry/auth.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # If token file not provided, check environment if secrets is None: secrets = os.environ.get("SREGISTRY_CLIENT_SECRETS") # Fall back to default if secrets is None: userhome = pwd.getpwuid(os.getuid())[5] secrets = "%s/.sregistry" % (userhome) if secrets is not...
code_fim
hard
{ "lang": "python", "repo": "mconcas/singularity-python", "path": "/singularity/registry/auth.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mconcas/singularity-python path: /singularity/registry/auth.py ''' auth.py: authentication functions for singularity hub api currently no token / auth for private collections The MIT License (MIT) Copyright (c) 2016-2017 Vanessa Sochat Permission is hereby granted, free of charge, to ...
code_fim
hard
{ "lang": "python", "repo": "mconcas/singularity-python", "path": "/singularity/registry/auth.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: molejar/project_generator path: /tests/test_commands/test_import.py # Copyright 2015 0xc0170 # # 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.o...
code_fim
medium
{ "lang": "python", "repo": "molejar/project_generator", "path": "/tests/test_commands/test_import.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """test import command""" def setUp(self): if not os.path.exists('test_workspace'): os.makedirs('test_workspace') # write project file with open(os.path.join(os.getcwd(), 'test_workspace/template_file'), 'wt') as f: f.write(yaml.dump('Hello', defau...
code_fim
medium
{ "lang": "python", "repo": "molejar/project_generator", "path": "/tests/test_commands/test_import.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: CheetahTemplate3/cheetah3 path: /Cheetah/Tests/Test.py #!/usr/bin/env python """ Core module of Cheetah's Unit-testing framework TODO ================================================================================ # combo tests # negative test cases for expected exceptions # black-box vs clear-...
code_fim
hard
{ "lang": "python", "repo": "CheetahTemplate3/cheetah3", "path": "/Cheetah/Tests/Test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>from Cheetah.Tests import Analyzer # noqa: E402 from Cheetah.Tests import CheetahWrapper # noqa: E402 from Cheetah.Tests import Filters # noqa: E402 from Cheetah.Tests import ImportHooks # noqa: E402 from Cheetah.Tests import LoadTemplate # noqa: E402 from Cheetah.Tests import Misc # noqa: E402 from...
code_fim
hard
{ "lang": "python", "repo": "CheetahTemplate3/cheetah3", "path": "/Cheetah/Tests/Test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Args: x(torch.Tensor): Input tensor. """ b, _, _ = x.shape if self.has_cls: cls_tokens = self.cls_token.expand(b, -1, -1) x = torch.cat((cls_tokens, x), dim=1) if self.sep_pos_embed: pos_em...
code_fim
hard
{ "lang": "python", "repo": "NbnbZero/towhee", "path": "/towhee/models/layers/spatial_temporal_cls_positional_encoding.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: NbnbZero/towhee path: /towhee/models/layers/spatial_temporal_cls_positional_encoding.py # Copyright 2021 Zilliz and Facebook. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtai...
code_fim
hard
{ "lang": "python", "repo": "NbnbZero/towhee", "path": "/towhee/models/layers/spatial_temporal_cls_positional_encoding.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """ Add a cls token and apply a spatial-temporal encoding to a tensor. Args: embed_dim(int): Embedding dimension for input sequence. patch_embed_shape(Tuple): The number of patches in each dimension (T, H, W) after patch embedding. sep_pos_embed(...
code_fim
hard
{ "lang": "python", "repo": "NbnbZero/towhee", "path": "/towhee/models/layers/spatial_temporal_cls_positional_encoding.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: kilbyjmichael/pi_temp path: /led_temp.py from w1thermsensor import W1ThermSensor import RPi.GPIO as GPIO from datetime import datetime import time import sqlite3 GPIO.setmode(GPIO.BCM) blue_led = 16 orange_led = 20 red_led = 21 GPIO.setup(blue_led,GPIO.OUT) GPIO.setup(orange_led,GPIO.OUT) GPIO.s...
code_fim
hard
{ "lang": "python", "repo": "kilbyjmichael/pi_temp", "path": "/led_temp.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> GPIO.output(chosen_light,GPIO.HIGH) time.sleep(0.25) GPIO.output(chosen_light,GPIO.LOW) time.sleep(0.25) GPIO.output(chosen_light,GPIO.HIGH) time.sleep(0.25) GPIO.output(chosen_light,GPIO.LOW) time.sleep(0.25) GPIO.output(chosen_light,GPIO.HIGH) time.sleep(0.25) ...
code_fim
hard
{ "lang": "python", "repo": "kilbyjmichael/pi_temp", "path": "/led_temp.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: aimanow/sft path: /src/backend/app/api/public/aspects/aspect/aspect_favorite.py import datetime from http import HTTPStatus from flask_login import current_user from flask_restplus import Resource, abort from app.api.models import AspectModel from app.api.namespaces import aspects from database...
code_fim
medium
{ "lang": "python", "repo": "aimanow/sft", "path": "/src/backend/app/api/public/aspects/aspect/aspect_favorite.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if not current_user.favorite_aspects_backref.filter_by(favorite_id=aspect_id).delete(): current_user.favorite_aspects_backref.append(FavoriteAspect( favorite_id=aspect_id, created_at=datetime.datetime.now() )) db.session.commit() ...
code_fim
hard
{ "lang": "python", "repo": "aimanow/sft", "path": "/src/backend/app/api/public/aspects/aspect/aspect_favorite.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: GabrielRojas74/CajeroEAN path: /CajeroEANFinal.py uiere retirar", font=("Bahnschrift SemiBold Condensed",25, BOLD), bg="purple", fg="#271F26", width="40", height=2, bd=8, relief=RAISED) reti.pack(pady=25) clavecd= tk.Label(bancop, text="Monto:", font=("Bahnschrift SemiBol...
code_fim
hard
{ "lang": "python", "repo": "GabrielRojas74/CajeroEAN", "path": "/CajeroEANFinal.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> bancop=tk.Toplevel() bancop.geometry("300x300") bancop.title("Transferencia exitosa") bancop.configure(bd=40, bg="Magenta") dinerocaja = Label(bancop, text="Su nuevo saldo es de: ", font=("Bahnschri...
code_fim
hard
{ "lang": "python", "repo": "GabrielRojas74/CajeroEAN", "path": "/CajeroEANFinal.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: GabrielRojas74/CajeroEAN path: /CajeroEANFinal.py tillium", 15, BOLD)) entradanud.pack(pady=7) # enti = tk.Label(win, text="Entidad", font=("titillium", 16), bg="#3bac53", fg="black") enti.pack(pady=3, side=tk.TOP) entradant = tk.Entry(win, font=("titillium", 15, BOLD)) en...
code_fim
hard
{ "lang": "python", "repo": "GabrielRojas74/CajeroEAN", "path": "/CajeroEANFinal.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: openprocurement/openprocurement.auctions.core path: /openprocurement/auctions/core/tests/plugins/awarding/v3/tests/blanks/migration_blanks.py from uuid import uuid4 from copy import deepcopy from isodate import parse_datetime from openprocurement.api.utils import get_now, set_specific_hour fro...
code_fim
hard
{ "lang": "python", "repo": "openprocurement/openprocurement.auctions.core", "path": "/openprocurement/auctions/core/tests/plugins/awarding/v3/tests/blanks/migration_blanks.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> auction.update(auction) self.db.save(auction) self.migrate_data(self.app.app.registry) response = self.app.get('/auctions/{}'.format(self.auction_id)) auction = response.json['data'] self.assertEqual(auction['status'], u'active.qualification') self.assertEqual(auction['awards'...
code_fim
hard
{ "lang": "python", "repo": "openprocurement/openprocurement.auctions.core", "path": "/openprocurement/auctions/core/tests/plugins/awarding/v3/tests/blanks/migration_blanks.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: HiroIshida/RobotOS.jl path: /src/ros_callbacks.py #Python 2/3 compatibility with 3 style code from __future__ import absolute_import, division, print_function, unicode_literals __metaclass__ = type import sys import ctypes import threading try: import queue except ImportError: import Que...
code_fim
hard
{ "lang": "python", "repo": "HiroIshida/RobotOS.jl", "path": "/src/ros_callbacks.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self._queue.put(msg) self._cb_notify(self._notify_handle) def size(self): return self._queue.qsize() def get(self): return self._queue.get() class ServiceCallback: def __init__(self, cbptr, notify_handle): CBType = ctypes.CFUNCTYPE(ctypes.c_int, ctype...
code_fim
medium
{ "lang": "python", "repo": "HiroIshida/RobotOS.jl", "path": "/src/ros_callbacks.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> CBType = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p) self._cb_notify = CBType(cbptr.value) self._notify_handle = notify_handle self._queue = queue.Queue() def storemsg(self, msg): self._queue.put(msg) self._cb_notify(self._notify_handle) def s...
code_fim
medium
{ "lang": "python", "repo": "HiroIshida/RobotOS.jl", "path": "/src/ros_callbacks.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jpiv/RocketLeagueRL path: /bot-1/src/bot.py import logging, os import math logging.disable(logging.INFO) os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3" from rlbot.agents.base_agent import BaseAgent, SimpleControllerState from rlbot.messages.flat.QuickChatSelection import QuickChatSelection from rlbot....
code_fim
hard
{ "lang": "python", "repo": "jpiv/RocketLeagueRL", "path": "/bot-1/src/bot.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.set_controls_from_model(packet, controls) self.last_state = controls return controls def set_controls_from_model(self, tick, controls): actions = self.get_actions(tick) if (len(actions) > 1): controls.throttle = actions[OutputOptions.THROTTL...
code_fim
hard
{ "lang": "python", "repo": "jpiv/RocketLeagueRL", "path": "/bot-1/src/bot.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: proh4cktive/phk-logger path: /phk_logger/phkLogger.py # -*- coding: utf-8 -*- import logging from .stdLogger import STDLogger class PHKLogger(STDLogger): """ProHacktive Logging class Set user-friendly methods to log event with specific log level """ def __init__( self, ...
code_fim
hard
{ "lang": "python", "repo": "proh4cktive/phk-logger", "path": "/phk_logger/phkLogger.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Returns: None """ # Clean message message = str(message).rstrip() # Only log if there is a message (not just a new line) if message == "": return None # Autoset level if necessary if level is None: level...
code_fim
hard
{ "lang": "python", "repo": "proh4cktive/phk-logger", "path": "/phk_logger/phkLogger.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def generate_pretty_key(*args, **kwargs): """Same as generate_str_key(), except the key is formated to make debugging easier """ return '\n'.join(( "", "\tindex: {}".format(str(kwargs.get('index'))), "\tdoc_type: {}".format(str(kwargs.get('doc_type'))), "\tb...
code_fim
hard
{ "lang": "python", "repo": "fjbsantiago/elasticmock", "path": "/elasticmock/utilities/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if isinstance(item, dict): self.sort_dict_recursively(item) elif not isinstance(item, str) and isinstance(item, collections.Iterable): self.sort_items_recursively(item) def generate_str_key(*args, **kwargs): """Converts elastic search kwargs in...
code_fim
hard
{ "lang": "python", "repo": "fjbsantiago/elasticmock", "path": "/elasticmock/utilities/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: fjbsantiago/elasticmock path: /elasticmock/utilities/__init__.py # -*- coding: utf-8 -*- import random import string import hashlib import collections from sortedcontainers import SortedDict DEFAULT_ELASTICSEARCH_ID_SIZE = 20 CHARSET_FOR_ELASTICSEARCH_ID = string.ascii_letters + string.digits ...
code_fim
hard
{ "lang": "python", "repo": "fjbsantiago/elasticmock", "path": "/elasticmock/utilities/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: michaelhabeck/isdhic path: /tests/test_nblist.py """ Testing neighbor list """ import isdhic import numpy as np from scipy.spatial import cKDTree from scipy.spatial.distance import squareform from csb.bio.utils import distance_matrix <|fim_suffix|> c = np.zeros((n_particles,n_particles),'i'...
code_fim
hard
{ "lang": "python", "repo": "michaelhabeck/isdhic", "path": "/tests/test_nblist.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def nblist_contacts(nblist, universe): nblist.update(universe) return nblist.ctype.contacts def nblist_pairs(nblist, universe): contacts = nblist_contacts(nblist, universe) contacts = [contacts[i,:l] for i, l in enumerate(nblist.ctype.n_contacts.tolist())] return [(i,j) for i in ra...
code_fim
medium
{ "lang": "python", "repo": "michaelhabeck/isdhic", "path": "/tests/test_nblist.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def nblist_pairs(nblist, universe): contacts = nblist_contacts(nblist, universe) contacts = [contacts[i,:l] for i, l in enumerate(nblist.ctype.n_contacts.tolist())] return [(i,j) for i in range(len(contacts)) for j in contacts[i]] def pairs_to_matrix(pairs, n_particles): c = np.zeros((...
code_fim
medium
{ "lang": "python", "repo": "michaelhabeck/isdhic", "path": "/tests/test_nblist.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def insert_data(sql, params): #Insert crypto currencies data to database. try: con = connect_to_db() logging.info('Connected to database.') stmt = ibm_db.prepare(con, sql) o = ibm_db.execute_many(stmt, tuple(params)) logging.info(f'{o} records inserte...
code_fim
hard
{ "lang": "python", "repo": "rmayherr/crypto_app", "path": "/crypto_app.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: rmayherr/crypto_app path: /crypto_app.py """ Application download current stock prices of 5 top crypto currency. Data are inserted to db2 database. """ import os.path import json import configparser import logging import sys import requests import ibm_db coins = {'BTC': 'Bitcoin', ...
code_fim
hard
{ "lang": "python", "repo": "rmayherr/crypto_app", "path": "/crypto_app.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }