text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> name = 'Pineapple' aliases = ['pine', 'pineapple'] filenames = ['*.pine', '*.pineapple'] flags = re.DOTALL | re.UNICODE | re.MULTILINE tokens = { 'commentsandwhitespace': [ (r'\s+', Text), (r'<!--', Comment), (r'//.*?\n', Comment.Single), ...
code_fim
hard
{ "lang": "python", "repo": "wongjiahau/Pineapple", "path": "/pineapple.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: wongjiahau/Pineapple path: /pineapple.py # -*- coding: utf-8 -*- """ pygments.lexers.pineapple ~~~~~~~~~~~~~~~~~~~~~~~~~~ Lexers for Pineapple language. :copyright: Copyright 2018 by Wong Jia Hau. :license: Apache 2.0 """ """ This file is modified from pygments.lexers.javasc...
code_fim
hard
{ "lang": "python", "repo": "wongjiahau/Pineapple", "path": "/pineapple.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>all_data = sorted(all_data, key = lambda i: i['count'], reverse=True) ujson.dump(all_data,open(f"{viz_data_dir}wiki_identifier_links.json",'w'),indent=2)<|fim_prefix|># repo: thisismattmiller/swib-2020-resources path: /build_data_scripts/wiki_ident_links.py import requests import ujson from pathlib impor...
code_fim
hard
{ "lang": "python", "repo": "thisismattmiller/swib-2020-resources", "path": "/build_data_scripts/wiki_ident_links.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: thisismattmiller/swib-2020-resources path: /build_data_scripts/wiki_ident_links.py import requests import ujson from pathlib import Path wikidata_data_file = f"{str(Path.home())}/data/swib_data/wikidata_entities.ndjson" viz_data_dir = f"{str(Path.home())}/data/swib_data/viz_data_source/" wikid...
code_fim
hard
{ "lang": "python", "repo": "thisismattmiller/swib-2020-resources", "path": "/build_data_scripts/wiki_ident_links.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return self._approximator.predict(state, **self._predict_params) def set_weights(self, weights): self._approximator.set_weights(weights) def get_weights(self): return self._approximator.get_weights() @property def weights_size(self): return self._approxim...
code_fim
hard
{ "lang": "python", "repo": "MushroomRL/mushroom-rl", "path": "/mushroom_rl/policy/deterministic_policy.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: MushroomRL/mushroom-rl path: /mushroom_rl/policy/deterministic_policy.py import numpy as np from .policy import ParametricPolicy class DeterministicPolicy(ParametricPolicy): """ Simple parametric policy representing a deterministic policy. As deterministic policies are degenerate pr...
code_fim
medium
{ "lang": "python", "repo": "MushroomRL/mushroom-rl", "path": "/mushroom_rl/policy/deterministic_policy.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def get_regressor(self): """ Getter. Returns: The regressor that is used to map state to actions. """ return self._approximator def __call__(self, state, action): policy_action = self._approximator.predict(state, **self._predict_params...
code_fim
hard
{ "lang": "python", "repo": "MushroomRL/mushroom-rl", "path": "/mushroom_rl/policy/deterministic_policy.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if replacements != None: replace_sets = replace_sets + replacements for replace_set in replace_sets: text = replace_set[0] replacement = replace_set[1] html = html.replace(text,replacement) return html def update_lookup(lookup,key,entry): '''update_lo...
code_fim
hard
{ "lang": "python", "repo": "rwblair/cogat-docker", "path": "/cognitive/apps/atlas/utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: rwblair/cogat-docker path: /cognitive/apps/atlas/utils.py from django.utils.crypto import get_random_string from py2neo import Path, Node, Relationship from cognitive.settings import graph import pandas def generate_uid(node_type): '''generte_uid will generate a unique identifier for a new ...
code_fim
hard
{ "lang": "python", "repo": "rwblair/cogat-docker", "path": "/cognitive/apps/atlas/utils.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pix_hw = [h//2,w//2] # pix_hw = [h//2,w//2] vBurst = vals.Burst[:,pix_hw[0],pix_hw[1],:].cpu().numpy()[0] vSubBurst = vals.SubBurst[:,pix_hw[0],pix_hw[1],:].cpu().numpy()[0] iBurstValid = np.where(vBurst < 1e10) iSubBurstValid = np.where(vSubBurst < 1e10) assert np.all(iBurstVa...
code_fim
hard
{ "lang": "python", "repo": "gauenk/faiss_fork", "path": "/tests/test_burst_patch_distance.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: gauenk/faiss_fork path: /tests/test_burst_patch_distance.py hw[0]+flow_t[0]# - psHalf +0# dx startW = pix_hw[1] + flow_t[1] + padOffset # dx endW = startW + ps sliceW = slice(startW,endW) # print(pix_hw,startH,startW,burst.shape) patch_t = burst[t,0,:,slic...
code_fim
hard
{ "lang": "python", "repo": "gauenk/faiss_fork", "path": "/tests/test_burst_patch_distance.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: gauenk/faiss_fork path: /tests/test_burst_patch_distance.py ls,_locs = bnnf_utils.runBurstNnf(burst, patchsize, nblocks, k = k, valMean = valMean, blockLabels=None, ...
code_fim
hard
{ "lang": "python", "repo": "gauenk/faiss_fork", "path": "/tests/test_burst_patch_distance.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> regex = DifferentiableRegex(Regex('(a * b | c) * d')) correct = ['cd', 'aaabd', 'aabcd', 'abbd'] incorrect = ['dd', 'aaaad', 'ababc', 'q'] for word in correct: assert(regex.accepts(word)) for word in incorrect: assert(not regex.accepts(word)) def test_comp_regex_redu...
code_fim
hard
{ "lang": "python", "repo": "AlekseiPrivalihin/FormalLanguageTheory", "path": "/tests/test_ExtraTask01.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: AlekseiPrivalihin/FormalLanguageTheory path: /tests/test_ExtraTask01.py from pyformlang.regular_expression import Regex from DifferentiableRegex import DifferentiableRegex def test_simple_regex(): regexes = ["a", "a b", "a | b", "a*"] answers = ["a", "ab", "b", "aaa"] for i in range(...
code_fim
hard
{ "lang": "python", "repo": "AlekseiPrivalihin/FormalLanguageTheory", "path": "/tests/test_ExtraTask01.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: 4DNucleome/PartSeg path: /package/PartSeg/common_gui/algorithms_description.py s) for name, value in values.items(): if name in self.widgets_dict: self.widgets_dict[name].set_value(value) def image_changed(self, image: Image): if not image: ...
code_fim
hard
{ "lang": "python", "repo": "4DNucleome/PartSeg", "path": "/package/PartSeg/common_gui/algorithms_description.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: 4DNucleome/PartSeg path: /package/PartSeg/common_gui/algorithms_description.py if ap.range is not None: res.setRange(*ap.range) return res @classmethod def _get_field_from_value_type(cls, ap: AlgorithmProperty): if issubclass(ap.value_type, Channel): ...
code_fim
hard
{ "lang": "python", "repo": "4DNucleome/PartSeg", "path": "/package/PartSeg/common_gui/algorithms_description.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def set_values(self, values: typing.Union[dict, BaseModel]): if isinstance(values, BaseModel): values = dict(values) for name, value in values.items(): if name in self.widgets_dict: self.widgets_dict[name].set_value(value) def image_changed(...
code_fim
hard
{ "lang": "python", "repo": "4DNucleome/PartSeg", "path": "/package/PartSeg/common_gui/algorithms_description.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: yangsuhui/Boosted-OICR path: /code/tasks/test.py lipped image. Function signature is the same as for im_detect_bbox. """ # Compute predictions on the flipped image im_hf = im[:, ::-1, :] im_width = im.shape[1] box_proposals_hf = box_utils.flip_boxes(box_proposals, im_widt...
code_fim
hard
{ "lang": "python", "repo": "yangsuhui/Boosted-OICR", "path": "/code/tasks/test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """Return empty results lists for boxes, masks, and keypoints. Box detections are collected into: all_boxes[cls][image] = N x 5 array with columns (x1, y1, x2, y2, score) Instance mask predictions are collected into: all_segms[cls][image] = [...] list of COCO RLE encoded masks that...
code_fim
hard
{ "lang": "python", "repo": "yangsuhui/Boosted-OICR", "path": "/code/tasks/test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # print("test_net_on_dataset") """Run inference on a dataset.""" dataset = JsonDataset(dataset_name) test_timer = Timer() test_timer.tic() all_boxes = test_net(args, dataset_name, proposal_file, output_dir, gpu_id=gpu_id, early_stop=early_stop) test_timer.to...
code_fim
hard
{ "lang": "python", "repo": "yangsuhui/Boosted-OICR", "path": "/code/tasks/test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: myteksi/Flask-AppBuilder path: /flask_appbuilder/validators.py from wtforms import ValidationError class Unique(object): """ Checks field value unicity against specified table field. <|fim_suffix|> def __init__(self, datamodel, col_name, message=None): self.datamodel = d...
code_fim
hard
{ "lang": "python", "repo": "myteksi/Flask-AppBuilder", "path": "/flask_appbuilder/validators.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def __call__(self, form, field): filters = self.datamodel.get_filters().add_filter( self.col_name, self.datamodel.FilterEqual, field.data ) count, obj = self.datamodel.query(filters) if count > 0: # only test if Unique, if pk value is different o...
code_fim
hard
{ "lang": "python", "repo": "myteksi/Flask-AppBuilder", "path": "/flask_appbuilder/validators.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def to_ListOffsetArray64(self, start_at_zero: bool = False) -> ListOffsetArray: offsets = self._compact_offsets64(start_at_zero) return self._broadcast_tooffsets64(offsets) def to_RegularArray(self): return self def maybe_to_NumpyArray(self) -> ak.contents.NumpyArray ...
code_fim
hard
{ "lang": "python", "repo": "scikit-hep/awkward", "path": "/src/awkward/contents/regulararray.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> out = nextcontent._getitem_next(nexthead, nexttail, nextadvanced) if advanced is None: return ak._slicing.getitem_next_array_wrap( out, head.metadata.get("shape", (head.length,)), self._length ) ...
code_fim
hard
{ "lang": "python", "repo": "scikit-hep/awkward", "path": "/src/awkward/contents/regulararray.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: scikit-hep/awkward path: /src/awkward/contents/regulararray.py tent.backend, ) else: return None def _getitem_nothing(self): return self._content._getitem_range(0, 0) def _getitem_at(self, where: IndexType): index_nplike = self._backend.in...
code_fim
hard
{ "lang": "python", "repo": "scikit-hep/awkward", "path": "/src/awkward/contents/regulararray.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def update_one_gpu(self, param, grad, h): cuda.elementwise( 'T grad, T lr, T eps', 'T param, T h', '''h += grad * grad; param -= lr * grad / (sqrt(h) + eps);''', 'adagrad')(grad, self.lr, self.eps, param, h)<...
code_fim
hard
{ "lang": "python", "repo": "sw005320/chainer", "path": "/chainer/optimizers/ada_grad.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def update_one_cpu(self, param, grad, h): h += grad * grad param -= self.lr * grad / (numpy.sqrt(h) + self.eps) def update_one_gpu(self, param, grad, h): cuda.elementwise( 'T grad, T lr, T eps', 'T param, T h', '''h += grad * grad; ...
code_fim
medium
{ "lang": "python", "repo": "sw005320/chainer", "path": "/chainer/optimizers/ada_grad.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sw005320/chainer path: /chainer/optimizers/ada_grad.py import numpy from chainer import cuda from chainer import optimizer class AdaGrad(optimizer.Optimizer): """AdaGrad implementation. See: http://jmlr.org/papers/v12/duchi11a.html """ def __init__(self, lr=0.001, eps=1e-8)...
code_fim
medium
{ "lang": "python", "repo": "sw005320/chainer", "path": "/chainer/optimizers/ada_grad.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: the-mandarine/esiea-school-projects path: /pymas/pymas/modules/udp_sender.py """Description of the module goes here""" from socket import socket, AF_INET, SOCK_DGRAM # Is the module blocking or not ? BLOCKING = False # Beliefs that are impacted by this module USEFUL_FOR = ['nothing'] # Comman...
code_fim
medium
{ "lang": "python", "repo": "the-mandarine/esiea-school-projects", "path": "/pymas/pymas/modules/udp_sender.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> """Execute the command string : udp_send::ip,port,message::opts""" cmd_list = cmd_string.split('::') cmd_args = '::'.join(cmd_list[1:-1]).split(',') dest_host = cmd_args[0] dest_port = int(cmd_args[1]) message = ','.join(cmd_args[2:]).encode() sock = socket(AF_INET, SOCK_DGRAM...
code_fim
medium
{ "lang": "python", "repo": "the-mandarine/esiea-school-projects", "path": "/pymas/pymas/modules/udp_sender.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: lsst-camera-dh/EO-utilities path: /python/lsst/eo_utils/bias/correl_wrt_oscan.py """Tasks to analyze the correlation between the overscan and the imaging region""" import numpy as np from lsst.eo_utils.base.defaults import ALL_SLOTS from lsst.eo_utils.base.config_utils import EOUtilOptions fr...
code_fim
hard
{ "lang": "python", "repo": "lsst-camera-dh/EO-utilities", "path": "/python/lsst/eo_utils/bias/correl_wrt_oscan.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> outtables = TableDict() outtables.make_datatable("biasoscorr_stats", data_dict) return outtables def plot(self, dtables, figs, **kwargs): """Plot the summary data from the statistics study Parameters ---------- dtables : `TableDict` ...
code_fim
hard
{ "lang": "python", "repo": "lsst-camera-dh/EO-utilities", "path": "/python/lsst/eo_utils/bias/correl_wrt_oscan.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: MTES-MCT/envergo path: /envergo/pages/urls.py from django.urls import include, path from django.utils.translation import gettext_lazy as _ from django.views.generic import RedirectView, TemplateView from envergo.geodata.views import ParcelsExport from envergo.pages.views import ( Availabilit...
code_fim
hard
{ "lang": "python", "repo": "MTES-MCT/envergo", "path": "/envergo/pages/urls.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> _("envergo-news/feed/"), NewsFeed(), name="news_feed", ), path( _("available-departments/"), AvailabilityInfo.as_view(), name="faq_availability_info", ...
code_fim
hard
{ "lang": "python", "repo": "MTES-MCT/envergo", "path": "/envergo/pages/urls.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: pythonspeed/filprofiler path: /tests/test-scripts/oom.py import os, signal import numpy # This is peak: x = numpy.ones((200 * 1024 * 1024), dtype=nump<|fim_suffix|> Trigger a MemoryError: toobig = numpy.ones((1024, 1024 * 1024, 1024 * 1024), dtype=numpy.int8)<|fim_middle|>y.int8) del x # Below p...
code_fim
medium
{ "lang": "python", "repo": "pythonspeed/filprofiler", "path": "/tests/test-scripts/oom.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>be dumped, not the deleted allocation: x = numpy.ones((100 * 1024 * 1024), dtype=numpy.int8) # Trigger a MemoryError: toobig = numpy.ones((1024, 1024 * 1024, 1024 * 1024), dtype=numpy.int8)<|fim_prefix|># repo: pythonspeed/filprofiler path: /tests/test-scripts/oom.py import os, signal import numpy # Th...
code_fim
medium
{ "lang": "python", "repo": "pythonspeed/filprofiler", "path": "/tests/test-scripts/oom.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> return self.model.predict(X) def score(self, X, Y, metric='f1', verbose=True): Y = convert_labels(Y, 'categorical', 'onezero') Y_p = self.predict(X) metric_list = metric if isinstance(metric, list) else [metric] scores = [] for metric in metric_list: ...
code_fim
hard
{ "lang": "python", "repo": "rit-git/snorkel-notebooks", "path": "/babble/disc_model.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def train(self, X, Y, X_dev=None, Y_dev=None, **kwargs): Y_bin = convert_labels(Y, 'categorical', 'onezero') self.model.fit(X, Y_bin) def predict(self, X): return self.model.predict(X) def score(self, X, Y, metric='f1', verbose=True): Y = convert_labels(Y, 'ca...
code_fim
hard
{ "lang": "python", "repo": "rit-git/snorkel-notebooks", "path": "/babble/disc_model.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: rit-git/snorkel-notebooks path: /babble/disc_model.py import random from sklearn.linear_model import LogisticRegression from metal.utils import convert_labels from metal.metrics import metric_score <|fim_suffix|> return self.model.predict(X) def score(self, X, Y, metric='f1', verbo...
code_fim
hard
{ "lang": "python", "repo": "rit-git/snorkel-notebooks", "path": "/babble/disc_model.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: DarklightGames/io_scene_psk_psa path: /io_scene_psk_psa/psk/data.py from typing import List from ..data import * class Psk(object): class Wedge(object): def __init__(self): self.point_index: int = 0 self.u: float = 0.0 self.v: float = 0.0 ...
code_fim
hard
{ "lang": "python", "repo": "DarklightGames/io_scene_psk_psa", "path": "/io_scene_psk_psa/psk/data.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> _fields_ = [ ('position_delta', Vector3), ('tangent_z_delta', Vector3), ('point_index', c_int32) ] @property def has_extra_uvs(self): return len(self.extra_uvs) > 0 @property def has_vertex_colors(self): return len(self....
code_fim
hard
{ "lang": "python", "repo": "DarklightGames/io_scene_psk_psa", "path": "/io_scene_psk_psa/psk/data.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_node_exporter_running_and_enabled(host): nginx = host.service("node_exporter") assert nginx.is_running assert nginx.is_enabled<|fim_prefix|># repo: integritee-network/collator-setup path: /ansible/roles/node-exporter/molecule/default/tests/test_node_exporter.py def test_node_exporte...
code_fim
hard
{ "lang": "python", "repo": "integritee-network/collator-setup", "path": "/ansible/roles/node-exporter/molecule/default/tests/test_node_exporter.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>def test_node_exporter_running_and_enabled(host): nginx = host.service("node_exporter") assert nginx.is_running assert nginx.is_enabled<|fim_prefix|># repo: integritee-network/collator-setup path: /ansible/roles/node-exporter/molecule/default/tests/test_node_exporter.py def test_node_exporter...
code_fim
hard
{ "lang": "python", "repo": "integritee-network/collator-setup", "path": "/ansible/roles/node-exporter/molecule/default/tests/test_node_exporter.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: integritee-network/collator-setup path: /ansible/roles/node-exporter/molecule/default/tests/test_node_exporter.py def test_node_exporter(host): binary = host.file("/usr/local/bin/node_exporter") assert binary.exists assert binary.user == 'root' assert binary.group == 'root' as...
code_fim
medium
{ "lang": "python", "repo": "integritee-network/collator-setup", "path": "/ansible/roles/node-exporter/molecule/default/tests/test_node_exporter.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: architprasar/concric path: /concricv1/urls.py from django.contrib import admin from django.conf import settings from django.conf.urls.static import static from django.urls import path, include <|fim_suffix|>urlpatterns = urlpatterns + \ static(settings.MEDIA_URL, document_root=settings.MEDI...
code_fim
hard
{ "lang": "python", "repo": "architprasar/concric", "path": "/concricv1/urls.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> urlpatterns = urlpatterns + \ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)<|fim_prefix|># repo: architprasar/concric path: /concricv1/urls.py from django.contrib import admin from django.conf import settings from django.conf.urls.static import static from django.urls import path, i...
code_fim
hard
{ "lang": "python", "repo": "architprasar/concric", "path": "/concricv1/urls.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Rowing0914/TF2_RL path: /tf_rl/common/to_markdown.py # reference: https://github.com/thombashi/pytablewriter from pytablewriter import MarkdownTableWriter def params_to_markdown(params_str): <|fim_suffix|> writer = MarkdownTableWriter() writer.table_name = "Hyper-parameters" writer.h...
code_fim
medium
{ "lang": "python", "repo": "Rowing0914/TF2_RL", "path": "/tf_rl/common/to_markdown.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for _str in list_str: _str.replace(" ", "") param = _str.split("=") params[param[0]] = param[1] return params<|fim_prefix|># repo: Rowing0914/TF2_RL path: /tf_rl/common/to_markdown.py # reference: https://github.com/thombashi/pytablewriter from pytablewriter import Markdo...
code_fim
hard
{ "lang": "python", "repo": "Rowing0914/TF2_RL", "path": "/tf_rl/common/to_markdown.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nazrulworld/fhir.resources path: /fhir/resources/biologicallyderivedproduct.py of this resource. element_property=True, ) division__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( None, alias="_division", title="Extension field for ``division``." ) expirationDa...
code_fim
hard
{ "lang": "python", "repo": "nazrulworld/fhir.resources", "path": "/fhir/resources/biologicallyderivedproduct.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> valueCodeableConcept: fhirtypes.CodeableConceptType = Field( None, alias="valueCodeableConcept", title="Property values", description=None, # if property is element of this resource. element_property=True, # Choice of Data Types. i.e value[x] ...
code_fim
hard
{ "lang": "python", "repo": "nazrulworld/fhir.resources", "path": "/fhir/resources/biologicallyderivedproduct.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>class BiologicallyDerivedProductProperty(backboneelement.BackboneElement): """Disclaimer: Any field name ends with ``__ext`` doesn't part of Resource StructureDefinition, instead used to enable Extensibility feature for FHIR Primitive Data Types. A property that is specific to this Biolog...
code_fim
hard
{ "lang": "python", "repo": "nazrulworld/fhir.resources", "path": "/fhir/resources/biologicallyderivedproduct.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> numbers = [] got = sum_numbers(numbers) want = 0 assert got == want def test_sum_with_floats(): numbers = [1.5, 2.0, 3.5] got = sum_numbers(numbers) want = 7.0 assert got == want<|fim_prefix|># repo: py-bootcamp/learn-python-with-tdd path: /lists/v4/test_sum.py from ...
code_fim
medium
{ "lang": "python", "repo": "py-bootcamp/learn-python-with-tdd", "path": "/lists/v4/test_sum.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: py-bootcamp/learn-python-with-tdd path: /lists/v4/test_sum.py from sum_numbers import sum_numbers def test_sum(): numbers = [1, 2, 3, 4, 5] got = sum_numbers(numbers) want = 15 <|fim_suffix|> got = sum_numbers(numbers) want = 7.0 assert got == want<|fim_middle|> ass...
code_fim
medium
{ "lang": "python", "repo": "py-bootcamp/learn-python-with-tdd", "path": "/lists/v4/test_sum.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def validateModel(args): with tf.Session() as sess: data = DataMNIST() model = NNModel() model.load(sess, 'models/nn/') model.predict(sess, data) if __name__ == '__main__': # Arguments to be parsed via command line parser=argpar...
code_fim
hard
{ "lang": "python", "repo": "chenkenie/tft", "path": "/nn_model.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> with tf.Session() as sess: data = DataMNIST() model = NNModel() model.load(sess, 'models/nn/') model.predict(sess, data) if __name__ == '__main__': # Arguments to be parsed via command line parser=argparse.ArgumentParser(descrip...
code_fim
medium
{ "lang": "python", "repo": "chenkenie/tft", "path": "/nn_model.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: chenkenie/tft path: /nn_model.py #!/usr/bin/env python import argparse import tensorflow as tf import numpy as np from trainer_template import SimpleTrainer from data_loader_template import DataMNIST from model_template import TensorFlowModelTemplate from model_template import TensorFlowClassif...
code_fim
medium
{ "lang": "python", "repo": "chenkenie/tft", "path": "/nn_model.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|># savefig(fname, dpi=None, facecolor='w', edgecolor='w', # orientation='portrait', papertype=None, format=None, # transparent=False, bbox_inches=None, pad_inches=0.1, # frameon=None) # x = np.arange(-9, 10) # y = np.arange(-9, 10).reshape(-1, 1) # base = np.hypot(x, y) # ims = [] # f...
code_fim
hard
{ "lang": "python", "repo": "v1thesource/ParaSweep", "path": "/sensitivity_analysis.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def superplot(batch): plt.figure(figsize=(9,9)) # plot size plt.figure().add_axes([0.1, 0.1, 0.6, 0.8]) lineNames = { 0: 'pO2', 1: 'mew_e', 2: 'electrons', 3: 'holes', 4: 'VO{2}', 5: 'VO{1}', 6: 'VO{0}', 7: 'VM{-4}', 8: 'VM{-3}', 9: 'VM{-2}', 10:'VM{-1}', 11:'VM{0}', 12:'Oi{-2...
code_fim
hard
{ "lang": "python", "repo": "v1thesource/ParaSweep", "path": "/sensitivity_analysis.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: v1thesource/ParaSweep path: /sensitivity_analysis.py # Sensitivity analysis tool for Brouwer diagrams! By Alexandros Kenich # Example usage (to be improved with argument passing): # python matplotlib_test.py import matplotlib matplotlib.use('Agg') import numpy as np import matplotlib.pyplot as ...
code_fim
hard
{ "lang": "python", "repo": "v1thesource/ParaSweep", "path": "/sensitivity_analysis.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: s22l1g11/PyChat path: /src/client2.py import pyNotificationCenter import socket host = input("Enter hostname: ") if host == '': host="127.0.0.1" port = 4446 server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.connect((host, port)) <|fim_suffix|>while running: # handling differen...
code_fim
medium
{ "lang": "python", "repo": "s22l1g11/PyChat", "path": "/src/client2.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if "#rename" in message: nick = message.replace("#rename ","",1) print("Your new username is: "+nick) elif "#exit" in message: server.close() print("System stops...") exit(0) elif "#shutdown" in message: server.send("!!shutdown!!") server.close() print("System stops...") ...
code_fim
hard
{ "lang": "python", "repo": "s22l1g11/PyChat", "path": "/src/client2.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> placed.append(block.arguments[0]) t += 1 return State(set(part_states)) def get_blocks(self) -> list: """Returns a list of blocks in the blocks world. :return: a list of blocks """ self.clingo = ClingoBridge() # reset clingo ...
code_fim
hard
{ "lang": "python", "repo": "fxgst/RLASP", "path": "/BlocksWorld.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: fxgst/RLASP path: /BlocksWorld.py from ClingoBridge import * import random from entities import * import numpy as np state_enumeration_limit = 9 # blocks worlds bigger than this don't try to enumerate all possible states class BlocksWorld: def __init__(self): self.clingo = ClingoB...
code_fim
hard
{ "lang": "python", "repo": "fxgst/RLASP", "path": "/BlocksWorld.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def parse_part_state(self, atom: clingo.Symbol) -> PartState: """Parse a part-state. :param atom: a clingo atom :return: a part-state object representing one on/2 atom """ on_predicate = atom.arguments[0] top_block = on_predicate.arguments[0] bo...
code_fim
hard
{ "lang": "python", "repo": "fxgst/RLASP", "path": "/BlocksWorld.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: y95847frank/Semantic-Relations-Classifier path: /angelo_src/rnn.py import numpy as np import data import os import pickle import keras from keras.layers import Embedding , Dense ,Input , GlobalMaxPooling1D , Bidirectional , LSTM, GRU, Concatenate, Flatten ,Dropout from keras.models import Model f...
code_fim
hard
{ "lang": "python", "repo": "y95847frank/Semantic-Relations-Classifier", "path": "/angelo_src/rnn.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def main(): train_data_file = os.path.join(os.path.join(BASE_DIR , "dataset") , "TRAIN_FILE.txt") train_data = data.Data(train_data_file , "train") quit() #rnn model rnn_model = create_rnn_model(train_data.embedding_layer) print(rnn_model.summary()) #train model_file = 'model/lstm%ssum_drop2_h...
code_fim
hard
{ "lang": "python", "repo": "y95847frank/Semantic-Relations-Classifier", "path": "/angelo_src/rnn.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: microfossil/particle-classification path: /miso/data/image_dataset.py import numpy as np import skimage.io as skio from miso.data.dataset import DatasetBase from miso.data.image_loader import ParallelImageLoader from miso.data.image_utils import resize_transform, resize_with_pad_transform, null_...
code_fim
hard
{ "lang": "python", "repo": "microfossil/particle-classification", "path": "/miso/data/image_dataset.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.transform_fn is None: self.transform_fn = null_transform self.transform_args = [0] # Get dataset unique identification hash super().__init__(memmap_directory=memmap_directory, overwrite_memmap=overwrite_memmap, dtype=dtype) self.hash_data = ...
code_fim
hard
{ "lang": "python", "repo": "microfossil/particle-classification", "path": "/miso/data/image_dataset.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># for filename in filenames: # startCalculation(filename) # startCalculation(filenames[0]) # pool.map(startCalculation, [1, 2, 3]) if len(sys.argv) < 2: print ("python op_fairness.py <directory>, e.g. 'python op_fairness pldi13/' for logfiles in /mnt/local_homes/ahaas/pldi13/") else: calcOpFair...
code_fim
hard
{ "lang": "python", "repo": "cksystemsgroup/zeta", "path": "/scripts/lin_point_linearization.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: cksystemsgroup/zeta path: /scripts/lin_point_linearization.py import os; import multiprocessing; import subprocess; import ah_config; import sys; def getLineCount(filename): if not os.path.exists(filename): return -1 logfile = open(filename, 'r') lines = 0 for line in logfile: ...
code_fim
hard
{ "lang": "python", "repo": "cksystemsgroup/zeta", "path": "/scripts/lin_point_linearization.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> outputDir = "../results/{directory}".format(directory = directory) if not os.path.exists(outputDir) : os.makedirs(outputDir) logDir = "/mnt/local_homes/ahaas/{directory}".format(directory = directory) filenames = [{"filename":os.path.join(logDir, f), "directory":directory} for f in os.listdi...
code_fim
hard
{ "lang": "python", "repo": "cksystemsgroup/zeta", "path": "/scripts/lin_point_linearization.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: catapult-project/catapult path: /third_party/webapp2/tests/extras_json_test.py # -*- coding: utf-8 -*- from webapp2_extras import json import test_base class TestJson(test_base.BaseTestCase): def test_encode(self): self.assertEqual(json.encode( '<script>alert("hello")</...
code_fim
medium
{ "lang": "python", "repo": "catapult-project/catapult", "path": "/third_party/webapp2/tests/extras_json_test.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self.assertEqual(json.b64encode( '<script>alert("hello")</script>'), 'IjxzY3JpcHQ+YWxlcnQoXCJoZWxsb1wiKTxcL3NjcmlwdD4i') def test_b64decode(self): self.assertEqual(json.b64decode( 'IjxzY3JpcHQ+YWxlcnQoXCJoZWxsb1wiKTxcL3NjcmlwdD4i'), '<sc...
code_fim
medium
{ "lang": "python", "repo": "catapult-project/catapult", "path": "/third_party/webapp2/tests/extras_json_test.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: TR19006/robot_controller path: /run.py #!/usr/bin/env python # -*- coding: utf-8 -*- ######################################## # Robot Controller Script # # Copyright (c) Takuya Tsukahara, 2019 # ######################################## import argparse import cv2 import logging from ...
code_fim
hard
{ "lang": "python", "repo": "TR19006/robot_controller", "path": "/run.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ''' GPIO.output(m11, 1) GPIO.output(m12, 0) GPIO.output(m21, 1) GPIO.output(m22, 0) ''' print('FORWARD') return 'forward' @app.route('/left') def left(): ''' GPIO.output(m11, 0) GPIO.output(m12, 0) GPIO.output(m21, 1) GPIO.output(m22, 1) ''' pri...
code_fim
hard
{ "lang": "python", "repo": "TR19006/robot_controller", "path": "/run.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ShengrongYang/Colors-of-Zhang-Yimou path: /scripts/HSV_K-means/GS_test.py from datetime import datetime import scipy from scipy.spatial.distance import euclidean from sklearn.cluster import KMeans from sklearn.datasets.samples_generator import make_blobs dst = euclidean X, labels_true = make_bl...
code_fim
hard
{ "lang": "python", "repo": "ShengrongYang/Colors-of-Zhang-Yimou", "path": "/scripts/HSV_K-means/GS_test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>KMeans_args_dict = { 'n_clusters': 0, # drastically saves convergence time 'init': 'k-means++', 'random_state': 0, 'max_iter': 300, 'n_init': 10, 'verbose': 0, # 'n_jobs':8 } def gap(data, refs=None, nrefs=20, ks=range(3, 10)): """ I: NumPy array, reference matrix...
code_fim
hard
{ "lang": "python", "repo": "ShengrongYang/Colors-of-Zhang-Yimou", "path": "/scripts/HSV_K-means/GS_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @token_auth.login_required(optional=True) def get(self, organisation_id): """ Retrieves an organisation --- tags: - organisations produces: - application/json parameters: - in: header name: Authorizat...
code_fim
hard
{ "lang": "python", "repo": "hotosm/tasking-manager", "path": "/backend/api/organisations/resources.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: hotosm/tasking-manager path: /backend/api/organisations/resources.py from distutils.util import strtobool from flask_restful import Resource, request, current_app from schematics.exceptions import DataError from backend.models.dtos.organisation_dto import ( NewOrganisationDTO, UpdateOrga...
code_fim
hard
{ "lang": "python", "repo": "hotosm/tasking-manager", "path": "/backend/api/organisations/resources.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: omunroe-com/ietfdb2 path: /ietf/nomcom/models.py # -*- coding: utf-8 -*- import os from django.db import models from django.db.models.signals import post_delete from django.conf import settings from django.contrib.auth.models import User from django.template.loader import render_to_string from d...
code_fim
hard
{ "lang": "python", "repo": "omunroe-com/ietfdb2", "path": "/ietf/nomcom/models.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def __unicode__(self): if self.email.person and self.email.person.name: return u'%s <%s> %s' % (self.email.person.plain_name(), self.email.address, self.nomcom.year()) else: return u'%s %s' % (self.email.address, self.nomcom.year()) def name(self): ...
code_fim
hard
{ "lang": "python", "repo": "omunroe-com/ietfdb2", "path": "/ietf/nomcom/models.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def get_questionnaire(self): return render_to_string(self.questionnaire.path, {'position': self}) def get_requirement(self): rendered = render_to_string(self.requirement.path, {'position': self}) if self.requirement.type_id=='plain': rendered = linebreaks(rende...
code_fim
hard
{ "lang": "python", "repo": "omunroe-com/ietfdb2", "path": "/ietf/nomcom/models.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def to_timeseries(benchmark_data, x_label='Episode', y_label='Average Episode Reward', target=rewards_by_episode, cut_x=1e12, smooth=0): """ Convert benchmark data to timeseries data, plottable my mathplotlib. Args: benchmark_data: BenchmarkData object x_lab...
code_fim
hard
{ "lang": "python", "repo": "afcarl/rl-benchmark", "path": "/rl_benchmark/analyze/transform.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if cut_x > len(rewards): seconds = np.linspace(0, cut_x, 200) rewards = n_step_average(rewards, 200) else: seconds = np.linspace(0, cut_x, cut_x) rewards = n_step_average(rewards, cut_x) return seconds, rewards def to_timeseries(benchmark_data, x_label='Episo...
code_fim
hard
{ "lang": "python", "repo": "afcarl/rl-benchmark", "path": "/rl_benchmark/analyze/transform.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: afcarl/rl-benchmark path: /rl_benchmark/analyze/transform.py # Copyright 2018 The RLgraph project. 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 ...
code_fim
hard
{ "lang": "python", "repo": "afcarl/rl-benchmark", "path": "/rl_benchmark/analyze/transform.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: suheb/cltk_api path: /metadata/translation/map_translation.py """ Map a translation to the original Must already have definitions ingested for this to work """ import optparse import pymongo import re import copy import string import numpy as np from cltk_api.util.db import mongo from nltk.c...
code_fim
hard
{ "lang": "python", "repo": "suheb/cltk_api", "path": "/metadata/translation/map_translation.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # split at words words = text_unit.split(" ") # lemmas lemmas = [] for word in words: if len(word): word = self.lmtzr.lemmatize(word) if word not in self.stops: lemmas.append(word) # syns syns = [] for lemma in lemmas: synsets = wn.synsets(lemma) wor...
code_fim
hard
{ "lang": "python", "repo": "suheb/cltk_api", "path": "/metadata/translation/map_translation.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: m3h0w/TRAiVEL path: /back-end/skyscan/mainapp/__init__.py # Import flask and template operators from flask import Flask from flask import jsonify, request from prices import get_prices_from_cities, get_next_friday_sunday from flask_cors import CORS app = Flask(__name__, static_url_path='/stati...
code_fim
medium
{ "lang": "python", "repo": "m3h0w/TRAiVEL", "path": "/back-end/skyscan/mainapp/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@app.route("/get_prices", methods=['POST']) def get_prices(): if 'cities_list' in request.json and isinstance(request.json['cities_list'], list): strings_list = request.json['cities_list'] data = get_prices_from_cities(strings_list) # month = "2018-04" # if 'month' in request.json and isin...
code_fim
medium
{ "lang": "python", "repo": "m3h0w/TRAiVEL", "path": "/back-end/skyscan/mainapp/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> data = get_prices_from_cities(strings_list) # month = "2018-04" # if 'month' in request.json and isinstance(request.json['month'], str): # month = request.json['month'] return jsonify(data)<|fim_prefix|># repo: m3h0w/TRAiVEL path: /back-end/skyscan/mainapp/__init__.py # Import flask and t...
code_fim
medium
{ "lang": "python", "repo": "m3h0w/TRAiVEL", "path": "/back-end/skyscan/mainapp/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def setup(bot): """Sets up the extension.""" @bot.listen("on_command") async def log_command(ctx): message = (f"{ctx.message.content} | " f"{ctx.author.id} in {ctx.guild.name}:{ctx.guild.id}") logger.info(message) message = f"{ctx.message.created_at....
code_fim
hard
{ "lang": "python", "repo": "DasWolke/kitsuchan-2", "path": "/cogs/owner/command_log.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: DasWolke/kitsuchan-2 path: /cogs/owner/command_log.py #!/usr/bin/env python3 # pylint: disable=C0103 """Command logging functionality.""" import logging FORMAT = "%(asctime)-15s: %(message)s" formatter = logging.Formatter(FORMAT) <|fim_suffix|> def setup(bot): """Sets up the extension."""...
code_fim
hard
{ "lang": "python", "repo": "DasWolke/kitsuchan-2", "path": "/cogs/owner/command_log.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fs = args["fs"] fs_path = args["fs_path"] self.trash(path=fs.getsyspath(fs_path), simulate=simulate)<|fim_prefix|># repo: iburunat/organize path: /organize/actions/trash.py import logging from .action import Action logger = logging.getLogger(__name__) class Trash(Action): ...
code_fim
hard
{ "lang": "python", "repo": "iburunat/organize", "path": "/organize/actions/trash.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: iburunat/organize path: /organize/actions/trash.py import logging from .action import Action logger = logging.getLogger(__name__) class Trash(Action): """Move a file or dir into the trash.""" <|fim_suffix|> from send2trash import send2trash self.print(f'Trash "{path}"') ...
code_fim
medium
{ "lang": "python", "repo": "iburunat/organize", "path": "/organize/actions/trash.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: chenpaopao/- path: /classification/convNext/models/networks.py """ original code from facebook research: https://github.com/facebookresearch/ConvNeXt """ import torch import torch.nn as nn import torch.nn.functional as F def drop_path(x, drop_prob: float = 0., training: bool = False): """D...
code_fim
hard
{ "lang": "python", "repo": "chenpaopao/-", "path": "/classification/convNext/models/networks.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in range(4): x = self.downsample_layers[i](x) x = self.stages[i](x) return self.norm(x.mean([-2, -1])) # global average pooling, (N, C, H, W) -> (N, C) def forward(self, x: torch.Tensor) -> torch.Tensor: x = self.forward_features(x) x = ...
code_fim
hard
{ "lang": "python", "repo": "chenpaopao/-", "path": "/classification/convNext/models/networks.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def forward(self, x: torch.Tensor) -> torch.Tensor: x = self.forward_features(x) x = self.head(x) return x def convnext_tiny(num_classes: int): # https://dl.fbaipublicfiles.com/convnext/convnext_tiny_1k_224_ema.pth model = ConvNeXt(depths=[3, 3, 9, 3], ...
code_fim
hard
{ "lang": "python", "repo": "chenpaopao/-", "path": "/classification/convNext/models/networks.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: erjihaoshi/audio path: /torchaudio/compliance/kaldi.py import math import random import torch __all__ = [ 'spectrogram' ] # numeric_limits<float>::epsilon() EPSILON = torch.tensor(1.19209290e-07, dtype=torch.get_default_dtype()) # 1 milliseconds = 0.001 seconds MILLISECONDS_TO_SECONDS = 0....
code_fim
hard
{ "lang": "python", "repo": "erjihaoshi/audio", "path": "/torchaudio/compliance/kaldi.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>def spectrogram( sig, blackman_coeff=0.42, channel=-1, dither=1.0, energy_floor=0.0, frame_length=25.0, frame_shift=10.0, min_duration=0.0, preemphasis_coefficient=0.97, raw_energy=True, remove_dc_offset=True, round_to_power_of_two=True, sample_frequency=16000.0, snip_edges...
code_fim
hard
{ "lang": "python", "repo": "erjihaoshi/audio", "path": "/torchaudio/compliance/kaldi.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> inventory = configure_inventory(args) try: configdrive = json.loads(args.configdrive) except (ValueError, TypeError): configdrive = args.configdrive extra_vars = args.extra_vars or [] if configdrive: # Need to preserve JSON extra_vars.append(json.dumps(...
code_fim
hard
{ "lang": "python", "repo": "openstack/bifrost", "path": "/bifrost/cli.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }