text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: pstansell/stable-baselines3-contrib path: /tests/test_run.py
import pytest
from sb3_contrib import QRDQN, TQC
@pytest.mark.parametrize("ent_coef", ["auto", 0.01, "auto_0.01"])
def test_tqc(ent_coef):
model = TQC(
"MlpPolicy",
"Pendulum-v0",
policy_kwargs=dict(net_ar... | code_fim | hard | {
"lang": "python",
"repo": "pstansell/stable-baselines3-contrib",
"path": "/tests/test_run.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_qrdqn():
model = QRDQN(
"MlpPolicy",
"CartPole-v1",
policy_kwargs=dict(n_quantiles=25, net_arch=[64, 64]),
learning_starts=100,
buffer_size=500,
learning_rate=3e-4,
verbose=1,
create_eval_env=True,
)
model.learn(total_ti... | code_fim | hard | {
"lang": "python",
"repo": "pstansell/stable-baselines3-contrib",
"path": "/tests/test_run.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> new = self.pk is None
super().save(*args, **kwargs)
if new:
subject = self.subject
units = Unit.objects.filter(subject=subject)
for unit in units:
lecture = Lecture(course=self, unit=unit.name,
date=dateti... | code_fim | medium | {
"lang": "python",
"repo": "CollinsLord/seedofknowledge",
"path": "/courses/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return "{} on {} ({} - {})".format(self.course, self.date,
self.start_time, self.end_time)<|fim_prefix|># repo: CollinsLord/seedofknowledge path: /courses/models.py
from django.db import models
from django.urls import reverse
from subjects.models import Subject, Unit
from dateti... | code_fim | hard | {
"lang": "python",
"repo": "CollinsLord/seedofknowledge",
"path": "/courses/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CollinsLord/seedofknowledge path: /courses/models.py
from django.db import models
from django.urls import reverse
from subjects.models import Subject, Unit
from datetime import datetime
class Course(models.Model):
subject = models.ForeignKey(Subject, on_delete=models.CASCADE)
def __str... | code_fim | hard | {
"lang": "python",
"repo": "CollinsLord/seedofknowledge",
"path": "/courses/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # ---------------------------
# class and pandas to numpy
attribute = [i.replace(' ','') for i in df]
train_data_value = train_data.to_numpy()
test_data_value = test_data.to_numpy()
train_data = [Dataization(attribute, df.iloc[i]) for i in range(train_data_v... | code_fim | hard | {
"lang": "python",
"repo": "donghyun305/Chefboost-project",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: donghyun305/Chefboost-project path: /main.py
import pandas as pd
import CB as cb
# ----------------------------------------------
parallelism_cases = [True]
class Dataization(object):
def __init__(self, keys, values):
<|fim_suffix|> config = {'algorithm': 'C4.5', 'enableParallelism... | code_fim | hard | {
"lang": "python",
"repo": "donghyun305/Chefboost-project",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: abdullah-if/my-ojs path: /dimik/dimik-42.py
repeat = int(input())
for x in range(repeat):
uplim = int(input())
for i in range(uplim, -1, -1):
if i > 1:
<|fim_suffix|> print("2 + ", end="")
else:
print(1)<|fim_middle|> print("2^{k} + ".format... | code_fim | medium | {
"lang": "python",
"repo": "abdullah-if/my-ojs",
"path": "/dimik/dimik-42.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("2 + ", end="")
else:
print(1)<|fim_prefix|># repo: abdullah-if/my-ojs path: /dimik/dimik-42.py
repeat = int(input())
for x in range(repeat):
uplim = int(inp<|fim_middle|>ut())
for i in range(uplim, -1, -1):
if i > 1:
print("2^{k} + ".format... | code_fim | medium | {
"lang": "python",
"repo": "abdullah-if/my-ojs",
"path": "/dimik/dimik-42.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: goncalopp/mexbtcapi path: /mexbtcapi/api/poloniex/__init__.py
from . import rest, stream
from .currencies import CURRENCY_PAIRS
from mexbtcapi.market import Exchange, MarketList, Market
from mexbtcapi.currency import ExchangeRate
class PoloniexMarket(Market):
def __init__(self, exchange, co... | code_fim | hard | {
"lang": "python",
"repo": "goncalopp/mexbtcapi",
"path": "/mexbtcapi/api/poloniex/__init__.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Market.__init__(self, exchange, counter_currency, base_currency)
@property
def curr_code(self):
return "{}_{}".format(self.counter_currency.name, self.base_currency.name)
def create_er(self, rate):
return ExchangeRate(numerator_currency=self.counter_currency, denomina... | code_fim | medium | {
"lang": "python",
"repo": "goncalopp/mexbtcapi",
"path": "/mexbtcapi/api/poloniex/__init__.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> markets = (PoloniexMarket(self, *cp) for cp in CURRENCY_PAIRS)
Exchange.__init__(self, 'Poloniex', markets)
exchange = PoloniexExchange()
stream.CURRENCY_PAIR_CODE_TO_MARKET = {m.curr_code:m for m in exchange.markets}
for m in exchange.markets:
m._ticker_stream = stream.get_ticker_str... | code_fim | medium | {
"lang": "python",
"repo": "goncalopp/mexbtcapi",
"path": "/mexbtcapi/api/poloniex/__init__.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Carlososuna11/codewars-handbook path: /python/kata/6-kyu/Persistent Bugger/main.py
import codewars_test as test
from solution import persistenc<|fim_suffix|>, 3)
test.assert_equals(persistence(4), 0)
test.assert_equals(persistence(25), 2)
test.assert_equals(persistence(999), 4)<|fim_middle|>e
te... | code_fim | medium | {
"lang": "python",
"repo": "Carlososuna11/codewars-handbook",
"path": "/python/kata/6-kyu/Persistent Bugger/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>s(persistence(25), 2)
test.assert_equals(persistence(999), 4)<|fim_prefix|># repo: Carlososuna11/codewars-handbook path: /python/kata/6-kyu/Persistent Bugger/main.py
import codewars_test as test
from solution import persistenc<|fim_middle|>e
test.it("Basic tests")
test.assert_equals(persistence(39), 3)
... | code_fim | medium | {
"lang": "python",
"repo": "Carlososuna11/codewars-handbook",
"path": "/python/kata/6-kyu/Persistent Bugger/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>, 3)
test.assert_equals(persistence(4), 0)
test.assert_equals(persistence(25), 2)
test.assert_equals(persistence(999), 4)<|fim_prefix|># repo: Carlososuna11/codewars-handbook path: /python/kata/6-kyu/Persistent Bugger/main.py
import codewars_test as test
from solution import persistenc<|fim_middle|>e
te... | code_fim | medium | {
"lang": "python",
"repo": "Carlososuna11/codewars-handbook",
"path": "/python/kata/6-kyu/Persistent Bugger/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ercommit_memory': 1,
},
},
}<|fim_prefix|># repo: voc/cm path: /bundlewrap/bundles/sysctl/metadata.py
defaults = {
'sysctl': {
'o<|fim_middle|>ptions': {
'net.ipv6.conf.all.disable_ipv6': '1',
'vm.ov | code_fim | medium | {
"lang": "python",
"repo": "voc/cm",
"path": "/bundlewrap/bundles/sysctl/metadata.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: voc/cm path: /bundlewrap/bundles/sysctl/metadata.py
defaults = {
'sysctl': {
'options': {
'net.ipv6.conf.al<|fim_suffix|>ercommit_memory': 1,
},
},
}<|fim_middle|>l.disable_ipv6': '1',
'vm.ov | code_fim | easy | {
"lang": "python",
"repo": "voc/cm",
"path": "/bundlewrap/bundles/sysctl/metadata.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> share_mode=WindowsInterface.ShareMode.ALL,
creation_disposition=WindowsInterface.CreationDisposition.OPEN_EXISTING,
flags_and_attributes=0):
"""
:param desired_access: WindowsInterface.DesiredAccess
:type desired_access: int
... | code_fim | hard | {
"lang": "python",
"repo": "pannal/Sub-Zero.bundle",
"path": "/Contents/Libraries/Shared/asio/open_parameters.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pannal/Sub-Zero.bundle path: /Contents/Libraries/Shared/asio/open_parameters.py
from asio.interfaces.posix import PosixInterface
from asio.interfaces.windows import WindowsInterface
class OpenParameters(object):
def __init__(self):
self.handlers = {}
# Update handler_parame... | code_fim | hard | {
"lang": "python",
"repo": "pannal/Sub-Zero.bundle",
"path": "/Contents/Libraries/Shared/asio/open_parameters.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.handlers.update({WindowsInterface: {
'desired_access': desired_access,
'share_mode': share_mode,
'creation_disposition': creation_disposition,
'flags_and_attributes': flags_and_attributes
}})<|fim_prefix|># repo: pannal/Sub-Zero.bundle ... | code_fim | hard | {
"lang": "python",
"repo": "pannal/Sub-Zero.bundle",
"path": "/Contents/Libraries/Shared/asio/open_parameters.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> related = sp.artist_related_artists(uri)
print('Related artists for', name)
for artist in related['artists']:
print(' ', artist['name'])
except BaseException:
print("usage show_related.py [artist-name]")<|fim_prefix|># repo: spotipy-dev/spotipy path: /examples/show_related.py
# ... | code_fim | hard | {
"lang": "python",
"repo": "spotipy-dev/spotipy",
"path": "/examples/show_related.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spotipy-dev/spotipy path: /examples/show_related.py
# shows related artists for the given seed artist
from spotipy.oauth2 import SpotifyClientCredentials
import spotipy
import sys
<|fim_suffix|> related = sp.artist_related_artists(uri)
print('Related artists for', name)
for artist i... | code_fim | hard | {
"lang": "python",
"repo": "spotipy-dev/spotipy",
"path": "/examples/show_related.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TheMoksej/Wavelink path: /setup.py
# -*- coding: utf-8 -*-
"""MIT License
Copyright (c) 2019-2020 PythonistaGuild
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without r... | code_fim | medium | {
"lang": "python",
"repo": "TheMoksej/Wavelink",
"path": "/setup.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def normalize_data(X_train, X_devel):
scaler = StandardScaler()
scaler = scaler.fit(X_train)
X_train = scaler.transform(X_train)
X_devel = scaler.transform(X_devel)
return (X_train, X_devel)<|fim_prefix|># repo: aascode/elderly-emotion-SC path: /valence/scripts/feature_extraction/fast... | code_fim | hard | {
"lang": "python",
"repo": "aascode/elderly-emotion-SC",
"path": "/valence/scripts/feature_extraction/fasttext_extractor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aascode/elderly-emotion-SC path: /valence/scripts/feature_extraction/fasttext_extractor.py
import numpy as np
from gensim.models import FastText
from nltk.tokenize import word_tokenize
from sklearn.preprocessing import StandardScaler
import pandas as pd
<|fim_suffix|>def normalize_data(X_train, ... | code_fim | hard | {
"lang": "python",
"repo": "aascode/elderly-emotion-SC",
"path": "/valence/scripts/feature_extraction/fasttext_extractor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def boundary_tilting(xr_dataset, xs_dataset, xr_adv_dataset, model, batch_size, reduce_clean=False):
eps_for_division = 1e-10 # avoid divide by zero
model.eval()
# Build loaders
clean_dataset = ParallelDataset(xr_dataset, xs_dataset)
clean_loader = DataLoader(clean_dataset, ba... | code_fim | hard | {
"lang": "python",
"repo": "dominiccarrano/backdoor-nn-geometry",
"path": "/boundary_geometry.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dominiccarrano/backdoor-nn-geometry path: /boundary_geometry.py
"""boundary_thickness was adapted from code at https://github.com/nsfzyzz/boundary_thickness."""
import numpy as np
import pandas as pd
import torch
import seaborn as sns
import os
import multiprocessing
import torch.nn.functional as... | code_fim | hard | {
"lang": "python",
"repo": "dominiccarrano/backdoor-nn-geometry",
"path": "/boundary_geometry.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Use difference in probabilities to compute thickness
data_dimensions = [i+1 for i in range(len(xr[0].size()))]
dist = torch.norm(xr - xs, p=2, dim=data_dimensions).squeeze() # [batch_size]
for i, (alpha, beta) in enumerate(alpha_beta_list):
# Only use (xr, xs... | code_fim | hard | {
"lang": "python",
"repo": "dominiccarrano/backdoor-nn-geometry",
"path": "/boundary_geometry.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GoogleCloudPlatform/cloud-sql-python-connector path: /noxfile.py
"""
Copyright 2019 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licens... | code_fim | hard | {
"lang": "python",
"repo": "GoogleCloudPlatform/cloud-sql-python-connector",
"path": "/noxfile.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@nox.session(python=["3.8", "3.9", "3.10", "3.11"])
def unit(session):
default(session, os.path.join("tests", "unit"))
@nox.session(python=["3.8", "3.9", "3.10", "3.11"])
def system(session):
default(session, os.path.join("tests", "system"))
@nox.session(python=["3.8", "3.9", "3.10", "3.11"])
... | code_fim | hard | {
"lang": "python",
"repo": "GoogleCloudPlatform/cloud-sql-python-connector",
"path": "/noxfile.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Run linters.
Returns a failure if the linters find linting errors or sufficiently
serious code quality issues.
"""
session.install("-r", "requirements-test.txt")
session.install("-r", "requirements.txt")
session.install("flake8-import-order")
session.run("black", "--chec... | code_fim | hard | {
"lang": "python",
"repo": "GoogleCloudPlatform/cloud-sql-python-connector",
"path": "/noxfile.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.sql_db.reset()
@classmethod
def teardown_class(cls) -> None:
cls.sql_db.stop()
def test_create_insert_query_data(self) -> None:
metadata = ExampleMetadata(
test_str="test",
test_int=123,
test_float=0.123,
test_bool=... | code_fim | hard | {
"lang": "python",
"repo": "M-J-Murray/tanuki",
"path": "/test/test_acceptance.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: M-J-Murray/tanuki path: /test/test_acceptance.py
from datetime import datetime
from helpers.example_metadata import ExampleMetadata
from helpers.example_store import ExampleStore
from helpers.sqlite3_container import Sqlite3Container
from hamcrest import assert_that, equal_to
from tanuki.databa... | code_fim | hard | {
"lang": "python",
"repo": "M-J-Murray/tanuki",
"path": "/test/test_acceptance.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # system summaries
peers = []
system_folder = os.path.join(map_folder, os.path.split(topic)[1])
for file in glob.glob(os.path.join(system_folder, '*.cmap')):
if re.match(map_pattern, os.path.split(file)[1]):
with codecs.open(file, encoding='utf-8') as f:
... | code_fim | hard | {
"lang": "python",
"repo": "UKPLab/emnlp2017-cmapsum-corpus",
"path": "/eval/scripts/prepare_files_rouge_meteor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: UKPLab/emnlp2017-cmapsum-corpus path: /eval/scripts/prepare_files_rouge_meteor.py
'''
prepare concept maps for ROUGE and METEOR evaluation
'''
import sys, os, glob, datetime, codecs, re
from __builtin__ import file
gold_folder = sys.argv[1]
map_folder = sys.argv[2]
tmp_folder = 'eval_tmp'
map_p... | code_fim | medium | {
"lang": "python",
"repo": "UKPLab/emnlp2017-cmapsum-corpus",
"path": "/eval/scripts/prepare_files_rouge_meteor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yangjb1/warped2-models path: /scripts/combineAndPlot.py
#!/usr/bin/python
# Combines and averages the given csv file(s) using the given settings
from __future__ import print_function
import csv, sys
import itertools, operator
import subprocess
import Gnuplot
import Gnuplot.funcutils
import nump... | code_fim | hard | {
"lang": "python",
"repo": "yangjb1/warped2-models",
"path": "/scripts/combineAndPlot.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> reader = [i for i in reader if i[nFilterColumn1] == FILTERVALUE1]
reader1 = [i for i in reader if i[nFilterColumn2] == FILTERVALUE2_1]
reader2 = [i for i in reader if i[nFilterColumn2] == FILTERVALUE2_2]
reader1 = sorted(reader1, key=lambda x: x[nLines], reverse=False)
reader1 = sorted... | code_fim | hard | {
"lang": "python",
"repo": "yangjb1/warped2-models",
"path": "/scripts/combineAndPlot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> outData = {'header':[],'data':{}}
# First sorting criteria (loadBalancing) - different lines
for sqCount, data in itertools.groupby(reader1, lambda x: x[nXaxis]):
# Label column
outData['header'].append(int(sqCount))
# Second sorting criteria (sqCount) - x-axis
... | code_fim | hard | {
"lang": "python",
"repo": "yangjb1/warped2-models",
"path": "/scripts/combineAndPlot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: google/blockly-games path: /build/messages_to_json.py
#!/usr/bin/python3
# Converts message.json file into en.json and qqq.json files for Translatewiki.
#
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in complia... | code_fim | hard | {
"lang": "python",
"repo": "google/blockly-games",
"path": "/build/messages_to_json.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> json_file = codecs.open(filename, 'r', 'utf-8')
data = json.load(json_file)
json_file.close()
return data
def saveJson(output_dir, lang_name, json_data):
data = json.dumps(json_data, indent=4, ensure_ascii=False)
data = re.sub(' ', '\t', data)
filename = os.path.join(output_dir, lang_na... | code_fim | hard | {
"lang": "python",
"repo": "google/blockly-games",
"path": "/build/messages_to_json.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if torch._running_with_deploy():
# not valid inside torch_deploy interpreter, no paths exists for frozen modules
cmake_prefix_path = None
else:
cmake_prefix_path = _osp.join(_osp.dirname(_osp.dirname(__file__)), 'share', 'cmake')<|fim_prefix|># repo: pytorch/pytorch path: /torch/utils/__init_... | code_fim | hard | {
"lang": "python",
"repo": "pytorch/pytorch",
"path": "/torch/utils/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Set the module attribute on a python object for a given object for nicer printing
"""
if not isinstance(mod, str):
raise TypeError("The mod argument should be a string")
obj.__module__ = mod
if torch._running_with_deploy():
# not valid inside torch_deploy interpreter, ... | code_fim | medium | {
"lang": "python",
"repo": "pytorch/pytorch",
"path": "/torch/utils/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pytorch/pytorch path: /torch/utils/__init__.py
import os.path as _osp
import torch
from .throughput_benchmark import ThroughputBenchmark
from .cpp_backtrace import get_cpp_backtrace
from .backend_registration import rename_privateuse1_backend, generate_methods_for_privateuse1_backend
def set_mo... | code_fim | hard | {
"lang": "python",
"repo": "pytorch/pytorch",
"path": "/torch/utils/__init__.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: monkee52/NCSSChallenge path: /Triple-Double-Letter.py
# Enter your code for "Triple-Double-Letter" here.
import re
m = re.compile(r"([a-zA-Z])\1")
f = open("words.txt", "r")
d = ""
for l in f:
d += l
f.close()
d = d.split("\n")
o = []
<|fim_suffix|> if len(u) >= 3:
o.append(d[i])
o... | code_fim | medium | {
"lang": "python",
"repo": "monkee52/NCSSChallenge",
"path": "/Triple-Double-Letter.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>f.close()
d = d.split("\n")
o = []
for i in range(0, len(d)):
x = m.findall(d[i])
u = list(set(x))
if len(u) >= 3:
o.append(d[i])
o = sorted(o, key=str.lower)
for i in o:
print(i)<|fim_prefix|># repo: monkee52/NCSSChallenge path: /Triple-Double-Letter.py
# Enter your code for "Triple-D... | code_fim | easy | {
"lang": "python",
"repo": "monkee52/NCSSChallenge",
"path": "/Triple-Double-Letter.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jwg4/normie path: /normie/compat/excel.py
from normie import cdf, invcdf, pdf
<|fim_suffix|>def NORM_DIST(z, m, sd, cumulative):
if cumulative:
return cdf((z - m) / sd)
else:
return pdf((z - m) / sd) / 2<|fim_middle|>def NORM_INV(p, m, sd):
return invcdf(p) * sd + m
... | code_fim | easy | {
"lang": "python",
"repo": "jwg4/normie",
"path": "/normie/compat/excel.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jwg4/normie path: /normie/compat/excel.py
from normie import cdf, invcdf, pdf
<|fim_suffix|>
def NORM_DIST(z, m, sd, cumulative):
if cumulative:
return cdf((z - m) / sd)
else:
return pdf((z - m) / sd) / 2<|fim_middle|>def NORM_INV(p, m, sd):
return invcdf(p) * sd + m... | code_fim | easy | {
"lang": "python",
"repo": "jwg4/normie",
"path": "/normie/compat/excel.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def NORM_DIST(z, m, sd, cumulative):
if cumulative:
return cdf((z - m) / sd)
else:
return pdf((z - m) / sd) / 2<|fim_prefix|># repo: jwg4/normie path: /normie/compat/excel.py
from normie import cdf, invcdf, pdf
<|fim_middle|>
def NORM_INV(p, m, sd):
return invcdf(p) * sd + m
... | code_fim | easy | {
"lang": "python",
"repo": "jwg4/normie",
"path": "/normie/compat/excel.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Nomadblue/django-chile-payments path: /getpaid/backends/paypal/urls.py
from django.conf.urls import patterns, url
urlpatterns = patterns('',
url(r'^payment/authorization/<|fim_suffix|>thorization', name='getpaid-paypal-authorization'),
)<|fim_middle|>(?P<pk>[0-9]+)/$', 'getpaid.backends.payp... | code_fim | easy | {
"lang": "python",
"repo": "Nomadblue/django-chile-payments",
"path": "/getpaid/backends/paypal/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>thorization', name='getpaid-paypal-authorization'),
)<|fim_prefix|># repo: Nomadblue/django-chile-payments path: /getpaid/backends/paypal/urls.py
from django.conf.urls import patterns, url
urlpatterns = patterns('',
url(r'^payment/authorization/<|fim_middle|>(?P<pk>[0-9]+)/$', 'getpaid.backends.payp... | code_fim | easy | {
"lang": "python",
"repo": "Nomadblue/django-chile-payments",
"path": "/getpaid/backends/paypal/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ Can we instantiate with a tuple
"""
input = (13, 42, 7)
d = BinaryTree(input)
assert isinstance(d, BinaryTree)
def test_binarytree_str_as_expected():
""" After instanting with a few items, does BinaryTree str look right.
"""
input = (13, 42, 7)
expected = 'BinaryT... | code_fim | hard | {
"lang": "python",
"repo": "SeattleChris/data-structures-and-algorithms",
"path": "/data_structures/binary_tree/test_bst.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SeattleChris/data-structures-and-algorithms path: /data_structures/binary_tree/test_bst.py
from .bst import Node, BinaryTree
import pytest
def test_alive():
""" Does our test file even run
"""
pass
@pytest.fixture
def empty_list():
e = BinaryTree()
return e
@pytest.fixtu... | code_fim | hard | {
"lang": "python",
"repo": "SeattleChris/data-structures-and-algorithms",
"path": "/data_structures/binary_tree/test_bst.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carlos10seg/lkpy path: /lenskit/util/test.py
"""
Test utilities for LKPY tests.
"""
import os
import os.path
import logging
from contextlib import contextmanager
import numpy as np
from .. import matrix
import pytest
from hypothesis import given, assume
import hypothesis.strategies as st
impor... | code_fim | hard | {
"lang": "python",
"repo": "carlos10seg/lkpy",
"path": "/lenskit/util/test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> coords = draw(nph.arrays(np.int32, nnz, elements=st.integers(0, nrows*ncols - 1), unique=True))
rows = np.mod(coords, nrows, dtype=np.int32)
cols = np.floor_divide(coords, nrows, dtype=np.int32)
if values is None:
values = draw(st.booleans())
if values:
rng = draw(st.ra... | code_fim | hard | {
"lang": "python",
"repo": "carlos10seg/lkpy",
"path": "/lenskit/util/test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if ncols is None:
ncols = draw(st.integers(5, 100))
elif not isinstance(ncols, int):
ncols = draw(ncols)
if nrows is None:
nrows = draw(st.integers(5, 100))
elif not isinstance(nrows, int):
nrows = draw(nrows)
if nnz is None:
nnz = draw(st.inte... | code_fim | medium | {
"lang": "python",
"repo": "carlos10seg/lkpy",
"path": "/lenskit/util/test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>x0, y0 = map(1., 31.)
x1, y1 = map(15., 39.)
plt.imshow(plt.imread('../sample_files/by.png'), extent = (x0, x1, y0, y1))
axicon = fig.add_axes([0.1, 0., 0.15, 0.15])
axicon.imshow(plt.imread('../sample_files/by.png'), origin = 'upper')
axicon.set_xticks([])
axicon.set_yticks([])
plt.show()<|fi... | code_fim | medium | {
"lang": "python",
"repo": "rakiduam/BasemapTutorial",
"path": "/code_examples/plotting_data/imshow_logo.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rakiduam/BasemapTutorial path: /code_examples/plotting_data/imshow_logo.py
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
fig = plt.figure()
map = Basemap(projection='ortho',
lat_0=0, lon_0=0)
map.drawlsmask(land_color = "#ddaa66",
ocean_... | code_fim | medium | {
"lang": "python",
"repo": "rakiduam/BasemapTutorial",
"path": "/code_examples/plotting_data/imshow_logo.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: oshaughn/research-projects-RIT path: /MonteCarloMarginalizeCode/Code/annotate_ViaEOS.py
#! /usr/bin/env python
#
# GOAL
# - process file of eos_names.txt
# - return array of same names, annotated with EOS
# Notably, provides R_fiducial
# Designed to work on *any* file (e.g., outpu... | code_fim | hard | {
"lang": "python",
"repo": "oshaughn/research-projects-RIT",
"path": "/MonteCarloMarginalizeCode/Code/annotate_ViaEOS.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Read first line, identify eos_name column
line_header=''
with open(opts.fname_to_annotate, 'r') as f:
line_header = f.readline()
param_names_orig = line_header.replace('#','').split()
dtype_list =[]
for name in param_names_orig:
if 'eos_name' == name:
dtype_list.append( (name, 'S32'))
... | code_fim | hard | {
"lang": "python",
"repo": "oshaughn/research-projects-RIT",
"path": "/MonteCarloMarginalizeCode/Code/annotate_ViaEOS.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# write format specifier :
fmt = ""
for param_name in samples.dtype.names:
if param_name == 'eos_name':
fmt += " %s "
else:
fmt += " %.18e "
# Vastly superior data i/o
import pandas
dframe = pandas.DataFrame(samples)
dframe.to_csv(opts.fname_with_annotation,sep=' ',header=' # '+... | code_fim | hard | {
"lang": "python",
"repo": "oshaughn/research-projects-RIT",
"path": "/MonteCarloMarginalizeCode/Code/annotate_ViaEOS.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def ResNet18(n_labels, pretrained=False):
return ResNet(n_labels, 18, pretrained=pretrained)
def ResNet152(n_labels, pretrained=False):
return ResNet(n_labels, 152, pretrained=pretrained)<|fim_prefix|># repo: shuoli90/PAC-pred-set path: /model/resnet.py
import os, sys
import torch as tc
from ... | code_fim | hard | {
"lang": "python",
"repo": "shuoli90/PAC-pred-set",
"path": "/model/resnet.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shuoli90/PAC-pred-set path: /model/resnet.py
import os, sys
import torch as tc
from torch import nn
import torch.nn.functional as F
from torchvision import models
class ResNet(nn.Module):
def __init__(self, n_labels, resnet_id, pretrained=False):
<|fim_suffix|> return ResNet(n_labels, 18... | code_fim | hard | {
"lang": "python",
"repo": "shuoli90/PAC-pred-set",
"path": "/model/resnet.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if training:
self.train()
else:
self.eval()
x = self.model(x)
return {'fh': x, 'ph': F.softmax(x, -1), 'yh_top': x.argmax(-1), 'ph_top': F.softmax(x, -1).max(-1)[0], 'feat': self.feat}
def ResNet18(n_labels, pretrained=False):
retur... | code_fim | hard | {
"lang": "python",
"repo": "shuoli90/PAC-pred-set",
"path": "/model/resnet.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stymy/npairs path: /text_out.py
from nipype.interfaces.base import BaseInterface, \
BaseInterfaceInputSpec, traits, File, TraitedSpec, InputMultiPath
import os
import re
class Text_outInputSpec(BaseInterfaceInputSpec):
in_file = traits.List(desc="multiple files in joinNode")
<|fim_suffi... | code_fim | hard | {
"lang": "python",
"repo": "stymy/npairs",
"path": "/text_out.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _list_outputs(self):
outputs = self._outputs().get()
outputs["label_file"] = os.path.abspath('labels')
outputs["data_paths"] = os.path.abspath('paths')
return outputs<|fim_prefix|># repo: stymy/npairs path: /text_out.py
from nipype.interfaces.base import BaseInterf... | code_fim | hard | {
"lang": "python",
"repo": "stymy/npairs",
"path": "/text_out.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> with freeze_time(time):
scorekeeper_obj = ScorekeeperObjWithDefaults()
scorekeeper_obj(points)
assert scorekeeper_obj.score == expected
def test_scorekeeper_decorator():
scorekeeper_obj = ScorekeeperObj()
assert scorekeeper_obj.score == 0
@score(ScorekeeperObj, 1... | code_fim | hard | {
"lang": "python",
"repo": "dhosterman/scorekeeper",
"path": "/tests/test_scorekeeper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dhosterman/scorekeeper path: /tests/test_scorekeeper.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_scorekeeper
----------------------------------
Tests for `scorekeeper` module.
"""
import pytest
from freezegun import freeze_time
from scorekeeper import Scorekeeper
from scorekeep... | code_fim | hard | {
"lang": "python",
"repo": "dhosterman/scorekeeper",
"path": "/tests/test_scorekeeper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MomsFriendlyRobotCompany/pydar path: /examples/urg_test.py
#!/usr/bin/env python3
# MIT License Kevin Walchko (c) 2018
#
# this needs: pip install pydar
from pydar import URG04LX
import time
from math import pi
if __name__ == '__main__':
a = URG04LX()
port = "/dev/serial/by-id/usb-Hokuyo_Dat... | code_fim | medium | {
"lang": "python",
"repo": "MomsFriendlyRobotCompany/pydar",
"path": "/examples/urg_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # plt.ion()
for i in range(2):
pts = a.capture()
print('-'*40)
print('distance points:', pts)
# print('timestamp:', tm)
print('number points:', len(pts.scan))
a.close()
time.sleep(3)<|fim_prefix|># repo: MomsFriendlyRobotCompany/pydar path: /examples/urg_test.py
#!/usr/bin/env python3
# MI... | code_fim | hard | {
"lang": "python",
"repo": "MomsFriendlyRobotCompany/pydar",
"path": "/examples/urg_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Egojr/optagan path: /optagan/modules/decoders/decoder.py
import torch
import torch.nn as nn
class DecoderBase(nn.Module):
"""docstring for Decoder"""
def __init__(self):
super(DecoderBase, self).__init__()
def freeze(self):
for param in self.parameters()... | code_fim | hard | {
"lang": "python",
"repo": "Egojr/optagan",
"path": "/optagan/modules/decoders/decoder.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def log_probability(self, x, z):
"""
Args:
x: (batch_size, *)
z: (batch_size, n_sample, nz)
Returns:
log_p: (batch_size, n_sample).
log_p(x|z) across different x and z
"""
raise NotImplementedError<|... | code_fim | hard | {
"lang": "python",
"repo": "Egojr/optagan",
"path": "/optagan/modules/decoders/decoder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MokkoFm/django-star-burger path: /foodcartapp/migrations/0034_orderproductitem_product_total.py
# Generated by Django 3.0.7 on 2020-10-09 11:50
from django.db import migrations, models
<|fim_suffix|> operations = [
migrations.AddField(
model_name='orderproductitem',
... | code_fim | medium | {
"lang": "python",
"repo": "MokkoFm/django-star-burger",
"path": "/foodcartapp/migrations/0034_orderproductitem_product_total.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('foodcartapp', '0033_order_orderproductitem'),
]
operations = [
migrations.AddField(
model_name='orderproductitem',
name='product_total',
field=models.DecimalField(decimal_places=2, default=0, max_digits=8, verbose_name='су... | code_fim | easy | {
"lang": "python",
"repo": "MokkoFm/django-star-burger",
"path": "/foodcartapp/migrations/0034_orderproductitem_product_total.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yiyiwang515/UA_COMET path: /tests/unit/models/test_comet_estimator.py
# -*- coding: utf-8 -*-
import unittest
from argparse import Namespace
from io import StringIO
import numpy as np
import torch
from comet.models import CometEstimator
from comet.models.utils import average_pooling, max_pooling... | code_fim | hard | {
"lang": "python",
"repo": "yiyiwang515/UA_COMET",
"path": "/tests/unit/models/test_comet_estimator.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> model_input, target = self.estimator.prepare_sample(sample)
model_output = self.estimator(**model_input)
self.assertTrue(model_output["score"].shape[0] == 2)
self.assertTrue(model_output["score"].shape[1] == 1)
def test_get_sentence_embedding(self):
self.estima... | code_fim | hard | {
"lang": "python",
"repo": "yiyiwang515/UA_COMET",
"path": "/tests/unit/models/test_comet_estimator.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>:
if x in tns and x in pens:
print(x)<|fim_prefix|># repo: shivamT95/projecteuler path: /Q45/sol.py
tns = set([n*(n+1)/2 for n in range(100000)])
pens = set([n*(3*n-1)/2 for n in range(100000)])
hx<|fim_middle|> = [n*(2*n-1) for n in range(100000)]
for x in hx | code_fim | easy | {
"lang": "python",
"repo": "shivamT95/projecteuler",
"path": "/Q45/sol.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shivamT95/projecteuler path: /Q45/sol.py
tns = set([n*(n+1)/2 for n in range(100000)])
pe<|fim_suffix|> = [n*(2*n-1) for n in range(100000)]
for x in hx:
if x in tns and x in pens:
print(x)<|fim_middle|>ns = set([n*(3*n-1)/2 for n in range(100000)])
hx | code_fim | easy | {
"lang": "python",
"repo": "shivamT95/projecteuler",
"path": "/Q45/sol.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sikendershahid91/DIP path: /dft_filtering/DFT/Filtering.py
# For this part of the assignment, You can use inbuilt functions to compute the fourier transform
# You are welcome to use fft that are available in numpy and opencv
from numpy import sqrt, zeros
import matplotlib.pyplot as plt
class Fi... | code_fim | hard | {
"lang": "python",
"repo": "sikendershahid91/DIP",
"path": "/dft_filtering/DFT/Filtering.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> max_value, min_value = max(image), min(image)
# print(min_value, max_value)
# print(image)
min_value = 0 if min_value < 0 else min_value
_image = 255 * ( ( image - min_value )/ (max_value - min_value) )
# print('next')
# print(min(_image), max(_ima... | code_fim | hard | {
"lang": "python",
"repo": "sikendershahid91/DIP",
"path": "/dft_filtering/DFT/Filtering.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> payload = "{\r\n \"grant_type\": \"client_credentials\"\r\n}"
headers = {
'Authorization': f"Basic {auth}",
'Content-Type': 'application/json'
}
response = requests.request("POST", endpoint, headers=headers, data = payload , cert= cert)
result = response.json().get('access_to... | code_fim | medium | {
"lang": "python",
"repo": "Matheusrlr/Matheusrlr-API_Pix_Gerencianet",
"path": "/auth.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Matheusrlr/Matheusrlr-API_Pix_Gerencianet path: /auth.py
from credentials import *
import requests
import base64
if (sandbox == True):
url = "https://api-pix.gerencianet.com.br/"
else: url = "https://api-pix-h.gerencianet.com.br/"
<|fim_suffix|>def token():
endpoint = f"{url}oauth/t... | code_fim | hard | {
"lang": "python",
"repo": "Matheusrlr/Matheusrlr-API_Pix_Gerencianet",
"path": "/auth.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>(FUSESCMD="avrdude $UPLOADERFLAGS " + fusebits[env['BOARD']])<|fim_prefix|># repo: trombik/pio-dht-i2c-slave path: /extra_script/bootloader.py
Import('env')
fusebits = {
'attiny13': '-U lfuse:w:0x<|fim_middle|>7a:m -U hfuse:w:0xff:m',
'attiny85': '-U hfuse:w:0xdf:m -U lfuse:w:0xe2:m -U ef... | code_fim | medium | {
"lang": "python",
"repo": "trombik/pio-dht-i2c-slave",
"path": "/extra_script/bootloader.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: trombik/pio-dht-i2c-slave path: /extra_script/bootloader.py
Import('env')
fusebits = {
'attiny13': '-U lfuse:w:0x<|fim_suffix|>:m -U lfuse:w:0xe2:m -U efuse:w:0xff:m'
}
env.Replace(FUSESCMD="avrdude $UPLOADERFLAGS " + fusebits[env['BOARD']])<|fim_middle|>7a:m -U hfuse:w:0xff:m',
... | code_fim | medium | {
"lang": "python",
"repo": "trombik/pio-dht-i2c-slave",
"path": "/extra_script/bootloader.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: johanmeh/master path: /monsoon/monsoon_plot.py
import xarray as xr
import matplotlib.pyplot as plt
import numpy as np
import cartopy.crs as ccrs
import matplotlib.ticker as mticker
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
def fourplot_two_cb(ds5, ds6, ds7, ds8,... | code_fim | hard | {
"lang": "python",
"repo": "johanmeh/master",
"path": "/monsoon/monsoon_plot.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
for i in range(0,2):
for j in range(0,2):
axs[i,j].coastlines()
gl = axs[i,j].gridlines(xlocs=xticks, ylocs=yticks, draw_labels= True, alpha = 0.01, color = 'gray', linestyle = '--')
gl.xlabels_top = False
gl.ylabels_right = False
g... | code_fim | hard | {
"lang": "python",
"repo": "johanmeh/master",
"path": "/monsoon/monsoon_plot.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HanRui56/LightFieldReconstruction path: /networks/HDDRNet_Ax2.py
from utils.layers import *
from utils.convolve4d import *
from vgg19.vgg19 import VGG19
from tool.log_config import *
class HDDRNet(object):
'''
The HDDRNet framework
'''
def __init__(self, inputs, targets, is_tr... | code_fim | hard | {
"lang": "python",
"repo": "HanRui56/LightFieldReconstruction",
"path": "/networks/HDDRNet_Ax2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def views_flatten(self, x):
batch, w, h, s, t, c = x.get_shape().as_list()
x = tf.transpose(x, (0, 3, 4, 1, 2, 5))
x_flatten = tf.reshape(x, (batch*s*t, w, h, c))
return x_flatten
def compute_loss(self, labels, pre_recons, recons, use_perceptual_loss):
def ... | code_fim | hard | {
"lang": "python",
"repo": "HanRui56/LightFieldReconstruction",
"path": "/networks/HDDRNet_Ax2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lkrsnik/dragon_hack_2017 path: /los_pollos_hermanos/views.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import datetime
# import dateutil
import json
from django.core.exceptions import ObjectDoesNotExist
from django.http import JsonResponse
from django.views import View
fro... | code_fim | hard | {
"lang": "python",
"repo": "lkrsnik/dragon_hack_2017",
"path": "/los_pollos_hermanos/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class VisualisationView(View):
def get(self, request):
url = request.build_absolute_uri().split('/')[2]
return render(request, 'visualisation.html', {'url': url})
class AttackAPIView(View):
def get(self, request):
try:
# 2015-04-10 23:12:23
last_up... | code_fim | hard | {
"lang": "python",
"repo": "lkrsnik/dragon_hack_2017",
"path": "/los_pollos_hermanos/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """If the length of frames list is less than RGB_N_FRAMES,
it will be padded with blank frames (RGB -> 000).
"""
if len(frames) < config.RGB_N_FRAMES:
n_pad_frames = config.RGB_N_FRAMES - len(frames)
for _ in range(n_pad_frames):
blan... | code_fim | hard | {
"lang": "python",
"repo": "michaelnation26/skateboard_trick_classification",
"path": "/utils/data_generator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: michaelnation26/skateboard_trick_classification path: /utils/data_generator.py
import glob
import os
import sys
import cv2
from keras.preprocessing.image import ImageDataGenerator
from keras.utils import Sequence
import numpy as np
from . import config
class DataGenerator(Sequence):
def ... | code_fim | hard | {
"lang": "python",
"repo": "michaelnation26/skateboard_trick_classification",
"path": "/utils/data_generator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return frames
def _get_batch(self, batch_video_filepaths):
batch_frames = [self._get_frames(fp) for fp in batch_video_filepaths]
batch_frames = np.array(batch_frames)
batch_labels = [config.RGB_CLASS_NAME_TO_IDX[self._get_label_name(fp)]
for f... | code_fim | hard | {
"lang": "python",
"repo": "michaelnation26/skateboard_trick_classification",
"path": "/utils/data_generator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> baker.make('core.AssignmentGroup', parentnode=baker.make('core.Assignment'))
testuser = baker.make(settings.AUTH_USER_MODEL)
mockrequest = mock.MagicMock()
mockrequest.user = testuser
instance = crinstance_admin.AdminCrInstance(request=mockrequest)
self.asse... | code_fim | hard | {
"lang": "python",
"repo": "devilry/devilry-django",
"path": "/devilry/devilry_group/tests/test_crinstance/test_crinstance_admin.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: devilry/devilry-django path: /devilry/devilry_group/tests/test_crinstance/test_crinstance_admin.py
import mock
from django import test
from django.conf import settings
from model_bakery import baker
from devilry.devilry_dbcache.customsql import AssignmentGroupDbCacheCustomSql
from devilry.devilr... | code_fim | hard | {
"lang": "python",
"repo": "devilry/devilry-django",
"path": "/devilry/devilry_group/tests/test_crinstance/test_crinstance_admin.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: t0rx/dancecard path: /python/worker.py
#!/usr/bin/python3
import sys
import threading
import yaml
from sessions import Scenario
from driver import StrategyDriver
class Worker(object):
def __init__(self, mqtt_client, strategy_factory, publishers, importer, import_frequency, worker_name, session... | code_fim | hard | {
"lang": "python",
"repo": "t0rx/dancecard",
"path": "/python/worker.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with self.lock:
if self.running_driver:
print('Stopping scenario %s' % self.running_scenario.id, file=sys.stderr)
self.running_driver.stop()
self.running_driver = None
self.running_scenario = None<|fim_prefix|># repo: t0rx/dancecard path: /python/worker.py
#!/usr... | code_fim | hard | {
"lang": "python",
"repo": "t0rx/dancecard",
"path": "/python/worker.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: VincentFritzsche/google-ads-python path: /google/ads/google_ads/v6/proto/services/batch_job_service_pb2_grpc.py
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
from google.ads.google_ads... | code_fim | hard | {
"lang": "python",
"repo": "VincentFritzsche/google-ads-python",
"path": "/google/ads/google_ads/v6/proto/services/batch_job_service_pb2_grpc.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Service to manage batch jobs.
"""
@staticmethod
def MutateBatchJob(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
... | code_fim | hard | {
"lang": "python",
"repo": "VincentFritzsche/google-ads-python",
"path": "/google/ads/google_ads/v6/proto/services/batch_job_service_pb2_grpc.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 输出文件编码,Linux下可选X264
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
# 视频帧率
fps = cap.get(cv2.CAP_PROP_FPS)
print("视频size:" + str(size))
print("视频编码:" + str(fourcc))
print("视频的FPS:" + str(fps))
return size, fourcc, fps<|fim_prefix|># repo: jimbunny/cartoonVideo path: /combineVi... | code_fim | medium | {
"lang": "python",
"repo": "jimbunny/cartoonVideo",
"path": "/combineVideo/read_video_info.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 视频帧率
fps = cap.get(cv2.CAP_PROP_FPS)
print("视频size:" + str(size))
print("视频编码:" + str(fourcc))
print("视频的FPS:" + str(fps))
return size, fourcc, fps<|fim_prefix|># repo: jimbunny/cartoonVideo path: /combineVideo/read_video_info.py
import cv2
def read_video_info(file):
cap =... | code_fim | medium | {
"lang": "python",
"repo": "jimbunny/cartoonVideo",
"path": "/combineVideo/read_video_info.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.