text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: astropy/astropy path: /astropy/coordinates/builtin_frames/icrs_observed_transforms.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Contains the transformation functions for getting to "observed" systems from ICRS.
"""
import erfa
from astropy import units as u
from astropy... | code_fim | hard | {
"lang": "python",
"repo": "astropy/astropy",
"path": "/astropy/coordinates/builtin_frames/icrs_observed_transforms.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: astsu-dev/pizza-store-backend path: /pizza_store/routers/category.py
from fastapi import APIRouter, Depends, Response, status
from pizza_store import models
from pizza_store.dependencies.services import get_category_service
from pizza_store.enums.permissions import CategoryPermission
from pizza_s... | code_fim | hard | {
"lang": "python",
"repo": "astsu-dev/pizza-store-backend",
"path": "/pizza_store/routers/category.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@router.delete(
"/{category_id}", status_code=status.HTTP_204_NO_CONTENT, response_class=Response
)
async def delete_category(
category_id: int,
service: ICategoryService = Depends(get_category_service),
_: models.UserInToken = Depends(
AuthService.get_current_user(required_permis... | code_fim | hard | {
"lang": "python",
"repo": "astsu-dev/pizza-store-backend",
"path": "/pizza_store/routers/category.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NNUG2019/sound-classification path: /checkdatatest.py
#Sprawdzam czy dane do testowania są w tej samej kolejności co labelsy
<|fim_suffix|>testdatalabels = dumperlabels
print(testdatalist[0:10])
print(testdatalabels[0:10])
print(np.unique(dumperlabels))
print(dumperlabels)<|fim_middle|>fro... | code_fim | medium | {
"lang": "python",
"repo": "NNUG2019/sound-classification",
"path": "/checkdatatest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>testdatalabels = dumperlabels
print(testdatalist[0:10])
print(testdatalabels[0:10])
print(np.unique(dumperlabels))
print(dumperlabels)<|fim_prefix|># repo: NNUG2019/sound-classification path: /checkdatatest.py
#Sprawdzam czy dane do testowania są w tej samej kolejności co labelsy
<|fim_middle|>fro... | code_fim | medium | {
"lang": "python",
"repo": "NNUG2019/sound-classification",
"path": "/checkdatatest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> keymaker = Keymaker({})
with self.assertRaises(AttributeError):
keymaker.a()
self.assertEqual(len(keymaker.__dict__), 0, "There should be no method in keymaker")
def test_normal(self):
keymaker = Keymaker({'a': 'AAA', 'b': 'XX'})
self.assertEqual... | code_fim | hard | {
"lang": "python",
"repo": "AtteqCom/zsl",
"path": "/tests/utils/redis_helper_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AtteqCom/zsl path: /tests/utils/redis_helper_test.py
from unittest.case import TestCase
from zsl import Config, inject
from zsl.application.containers.container import IoCContainer
from zsl.testing.db import IN_MEMORY_DB_SETTINGS
from zsl.testing.zsl import ZslTestCase, ZslTestConfiguration
from... | code_fim | medium | {
"lang": "python",
"repo": "AtteqCom/zsl",
"path": "/tests/utils/redis_helper_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def constraint_for(dist=None, param=None):
"""Get bijector constraint for a given distribution's parameter."""
constraints = {
'atol':
tfb.Softplus(),
'rtol':
tfb.Softplus(),
'concentration':
tfb.Softplus(),
'GeneralizedPareto.concentration': # ... | code_fim | hard | {
"lang": "python",
"repo": "yadevi/probability",
"path": "/tensorflow_probability/python/experimental/vi/parameter_constraints.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yadevi/probability path: /tensorflow_probability/python/experimental/vi/parameter_constraints.py
# Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may ob... | code_fim | hard | {
"lang": "python",
"repo": "yadevi/probability",
"path": "/tensorflow_probability/python/experimental/vi/parameter_constraints.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JayjeetAtGithub/spack path: /var/spack/repos/builtin/packages/r-spacetime/package.py
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.pac... | code_fim | hard | {
"lang": "python",
"repo": "JayjeetAtGithub/spack",
"path": "/var/spack/repos/builtin/packages/r-spacetime/package.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Classes and Methods for Spatio-Temporal Data.
Classes and methods for spatio-temporal data, including space-time regular
lattices, sparse lattices, irregular data, and trajectories; utility
functions for plotting data as map sequences (lattice or animation) or
multiple time series;... | code_fim | medium | {
"lang": "python",
"repo": "JayjeetAtGithub/spack",
"path": "/var/spack/repos/builtin/packages/r-spacetime/package.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aristanetworks/ctypegen path: /CTypeGen/expression.py
# Copyright 2021 Arista Networks.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/li... | code_fim | hard | {
"lang": "python",
"repo": "aristanetworks/ctypegen",
"path": "/CTypeGen/expression.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # We only want things that parse as a single expression.
if len(tree.body) != 1 or not isinstance( tree.body[0], ast.Expr ):
return None, None
# Many system headers include macros for brace-initializers. They look
# like sets to python, and when they nest, it causes a pro... | code_fim | hard | {
"lang": "python",
"repo": "aristanetworks/ctypegen",
"path": "/CTypeGen/expression.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # If the token is a single character string, then convert it to the literal
# character ordinal. C characters a numeric types, so treat as a python
# number.
elif tok.type == token.STRING and tok.string[0] == "'" and \
len( tok.string ) == ... | code_fim | hard | {
"lang": "python",
"repo": "aristanetworks/ctypegen",
"path": "/CTypeGen/expression.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fractal520/dbops path: /taskmon/initmon.py
import sqlalchemy as sa
from sqlalchemy.orm import sessionmaker
from collections import OrderedDict
from dbmodels import Dbinfo, Dbtype, Check_item, Alarm_threshold, Alarm_level
from alarm_message import alarm_message
from check_instruction import check_... | code_fim | hard | {
"lang": "python",
"repo": "fractal520/dbops",
"path": "/taskmon/initmon.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif check_item.check_name == 'fra usage':
if db_type.db_type_name == 'oracle':
check_insn_dict[(check_item.check_id, db_type.db_type_id)] = check_instruction[('fra usage', 'oracle')]
else:
pass
else:
pass
for lev in al... | code_fim | hard | {
"lang": "python",
"repo": "fractal520/dbops",
"path": "/taskmon/initmon.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Keesiu/meta-kaggle path: /data/external/repositories/131929/sentiment-analysis-master/Sentiment/src/ensemble/combine.py
import pandas as pd
doc2vec_result = pd.read_csv("result\\doc2vec.csv", header = 0)
bow_result = pd.read_csv("result\\BOW_chi_tfidf.csv", header = 0)
<|fim_suffix|>out = open(... | code_fim | easy | {
"lang": "python",
"repo": "Keesiu/meta-kaggle",
"path": "/data/external/repositories/131929/sentiment-analysis-master/Sentiment/src/ensemble/combine.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for i in xrange(num_reviews):
score = (doc2vec_result["sentiment"][i] + bow_result["sentiment"][i]) / 2.0
out.write(doc2vec_result["id"][i] + "," + str(score) + "\n")
out.close()<|fim_prefix|># repo: Keesiu/meta-kaggle path: /data/external/repositories/131929/sentiment-analysis-master/Sentiment/s... | code_fim | medium | {
"lang": "python",
"repo": "Keesiu/meta-kaggle",
"path": "/data/external/repositories/131929/sentiment-analysis-master/Sentiment/src/ensemble/combine.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif cmd == Events.Command.RemovePlayer \
or cmd == Events.Command.AddAccount \
or cmd == Events.Command.RemoveAccount:
for name in args:
self.on_event(cmd, name)
finally:
pass
... | code_fim | hard | {
"lang": "python",
"repo": "sentrip/brawlhalla-score-scraper",
"path": "/brawlhalla_score_scraper/command_queue.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sentrip/brawlhalla-score-scraper path: /brawlhalla_score_scraper/command_queue.py
import time
from abc import ABC, abstractmethod
from threading import Thread
from typing import Any
from .constants import Events
from .delegate import Emitter
from .models import Player
__all__ = [
'CommandQ... | code_fim | hard | {
"lang": "python",
"repo": "sentrip/brawlhalla-score-scraper",
"path": "/brawlhalla_score_scraper/command_queue.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: akrherz/pyIEM path: /src/pyiem/nws/products/cli.py
ormal, departure, last
COLS = [
[16, 23, 30, 37, 42, 49, 56, 65],
[16, 23, 30, None, None, 37, 44, 53],
[16, 22, 31, 37, 43, 50, 58, 65],
[16, 23, None, 30, 35, 42, 49, 58],
[16, 23, 25, 37, 42, None, None, None],
[16, 23,... | code_fim | hard | {
"lang": "python",
"repo": "akrherz/pyIEM",
"path": "/src/pyiem/nws/products/cli.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: akrherz/pyIEM path: /src/pyiem/nws/products/cli.py
RE LAST"
),
"WEATHER ITEM OBSERVED LAST",
(
"WEATHER ITEM OBSERVED TIME RECORD YEAR NORMAL "
"DEPARTURE LAST"
),
]
# label, value, time, record, year, normal, departure, last
COLS = [
[16, ... | code_fim | hard | {
"lang": "python",
"repo": "akrherz/pyIEM",
"path": "/src/pyiem/nws/products/cli.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Figure out when this product is valid for"""
tokens = HEADLINE_RE.findall(section.replace("\n", " "))
myfmt = "%b %d %Y" if len(tokens[0][2].split()[0]) == 3 else "%B %d %Y"
cli_valid = datetime.datetime.strptime(tokens[0][2], myfmt).date()
cli_station = (tokens[0][0]).strip().upper... | code_fim | hard | {
"lang": "python",
"repo": "akrherz/pyIEM",
"path": "/src/pyiem/nws/products/cli.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tzhuuu/discord.py path: /discord/sliding_window.py
from threading import Timer
class SlidingWindow:
def __init__(self, size: int, max_sequence: int, callback):
self.size = size
self.max_sequence = max_sequence
self.callback = callback
self.sequence_offset = ... | code_fim | hard | {
"lang": "python",
"repo": "tzhuuu/discord.py",
"path": "/discord/sliding_window.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.buffer[(self.start_index + offset_from_start_index) % self.size] = data
while self.buffer[self.start_index] is not None:
self.callback(self.buffer[self.start_index])
self.buffer[self.start_index] = None
self.start_index = (self.start_index + 1) % s... | code_fim | hard | {
"lang": "python",
"repo": "tzhuuu/discord.py",
"path": "/discord/sliding_window.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if sequence_number < self.sequence_offset:
sequence_number += self.max_sequence
offset_from_start_index = sequence_number - self.sequence_offset
if offset_from_start_index > self.size - 1:
# Collapse on all existing data members and restart
self... | code_fim | hard | {
"lang": "python",
"repo": "tzhuuu/discord.py",
"path": "/discord/sliding_window.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yoojunwoong/miniproject_self path: /teamanalysis/water_2018Re.py
import pandas as pd;
import numpy as np;
import json
from confing.settings import DATA_DIRS
df = pd.read_excel(DATA_DIRS[0] + '//health_2018.xlsx', engine='openpyxl');
df2 = pd.read_excel(DATA_DIRS[0] + '//water_2018.xlsx', e... | code_fim | hard | {
"lang": "python",
"repo": "yoojunwoong/miniproject_self",
"path": "/teamanalysis/water_2018Re.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#서울특별시, 부산광역시, 대구광역시, 인천광역시, 광주광역시, 대전광역시, 울산광역시
#경기도,강원도,충청북도, 충청남도, 전라북도, 전라남도, 경상북도, 경상남도, 제주특별자치도
if __name__ == '__main__':
function().co();
# function().rew('경상남도', '질산성질소(기준:10/ 단위:(mg/L))');
# function().rew('경상남도', '잔류염소(기준:4/ 단위:(mg/L))');
# ... | code_fim | hard | {
"lang": "python",
"repo": "yoojunwoong/miniproject_self",
"path": "/teamanalysis/water_2018Re.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#서울특별시, 부산광역시, 대구광역시, 인천광역시, 광주광역시, 대전광역시, 울산광역시
#경기도,강원도,충청북도, 충청남도, 전라북도, 전라남도, 경상북도, 경상남도, 제주특별자치도
if __name__ == '__main__':
function().co();
# function().rew('경상남도', '질산성질소(기준:10/ 단위:(mg/L))');
# function().rew('경상남도', '잔류염소(기준:4/ 단위:(mg/L))');
# function... | code_fim | hard | {
"lang": "python",
"repo": "yoojunwoong/miniproject_self",
"path": "/teamanalysis/water_2018Re.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kritikalcoder/PySyft path: /syft/workers/virtual.py
from time import sleep
from syft.workers.base import BaseWorker
from syft.federated.federated_client import FederatedClient
<|fim_suffix|> def _recv_msg(self, message: bin) -> bin:
"""receive message"""
return self.recv_msg... | code_fim | hard | {
"lang": "python",
"repo": "Kritikalcoder/PySyft",
"path": "/syft/workers/virtual.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _recv_msg(self, message: bin) -> bin:
"""receive message"""
return self.recv_msg(message)<|fim_prefix|># repo: Kritikalcoder/PySyft path: /syft/workers/virtual.py
from time import sleep
from syft.workers.base import BaseWorker
from syft.federated.federated_client import Federated... | code_fim | medium | {
"lang": "python",
"repo": "Kritikalcoder/PySyft",
"path": "/syft/workers/virtual.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rafacarrascosa/samr path: /samr/predictor.py
"""
SAMR main module, PhraseSentimentPredictor is the class that does the
prediction and therefore one of the main entry points to the library.
"""
from collections import defaultdict
from sklearn.linear_model import SGDClassifier
from sklearn.neighbo... | code_fim | hard | {
"lang": "python",
"repo": "rafacarrascosa/samr",
"path": "/samr/predictor.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def build_synset_extraction(binary, min_df, ngram):
return make_pipeline(MapToSynsets(),
CountVectorizer(binary=binary,
tokenizer=lambda x: x.split(),
min_df=min_df,
... | code_fim | hard | {
"lang": "python",
"repo": "rafacarrascosa/samr",
"path": "/samr/predictor.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zeeexsixare/CarND-Behavioral-Cloning-P3 path: /model.py
"""
CarND-Behavioral-Cloning-P3 Project
Philip Lee 6/27/18
Udacity CarND: ami-c4c4e3a4
AWS CHECKLIST
1. CREATE AWS INSTANCE
2. LOG INTO INSTANCE (carnd, carnd)
3. PIP INSTALL OPENCV-PYTHON
4. PIP INSTALL TENSORFLOW
5. PIP INSTAL... | code_fim | hard | {
"lang": "python",
"repo": "zeeexsixare/CarND-Behavioral-Cloning-P3",
"path": "/model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#NVIDIA MODEL
model = Sequential()
model.add(Lambda(lambda x: x / 255.0 - 0.5, input_shape = (160,320,3)))
model.add(Cropping2D(cropping=((70,25),(0,0))))
model.add(Convolution2D(24,5,5, subsample=(2,2), activation="relu"))
model.add(BatchNormalization())
model.add(Convolution2D(36,5,5, subsample=(2... | code_fim | hard | {
"lang": "python",
"repo": "zeeexsixare/CarND-Behavioral-Cloning-P3",
"path": "/model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lenamax2355/many path: /many/stats/utils.py
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
def precheck_align(a_mat, b_mat, a_cast, b_cast):
"""
Perform basic checks and alignment on a_mat and b_mat.
<|fim_suffix|> # align samples
a_... | code_fim | hard | {
"lang": "python",
"repo": "lenamax2355/many",
"path": "/many/stats/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # check sample sizes
num_samples = a_mat.shape[0] # number of samples for each variable
if num_samples < 2:
raise ValueError("x and y must have length at least 2.")
return a_mat, b_mat<|fim_prefix|># repo: lenamax2355/many path: /many/stats/utils.py
import matplotlib.pyplot as p... | code_fim | hard | {
"lang": "python",
"repo": "lenamax2355/many",
"path": "/many/stats/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HPCC-Cloud-Computing/press path: /prediction/lstm/lstm.py
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import mean_squared_error
from keras.models import Sequential
from keras.layers import Dense, ... | code_fim | hard | {
"lang": "python",
"repo": "HPCC-Cloud-Computing/press",
"path": "/prediction/lstm/lstm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # learn
history = model.fit(x_train, y_train, epochs=100, validation_split=0.125)
# plot history
plt.figure('History', figsize=(16, 9))
plt.plot(history.history['loss'], label='train')
plt.plot(history.history['val_loss'], label='test')
plt.legend()
plt.show()
... | code_fim | hard | {
"lang": "python",
"repo": "HPCC-Cloud-Computing/press",
"path": "/prediction/lstm/lstm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MLunov/Python-programming-basics-HSE path: /Week 6: Sorting/6 (06).py
s, b = [], []
n, sel = int(input()), list(map(int, input().split()))
m, bom = int(input()), list(map(int, input().split()))
for i in range(1, n<|fim_suffix|>:
if c + 1 < m and abs(s[i][0] - b[c][0]) < abs(s[i][0] - b[c ... | code_fim | medium | {
"lang": "python",
"repo": "MLunov/Python-programming-basics-HSE",
"path": "/Week 6: Sorting/6 (06).py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>:
if c + 1 < m and abs(s[i][0] - b[c][0]) < abs(s[i][0] - b[c + 1][0]):
sel[s[i][1] - 1] = b[c][1]
else:
while c + 1 < m and \
abs(s[i][0] - b[c][0]) > abs(s[i][0] - b[c + 1][0]):
c += 1
sel[s[i][1] - 1] = b[c][1]
print(*sel)<|fim_prefix|... | code_fim | medium | {
"lang": "python",
"repo": "MLunov/Python-programming-basics-HSE",
"path": "/Week 6: Sorting/6 (06).py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> switch_init(self.client)
port_id = 0x800000001
role = SAI_TWAMP_SESSION_SENDER
udp_dst_port = 4789
udp_src_port = 45193
dst_ip = '10.1.2.3'
src_ip = '20.4.5.6'
tc = 5
vpn = 12
encap_type = SAI_TWAMP_ENCAPSULATION_TYPE_IP
... | code_fim | hard | {
"lang": "python",
"repo": "ly7799/sai-advance",
"path": "/test/neo_saithrift/testcase/ctc_sai_twamp.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ly7799/sai-advance path: /test/neo_saithrift/testcase/ctc_sai_twamp.py
# Copyright 2013-present Centec Networks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
... | code_fim | hard | {
"lang": "python",
"repo": "ly7799/sai-advance",
"path": "/test/neo_saithrift/testcase/ctc_sai_twamp.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chancejiang/tiddlyweb path: /test/test_make_cookie.py
"""
Cover tiddlyweb.web.util.make_cookie.
It creates the string used to put in a Set-Cookie
header.
"""
from tiddlyweb.util import sha
from tiddlyweb.web.util import make_cookie
def test_cookie_name_value():
string = make_cookie('test1... | code_fim | medium | {
"lang": "python",
"repo": "chancejiang/tiddlyweb",
"path": "/test/test_make_cookie.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> string = make_cookie('test5', 'alpha5', domain=".tiddlyspace.com")
assert string == 'test5=alpha5; Domain=.tiddlyspace.com; httponly'<|fim_prefix|># repo: chancejiang/tiddlyweb path: /test/test_make_cookie.py
"""
Cover tiddlyweb.web.util.make_cookie.
It creates the string used to put in a Set-Cooki... | code_fim | medium | {
"lang": "python",
"repo": "chancejiang/tiddlyweb",
"path": "/test/test_make_cookie.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.title
class Meta:
verbose_name_plural = "HeaderNavs"
class Blogs(models.Model):
title = models.CharField(max_length = 50)
short_description = models.TextField(max_length = 100)
description = models.TextField()
created_at ... | code_fim | medium | {
"lang": "python",
"repo": "designermanjeets/mscreativepixel",
"path": "/msblog/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: designermanjeets/mscreativepixel path: /msblog/models.py
from django.db import models
from datetime import datetime
import string, random
import uuid
# Create your models here.
<|fim_suffix|> title = models.CharField(max_length = 50)
url = models.CharField(max_length = 50)
def ... | code_fim | medium | {
"lang": "python",
"repo": "designermanjeets/mscreativepixel",
"path": "/msblog/models.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> verbose_name_plural = "HeaderNavs"
class Blogs(models.Model):
title = models.CharField(max_length = 50)
short_description = models.TextField(max_length = 100)
description = models.TextField()
created_at = models.DateTimeField(default=datetime.now... | code_fim | medium | {
"lang": "python",
"repo": "designermanjeets/mscreativepixel",
"path": "/msblog/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LSSTDESC/CCL path: /benchmarks/data/codes/param_space.py
mly choose index and then remove the number that was chosen
# (Latin hypercubes require at most one item per row and column)
for j, p in enumerate(pnames):
pmin, pmax = param_dict[p]
idx = random.choi... | code_fim | hard | {
"lang": "python",
"repo": "LSSTDESC/CCL",
"path": "/benchmarks/data/codes/param_space.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Open file for writing
f = open("%s_%05d.ini" % (root, i), 'w')
# Write output location into file (will be same as .ini file location)
f.write('root = %s_%05d\n' % (root, i))
# Write user-defined cosmo parameters into file
for p in pnames:
# H... | code_fim | hard | {
"lang": "python",
"repo": "LSSTDESC/CCL",
"path": "/benchmarks/data/codes/param_space.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LSSTDESC/CCL path: /benchmarks/data/codes/param_space.py
nts (values).
"""
# Get parameter names and build header
pnames = sample_points.keys()
pnames.sort()
hdr = " ".join(pnames)
# Build array
dat = np.column_stack([sample_points[p] for p in pnames])
np.savetxt(... | code_fim | hard | {
"lang": "python",
"repo": "LSSTDESC/CCL",
"path": "/benchmarks/data/codes/param_space.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dmarkey/aiohttp-aiopylimit path: /sample_app/simple.py
from aiohttp import web
from aiohttp_aiopylimit.decorators import aiopylimit
from aiohttp_aiopylimit.limit import AIOHTTPAIOPyLimit
# Initialise the AIOHTTP app
app = web.Application()
routes = web.RouteTableDef()
<|fim_suffix|>app.add_r... | code_fim | hard | {
"lang": "python",
"repo": "dmarkey/aiohttp-aiopylimit",
"path": "/sample_app/simple.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# A custom view to return. This has to be asynchronous
async def custom_view(request):
return web.json_response("bad", status=400)
# Sample simple view
@routes.get("/write")
@aiopylimit("write_api", (60, 1), key_func=custom_key,
limit_reached_view=custom_view) # 1 per 60 seconds
async ... | code_fim | hard | {
"lang": "python",
"repo": "dmarkey/aiohttp-aiopylimit",
"path": "/sample_app/simple.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: flavoi/diventi path: /diventi/landing/migrations/0057_auto_20190415_0838.py
# Generated by Django 2.1.7 on 2019-04-15 06:38
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
migrations.AddFi... | code_fim | medium | {
"lang": "python",
"repo": "flavoi/diventi",
"path": "/diventi/landing/migrations/0057_auto_20190415_0838.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AddField(
model_name='feature',
name='products',
field=models.ManyToManyField(null=True, related_name='product_features', to='products.Product'),
),
migrations.AddField(
model_name='feature',
... | code_fim | hard | {
"lang": "python",
"repo": "flavoi/diventi",
"path": "/diventi/landing/migrations/0057_auto_20190415_0838.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SpikeInterface/spikeinterface path: /src/spikeinterface/widgets/unit_depths.py
import numpy as np
from warnings import warn
from .base import BaseWidget, to_attr
from .utils import get_unit_colors
from ..core.template_tools import get_template_extremum_amplitude
class UnitDepthsWidget(BaseWi... | code_fim | hard | {
"lang": "python",
"repo": "SpikeInterface/spikeinterface",
"path": "/src/spikeinterface/widgets/unit_depths.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.figure, self.axes, self.ax = make_mpl_figure(**backend_kwargs)
ax = self.ax
size = dp.num_spikes / max(dp.num_spikes) * 120
ax.scatter(dp.unit_amplitudes, dp.unit_depths, color=dp.colors, s=size)
ax.set_aspect(3)
ax.set_xlabel("amplitude")
ax.... | code_fim | hard | {
"lang": "python",
"repo": "SpikeInterface/spikeinterface",
"path": "/src/spikeinterface/widgets/unit_depths.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fakedrake/WikipediaBase path: /wikipediabase/dbfetcher.py
# XXX: A good starting point but does not work. For mdb is good enough.
import sys
import threading
import datetime
from itertools import chain
import mysql.connector as mdb
from wikipediabase.util import time_interval
class DBUtil(o... | code_fim | hard | {
"lang": "python",
"repo": "fakedrake/WikipediaBase",
"path": "/wikipediabase/dbfetcher.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Get an iterator over of tuples (page_id, page_text)
"""
where = ("where page_namespace=%d" % ns if ns is not None else "")
lmt = ("limit %d" % limit if limit is not None else "")
self.cmd = "select page_title, old_text from text " \
"... | code_fim | hard | {
"lang": "python",
"repo": "fakedrake/WikipediaBase",
"path": "/wikipediabase/dbfetcher.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mcuntz/jams_python path: /jams/pritay.py
#!/usr/bin/env python
from __future__ import division, absolute_import, print_function
import numpy as np
def pritay(T, Rg, elev, a=1.12):
'''
Daily reference evapotranspiration after Priestley & Taylor
Definition
---... | code_fim | hard | {
"lang": "python",
"repo": "mcuntz/jams_python",
"path": "/jams/pritay.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Literature
-----
Priestley, C.H.B., Taylor, R.J., 1972. On the assessment of surface
heat flux and evaporation using large-scale parameters. Monthly
Weather Review 100, 81-92.
License
-------
This file is part of the JAMS Python package, di... | code_fim | hard | {
"lang": "python",
"repo": "mcuntz/jams_python",
"path": "/jams/pritay.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: polasekp/django-pyston path: /pyston/utils/decorators.py
def allow_tags(func):
"""Allows HTML tags to be returned from resource without escaping"""
if isinstance(func, property):
func = func.fget
func.allow_tags = True
return func
def humanized(humanized_func, **humanize... | code_fim | medium | {
"lang": "python",
"repo": "polasekp/django-pyston",
"path": "/pyston/utils/decorators.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def _humanized_func(*args, **kwargs):
return humanized_func(*args, **kwargs, **humanized_func_kwargs)
func.humanized = _humanized_func
return func
return decorator<|fim_prefix|># repo: polasekp/django-pyston path: /pyston/utils/decorators.py
def allow_tags(func):
... | code_fim | hard | {
"lang": "python",
"repo": "polasekp/django-pyston",
"path": "/pyston/utils/decorators.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> logging.info("Processing data...")
ret = []
train_data = []
with self._lock:
train_data = copy.deepcopy(self.train_data)
counts = {}
for time,station_id, direction, route in train_data:
if station_id == HOYT_SHLKJHKLJH and route ==... | code_fim | hard | {
"lang": "python",
"repo": "jakob223/subway-sign",
"path": "/index.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jakob223/subway-sign path: /index.py
#!/usr/bin/env python3
import time
from datetime import datetime, timedelta
import threading
import logging
import copy
def setup_logging():
ifmt = "%(asctime)s: %(message)s"
logging.basicConfig(format=ifmt, level=logging.DEBUG,
datefmt=... | code_fim | hard | {
"lang": "python",
"repo": "jakob223/subway-sign",
"path": "/index.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def refresh_data(self):
logging.info("Refreshing data...")
self.in_progress_data = []
threads = []
for feed in get_feedids(ALL_STATIONS):
thread = threading.Thread(target=self.update_feed, args=(feed,))
threads.append(thread)
thread.s... | code_fim | hard | {
"lang": "python",
"repo": "jakob223/subway-sign",
"path": "/index.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amogh00/google-dinosaur-game-using-screengrab path: /dinp.py
## importing all neccessary libraries
import numpy as np
from PIL import ImageGrab
from pyautogui import press
import cv2
import time
while(True):
printscreen_pil = ImageGrab.grab(bbox=(700,180,1000,326)) ##cont... | code_fim | hard | {
"lang": "python",
"repo": "amogh00/google-dinosaur-game-using-screengrab",
"path": "/dinp.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ge into negative (comment out if not nedded)
i = np.array(printscreen_numpy)
## cv2.imshow('window',printscreen_numpy )
## print(i[105 , 269]) print(i[115 , 269]) print(i[117 , 275])
if i[105 , 269][0] >= 80 or i[135 , 269][0] >= 80 or i[125 , 269][0] >= 80 or i[145 , 269][0] >= 80... | code_fim | hard | {
"lang": "python",
"repo": "amogh00/google-dinosaur-game-using-screengrab",
"path": "/dinp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mne-tools/mne-python path: /tutorials/preprocessing/45_projectors_background.py
# shadow cast by that point if the sun were directly above it:
ax = setup_3d_axes()
# plot the vector (3, 2, 5)
origin = np.zeros((3, 1))
point = np.array([[3, 2, 5]]).T
vector = np.hstack([origin, point])
ax.plot(*... | code_fim | hard | {
"lang": "python",
"repo": "mne-tools/mne-python",
"path": "/tutorials/preprocessing/45_projectors_background.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># %%
# ``raw.info['projs']`` is an ordinary Python :class:`list` of
# :class:`~mne.Projection` objects, so you can access individual projectors by
# indexing into it. The :class:`~mne.Projection` object itself is similar to a
# Python :class:`dict`, so you can use its ``.keys()`` method to see what
# fiel... | code_fim | hard | {
"lang": "python",
"repo": "mne-tools/mne-python",
"path": "/tutorials/preprocessing/45_projectors_background.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mne-tools/mne-python path: /tutorials/preprocessing/45_projectors_background.py
es of
# freedom") of the measurement — here, from 3 dimensions down to 2. On the
# other hand, if you know that measurement component in the :math:`z` direction
# is just noise due to your measurement method, and all ... | code_fim | hard | {
"lang": "python",
"repo": "mne-tools/mne-python",
"path": "/tutorials/preprocessing/45_projectors_background.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anjali-92/tuesday path: /app/libs/comment.py
import hug
from peewee import fn
from apphelpers.rest.hug import user_id
from app.models import Comment, Member, Asset
from app.models import rejection_reasons, groups, comment_actions
from app.libs import archived_comment as archivedcommentlib
from ... | code_fim | hard | {
"lang": "python",
"repo": "anjali-92/tuesday",
"path": "/app/libs/comment.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> comments = Comment.select().where(*where).order_by(Comment.id.asc())
if limit:
comments = comments.limit(limit)
return [comment.to_dict() for comment in comments]
def get_featured_comments_for_assets(asset_ids, no_of_comments=1):
# Calculate the ranked comments per asset as a se... | code_fim | hard | {
"lang": "python",
"repo": "anjali-92/tuesday",
"path": "/app/libs/comment.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JohanComparat/pySU path: /spm/bin_SMF/measure_SNMEDIAN_DEEP2.py
#! /usr/bin/env python
import sys
from os.path import join
import os
import time
import numpy as np
import glob
# for one galaxy spectrum
import GalaxySpectrumFIREFLY as gs
import astropy.io.fits as fits
<|fim_suffix|> print catal... | code_fim | hard | {
"lang": "python",
"repo": "JohanComparat/pySU",
"path": "/spm/bin_SMF/measure_SNMEDIAN_DEEP2.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>prihdr = fits.Header()
prihdr['author'] = "JC"
prihdu = fits.PrimaryHDU(header=prihdr)
hdu = fits.HDUList([prihdu, tbhdu])
if os.path.isfile(out_file):
os.remove(out_file)
hdu.writeto(out_file)<|fim_prefix|># repo: JohanComparat/pySU path: /spm/bin_SMF/measure_SNMEDIAN_DEEP2.py
#! /usr/bin/env p... | code_fim | hard | {
"lang": "python",
"repo": "JohanComparat/pySU",
"path": "/spm/bin_SMF/measure_SNMEDIAN_DEEP2.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ai0/filecup path: /controllers/.svn/text-base/kvclean.py.svn-base
#!/usr/bin/env python
# coding: utf-8
import web
from config import settings
import sae.kvdb
class cleanKV:
<|fim_suffix|> kv = sae.kvdb.KVClient()
keys=kv.getkeys_by_prefix("",300,None)
... | code_fim | easy | {
"lang": "python",
"repo": "ai0/filecup",
"path": "/controllers/.svn/text-base/kvclean.py.svn-base",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> kv = sae.kvdb.KVClient()
keys=kv.getkeys_by_prefix("",300,None)
for key in keys:
kv.delete(key)
return "Success"<|fim_prefix|># repo: ai0/filecup path: /controllers/.svn/text-base/kvclean.py.svn-base
#!/usr/bin/en... | code_fim | easy | {
"lang": "python",
"repo": "ai0/filecup",
"path": "/controllers/.svn/text-base/kvclean.py.svn-base",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, request_id):
self._request_id = request_id
@response_property('requestId')
def request_id(self):
return self._request_id
class ProgressiveDirective(JsonResponseData):
'''
Directive to use for a progressive response
'''
LIMITS = 600
def... | code_fim | hard | {
"lang": "python",
"repo": "scottenglert/AskAlexa",
"path": "/askalexa/response/progressive.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: scottenglert/AskAlexa path: /askalexa/response/progressive.py
'''
Alexa Progressive Response Module
=================================
Provides the functionality to send Alexa a progressive response while
the real response is being processed. This is useful for giving an update
for request that t... | code_fim | hard | {
"lang": "python",
"repo": "scottenglert/AskAlexa",
"path": "/askalexa/response/progressive.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: econ-ark/HARK path: /HARK/estimation.py
The values that minimize objective_func.
"""
# Execute the minimization, starting from the given parameter guess
t0 = time() # Time the process
OUTPUT = fmin_powell(
objective_func, parameter_guess, full_output=1, maxiter=... | code_fim | hard | {
"lang": "python",
"repo": "econ-ark/HARK",
"path": "/HARK/estimation.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: econ-ark/HARK path: /HARK/estimation.py
estimated. When
not provided, estimation is performed on all parameters.
verbose : boolean
A flag for the amount of output to print.
Returns
-------
xopt : [float]
The values that minimize objective_func.
"""
... | code_fim | hard | {
"lang": "python",
"repo": "econ-ark/HARK",
"path": "/HARK/estimation.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Begin a new Nelder-Mead search
if not resume:
temp_simplex = list(simplex) # Evaluate the initial simplex
fvals = np.array(parallel(delayed(obj_func)(params) for params in temp_simplex))
evals += N
# Reorder the initial simplex
order = np.argsort(fvals)
... | code_fim | hard | {
"lang": "python",
"repo": "econ-ark/HARK",
"path": "/HARK/estimation.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>tions.RemoveField(
model_name='weeklytimetableentry',
name='classroom',
),
migrations.RemoveField(
model_name='weeklytimetableentry',
name='day',
),
migrations.RemoveField(
model_name='weeklytimetableentry',
... | code_fim | hard | {
"lang": "python",
"repo": "crodriguezanton/photoboard-django",
"path": "/education/migrations/0003_auto_20161219_1306.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: crodriguezanton/photoboard-django path: /education/migrations/0003_auto_20161219_1306.py
# -*- coding: utf-8 -*-
# Generated by Django 1.10.2 on 2016-12-19 13:06
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(mi... | code_fim | hard | {
"lang": "python",
"repo": "crodriguezanton/photoboard-django",
"path": "/education/migrations/0003_auto_20161219_1306.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>th=10, null=True),
),
migrations.AddField(
model_name='subject',
name='semester',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='education.Semester'),
),
migrations.DeleteModel(
... | code_fim | hard | {
"lang": "python",
"repo": "crodriguezanton/photoboard-django",
"path": "/education/migrations/0003_auto_20161219_1306.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#3. DELETING DIFFERENT DICTIONARY ELEMENTS
# Delete method : removes the key but raises an keyerror if key doesn't exists
dict1 = { 'a' : 1,
'b' : 2,
'c' : 3,
'd' : 4}
del dict1['a']
print(dict1)
# Pop method : delete a key and doesn't raise a keyerror if assigned a value ... | code_fim | medium | {
"lang": "python",
"repo": "arushi09207/codingloops-fibonacci-series",
"path": "/programming-task-3.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: arushi09207/codingloops-fibonacci-series path: /programming-task-3.py
# operations on data structures
#1. ASSIGNING ELEMENTS FROM A LIST IN PYTHON
#Append method : adds element to the end of the list
lst = [] #empty list
lst.append(4)
print(lst)
lst1 = ['a','b',2,3] #existing list
lst1.append... | code_fim | hard | {
"lang": "python",
"repo": "arushi09207/codingloops-fibonacci-series",
"path": "/programming-task-3.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Indexing method : using the index of the element we can access elements of a tuple
tup = ('a',1,'2')
print(tup[0])
#Slicing method : we slice out various elements in the specific order from the tuple
print(tup[:1])
print(tup[:])
#3. DELETING DIFFERENT DICTIONARY ELEMENTS
# Delete method : removes th... | code_fim | hard | {
"lang": "python",
"repo": "arushi09207/codingloops-fibonacci-series",
"path": "/programming-task-3.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qzaidi/amon path: /amonlite/web/utils.py
try:
import json
except ImportError:
import simplejson as json
def json_string_to_dict(string):
try:
_convert = string.replace("'", '"')
<|fim_suffix|> for _dict in list:
converted_list.append(json_string_to_dict(... | code_fim | medium | {
"lang": "python",
"repo": "qzaidi/amon",
"path": "/amonlite/web/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def json_list_to_dict(list):
converted_list = []
for _dict in list:
converted_list.append(json_string_to_dict(_dict))
return converted_list<|fim_prefix|># repo: qzaidi/amon path: /amonlite/web/utils.py
try:
import json
except ImportError:
import simplejson as json
... | code_fim | medium | {
"lang": "python",
"repo": "qzaidi/amon",
"path": "/amonlite/web/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: medialab/bibliotools3.0 path: /scripts/corpus_parsed_overview.py
import os
import itertools
from config import CONFIG
def print_and_report(message):
print message
with open(os.path.join(CONFIG["reports_directory"],"corpus_overview.txt"),"a") as f:
f.write(message+"\n")
def print_statistics_... | code_fim | hard | {
"lang": "python",
"repo": "medialab/bibliotools3.0",
"path": "/scripts/corpus_parsed_overview.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>for span in CONFIG["spans"]:
print_and_report("\n\n#%s"%span)
with open(os.path.join(CONFIG["parsed_data"],span,"articles.dat"),"r") as file:
# dat file have one trailing blank line at end of file
data_lines=file.read().split("\n")[:-1]
print_and_report("- number of articles : %s"%len(data_lines))... | code_fim | medium | {
"lang": "python",
"repo": "medialab/bibliotools3.0",
"path": "/scripts/corpus_parsed_overview.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # cumulative distribution of entities distribution
with open(os.path.join(CONFIG["reports_directory"],"%s_%s_distribution.csv"%(span,entity_name)),"w") as f:
f.write("occ,nb_%s,cumulative %%\n"%(entity_name))
occs=[len(list(g)) for (k,g) in itertools.groupby(sorted(entities_by_articles,reverse=T... | code_fim | hard | {
"lang": "python",
"repo": "medialab/bibliotools3.0",
"path": "/scripts/corpus_parsed_overview.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># https://bugzilla.samba.org/show_bug.cgi?id=8410
SRC_URI += "file://bug-8410-workaround.patch;striplevel=2"
DEFAULT_PREFERENCE = "-1"<|fim_prefix|># repo: jacobbarsoe/rpi-base path: /recipes/samba/samba_3.6.9.oe
# -*- mode:python; -*-
require samba.inc
require samba-basic.inc
LICENSE = "GPL-3.0+"
S = "... | code_fim | medium | {
"lang": "python",
"repo": "jacobbarsoe/rpi-base",
"path": "/recipes/samba/samba_3.6.9.oe",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># FIXME: need to figure out if we should add support for patchdir
#SRC_URI += "file://tdbheaderfix.patch;patchdir=${SRCDIR}/samba-${PV}"
# https://bugzilla.samba.org/show_bug.cgi?id=8410
SRC_URI += "file://bug-8410-workaround.patch;striplevel=2"
DEFAULT_PREFERENCE = "-1"<|fim_prefix|># repo: jacobbarsoe... | code_fim | easy | {
"lang": "python",
"repo": "jacobbarsoe/rpi-base",
"path": "/recipes/samba/samba_3.6.9.oe",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jacobbarsoe/rpi-base path: /recipes/samba/samba_3.6.9.oe
# -*- mode:python; -*-
require samba.inc
require samba-basic.inc
LICENSE = "GPL-3.0+"
S = "${SRCDIR}/samba-${PV}/source3"
<|fim_suffix|># FIXME: need to figure out if we should add support for patchdir
#SRC_URI += "file://tdbheaderfix.patc... | code_fim | easy | {
"lang": "python",
"repo": "jacobbarsoe/rpi-base",
"path": "/recipes/samba/samba_3.6.9.oe",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Animate
for k, (xx, yy_xx) in progbar(list(enumerate(ts)), "Animating"):
if k % 2 == 0:
fig.suptitle("k: "+str(k))
setter1(xx)
setter2(yy_xx)
plt.pause(0.01)<|fim_prefix|># repo: nansencenter/DAPPER path: /dapper/mods/QG/illust_obs.py
"""S... | code_fim | medium | {
"lang": "python",
"repo": "nansencenter/DAPPER",
"path": "/dapper/mods/QG/illust_obs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Create double iterable for the animation
ts = zip(xx, yy_xx)
# Animate
for k, (xx, yy_xx) in progbar(list(enumerate(ts)), "Animating"):
if k % 2 == 0:
fig.suptitle("k: "+str(k))
setter1(xx)
setter2(yy_xx)
plt.pause(0.01)<|fim_prefi... | code_fim | hard | {
"lang": "python",
"repo": "nansencenter/DAPPER",
"path": "/dapper/mods/QG/illust_obs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nansencenter/DAPPER path: /dapper/mods/QG/illust_obs.py
"""Stream function and observation time series for QG (quasi-geostrophic) model."""
if __name__ == "__main__": # dont run if pdoc (sample may not be avail/generate-able)
import numpy as np
from matplotlib import pyplot as plt
... | code_fim | medium | {
"lang": "python",
"repo": "nansencenter/DAPPER",
"path": "/dapper/mods/QG/illust_obs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: djangocon/2019.djangocon.eu path: /dceu2019/src/dceu2019/apps/ticketholders/decorators.py
from dceu2019.apps.invoices.models import TicketbutlerTicket
from django.contrib.auth.decorators import user_passes_test
<|fim_suffix|>def login_required(function=None, redirect_field_name=REDIRECT_FIELD_NA... | code_fim | medium | {
"lang": "python",
"repo": "djangocon/2019.djangocon.eu",
"path": "/dceu2019/src/dceu2019/apps/ticketholders/decorators.py",
"mode": "psm",
"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.