text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>app_name = 'tavastiaevents'
urlpatterns = [
url(r'report/', message_event, name='message-event'),
url(r'documentation/$', TemplateView.as_view(template_name="rest_framework/api_info.html"), name='documentation'),
]<|fim_prefix|># repo: hamk-uas/TavastiaEvents path: /tavastiaevents/urls.py
from dj... | code_fim | medium | {
"lang": "python",
"repo": "hamk-uas/TavastiaEvents",
"path": "/tavastiaevents/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RyanHolstien/datahub path: /metadata-ingestion/examples/library/dataset_add_properties.py
import logging
from typing import Union
from datahub.configuration.kafka import KafkaProducerConnectionConfig
from datahub.emitter.kafka_emitter import DatahubKafkaEmitter, KafkaEmitterConfig
from datahub.e... | code_fim | hard | {
"lang": "python",
"repo": "RyanHolstien/datahub",
"path": "/metadata-ingestion/examples/library/dataset_add_properties.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> USE_REST_EMITTER = True
if USE_REST_EMITTER:
gms_endpoint = "http://localhost:8080"
return DataHubRestEmitter(gms_server=gms_endpoint)
else:
kafka_server = "localhost:9092"
schema_registry_url = "http://localhost:8081"
return DatahubKafkaEmitter(
... | code_fim | medium | {
"lang": "python",
"repo": "RyanHolstien/datahub",
"path": "/metadata-ingestion/examples/library/dataset_add_properties.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: csvoss/lucid path: /lucid/misc/io/writing.py
# Copyright 2018 The Lucid Authors. 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... | code_fim | hard | {
"lang": "python",
"repo": "csvoss/lucid",
"path": "/lucid/misc/io/writing.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def _supports_binary_writing(path):
"""Whether this path implies a storage system that supports and requires
intermediate directories to be created explicitly."""
return not path.startswith("/bigstore")
def _write_to_path(data, path, mode="wb"):
with write_handle(path, mode) as handle:
... | code_fim | hard | {
"lang": "python",
"repo": "csvoss/lucid",
"path": "/lucid/misc/io/writing.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tblondelle/PAr142 path: /post_processing/unused/clean_dictionnary.py
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 5 19:49:24 2017
@author: thomas
Delete some useless keys in the postag_dict dictionnary
(postag_dict_2 is a copy of postag_dict).
Eventually, the final dictionnary is 45-key l... | code_fim | hard | {
"lang": "python",
"repo": "tblondelle/PAr142",
"path": "/post_processing/unused/clean_dictionnary.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
"""
The final dictionary:
PRP$ - size: 71 ['her', 'its', 'my', 'your']
WDT - size: 31 ['which', 'that', 'What', 'what']
JJ - size: 32598 ['olden', 'beautiful', 'much', 'great']
WP - size: 45 ['What', 'what', 'Whatever', 'who']
RP - size: 77 ['down', 'up', 'off', 'away']
$ - size: 1... | code_fim | hard | {
"lang": "python",
"repo": "tblondelle/PAr142",
"path": "/post_processing/unused/clean_dictionnary.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Migration(migrations.Migration):
dependencies = [
('feeds', '0002_auto_20190604_0845'),
]
operations = [
migrations.AddField(
model_name='post',
name='image_url',
field=models.CharField(blank=True, max_length=255, null=True),
... | code_fim | easy | {
"lang": "python",
"repo": "xurble/django-feed-reader",
"path": "/feeds/migrations/0003_post_image_url.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xurble/django-feed-reader path: /feeds/migrations/0003_post_image_url.py
# Generated by Django 2.2.1 on 2019-06-20 09:32
from django.db import migrations, models
<|fim_suffix|> dependencies = [
('feeds', '0002_auto_20190604_0845'),
]
operations = [
migrations.AddFie... | code_fim | easy | {
"lang": "python",
"repo": "xurble/django-feed-reader",
"path": "/feeds/migrations/0003_post_image_url.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>geLogin.html'}, name='login'),
url(r'^logout/$', auth_views.logout, {'next_page': 'login'}, name='logout'),
url(r'^password_change/$', auth_views.password_change, {'template_name': 'accounts/password_change_form.html'}, name='password_chage'),
... | code_fim | hard | {
"lang": "python",
"repo": "KanJam/Finpy",
"path": "/Finpy/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KanJam/Finpy path: /Finpy/urls.py
from django.conf.urls import include, patterns, url
from django.contrib.auth import views as auth_views
from Finpy import views
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^about.html', ... | code_fim | hard | {
"lang": "python",
"repo": "KanJam/Finpy",
"path": "/Finpy/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> done = []
sorted_jobs = sorted(self.jobs, key=lambda j: j.priority)
for job in sorted_jobs:
if job.started():
# Check if it's finished
if job.ready():
self.jobs.remove(job)
self.in_pipe -= 1
... | code_fim | hard | {
"lang": "python",
"repo": "AliShug/RoboVis",
"path": "/robovis/workerpool.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AliShug/RoboVis path: /robovis/workerpool.py
from multiprocessing.pool import Pool
import os
class JobRef(object):
def __init__(self, func, args, ref=None, priority=1):
self.func = func
self.args = args
self.ref = ref
self.priority= priority
self._res ... | code_fim | hard | {
"lang": "python",
"repo": "AliShug/RoboVis",
"path": "/robovis/workerpool.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def registerJob(self, func, args, ref=None, priority=1):
job = JobRef(func, args, ref, priority)
# Replace duplicate-source unstarted jobs
if ref is not None:
self.jobs = [j for j in self.jobs if j.ref != ref or j.started()]
self.jobs.append(job)
if ... | code_fim | hard | {
"lang": "python",
"repo": "AliShug/RoboVis",
"path": "/robovis/workerpool.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chyidl/chyidlTutorial path: /root/os/DSAA/DataStructuresAndAlgorithms/python/fibonacci.py
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
#
# fibonacci.py
# python
#
# 🎂"Here's to the crazy ones. The misfits. The rebels.
# The troublemakers. The round pegs in the square holes.
# The ones who see... | code_fim | hard | {
"lang": "python",
"repo": "chyidl/chyidlTutorial",
"path": "/root/os/DSAA/DataStructuresAndAlgorithms/python/fibonacci.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return '斐波那契数列'
__repr__ = __str__
def __getattr__(self, attr):
'动态返回一个属性'
if attr == 'author':
return 'Chyi Yaqing'
raise AttributeError("Fibonacci object has no attribute %s" % attr)
def __getitem__(self, n):
'下标访问数列的任意项'
if isins... | code_fim | hard | {
"lang": "python",
"repo": "chyidl/chyidlTutorial",
"path": "/root/os/DSAA/DataStructuresAndAlgorithms/python/fibonacci.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'--output_dir',
type=str,
default='mustbedefined',
help='Output directory.'
)
parser.add_argument(
'--tiles_stats',
type=str,
default='',
help='text file where ... | code_fim | hard | {
"lang": "python",
"repo": "ncoudray/DeepPATH",
"path": "/DeepPATH_code/03_postprocessing/multiClasses/0f_ProbHistogram.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ncoudray/DeepPATH path: /DeepPATH_code/03_postprocessing/multiClasses/0f_ProbHistogram.py
""" NYU modifications:
Author: Nicolas Coudray
Date created: August/2017
Python Version: 3.5.3
Use it with Lung images stat file:
Generate class probability histograms for each slide
"""
fro... | code_fim | hard | {
"lang": "python",
"repo": "ncoudray/DeepPATH",
"path": "/DeepPATH_code/03_postprocessing/multiClasses/0f_ProbHistogram.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> {}°C corresponde a {}°F'.format(c, conv))<|fim_prefix|># repo: LucasLima337/CEV_Python_Exercises path: /exercicios/ex014.py
# Conversor de Temperaturas
c = float(inp<|fim_middle|>ut('Digite a temperatura em °C: '))
conv = (c * 9 / 5) + 32
print('A temperatura de | code_fim | medium | {
"lang": "python",
"repo": "LucasLima337/CEV_Python_Exercises",
"path": "/exercicios/ex014.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LucasLima337/CEV_Python_Exercises path: /exercicios/ex014.py
# Conversor de Temperaturas
c = float(inp<|fim_suffix|> {}°C corresponde a {}°F'.format(c, conv))<|fim_middle|>ut('Digite a temperatura em °C: '))
conv = (c * 9 / 5) + 32
print('A temperatura de | code_fim | medium | {
"lang": "python",
"repo": "LucasLima337/CEV_Python_Exercises",
"path": "/exercicios/ex014.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ce=no --top_seller_uri=gs://lbanor/pyspark/marreco/top_seller/results --algorithm=top_seller<|fim_prefix|># repo: WillianFuks/PySpark-RecSys path: /bin/dataproc_top_seller.py
gcloud dataproc jobs submit pyspark --cluster=test3 --py-files=base.py,factory.py,top_seller.py --bucket=lbanor run_marreco.py -- ... | code_fim | medium | {
"lang": "python",
"repo": "WillianFuks/PySpark-RecSys",
"path": "/bin/dataproc_top_seller.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WillianFuks/PySpark-RecSys path: /bin/dataproc_top_seller.py
gcloud dataproc jobs submit pyspark --cluster=test3 --py-files=base.py,factory.py,top_seller<|fim_suffix|>ce=no --top_seller_uri=gs://lbanor/pyspark/marreco/top_seller/results --algorithm=top_seller<|fim_middle|>.py --bucket=lbanor run_... | code_fim | medium | {
"lang": "python",
"repo": "WillianFuks/PySpark-RecSys",
"path": "/bin/dataproc_top_seller.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return model
def np_dataset(datasets, batch_size, seed):
""" load npz datasets """
datasets = sorted(glob.glob(datasets))
print(datasets)
## x_train1
array = np.load(datasets[0])
x_train, x_valid, x_test, y_train, y_valid = [array[k] for k in list(array)]
# Shuffle
... | code_fim | hard | {
"lang": "python",
"repo": "henrique/jigsaw20",
"path": "/dual_model.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: henrique/jigsaw20 path: /dual_model.py
""" build a dual TFAutoModel and load its data from npz or tfrec dataset """
import glob
import numpy as np
import pandas as pd
import tensorflow as tf
from tensorflow.keras.layers import Dense, Dropout, Input
from tensorflow.keras.models import Model
from... | code_fim | hard | {
"lang": "python",
"repo": "henrique/jigsaw20",
"path": "/dual_model.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> x_train2, x_valid2, x_test2 = x_train, x_valid, x_test
## Set Datasets
auto_tune = tf.data.experimental.AUTOTUNE
train_dataset = (
tf.data.Dataset.zip((
tf.data.Dataset.from_tensor_slices((x_train1, x_train2)),
tf.data.Dataset.from_tensor_slices(y_train)
... | code_fim | hard | {
"lang": "python",
"repo": "henrique/jigsaw20",
"path": "/dual_model.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gamingrobot/SpockBot path: /spockbot/__init__.py
import logging
from spockbot.plugins.loader import PluginLoader as Client # noq<|fim_suffix|>message)s')
streamHandler.setFormatter(formatter)
logger.addHandler(streamHandler)<|fim_middle|>a
logger = logging.getLogger('spockbot')
logger.setLevel... | code_fim | medium | {
"lang": "python",
"repo": "gamingrobot/SpockBot",
"path": "/spockbot/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>message)s')
streamHandler.setFormatter(formatter)
logger.addHandler(streamHandler)<|fim_prefix|># repo: gamingrobot/SpockBot path: /spockbot/__init__.py
import logging
from spockbot.plugins.loader import PluginLoader as Client # noq<|fim_middle|>a
logger = logging.getLogger('spockbot')
logger.setLevel... | code_fim | medium | {
"lang": "python",
"repo": "gamingrobot/SpockBot",
"path": "/spockbot/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Yizhar-Lab/printz_nat_comm_2023 path: /Event_detection/01_decon_oasis/my_funcs_detect_and_save.py
import logging
# %%
import copy
import json
import pathlib
import pickle
import pprint
import warnings
from collections import defaultdict
import box
# import matplotlib.pyplot as plt
import numpy... | code_fim | hard | {
"lang": "python",
"repo": "Yizhar-Lab/printz_nat_comm_2023",
"path": "/Event_detection/01_decon_oasis/my_funcs_detect_and_save.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #remove endpoints filterig artefacr
ms25 = int(25*f_new/1000)
trace_zeroed=trace_zeroed[ms25:-ms25]
times=times[ms25:-ms25]
return_data.trace_zeroed=trace_zeroed
return_data.MAD=MAD
return_data.times=times
return_data.factor = factor
logging.info(f"decimate factor =... | code_fim | hard | {
"lang": "python",
"repo": "Yizhar-Lab/printz_nat_comm_2023",
"path": "/Event_detection/01_decon_oasis/my_funcs_detect_and_save.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mehdirezaie/SYSNet path: /mocks_factory/fftpower.py
'''
utility to compute the power spectrum from a 3D box log-normal mocks
with Nbodykit (c) Nick Hand, Yu Feng
see http://nbodykit.readthedocs.io/en/stable/catalogs/mock-data.html#Log-normal-Mocks
'''
#
import nbodykit.lab as nb
impor... | code_fim | hard | {
"lang": "python",
"repo": "mehdirezaie/SYSNet",
"path": "/mocks_factory/fftpower.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> FILE = bf.BigFile(filename)
n = FILE.size
pos = FILE.read('Position', 0, n)
return nb.ArrayCatalog(pos)
# MR: very slow
# BigFile is faster
# def read_txtfile(filename):
# cat_i = open(filename, 'r')
# lines = cat_i.readlines()
# x = []
# for line in lines:
# ... | code_fim | hard | {
"lang": "python",
"repo": "mehdirezaie/SYSNet",
"path": "/mocks_factory/fftpower.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
"""
Copyright 2023 Sandia National Laboratories
Notice: This computer software was prepared by National Technology and Engineering Solutions of
Sandia, LLC, hereinafter the Contractor, under Contract DE-NA0003525 with the Department of Energy
(DOE). All rights in the computer software are reserved by DO... | code_fim | hard | {
"lang": "python",
"repo": "sandialabs/sibl",
"path": "/geo/examples/image2movie.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>"""
Copyright 2023 Sandia National Laboratories
Notice: This computer software was prepared by National Technology and Engineering Solutions of
Sandia, LLC, hereinafter the Contractor, under Contract DE-NA0003525 with the Department of Energy
(DOE). All rights in the computer software are reserved by DOE... | code_fim | hard | {
"lang": "python",
"repo": "sandialabs/sibl",
"path": "/geo/examples/image2movie.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sandialabs/sibl path: /geo/examples/image2movie.py
"""This module uses imageio to concatenate sequence image files into movie."""
import imageio
from pygifsicle import optimize
# base_name = "bspline_surface_biquad2tri_animation"
# base_name = "bspline_surface_cyl2sphere_animation"
# base_name... | code_fim | hard | {
"lang": "python",
"repo": "sandialabs/sibl",
"path": "/geo/examples/image2movie.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gistable/gistable path: /all-gists/3103436/snippet.py
#!/usr/bin/python
import re, os, sys
def convertText(c):
# replace all links
# c = re.sub(r'\[([^\]]+)\]\(([^\]]+)\)', r'[\1|\2]', c)
c = re.sub(r'\[(.*?)\]\((.*?)\)', r'[\1|\2]', c)
# replace bold temporarily
c = re.sub... | code_fim | hard | {
"lang": "python",
"repo": "gistable/gistable",
"path": "/all-gists/3103436/snippet.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> f_counter = 0
for f in os.listdir(dirname):
fname = os.path.join(dirname,f)
if fname[-3:] =='.md':
f_counter += 1
convertFile(fname)
if __name__=='__main__':
if len(sys.argv)<2:
convertAllFiles(".")
sys.exit()
infile = sys.argv[1]
if ... | code_fim | hard | {
"lang": "python",
"repo": "gistable/gistable",
"path": "/all-gists/3103436/snippet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not self.pk:
return
from pretalx.common.models import ActivityLog
if data and not isinstance(data, str):
data = json.dumps(data, cls=I18nJSONEncoder)
ActivityLog.objects.create(
event=getattr(self, 'event', None), person=person, cont... | code_fim | medium | {
"lang": "python",
"repo": "MaxRink/pretalx",
"path": "/src/pretalx/common/mixins/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MaxRink/pretalx path: /src/pretalx/common/mixins/models.py
import json
from django.contrib.contenttypes.models import ContentType
from i18nfield.utils import I18nJSONEncoder
class LogMixin:
def log_action(self, action, data=None, person=None, orga=False):
if not self.pk:
... | code_fim | hard | {
"lang": "python",
"repo": "MaxRink/pretalx",
"path": "/src/pretalx/common/mixins/models.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ARM-software/Tool-Solutions path: /docker/pytorch-aarch64/examples/torchtext_example.py
# *****************************************************************************$
# Copyright 2023 Arm Limited and affiliates.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Versio... | code_fim | hard | {
"lang": "python",
"repo": "ARM-software/Tool-Solutions",
"path": "/docker/pytorch-aarch64/examples/torchtext_example.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # This variable needs to be initialized twice or else an IndexError occurs
train_iter = AG_NEWS(split='train')
dataloader = DataLoader(train_iter, batch_size=8, shuffle=False,
collate_fn=collate_batch)
# Build an instance
num_class = len(set([label for (label, text) in train_i... | code_fim | hard | {
"lang": "python",
"repo": "ARM-software/Tool-Solutions",
"path": "/docker/pytorch-aarch64/examples/torchtext_example.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> z = self.z
np.testing.assert_array_almost_equal(
StreamFlow_1.StreamFlow_1_f(z.NYrs, z.DaysMonth, z.Temp, z.InitSnow_0, z.Prec, z.NRur, z.NUrb, z.Area,
z.CNI_0, z.AntMoist_0, z.Grow_0, z.CNP_0, z.Imper,
... | code_fim | hard | {
"lang": "python",
"repo": "WikiWatershed/gwlf-e",
"path": "/test/unittests/test_StreamFlow_1.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WikiWatershed/gwlf-e path: /test/unittests/test_StreamFlow_1.py
import numpy as np
from .VariableUnitTest import VariableUnitTest
from gwlfe.MultiUse_Fxns.Discharge import StreamFlow_1
<|fim_suffix|> def test_StreamFlow_1(self):
z = self.z
np.testing.assert_array_almost_equa... | code_fim | hard | {
"lang": "python",
"repo": "WikiWatershed/gwlf-e",
"path": "/test/unittests/test_StreamFlow_1.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_StreamFlow_1(self):
z = self.z
np.testing.assert_array_almost_equal(
StreamFlow_1.StreamFlow_1_f(z.NYrs, z.DaysMonth, z.Temp, z.InitSnow_0, z.Prec, z.NRur, z.NUrb, z.Area,
z.CNI_0, z.AntMoist_0, z.Grow_0, z.CNP_0, z.Imper,
... | code_fim | hard | {
"lang": "python",
"repo": "WikiWatershed/gwlf-e",
"path": "/test/unittests/test_StreamFlow_1.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: summonersRift/sst-macro path: /bin/pysst/header.py
import os
import re
import sys
from standardize import clean_comments
class HeaderContextError:
def __init__(self, msg = "parse header error"):
self.msg = msg
def __repr__(self):
return self.msg
class HeaderData:
... | code_fim | hard | {
"lang": "python",
"repo": "summonersRift/sst-macro",
"path": "/bin/pysst/header.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> HeaderData.parsed_files[fullpath] = True
HeaderData.include_arrs[fullpath] = my_include_arr
#get all the includes
for incpath in my_include_arr:
parse_header(incpath, do_gui)
from pysst.parse import do_parse_text
do_parse_text(fullpath, text, do_gui)
def set_using_namesp... | code_fim | hard | {
"lang": "python",
"repo": "summonersRift/sst-macro",
"path": "/bin/pysst/header.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> already_included[path] = True
if path in HeaderData.using_cls_arrs:
new_using_arr = HeaderData.using_cls_arrs[path]
for entry in new_using_arr:
if not entry in using_cls_arr:
using_cls_arr.append(entry)
try:
subincludes = HeaderData.include... | code_fim | hard | {
"lang": "python",
"repo": "summonersRift/sst-macro",
"path": "/bin/pysst/header.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># TODO: Add functions here as needed.
def go(mqtt_sender, direction, spin_left_speed, spin_right_speed, deg):
print()
print(direction)
print("Left wheel motor speed:", spin_left_speed, "for", deg, "degrees")
print("Right wheel motor speed:", spin_right_speed, "for", deg, "degrees")
mq... | code_fim | hard | {
"lang": "python",
"repo": "egertsja/99-CapstoneProject-201930",
"path": "/src/m2_laptop_code.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: egertsja/99-CapstoneProject-201930 path: /src/m2_laptop_code.py
"""
Capstone Project. Code to run on a LAPTOP (NOT the robot).
Displays the Graphical User Interface (GUI) and communicates with the robot.
Authors: Your professors (for the framework)
and Zach Witonsky.
Spring term, 2... | code_fim | hard | {
"lang": "python",
"repo": "egertsja/99-CapstoneProject-201930",
"path": "/src/m2_laptop_code.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> left = -int(spin_left_box.get())
right = int(spin_right_box.get())
deg = int(deg_box.get())
go(mqtt_sender, "SPIN LEFT", left, right, deg)
def handle_spin_right(spin_left_box, spin_right_box, deg_box, mqtt_sender):
left = int(spin_left_box.get())
right = -int(spin_right_box.get())... | code_fim | hard | {
"lang": "python",
"repo": "egertsja/99-CapstoneProject-201930",
"path": "/src/m2_laptop_code.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: crwhite14/Keras-MNIST-GAN path: /gan.py
import logging
import argparse
import sys
import os
import numpy as np
import matplotlib.pyplot as plt
from tqdm import tqdm
os.environ["KERAS_BACKEND"] = "tensorflow"
from keras.layers import Input
from keras.models import Model, Sequential
fro... | code_fim | hard | {
"lang": "python",
"repo": "crwhite14/Keras-MNIST-GAN",
"path": "/gan.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
generator = Sequential()
generator.add(Dense(256, input_dim=self.random_dim, kernel_initializer=initializers.RandomNormal(stddev=0.02)))
generator.add(LeakyReLU(0.2))
generator.add(Dense(512))
generator.add(LeakyReLU(0.2))
generator.add(Dense(1024))
... | code_fim | hard | {
"lang": "python",
"repo": "crwhite14/Keras-MNIST-GAN",
"path": "/gan.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stylight/pypicloud path: /pypicloud/access/config.py
""" Backend that reads access control rules from config file """
import logging
import six
from collections import defaultdict
from pyramid.security import Everyone, Authenticated
from pyramid.settings import aslist, asbool
from .base import I... | code_fim | hard | {
"lang": "python",
"repo": "stylight/pypicloud",
"path": "/pypicloud/access/config.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if admins:
lines.append('auth.admins =')
for admin in admins:
lines.append(' {0}'.format(admin))
for group, members in six.iteritems(data['groups']):
lines.append('group.{0} ='.format(group))
for member in members:
... | code_fim | hard | {
"lang": "python",
"repo": "stylight/pypicloud",
"path": "/pypicloud/access/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> })
return perms
def load(self, data):
lines = []
admins = []
for user in data['users']:
lines.append('user.{username} = {password}'.format(**user))
if user.get('admin'):
admins.append(user['username'])
if... | code_fim | hard | {
"lang": "python",
"repo": "stylight/pypicloud",
"path": "/pypicloud/access/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.dividends._set_claimed(self.test_account1, 1)
self.assertTrue(self.dividends._is_claimed(self.test_account1, 1))
self.assertFalse(self.dividends._is_claimed(self.test_account1, 2))
self.assertFalse(self.dividends._is_claimed(self.test_account3, 1))
self.assertF... | code_fim | hard | {
"lang": "python",
"repo": "subba72/balanced-contracts",
"path": "/tests/test_unit_dividends.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: subba72/balanced-contracts path: /tests/test_unit_dividends.py
from iconservice import Address
from iconservice.base.exception import IconScoreException
from tbears.libs.scoretest.score_test_case import ScoreTestCase
from core_contracts.dividends.dividends import Dividends
class TestDividendsUn... | code_fim | hard | {
"lang": "python",
"repo": "subba72/balanced-contracts",
"path": "/tests/test_unit_dividends.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> token1 = Address.from_string(f"cx{'0' * 40}")
token2 = Address.from_string(f"cx{'12345' * 8}")
self.dividends._accepted_tokens.put(token1)
self.dividends._accepted_tokens.put(token2)
self.dividends._daofund.set(Address.from_string(f"cx{'12345'*8}"))
day = 1
... | code_fim | hard | {
"lang": "python",
"repo": "subba72/balanced-contracts",
"path": "/tests/test_unit_dividends.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Registration(db.Model):
date_registered = db.DateTimeProperty(auto_now_add=True)
first_name = db.StringProperty(required=True)
last_name = db.StringProperty(required=True)
mobile = db.StringProperty(required=True)
email = db.StringProperty(required=True)
sobriety_date = db.Da... | code_fim | medium | {
"lang": "python",
"repo": "tintinnabulate/fictional-parakeet",
"path": "/eurypaa/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tintinnabulate/fictional-parakeet path: /eurypaa/models.py
from google.appengine.ext import db
from slugify import slugify
class Post(db.Model):
title = db.StringProperty(required=True)
content = db.TextProperty(required=True)
when = db.DateTimeProperty(auto_now_add=True)
author ... | code_fim | hard | {
"lang": "python",
"repo": "tintinnabulate/fictional-parakeet",
"path": "/eurypaa/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self):
data = []
for line in sys.stdin:
data.append(line)
# print "Data: {0}".format(data)
data = map(lambda s: s.strip(), data)
self.data = data
self.instances = []
self.parse()
def parse(self):
"""
... | code_fim | hard | {
"lang": "python",
"repo": "GMadorell/programming-challenges",
"path": "/tuenti/tuenti_challenge_4/qualification/2_f1_racing_team/f1_racing_team.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
This method should populate the instances list.
"""
for line in self.data:
row = line.strip()
instance = F1RacingTeamInstance()
instance.road = row
self.instances.append(instance)
def get_data_as_type(self, type_):
... | code_fim | hard | {
"lang": "python",
"repo": "GMadorell/programming-challenges",
"path": "/tuenti/tuenti_challenge_4/qualification/2_f1_racing_team/f1_racing_team.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GMadorell/programming-challenges path: /tuenti/tuenti_challenge_4/qualification/2_f1_racing_team/f1_racing_team.py
#!/usr/bin/env python
"""
Problem description.
"""
from __future__ import division
import sys
import numpy as np
CORNERS = ("\\", "/")
START = "#"
RIGHT = 1
LEFT = 2
UP = 3
DOWN... | code_fim | hard | {
"lang": "python",
"repo": "GMadorell/programming-challenges",
"path": "/tuenti/tuenti_challenge_4/qualification/2_f1_racing_team/f1_racing_team.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: luckynote/menpobench path: /menpobench/imgprocess.py
def union_bounding_box(landmarks):
import numpy as np
from menpo.shape import PointCloud
return PointCloud(np.concatenate([landmarks[l].lms.points
for l in landmarks]), copy=False)
<|fim_suffix... | code_fim | hard | {
"lang": "python",
"repo": "luckynote/menpobench",
"path": "/menpobench/imgprocess.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> new_img.pixels = np.array(new_img.pixels, dtype=np.float) * (1.0 / 255.0)
if new_img.n_channels == 3:
new_img = new_img.as_greyscale(mode='luminosity')
return new_img<|fim_prefix|># repo: luckynote/menpobench path: /menpobench/imgprocess.py
def union_bounding_box(landmarks):
impor... | code_fim | hard | {
"lang": "python",
"repo": "luckynote/menpobench",
"path": "/menpobench/imgprocess.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def menpo_img_process(img, crop=True):
import numpy as np
# for menpo methods we always want greyscale. we also don't want images
# that are too large, and we want floating point images.
if crop:
img.landmarks['__super_bbox'] = union_bounding_box(img.landmarks)
new_img = i... | code_fim | hard | {
"lang": "python",
"repo": "luckynote/menpobench",
"path": "/menpobench/imgprocess.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># Step 3: Traverse CSV List
for row in csvReader:
print row<|fim_prefix|># repo: vikash-india/DeveloperNotes2Myself path: /languages/python/src/topics/csv/P002_CSVReader_FromList.py
# Description: Parse a List of String Into a List of Lists
import csv
<|fim_middle|># Step 1: CSV String
csvString = ... | code_fim | hard | {
"lang": "python",
"repo": "vikash-india/DeveloperNotes2Myself",
"path": "/languages/python/src/topics/csv/P002_CSVReader_FromList.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vikash-india/DeveloperNotes2Myself path: /languages/python/src/topics/csv/P002_CSVReader_FromList.py
# Description: Parse a List of String Into a List of Lists
<|fim_suffix|># Step 2: Initialise CSV Reader
csvReader = csv.reader(csvString)
# Step 3: Traverse CSV List
for row in csvReader:
p... | code_fim | hard | {
"lang": "python",
"repo": "vikash-india/DeveloperNotes2Myself",
"path": "/languages/python/src/topics/csv/P002_CSVReader_FromList.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Calculates loss- the difference between model predictions and true labels
Parameters:
logits: A Torch tensor of model output predictions
labels: A Torch tensor of true values for predictions
Returns:
Cross entropy loss"""
return F.cr... | code_fim | hard | {
"lang": "python",
"repo": "suhacker1/PrivacyRaven",
"path": "/src/privacyraven/models/pytorch.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: suhacker1/PrivacyRaven path: /src/privacyraven/models/pytorch.py
"""
These models will be depreciated soon. Use at your own risk.
"""
import os
import numpy as np
import pytorch_lightning as pl
import torch
from torch import nn
from torch.nn import functional as F
from torchvision import dataset... | code_fim | hard | {
"lang": "python",
"repo": "suhacker1/PrivacyRaven",
"path": "/src/privacyraven/models/pytorch.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class ImagenetTransferLearning(pl.LightningModule):
def __init__(self, hparams):
"""Create a classifier with a pretrained MobileNet backbone"""
super(ImagenetTransferLearning, self).__init__()
self.hparams = hparams
self.feature_extractor = models.mobilenet_v2(pretraine... | code_fim | hard | {
"lang": "python",
"repo": "suhacker1/PrivacyRaven",
"path": "/src/privacyraven/models/pytorch.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>se the ProfileNeuralNetwork you need to install tensorflow.")
from pywatts.modules.postprocessing.ensemble import Ensemble
from pywatts.modules.preprocessing.average import Average
from pywatts.modules.preprocessing.change_direction import ChangeDirection
from pywatts.modules.preprocessing.clock_shift imp... | code_fim | hard | {
"lang": "python",
"repo": "KIT-IAI/pyWATTS",
"path": "/pywatts/modules/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KIT-IAI/pyWATTS path: /pywatts/modules/__init__.py
import warnings
from pywatts.modules.feature_extraction.calendar_extraction import CalendarExtraction, CalendarFeature
from pywatts.modules.feature_extraction.rolling_base import RollingGroupBy
from pywatts.modules.feature_extraction.rolling_kurt... | code_fim | hard | {
"lang": "python",
"repo": "KIT-IAI/pyWATTS",
"path": "/pywatts/modules/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>les.preprocessing.missing_value_detection import MissingValueDetector
from pywatts.modules.preprocessing.resampler import Resampler
from pywatts.modules.preprocessing.sampler import Sampler
from pywatts.modules.preprocessing.select import Select
from pywatts.modules.preprocessing.slicer import Slicer
from... | code_fim | hard | {
"lang": "python",
"repo": "KIT-IAI/pyWATTS",
"path": "/pywatts/modules/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># sec = config.has_section('wupeiqi')
# sec = config.add_section('wupeiqi')
# config.write(open('i.cfg', "w"))
# config.set('group2','k1',11111)
# config.write(open('i.cfg', "w"))
# config.remove_option('group2','age')
# config.write(open('i.cfg', "w"))<|fim_prefix|># repo: sven820/python path: /python... | code_fim | hard | {
"lang": "python",
"repo": "sven820/python",
"path": "/python_base/day_5/configparser_.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sven820/python path: /python_base/day_5/configparser_.py
__author__ = "JJ.sven"
import configparser
'''write'''
config = configparser.ConfigParser()
config["DEFAULT"] = {'ServerAliveInterval': '55',
'Compression': 'yes',
'CompressionLevel': '9'}
confi... | code_fim | hard | {
"lang": "python",
"repo": "sven820/python",
"path": "/python_base/day_5/configparser_.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># config.set('group2','k1',11111)
# config.write(open('i.cfg', "w"))
# config.remove_option('group2','age')
# config.write(open('i.cfg', "w"))<|fim_prefix|># repo: sven820/python path: /python_base/day_5/configparser_.py
__author__ = "JJ.sven"
import configparser
'''write'''
config = configparser.Conf... | code_fim | hard | {
"lang": "python",
"repo": "sven820/python",
"path": "/python_base/day_5/configparser_.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OpenTwinCities/ndia-django path: /ndiaDjango/communityAssets/migrations/0001_initial.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import djgeojson.fields
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
... | code_fim | hard | {
"lang": "python",
"repo": "OpenTwinCities/ndia-django",
"path": "/ndiaDjango/communityAssets/migrations/0001_initial.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carmenalab/brain-python-interface path: /db/tracker/tasktrack.py
'''
Web browser GUI-launched tasks run in a separate process. This module provides
mechanisms for interacting withe the task running in another process, e.g.,
calling functions to start/stop the task, enabling/disabling decoder adap... | code_fim | hard | {
"lang": "python",
"repo": "carmenalab/brain-python-interface",
"path": "/db/tracker/tasktrack.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # allow time for files, etc. to be saved
time.sleep(3)
if self.proc.saveid is not None:
from tracker import models
te = models.TaskEntry.objects.get(id=self.proc.saveid)
# Wrap up HDF file saving
models.DataFile.objects.get(entry__i... | code_fim | hard | {
"lang": "python",
"repo": "carmenalab/brain-python-interface",
"path": "/db/tracker/tasktrack.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if msg['status'] == "error" or msg['State'] == "stopped":
self.status.value = b""
def runtask(self, base_class=experiment.Experiment, feats=[], cli=False, **kwargs):
'''
Begin running of task
'''
log_str("Running new task: \n", mode="w")
if... | code_fim | hard | {
"lang": "python",
"repo": "carmenalab/brain-python-interface",
"path": "/db/tracker/tasktrack.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: g842995907/guops-know path: /test-xooj/system_configuration/web/api.py
# -*- coding: utf-8 -*-
from django.db.models import Q
from rest_framework import viewsets, filters, permissions, status
from rest_framework.decorators import list_route, detail_route
from rest_framework.permissions import... | code_fim | hard | {
"lang": "python",
"repo": "g842995907/guops-know",
"path": "/test-xooj/system_configuration/web/api.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> @list_route(methods=['delete'])
def batch_destroy(self, request):
ids = self.request.data.getlist('ids',[])
if not ids:
return Response(status=status.HTTP_204_NO_CONTENT)
user_id = self.request.user.id
usernotice_list = []
for id in ids:... | code_fim | hard | {
"lang": "python",
"repo": "g842995907/guops-know",
"path": "/test-xooj/system_configuration/web/api.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Calculate the ratio
# See balancer-core/contracts/BNum.sol::bdiv()
c0 = staked_after_fees * BONE
c1 = c0 + Decimal(pool_total_supply / 2)
c2 = Decimal(c1 / pool_total_supply)
ratio = c2
position: LPPosition = [
(
contr... | code_fim | hard | {
"lang": "python",
"repo": "pmerkleplant/geyser-cli",
"path": "/geyser/dexs/balancer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pmerkleplant/geyser-cli path: /geyser/dexs/balancer.py
from decimal import Decimal
from typing import List
from web3.eth import Contract
from .dex import Dex
from ..types import LPPosition
class Balancer(Dex):
"""
Dex class implementing the Balancer dex.
"""
def get_current_l... | code_fim | hard | {
"lang": "python",
"repo": "pmerkleplant/geyser-cli",
"path": "/geyser/dexs/balancer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>gs = parser.parse_args()
print(args.first_number * args.second_number)<|fim_prefix|># repo: MarcusDEFGH/script-repo path: /scripts/multiply.py
import argparse
parser = argparse.ArgumentParser(description='Multipl<|fim_middle|>y numbers')
parser.add_argument("first_number", help="int: First number")
parse... | code_fim | medium | {
"lang": "python",
"repo": "MarcusDEFGH/script-repo",
"path": "/scripts/multiply.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MarcusDEFGH/script-repo path: /scripts/multiply.py
import argparse
parser = argparse.ArgumentParser(description='Multipl<|fim_suffix|>r")
parser.add_argument("second_number", help="int: Second number")
args = parser.parse_args()
print(args.first_number * args.second_number)<|fim_middle|>y numbers... | code_fim | medium | {
"lang": "python",
"repo": "MarcusDEFGH/script-repo",
"path": "/scripts/multiply.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if CONF.fatal_exception_format_errors:
raise e
else:
# at least get the core message out if something happened
message = self.message
'''
super(CloudframeException, self).__init__(message)
... | code_fim | hard | {
"lang": "python",
"repo": "cloudken/faas-worker",
"path": "/cloudframe/common/exception.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># base class: resource can not found
class NotFound(CloudframeException):
message = "Resource could not be found."
code = http_client.NOT_FOUND
class Invalid(CloudframeException):
message = "Unacceptable parameters."
code = http_client.BAD_REQUEST
class HttpError(CloudframeException):
... | code_fim | hard | {
"lang": "python",
"repo": "cloudken/faas-worker",
"path": "/cloudframe/common/exception.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cloudken/faas-worker path: /cloudframe/common/exception.py
import six
from six.moves import http_client
def _cleanse_dict(original):
"""Strip all admin_password, new_pass, rescue_pass keys from a dict."""
return dict((k, v) for k, v in original.items() if "_pass" not in k)
class Clou... | code_fim | hard | {
"lang": "python",
"repo": "cloudken/faas-worker",
"path": "/cloudframe/common/exception.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
plt.figure(2)
plt.tight_layout()
for data in data_list:
#print(max(data[0]))
weights=[data[0][1][0]] + [1] * (len(data[0][0]) - 1)
n,bins, patches = plt.hist(data[0][0], weights=weights, bins=1000, density=True, cumulative=True, histtype... | code_fim | hard | {
"lang": "python",
"repo": "kacsa123/acs_project",
"path": "/plots/graph_utils/burst_graph.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kacsa123/acs_project path: /plots/graph_utils/burst_graph.py
import argparse
import csv
import json
import numpy as np
import sys
import matplotlib
matplotlib.use('Agg')
from decimal import *
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
def main():
... | code_fim | hard | {
"lang": "python",
"repo": "kacsa123/acs_project",
"path": "/plots/graph_utils/burst_graph.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: absalon-james/roletester path: /roletester/actions/keystone/role.py
"""Module containing actions to manage keystone roles."""
from roletester.log import logging
logger = logging.getLogger('roletester.actions.keystone.role')
def _get_role_uuid_by_name(keystone, name):
"""Gets a role UUID wh... | code_fim | hard | {
"lang": "python",
"repo": "absalon-james/roletester",
"path": "/roletester/actions/keystone/role.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def grant_user_project(clients, context, role="_member_"):
"""Grant a role to (user,project)
Uses context['user_obj']
Uses context['project_obj']
Sets context['role']
:param clients: Client Manager
:type clients: roletester.clients.ClientManager
:param context: Pass by refer... | code_fim | hard | {
"lang": "python",
"repo": "absalon-james/roletester",
"path": "/roletester/actions/keystone/role.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: baijianhua/pymath path: /人工智能/线性二分类函数.py
# from math import e
from math import e
from sympy import symbols, print_latex
from matplotlib import pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
plt.figure()
ax = plt.axes(projection="3d")
MAX = 10
MIN = -10
w1 = 1
w2 = 2
... | code_fim | medium | {
"lang": "python",
"repo": "baijianhua/pymath",
"path": "/人工智能/线性二分类函数.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ax.plot_surface(X, Y, Z, alpha=0.5, cmap="winter")
ax.plot_surface(X, Y, Z1, alpha=0.7, cmap="rainbow")
ax.scatter(0, 0, 0, c='r', marker='o')
# 生成表面,alpha用于控制透明度
# ax.contour(X,Y,Z,zdir="x",offset=-6,cmap="rainbow") #x轴投影
# ax.contour(X,Y,Z,zdir="y",offset=6,cmap="rainbow") #y轴投影
# ax.contour(X,Y,Z... | code_fim | hard | {
"lang": "python",
"repo": "baijianhua/pymath",
"path": "/人工智能/线性二分类函数.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("My IPAM test:")
results=swis.query("SELECT TOP 1 Status, DisplayName FROM IPAM.IPNode WHERE Status=2")
print (results)
### for a formatted printing
for row in results['results']:
print("Avaliable: {DisplayName}".format(**row))<|fim_prefix|># repo: PacktPublishing/Python-Network-Programming path:... | code_fim | medium | {
"lang": "python",
"repo": "PacktPublishing/Python-Network-Programming",
"path": "/Chapter03/checksolarwindsipam.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PacktPublishing/Python-Network-Programming path: /Chapter03/checksolarwindsipam.py
from orionsdk import SwisClient
npm_server = 'mysolarwindsserver'
username = "test"
password = "test"
verify = False
if not verify:
from requests.packages.urllib3.exceptions import InsecureRequestWarning
... | code_fim | medium | {
"lang": "python",
"repo": "PacktPublishing/Python-Network-Programming",
"path": "/Chapter03/checksolarwindsipam.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>swis = SwisClient(npm_server, username, password)
print("My IPAM test:")
results=swis.query("SELECT TOP 1 Status, DisplayName FROM IPAM.IPNode WHERE Status=2")
print (results)
### for a formatted printing
for row in results['results']:
print("Avaliable: {DisplayName}".format(**row))<|fim_prefix|># repo... | code_fim | medium | {
"lang": "python",
"repo": "PacktPublishing/Python-Network-Programming",
"path": "/Chapter03/checksolarwindsipam.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mom1/stubmaker path: /src/viewers/stub_viewer.py
__all__ = [
'StubViewer',
]
import inspect
import os
from io import StringIO
from stubmaker.viewers.basic_viewer import BasicViewer
from stubmaker.viewers.common import add_inherited_singledispatchmethod
from stubmaker.viewers.util import (
... | code_fim | hard | {
"lang": "python",
"repo": "mom1/stubmaker",
"path": "/src/viewers/stub_viewer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def view_module_definition(self, module_def: ModuleDef):
sio = StringIO()
with StubViewer.ModuleContext(module_def, self) as ctx:
# docstring
if module_def.docstring:
sio.write(f'{self.view(module_def.docstring)}\n')
# all
... | code_fim | hard | {
"lang": "python",
"repo": "mom1/stubmaker",
"path": "/src/viewers/stub_viewer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.