text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|># repo: Bohdanski/daily-oos-report path: /daily_oos_report.py """ Builds the datasheet for the daily out-of-stock report. """ import os import re import sys import glob import zipfile import fnmatch import datetime import pandas as pd import numpy as np import openpyxl from zipfile import ZipFile from ...
code_fim
hard
{ "lang": "python", "repo": "Bohdanski/daily-oos-report", "path": "/daily_oos_report.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> df_cs = workbook.parse(0, skiprows=3, skipfooter=20, header=None) df_cs = df_cs[~df_cs[7].isin(to_drop)] df_cs = df_cs.filter([0, 14, 15, 17, 34]) df_cs.columns = ["custCode", "poDueDate", ...
code_fim
hard
{ "lang": "python", "repo": "Bohdanski/daily-oos-report", "path": "/daily_oos_report.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: HENNGE/aapns path: /src/aapns/errors.py from typing import Any, Dict, Optional, Type class APNSError(Exception): pass class Blocked(APNSError): """This connection can't send more data at this point, can try later.""" class Closed(APNSError): """This connection is now closed, try...
code_fim
hard
{ "lang": "python", "repo": "HENNGE/aapns", "path": "/src/aapns/errors.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self, reason: str, apns_id: Optional[str]): self.reason = reason self.apns_id = apns_id super().__init__(reason) class UnknownResponseError(ResponseError): codename = "!unknown" CODES: Dict[str, Type[ResponseError]] = {} def create(codename: str) -> Type[...
code_fim
hard
{ "lang": "python", "repo": "HENNGE/aapns", "path": "/src/aapns/errors.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> codename: str def __init__(self, reason: str, apns_id: Optional[str]): self.reason = reason self.apns_id = apns_id super().__init__(reason) class UnknownResponseError(ResponseError): codename = "!unknown" CODES: Dict[str, Type[ResponseError]] = {} def create(code...
code_fim
hard
{ "lang": "python", "repo": "HENNGE/aapns", "path": "/src/aapns/errors.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: czs108/LeetCode-Solutions path: /Medium/334. Increasing Triplet Subsequence/solution (2).py # 334. Increasing Triplet Subsequence # Runtime: 885 ms, faster than 15.19% of Python3 online submissions for Increasing Triplet Subsequence. # Memory Usage: 25.2 MB, less than 49.40% of Python3 online s...
code_fim
medium
{ "lang": "python", "repo": "czs108/LeetCode-Solutions", "path": "/Medium/334. Increasing Triplet Subsequence/solution (2).py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Linear Scan def increasingTriplet(self, nums: list[int]) -> bool: if len(nums) < 3: return False first, second = math.inf, math.inf for n in nums: if n <= first: first = n elif n <= second: second = n ...
code_fim
medium
{ "lang": "python", "repo": "czs108/LeetCode-Solutions", "path": "/Medium/334. Increasing Triplet Subsequence/solution (2).py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: AIandSocialGoodLab/identify-illegal-mining-sites path: /nonmine_annotate.py import numpy as np import os import cv2 import shutil folder = input("File to images of non mines: ") i = int(input("File number to start on: ")) <|fim_suffix|>for i in range(mineLength): image = mineJPG[:-4] ...
code_fim
hard
{ "lang": "python", "repo": "AIandSocialGoodLab/identify-illegal-mining-sites", "path": "/nonmine_annotate.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> image = mineJPG[:-4] import sys try: fn = sys.argv[1] except: fn = '%s/%s'%(folder, mineJPG) print(__doc__) img = cv2.imread(fn, True) h, w = img.shape[:2] f = open("%s/%s.xml"%(folder, image),"w") f.write((text)%(folder, mineJPG, folder, mineJPG, w, h, w, h)) f.cl...
code_fim
hard
{ "lang": "python", "repo": "AIandSocialGoodLab/identify-illegal-mining-sites", "path": "/nonmine_annotate.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Highlight the changes if False: for change in changes_in_delt: ax.axvline(x=change, color='maroon', alpha=0.5, zorder=1) # Show figure ax.set_yscale('log') ax.autoscale() ax.legend(labelspacing=0.0, handlelength=1, shadow=True) plt.show() return ...
code_fim
hard
{ "lang": "python", "repo": "stellaGK/stella", "path": "/stellapy/data/stella/check_cflcushion.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: stellaGK/stella path: /stellapy/data/stella/check_cflcushion.py import numpy as np import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec def check_cflcushion(delt=0.1, cfl_cushion_upper=0.5, cfl_cushion_lower=0.1, code_dt_max=0.1, nstep=100): """ We always want to kee...
code_fim
hard
{ "lang": "python", "repo": "stellaGK/stella", "path": "/stellapy/data/stella/check_cflcushion.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """Verify --limit X, where X is a positive integer, succeeds. The command will print out X number of project cells. """ self.shell('cell-list -r 1 --limit 1') mock_list.assert_called_once_with(limit=1) def test_cell_list_limit_negative_num_failure(self): ...
code_fim
hard
{ "lang": "python", "repo": "sigmavirus24/python-cratonclient", "path": "/cratonclient/tests/unit/test_cells_shell.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: sigmavirus24/python-cratonclient path: /cratonclient/tests/unit/test_cells_shell.py # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/...
code_fim
hard
{ "lang": "python", "repo": "sigmavirus24/python-cratonclient", "path": "/cratonclient/tests/unit/test_cells_shell.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> @app.command() def part2(input_file: str): _, line = read_input_file(input_file) ids, remainders = parse_second_line(line) solution = crt(ids, remainders) print(f"The solution for part 2 is {solution}") if __name__ == "__main__": app()<|fim_prefix|># repo: RJPlog/aoc-2020 path: /d...
code_fim
hard
{ "lang": "python", "repo": "RJPlog/aoc-2020", "path": "/day13/python/ceedee666/day13.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: RJPlog/aoc-2020 path: /day13/python/ceedee666/day13.py from pathlib import Path from functools import reduce from operator import mul import typer app = typer.Typer() def read_input_file(input_file_path): p = Path(input_file_path) with p.open() as f: lines = f.readlines() ...
code_fim
hard
{ "lang": "python", "repo": "RJPlog/aoc-2020", "path": "/day13/python/ceedee666/day13.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @app.command() def part1(input_file: str): time, busses = read_input_file(input_file) busses = map(lambda i: int(i), filter(lambda s: s.isdigit(), busses)) wating_time = reduce(lambda a, b: a if a[1] < b[1] else b, map(lambda b: (b, b - time % b), busses)) print...
code_fim
medium
{ "lang": "python", "repo": "RJPlog/aoc-2020", "path": "/day13/python/ceedee666/day13.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sebinjohn/replication_manager path: /src/replications/ds_replications.py from replications import * import sys from argparse import ArgumentParser parser = ArgumentParser(description='DS BDR Client') def parse_args(sys_args): group = parser.add_mutually_exclusive_group() group.add_argume...
code_fim
hard
{ "lang": "python", "repo": "sebinjohn/replication_manager", "path": "/src/replications/ds_replications.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> parser.add_argument('--service-name', nargs=1, required=True) parser.add_argument('--cluster-name', nargs=1, required=True) parser.add_argument('--api-host', nargs=1, required=True) parser.add_argument('--api-port', default=7180, type=int) parser.add_argument('--api-version', default=...
code_fim
hard
{ "lang": "python", "repo": "sebinjohn/replication_manager", "path": "/src/replications/ds_replications.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> args = parse_args(sys_args) service_name = args.service_name[0] cluster_name = args.cluster_name[0] api_host = args.api_host[0] api_user = args.api_user[0] api_pass = args.api_pass[0] api_port = args.api_port api_version = args.api_version auth = (api_user, api_pass) ...
code_fim
hard
{ "lang": "python", "repo": "sebinjohn/replication_manager", "path": "/src/replications/ds_replications.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> value = dict[key] del dict[key] return value if __name__=='__main__': root = Tk() #Done with imageEmbedder 1.0 utility img2pytk.py from # http://www.3dartist.com/WP/python/pycode.htm#img2pytk img00 = PhotoImage(format='gif',data= 'R0lGODlhGAAYAOb/AAAAAP///4GBl3F...
code_fim
hard
{ "lang": "python", "repo": "modal/tktoolbox", "path": "/tktoolbox/examples/buttonbar.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: modal/tktoolbox path: /tktoolbox/examples/buttonbar.py from tkinter import * """ ButtonBar widget Rick Lawson r_b_lawson at yahoo dot com Easy widget to mimic the ButtonBar which is showing up a lot in Windows Inspired by Iuri Wickert's notebook.py widget (esp. the Radiobutton tricks) config opt...
code_fim
hard
{ "lang": "python", "repo": "modal/tktoolbox", "path": "/tktoolbox/examples/buttonbar.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # init the base class Frame.__init__(self, master, options) # load the images & create the buttons self.buttons = [] index = 0 for image in self.images: button = Radiobutton(self, indicatoron=0, text=self.labels[index], relief=FLAT, variable = s...
code_fim
hard
{ "lang": "python", "repo": "modal/tktoolbox", "path": "/tktoolbox/examples/buttonbar.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>##Comparing python built in method and mine if a == b: print("It's working !") else: print("It's not working...")<|fim_prefix|># repo: WithaK16/karatsubaMultiplication path: /karatsuba.py import math def getNumberOfDigit(n, base = 10): if n > 0: return int(math.log(n, base)) + 1 ...
code_fim
hard
{ "lang": "python", "repo": "WithaK16/karatsubaMultiplication", "path": "/karatsuba.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: WithaK16/karatsubaMultiplication path: /karatsuba.py import math def getNumberOfDigit(n, base = 10): if n > 0: return int(math.log(n, base)) + 1 elif n == 0: return 1 else: return int(math.log(-n, base)) + 1 ## WARNING: works only with positive number and bas...
code_fim
hard
{ "lang": "python", "repo": "WithaK16/karatsubaMultiplication", "path": "/karatsuba.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: hpgundam/django-bIo9 path: /bIo9/views.py from django.shortcuts import render, redirect, get_object_or_404 from django.urls import reverse from django.contrib import messages from django.contrib.auth import login, logout, authenticate from django.contrib.auth.decorators import login_required from...
code_fim
hard
{ "lang": "python", "repo": "hpgundam/django-bIo9", "path": "/bIo9/views.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @login_required def reset_password(request): email = request.user.email if email == '': messages.error(request, "You don't have an email, Please set your email first.") return redirect(reverse('bIo9:index')) title = 'reset password' if request.method == 'POST': form = ResetPasswordForm(request....
code_fim
hard
{ "lang": "python", "repo": "hpgundam/django-bIo9", "path": "/bIo9/views.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: FRESH-TUNA/jockjebi-web path: /api/urls.py from api.views import * from rest_framework.routers import DefaultRouter from django.urls import path <|fim_suffix|>router.register(r'comment', CommentViewSet, basename='comment') router.register(r'university', UniViewSet, basename='university') url...
code_fim
medium
{ "lang": "python", "repo": "FRESH-TUNA/jockjebi-web", "path": "/api/urls.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>router.register(r'comment', CommentViewSet, basename='comment') router.register(r'university', UniViewSet, basename='university') urlpatterns += router.urls<|fim_prefix|># repo: FRESH-TUNA/jockjebi-web path: /api/urls.py from api.views import * from rest_framework.routers import DefaultRouter from djan...
code_fim
easy
{ "lang": "python", "repo": "FRESH-TUNA/jockjebi-web", "path": "/api/urls.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Morningstar/GoASQ path: /src/goasq_server.py # Copyright 2018 Morningstar 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.apache....
code_fim
hard
{ "lang": "python", "repo": "Morningstar/GoASQ", "path": "/src/goasq_server.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> viewCounter = 0 for key in app.config['URL_RULES']: if key == '/': app.add_url_rule(key, view_func=ServerRequestHandler.as_view('GOASQ_'+str(viewCounter)), defaults={'pathParam': ''}) else: app.add_url_rule(key, view_func=ServerRequestHandler.as_view('GOASQ_'+str(viewCounter))) ...
code_fim
hard
{ "lang": "python", "repo": "Morningstar/GoASQ", "path": "/src/goasq_server.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> p3dcollec = ax.plot_trisurf(coords[:, 0], coords[:, 1], coords[:, 2], triangles = tri, linewidth=0., antialiased = False) if mask is not N...
code_fim
hard
{ "lang": "python", "repo": "ohbm/handson-2021-reproducible-workflows", "path": "/code/myvis.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ohbm/handson-2021-reproducible-workflows path: /code/myvis.py import numpy as np import matplotlib.pyplot as plt # surface mesh plotting based on coords & triangles only def subplot_surf(coords, tri, bg_map, fig, limits, ...
code_fim
hard
{ "lang": "python", "repo": "ohbm/handson-2021-reproducible-workflows", "path": "/code/myvis.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> coords = surf_mesh['coords'] tri = surf_mesh['tri'] if stat_map is None: limits = [-70, 50] if figsize is None: figsize = (18,5) if darkness is None: darkness = 0.65 else : limits = [-80, 50] if darkness is None: ...
code_fim
hard
{ "lang": "python", "repo": "ohbm/handson-2021-reproducible-workflows", "path": "/code/myvis.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> group[i] = curr_group for nbr in graph[i]: if not self.dfs(nbr, graph, -curr_group, groups): return False return True # each node on an edge should belong to different group # O(N + E) time, N to be number of nodes, E to be number of edges # traverse eac...
code_fim
hard
{ "lang": "python", "repo": "kevinshenyang07/Data-Structures-and-Algorithms", "path": "/algorithms/dfs/is_graph_bipartite.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: kevinshenyang07/Data-Structures-and-Algorithms path: /algorithms/dfs/is_graph_bipartite.py # Is Graph Bipartite? # Note: # graph will have length in range [1, 100] # graph[i] will contain integers in range [0, graph.length - 1] # graph[i] will not contain i or duplicate values # graph is undirect...
code_fim
hard
{ "lang": "python", "repo": "kevinshenyang07/Data-Structures-and-Algorithms", "path": "/algorithms/dfs/is_graph_bipartite.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> super().__init__(config) self.config = config if producer is not None: self.producer = producer else: self.producer = Producer(self.config["PARAMS"]) self.time_encoder = self.config.get("TIME_ENCODER_CLASS", DateTimeEncoder) self.dyna...
code_fim
hard
{ "lang": "python", "repo": "alercebroker/APF", "path": "/apf/metrics/kafka.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: alercebroker/APF path: /apf/metrics/kafka.py from apf.metrics import GenericMetricsProducer from apf.metrics import DateTimeEncoder from confluent_kafka import Producer from apf.core import get_class import json class KafkaMetricsProducer(GenericMetricsProducer): """Write metrics in a Kafk...
code_fim
hard
{ "lang": "python", "repo": "alercebroker/APF", "path": "/apf/metrics/kafka.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sarvex/composer path: /composer/algorithms/cutout/__init__.py # Copyright 2022 MosaicML Composer authors # SPDX-License-Identifier: Apache-2.0 <|fim_suffix|>See the :doc:`Method Card </method_cards/cutout>` for more details. """ from composer.algorithms.cutout.cutout import CutOut as CutOut fro...
code_fim
medium
{ "lang": "python", "repo": "sarvex/composer", "path": "/composer/algorithms/cutout/__init__.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>from composer.algorithms.cutout.cutout import CutOut as CutOut from composer.algorithms.cutout.cutout import cutout_batch as cutout_batch __all__ = ['CutOut', 'cutout_batch']<|fim_prefix|># repo: sarvex/composer path: /composer/algorithms/cutout/__init__.py # Copyright 2022 MosaicML Composer authors # S...
code_fim
hard
{ "lang": "python", "repo": "sarvex/composer", "path": "/composer/algorithms/cutout/__init__.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>__version__ = "1.0.8" __all__ = [ "assign", "intersections", "prorate", "adjacencies", "close_gaps", "resolve_overlaps", "snap_to_grid", "IndexedGeometries", "normalize", "progress", "make_valid", "autorepair", "doctor" ]<|fim_prefix|># repo: mggg/maup ...
code_fim
hard
{ "lang": "python", "repo": "mggg/maup", "path": "/maup/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mggg/maup path: /maup/__init__.py from .adjacencies import adjacencies from .assign import assign from .indexed_geometries import IndexedGeometries from .intersections import intersections, prorate from .repair import close_gaps, resolve_overlaps, make_valid, autorepair, snap_to_grid, crop_to, ex...
code_fim
hard
{ "lang": "python", "repo": "mggg/maup", "path": "/maup/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.feature_extractor = feature_extractor def __call__(self, batch): encodings = self.feature_extractor([x[0] for x in batch], return_tensors='pt') encodings['labels'] = torch.tensor([x[1] for x in batch], dtype=torch.long) return encodings<|fim_prefix|># repo: ...
code_fim
easy
{ "lang": "python", "repo": "qanastek/HugsVision", "path": "/build/lib/hugsvision/dataio/ImageClassificationCollator.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> encodings = self.feature_extractor([x[0] for x in batch], return_tensors='pt') encodings['labels'] = torch.tensor([x[1] for x in batch], dtype=torch.long) return encodings<|fim_prefix|># repo: qanastek/HugsVision path: /build/lib/hugsvision/dataio/ImageClassificationCollator.py ...
code_fim
medium
{ "lang": "python", "repo": "qanastek/HugsVision", "path": "/build/lib/hugsvision/dataio/ImageClassificationCollator.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: qanastek/HugsVision path: /build/lib/hugsvision/dataio/ImageClassificationCollator.py import torch """ 📁 Image Classification Collator """ class ImageClassificationCollator: <|fim_suffix|> def __call__(self, batch): encodings = self.feature_extractor([x[0] for x in batch...
code_fim
medium
{ "lang": "python", "repo": "qanastek/HugsVision", "path": "/build/lib/hugsvision/dataio/ImageClassificationCollator.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def didYouMean(q, encrypted=False, context=""): q = str(str.lower(q)).strip() if encrypted: url = "https://encrypted.google.com/search?q=" + urllib.quote(q + " " + context) else: url = "https://www.google.com/search?q=" + urllib.quote(q + " " + context) html = get...
code_fim
hard
{ "lang": "python", "repo": "AndersonOyama/TCC", "path": "/talvez lixo/didYouMean2.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: AndersonOyama/TCC path: /talvez lixo/didYouMean2.py ### Based in a Script from https://github.com/bkvirendra/didyoumean # encoding: utf-8 # unicode("utf-8") import os import urllib2 import io import gzip import sys import urllib import re from bs4 import BeautifulSoup from StringIO i...
code_fim
hard
{ "lang": "python", "repo": "AndersonOyama/TCC", "path": "/talvez lixo/didYouMean2.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> response = urllib2.urlopen(request) if response.info().get('Content-Encoding') == 'gzip': buf = StringIO( response.read()) f = gzip.GzipFile(fileobj=buf) data = f.read() else: data = response.read() return data def didYouMean(q, encrypted=False, co...
code_fim
hard
{ "lang": "python", "repo": "AndersonOyama/TCC", "path": "/talvez lixo/didYouMean2.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: vulture990/NeuralNetworks path: /Activation.py #it ll be more neat and organized to treat the activation function as a layer from layer import Layer import numpy as np class Activation(layer): def __init__(self, activation,activation_prime): <|fim_suffix|> return np.multiply(output_g...
code_fim
hard
{ "lang": "python", "repo": "vulture990/NeuralNetworks", "path": "/Activation.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def forward(self,input): self.input=input return self.activation(self.input) def backward(self,output_gradient,learning_rate): return np.multiply(output_gradient,self.activation_prime(self.input)) ##multiply by element<|fim_prefix|># repo: vulture990/NeuralNetworks ...
code_fim
medium
{ "lang": "python", "repo": "vulture990/NeuralNetworks", "path": "/Activation.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if self.contents is None: await payload.respond( type=InteractionType.UpdateMessage, embed=self.embeds[self.page - 1], components=(await self.create_button()), ) else: await payload.respond( ...
code_fim
hard
{ "lang": "python", "repo": "popop098/ButtonPaginator", "path": "/ButtonPaginator/paginator.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: popop098/ButtonPaginator path: /ButtonPaginator/paginator.py import discord from discord import InvalidArgument from discord.ext import commands import asyncio from typing import List, Optional, Union from discord_components import ( Button, ButtonStyle, InteractionType, ) from disc...
code_fim
hard
{ "lang": "python", "repo": "popop098/ButtonPaginator", "path": "/ButtonPaginator/paginator.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sktime/sktime path: /sktime/networks/lstmfcn_layers.py ): """Apply `y . w + b` for every temporal slice y of x. # Arguments x: input tensor. w: weight matrix. b: optional bias vector. dropout: wether to apply dropout (same dropout ...
code_fim
hard
{ "lang": "python", "repo": "sktime/sktime", "path": "/sktime/networks/lstmfcn_layers.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> """Return property recurrent_constraint.""" return self.cell.recurrent_constraint @property def bias_constraint(self): """Return property bias_constraint.""" return self.cell.bias_constraint @property def attention_constrain...
code_fim
hard
{ "lang": "python", "repo": "sktime/sktime", "path": "/sktime/networks/lstmfcn_layers.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if K.backend() == "cntk": if not kwargs.get("unroll") and (dropout > 0 or recurrent_dropout > 0): warnings.warn( "RNN dropout is not supported with the CNTK backend " "when using dynamic RNNs (i.e. non-unrolled...
code_fim
hard
{ "lang": "python", "repo": "sktime/sktime", "path": "/sktime/networks/lstmfcn_layers.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: nim-lang/Nim path: /tools/debug/nim-gdb.py + "__" + m.group(3) + "_", "NTI" + m.group(2).replace("colon", "58").lower() + "__" + m.group(3) + "_" ] for l in lookups: try: return gdb.parse_and_eval(l) except: pass None def getNameFromNimRti(rti): ""...
code_fim
hard
{ "lang": "python", "repo": "nim-lang/Nim", "path": "/tools/debug/nim-gdb.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nim-lang/Nim path: /tools/debug/nim-gdb.py def getNimName(typ): if m := type_hash_regex.match(typ): return m.group(2) return f"unknown <{typ}>" def getNimRti(type_name): """ Return a ``gdb.Value`` object for the Nim Runtime Information of ``type_name``. """ # Get static const TNim...
code_fim
hard
{ "lang": "python", "repo": "nim-lang/Nim", "path": "/tools/debug/nim-gdb.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.new: return self.val is not None else: return bool(self.val) def __len__(self): if not self: return 0 if self.new: if self.isContent: return int(self.val["cap"]) else: return int(self.val["len"]) else: return self.val["Sup"...
code_fim
hard
{ "lang": "python", "repo": "nim-lang/Nim", "path": "/tools/debug/nim-gdb.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: KratosMultiphysics/Kratos path: /applications/ShallowWaterApplication/tests/test_ShallowWaterApplication.py # import Kratos import KratosMultiphysics as KM # Import Kratos "wrapper" for unittests import KratosMultiphysics.KratosUnittest as KratosUnittest from KratosMultiphysics.KratosUnittest im...
code_fim
hard
{ "lang": "python", "repo": "KratosMultiphysics/Kratos", "path": "/applications/ShallowWaterApplication/tests/test_ShallowWaterApplication.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> # Create a test suit with the validation tests plus all the nightly tests validationSuite = suites['validation'] validationSuite.addTests(nightlySuite) validationSuite.addTests(TestLoader().loadTestsFromTestCase(TestDamBreakValidation)) validationSuite.addTests(TestLoader().loadTestsFr...
code_fim
hard
{ "lang": "python", "repo": "KratosMultiphysics/Kratos", "path": "/applications/ShallowWaterApplication/tests/test_ShallowWaterApplication.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: fcakyon/small-object-detection-benchmark path: /xview/slice_xview.py import fire from sahi.scripts.slice_coco import slice from tqdm import tqdm MAX_WORKERS = 20 SLICE_SIZE_LIST = [300, 400, 500] OVERLAP_RATIO_LIST = [0, 0.25] IGNORE_NEGATIVE_SAMPLES = True <|fim_suffix|> total_run = len(SL...
code_fim
medium
{ "lang": "python", "repo": "fcakyon/small-object-detection-benchmark", "path": "/xview/slice_xview.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> total_run = len(SLICE_SIZE_LIST) * len(OVERLAP_RATIO_LIST) current_run = 1 for slice_size in SLICE_SIZE_LIST: for overlap_ratio in OVERLAP_RATIO_LIST: tqdm.write( f"{current_run} of {total_run}: slicing for slice_size={slice_size}, overlap_ratio={overlap_rat...
code_fim
medium
{ "lang": "python", "repo": "fcakyon/small-object-detection-benchmark", "path": "/xview/slice_xview.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>for model in models: admin.site.register(model)<|fim_prefix|># repo: sorinburghiu2323/Conffiliate path: /backend/admin.py from django.contrib import admin from backend.models import * <|fim_middle|>models = [User, Platform, UserPlatform, Keyword, UserKeyword]
code_fim
medium
{ "lang": "python", "repo": "sorinburghiu2323/Conffiliate", "path": "/backend/admin.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sorinburghiu2323/Conffiliate path: /backend/admin.py from django.contrib import admin <|fim_suffix|>for model in models: admin.site.register(model)<|fim_middle|>from backend.models import * models = [User, Platform, UserPlatform, Keyword, UserKeyword]
code_fim
medium
{ "lang": "python", "repo": "sorinburghiu2323/Conffiliate", "path": "/backend/admin.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>s.system (copy_id_cmd) ssh_cmd = 'ssh -o "StrictHostKeyChecking no" root@' + hostFqdn print "Executing : ", ssh_cmd # run ssh_cmd setupPasswordlessSSH()<|fim_prefix|># repo: ziiin/glusterfs-extras path: /geo/configureGeo.py import socket import os def setupPasswordlessSSH (): ''' sets u...
code_fim
medium
{ "lang": "python", "repo": "ziiin/glusterfs-extras", "path": "/geo/configureGeo.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ziiin/glusterfs-extras path: /geo/configureGeo.py import socket import os def setupPasswordlessSSH (): ''' sets up passwordless SSH from root to root user of self IP ''' hostFqdn = socket.getfqdn() # s<|fim_suffix|>s.system (copy_id_cmd) ssh_cmd = 'ssh -o "StrictHostKeyChecking n...
code_fim
hard
{ "lang": "python", "repo": "ziiin/glusterfs-extras", "path": "/geo/configureGeo.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> actions = ["run_selected_jobs"] def run_selected_jobs(self, request, queryset): scheduler = BackgroundScheduler() scheduler.add_jobstore(self._memory_jobstore) scheduler.add_listener(self._handle_execution_event, events.EVENT_JOB_EXECUTED) scheduler.start() ...
code_fim
hard
{ "lang": "python", "repo": "jcass77/django-apscheduler", "path": "/django_apscheduler/admin.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jcass77/django-apscheduler path: /django_apscheduler/admin.py import time from datetime import timedelta from apscheduler import events from apscheduler.schedulers.background import BackgroundScheduler from django.conf import settings from django.contrib import admin, messages from django.db.mod...
code_fim
hard
{ "lang": "python", "repo": "jcass77/django-apscheduler", "path": "/django_apscheduler/admin.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>t.replace (u"ی", u"ي") #Arabic Yah = ي return txt if __name__ == '__main__': test_unicode (u"ایست")<|fim_prefix|># repo: pythonprofilers/memory_profiler path: /test/test_unicode.py # -*- coding: utf-8 -*- @profile def test_unicode(t<|fim_middle|>xt): # test when unicode is present txt = tx
code_fim
easy
{ "lang": "python", "repo": "pythonprofilers/memory_profiler", "path": "/test/test_unicode.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: pythonprofilers/memory_profiler path: /test/test_unicode.py # -*- coding: utf-8 -*- @profile def test_unicode(t<|fim_suffix|>t.replace (u"ی", u"ي") #Arabic Yah = ي return txt if __name__ == '__main__': test_unicode (u"ایست")<|fim_middle|>xt): # test when unicode is present txt = tx
code_fim
easy
{ "lang": "python", "repo": "pythonprofilers/memory_profiler", "path": "/test/test_unicode.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>def test_expected(cross): rimg = rotate(cross, 90, order=0, pivot=[32, 32], missing=0) assert np.allclose(rimg, cross.T) rimg = rotate(cross, 45, order=1, pivot=[32, 32]) ones = np.array(np.nonzero(rimg == 1)) assert np.allclose(ones, [[30, 31, 31, 32, 33, 33, 34], ...
code_fim
medium
{ "lang": "python", "repo": "SOFIA-USRA/sofia_redux", "path": "/sofia_redux/toolkit/image/tests/test_adjust/test_rotate.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: SOFIA-USRA/sofia_redux path: /sofia_redux/toolkit/image/tests/test_adjust/test_rotate.py # Licensed under a 3-clause BSD style license - see LICENSE.rst import numpy as np import pytest from sofia_redux.toolkit.image.adjust import rotate @pytest.fixture def cross(): # squished crosshair ...
code_fim
hard
{ "lang": "python", "repo": "SOFIA-USRA/sofia_redux", "path": "/sofia_redux/toolkit/image/tests/test_adjust/test_rotate.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>def test_nan_handling(single): rimg1 = rotate(single, -45, order=1, missing_limit=0.5) single[34, 34] = np.nan rimg2 = rotate(single, -45, order=1, missing_limit=0.5) assert np.allclose(rimg1, rimg2, equal_nan=True) with pytest.raises(ValueError) as err: rotate(single, -45, na...
code_fim
hard
{ "lang": "python", "repo": "SOFIA-USRA/sofia_redux", "path": "/sofia_redux/toolkit/image/tests/test_adjust/test_rotate.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: Sudo-Kid/linklab_backend path: /user_profile/signals.py from django.db.models.signals import post_save from django.dispatch import receiver <|fim_suffix|> @receiver(post_save, sender=User) def my_callback(instance, created, **_kwargs): if not created: return template = models.Te...
code_fim
medium
{ "lang": "python", "repo": "Sudo-Kid/linklab_backend", "path": "/user_profile/signals.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> template = models.Template.objects.get(name='default') user_profile = models.UserProfile( user=instance, template=template ) user_profile.save() social_display = models.SocialDisplaySettings( name='twitch', limit=6, position=0, username=u...
code_fim
medium
{ "lang": "python", "repo": "Sudo-Kid/linklab_backend", "path": "/user_profile/signals.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> bias0 = torch.randn(3) meta_model[0].bias.data.copy_(bias0) model[0].bias.data.copy_(bias0) params = OrderedDict() params['2.weight'] = torch.randn(5, 3) model[2].weight.data.copy_(params['2.weight']) params['2.bias'] = torch.randn(5) model[2].bias.data.copy_(params['2.bi...
code_fim
hard
{ "lang": "python", "repo": "egrefen/pytorch-meta", "path": "/torchmeta/tests/modules/test_container.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: egrefen/pytorch-meta path: /torchmeta/tests/modules/test_container.py import pytest import numpy as np import torch import torch.nn as nn from collections import OrderedDict from torchmeta.modules import MetaSequential, MetaModule, MetaLinear def test_metasequential(): meta_model = MetaSe...
code_fim
hard
{ "lang": "python", "repo": "egrefen/pytorch-meta", "path": "/torchmeta/tests/modules/test_container.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> inputs = torch.randn(5, 2) outputs_torchmeta = meta_model(inputs, params=params) outputs_nn = model(inputs) np.testing.assert_equal(outputs_torchmeta.detach().numpy(), outputs_nn.detach().numpy())<|fim_prefix|># repo: egrefen/pytorch-meta path: /torchmeta/tes...
code_fim
hard
{ "lang": "python", "repo": "egrefen/pytorch-meta", "path": "/torchmeta/tests/modules/test_container.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: LeviNikhil/SebastianAldi-01082170015 path: /Week01-Intro/854A.py # the one and only input n = int(input()) if n % 2 == 1: numerator = n//2 denominator = n - numerator else: numerato<|fim_suffix|>= 1 denominator = n - numerator print(numerator, denominator)<|fim_middle|>r = (n//2) ...
code_fim
medium
{ "lang": "python", "repo": "LeviNikhil/SebastianAldi-01082170015", "path": "/Week01-Intro/854A.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>= 1 denominator = n - numerator print(numerator, denominator)<|fim_prefix|># repo: LeviNikhil/SebastianAldi-01082170015 path: /Week01-Intro/854A.py # the one and only input n = int(input()) if n % 2 == 1: numerator = n//2 denominator = n - numerator else: numerato<|fim_middle|>r = (n//2) ...
code_fim
medium
{ "lang": "python", "repo": "LeviNikhil/SebastianAldi-01082170015", "path": "/Week01-Intro/854A.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: tlhhup/datadeal path: /mongo/person.py from pymongo import MongoClient client = MongoClient("mongodb://localhost:27017/") db = client.test class Person(object): <|fim_suffix|> person = { 'name': '张三', 'age': 26 } db.person.insert_one(person) per...
code_fim
medium
{ "lang": "python", "repo": "tlhhup/datadeal", "path": "/mongo/person.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def find_persons(self): persons = db.person.find() if persons: for person in persons: print(person) def insert(self): person = { 'name': '张三', 'age': 26 } db.person.insert_one(person) person = Person() p...
code_fim
easy
{ "lang": "python", "repo": "tlhhup/datadeal", "path": "/mongo/person.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>" value="201"> <input type="text" name="callback" value="eyJjYWxsYmFja1VybCI6IjQ3LjEwNi45MS4xODY6NTAwMC93c2dpIiwiY2FsbGJhY2tCb2R5IjoiJHtmaWxlbmFtZX0ifQ=="> <input type="text" name="filename" value="${filename}"> <input type="text" name="x:namea" value="hanli...
code_fim
hard
{ "lang": "python", "repo": "yibozhang/aliyunproduct", "path": "/oss/python_call.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ser = OptionParser() parser.add_option("", "--bucket", dest="bucket", help="specify ") parser.add_option("", "--endpoint", dest="endpoint", help="specify") parser.add_option("", "--id", dest="id", help="access_key_id") parser.add_option("", "--key", dest="key", help="access_key_secret") ...
code_fim
hard
{ "lang": "python", "repo": "yibozhang/aliyunproduct", "path": "/oss/python_call.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: yibozhang/aliyunproduct path: /oss/python_call.py #coding=utf8 import md5 import hashlib import base64 import hmac from optparse import OptionParser #Content-Disposition:form-data;name="callback" def convert_base64(input): return base64.b64encode(input) def get_sign_policy(key, policy): ...
code_fim
hard
{ "lang": "python", "repo": "yibozhang/aliyunproduct", "path": "/oss/python_call.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: shapiromatron/hawc path: /hawc/apps/animal/migrations/0024_change_choices.py # Generated by Django 1.11.15 on 2019-04-11 11:13 from django.db import migrations, models def update_choices(apps, schema_editor): apps.get_model("animal", "DosingRegime").objects.filter(negative_control="Y").upd...
code_fim
hard
{ "lang": "python", "repo": "shapiromatron/hawc", "path": "/hawc/apps/animal/migrations/0024_change_choices.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.AlterField( model_name="dosingregime", name="negative_control", field=models.CharField( choices=[ ("NR", "Not-reported"), ("UN", "Untreated"), ("VT", "Vehic...
code_fim
hard
{ "lang": "python", "repo": "shapiromatron/hawc", "path": "/hawc/apps/animal/migrations/0024_change_choices.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: inkImage/Conv-Autoencoder path: /model.py import keras.backend as K from keras.layers import Input, Conv2D, UpSampling2D, BatchNormalization, ZeroPadding2D, MaxPooling2D from keras.models import Model from keras.utils import plot_model from custom_layers.unpooling_layer import Unpooling def cr...
code_fim
hard
{ "lang": "python", "repo": "inkImage/Conv-Autoencoder", "path": "/model.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> x = Conv2D(1, (5, 5), activation='sigmoid', padding='same', name='pred', kernel_initializer='he_normal', bias_initializer='zeros')(x) model = Model(inputs=input_tensor, outputs=x) return model if __name__ == '__main__': model = create_model(224, 224, 3) # input_layer ...
code_fim
hard
{ "lang": "python", "repo": "inkImage/Conv-Autoencoder", "path": "/model.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: abondar24/MachineLearnPython path: /scipy/sc_mnist.py import os import struct import numpy as np import matplotlib.pyplot as plt from sc_mnist_nnet import NeuralNetMLP # load and unpack mnist ds before running def load_mnist(path, kind='train'): labels_path = os.path.join(path, '%s-labels....
code_fim
hard
{ "lang": "python", "repo": "abondar24/MachineLearnPython", "path": "/scipy/sc_mnist.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>miscl_img = x_test[y_test != y_test_pred][:25] correct_lab = y_test[y_test != y_test_pred][:25] miscl_lab = y_test_pred[y_test != y_test_pred][:25] fig, ax = plt.subplots(nrows=5, ncols=5, sharex=True, sharey=True) ax = ax.flatten() for i in range(25): img = miscl_img[i].reshape(28, 28) ax[i].ims...
code_fim
hard
{ "lang": "python", "repo": "abondar24/MachineLearnPython", "path": "/scipy/sc_mnist.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> return c / 12.92 def _y_to_l(y: float) -> float: if y <= _epsilon: return y / _ref_y * _kappa return 116 * ((y / _ref_y) ** (1 / 3)) - 16 def _l_to_y(l: float) -> float: if l <= 8: return _ref_y * l / _kappa return _ref_y * (((l + 16) / 116) ** 3) def xyz_to_rgb...
code_fim
hard
{ "lang": "python", "repo": "has2k1/mizani", "path": "/mizani/colors/hsluv.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: has2k1/mizani path: /mizani/colors/hsluv.py """ This module is generated by transpiling Haxe into Python and cleaning the resulting code by hand, e.g. removing unused Haxe classes. To try it yourself, clone https://github.com/hsluv/hsluv and run: haxe -cp haxe/src hsluv.Hsluv -python hsluv.p...
code_fim
hard
{ "lang": "python", "repo": "has2k1/mizani", "path": "/mizani/colors/hsluv.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if c > 0.04045: return ((c + 0.055) / 1.055) ** 2.4 return c / 12.92 def _y_to_l(y: float) -> float: if y <= _epsilon: return y / _ref_y * _kappa return 116 * ((y / _ref_y) ** (1 / 3)) - 16 def _l_to_y(l: float) -> float: if l <= 8: return _ref_y * l / _ka...
code_fim
hard
{ "lang": "python", "repo": "has2k1/mizani", "path": "/mizani/colors/hsluv.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> print bucketsDis print bucketsCol print ranges p = [0]*len(ranges) for m in range(len(ranges)): if bucketsDis[m]>0: p[m]=bucketsCol[m]/float(bucketsDis[m]) pylab.plot(ranges,p) def testCollisionsE8(n,d=8): M = pylab.eye(8,8) S = [0.0]*n C = [0]...
code_fim
hard
{ "lang": "python", "repo": "olivierh59500/CardinalityShiftClustering", "path": "/CardinalityShift/src/crKNN.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> S = [0.0]*n C = [0]*n #generate distances and buckets for i in range(n): p = [random() for j in xrange(d)] q = [p[j] + (gauss(0,1)/(d**.5)) for j in xrange(d)] S[i]=distance(p,q,d) C[i]= int(decodeE8(dot(p,M)) == decodeE8(dot(q,M))) ranges = pylab.h...
code_fim
hard
{ "lang": "python", "repo": "olivierh59500/CardinalityShiftClustering", "path": "/CardinalityShift/src/crKNN.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: olivierh59500/CardinalityShiftClustering path: /CardinalityShift/src/crKNN.py ''' Copyright 2010 Lee Carraher. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributio...
code_fim
hard
{ "lang": "python", "repo": "olivierh59500/CardinalityShiftClustering", "path": "/CardinalityShift/src/crKNN.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: a-shah8/LeetCode path: /Easy/isSymmetric.py ## Check if given Binary Tree is symmetric ## i.e. left subtree on one side should be same as, ## right subtree on other ## and vice versa <|fim_suffix|> while q: t1 = q.popleft() t2 = q.popleft() ...
code_fim
hard
{ "lang": "python", "repo": "a-shah8/LeetCode", "path": "/Easy/isSymmetric.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return True # # Using recursion # return self.isMirror(root, root) # def isMirror(self, t1: TreeNode, t2: TreeNode) -> bool: # if t1==None and t2==None: return True # if t1==None or t2==None: return False # return (t1.val==t2.val) and self.isMi...
code_fim
medium
{ "lang": "python", "repo": "a-shah8/LeetCode", "path": "/Easy/isSymmetric.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # rewrite test count in mapreduced.yml test_count = len([x for x in os.listdir('%s/cases/' % staging_dir) if x.endswith(".in")]) replace_with_str("%s/mapreduced.yml" % staging_dir, "[[ test_count ]]", str(test_count)) # rewrite module name in mapper.py replace_with_str("%s/mapper.py" % staging_d...
code_fim
hard
{ "lang": "python", "repo": "ilebedev/py_web_gui", "path": "/make_assignment.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # copy solution shutil.copy("%s/solution.py" % settings.assignment_path, solution_path + "/" + settings.assignment_type + ".py") def create_staging_analyzer(settings): # create staging area staging_dir = ".analyzer_" + settings.assignment_type + ("_%s" % str(settings.assignment_num)) if os.path...
code_fim
hard
{ "lang": "python", "repo": "ilebedev/py_web_gui", "path": "/make_assignment.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }