text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> self.assertEqual(process_line_2("LURDL", 'D'), 'B')
def test_process_line_2__4(self):
self.assertEqual(process_line_2("UUUUD", 'B'), 3)
def test_aoc_2_test(self):
self.assertEqual(aoc_2(input_test), "5DB3")
def test_aoc_2(self):
self.assertEqual(aoc_2(input), "... | code_fim | hard | {
"lang": "python",
"repo": "globocom/dojo",
"path": "/2022_04_13/dojo_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def GetWriter(config):
'''Factory method for creating ADMLWriter objects for the Chrome OS platform.
See the constructor of TemplateWriter for description of arguments.
'''
return adml_writer.ADMLWriter(['chrome_os'], config)<|fim_prefix|># repo: RyoKodama/chromium path: /components/policy/tools/... | code_fim | easy | {
"lang": "python",
"repo": "RyoKodama/chromium",
"path": "/components/policy/tools/template_writers/writers/chromeos_adml_writer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RyoKodama/chromium path: /components/policy/tools/template_writers/writers/chromeos_adml_writer.py
#!/usr/bin/env python
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
<|fim_suffix... | code_fim | easy | {
"lang": "python",
"repo": "RyoKodama/chromium",
"path": "/components/policy/tools/template_writers/writers/chromeos_adml_writer.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>from writers import adml_writer
def GetWriter(config):
'''Factory method for creating ADMLWriter objects for the Chrome OS platform.
See the constructor of TemplateWriter for description of arguments.
'''
return adml_writer.ADMLWriter(['chrome_os'], config)<|fim_prefix|># repo: RyoKodama/chromiu... | code_fim | easy | {
"lang": "python",
"repo": "RyoKodama/chromium",
"path": "/components/policy/tools/template_writers/writers/chromeos_adml_writer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ETspielberg/alma-scripts path: /service/google_service.py
import json
import os
import time
import requests
google_maps_api_base_url = 'https://maps.googleapis.com/maps/api'
def get_google_data(address_lines):
api_key = os.environ['GOOGLE_MAPS_API_KEY']
query = ''
for i in range(1... | code_fim | medium | {
"lang": "python",
"repo": "ETspielberg/alma-scripts",
"path": "/service/google_service.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Prüfen, ob die Abfrage erfolgreich war (Status-Code ist dann 200)
if response.status_code == 200:
time.sleep(1)
try:
candidate_id = response.json()['candidates'][0]['place_id']
url = '{}/place/details/json?place_id={}&fields=address_components&key={}'.form... | code_fim | hard | {
"lang": "python",
"repo": "ETspielberg/alma-scripts",
"path": "/service/google_service.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Die Kodierung der Antwort auf UTF-8 festlegen
response.encoding = 'utf-8'
# Prüfen, ob die Abfrage erfolgreich war (Status-Code ist dann 200)
if response.status_code == 200:
time.sleep(1)
try:
candidate_id = response.json()['candidates'][0]['place_id']
... | code_fim | hard | {
"lang": "python",
"repo": "ETspielberg/alma-scripts",
"path": "/service/google_service.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yyhTHU/Zhihu_Spider path: /zhihu/zhihu/items.py
# Define here the models for your scraped items
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/items.html
from scrapy.item import Item, Field
from scrapy.contrib.loader.processor import MapCompose, Join, TakeFirst, Compose
from ... | code_fim | hard | {
"lang": "python",
"repo": "yyhTHU/Zhihu_Spider",
"path": "/zhihu/zhihu/items.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> id = Field(
output_processor = TakeFirst()
)
name = Field(
output_processor = TakeFirst()
)
url = Field(
output_processor = TakeFirst()
)
# zhihu answer
class ZhiHuA(Item):
id = Field(
input_processor = Ma... | code_fim | hard | {
"lang": "python",
"repo": "yyhTHU/Zhihu_Spider",
"path": "/zhihu/zhihu/items.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KratosMultiphysics/Kratos path: /applications/CoSimulationApplication/python_scripts/coupled_solvers/gauss_seidel_strong.py
# Importing the Kratos Library
import KratosMultiphysics as KM
import KratosMultiphysics.CoSimulationApplication as KratosCoSim
# Importing the base class
from KratosMultip... | code_fim | hard | {
"lang": "python",
"repo": "KratosMultiphysics/Kratos",
"path": "/applications/CoSimulationApplication/python_scripts/coupled_solvers/gauss_seidel_strong.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for conv_acc in self.convergence_accelerators_list:
conv_acc.InitializeNonLinearIteration()
for conv_crit in self.convergence_criteria_list:
conv_crit.InitializeNonLinearIteration()
for solver_name, solver in self.solver_wrappers.items(... | code_fim | hard | {
"lang": "python",
"repo": "KratosMultiphysics/Kratos",
"path": "/applications/CoSimulationApplication/python_scripts/coupled_solvers/gauss_seidel_strong.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for coupling_op in self.coupling_operations_dict.values():
coupling_op.InitializeCouplingIteration()
for conv_acc in self.convergence_accelerators_list:
conv_acc.InitializeNonLinearIteration()
for conv_crit in self.convergence_criteria_... | code_fim | hard | {
"lang": "python",
"repo": "KratosMultiphysics/Kratos",
"path": "/applications/CoSimulationApplication/python_scripts/coupled_solvers/gauss_seidel_strong.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rboman/progs path: /sandbox/vtk/selection/select.py
# -*- coding: utf-8 -*-
#
# inspired from:
# https://kitware.github.io/vtk-examples/site/Python/PolyData/ExtractSelection/
# https://vtk.org/Wiki/VTK/Examples/Cxx/Picking/CellPicking
import vtk
colors = vtk.vtkNamedColors()
# print(colors.... | code_fim | hard | {
"lang": "python",
"repo": "rboman/progs",
"path": "/sandbox/vtk/selection/select.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
print('There are %s input points' % ugrid.GetNumberOfPoints())
print('There are %s input cells' % ugrid.GetNumberOfCells())
# mesh
meshMapper = vtk.vtkDataSetMapper()
meshMapper.SetInputData(ugrid)
meshActor = vtk.vtkActor()
meshActor.GetProperty().SetColor(colors.GetColor3d... | code_fim | hard | {
"lang": "python",
"repo": "rboman/progs",
"path": "/sandbox/vtk/selection/select.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nstarman/astronat path: /astronat/dynamics/coordinates/representations.py
utes`
"""
__author__ = "Nathaniel Starkman"
__all__ = [
"OrbitRepresentationBase",
"OrbitSkyOffsetRepresentation",
"OrbitOffsetCartesianRepresentation",
"OrbitOffsetCylindricalRepresentation",
]
#######... | code_fim | hard | {
"lang": "python",
"repo": "nstarman/astronat",
"path": "/astronat/dynamics/coordinates/representations.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # /def
@classmethod
def from_cartesian(self, cartesian): # TODO
raise Exception("There is no cartesian representation, currently.")
# /def
def to_cartesian(self): # TODO
# Step 1: use afn to get orbit coordinate at that afn value
# Step 2: use `x` and `y` o... | code_fim | hard | {
"lang": "python",
"repo": "nstarman/astronat",
"path": "/astronat/dynamics/coordinates/representations.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nstarman/astronat path: /astronat/dynamics/coordinates/representations.py
###################################################
# PARAMETERS
##############################################################################
# CODE
######################################################################... | code_fim | hard | {
"lang": "python",
"repo": "nstarman/astronat",
"path": "/astronat/dynamics/coordinates/representations.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
async def get_project_analysis_by_name_and_ref(
project_name: str, branch_name: str, ref_name: str
):
query = (
select([analysis.c.id])
.where(
and_(
project.c.name == project_name,
or_(
analysis.c.branch_name == bran... | code_fim | hard | {
"lang": "python",
"repo": "Tioborto/raddar",
"path": "/raddar/crud/crud.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tioborto/raddar path: /raddar/crud/crud.py
from datetime import datetime, timezone
from typing import List
from sqlalchemy.sql import and_, or_, select
from raddar.db.database import analysis, database, project, secret
from raddar.lib.managers.repository_manager import get_branch_name
from radd... | code_fim | hard | {
"lang": "python",
"repo": "Tioborto/raddar",
"path": "/raddar/crud/crud.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MartinThoma/akademie-graph path: /create_nodes_and_edges.py
XPLANATION:
# This file reads in the people.csv and the files from the /data folder, and
# uses these data to create the nodes-and-edges.js.
# -----------------------------------------------------------------------------
# ------------... | code_fim | hard | {
"lang": "python",
"repo": "MartinThoma/akademie-graph",
"path": "/create_nodes_and_edges.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> x_, y_ = pol2cart(1500, np.pi/3*number)
x = x_ + np.random.normal(0, 250)
y = y_ + np.random.normal(0, 250)
while minDistance([x, y]) < 20000:
x = x_ + np.random.normal(0, 250)
y = y_ + np.random.normal(0, 250)
positions.append([x, y])
return (x, y)
def get_node_... | code_fim | hard | {
"lang": "python",
"repo": "MartinThoma/akademie-graph",
"path": "/create_nodes_and_edges.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_node_by_id(list_of_nodes_, id):
for node in list_of_nodes_:
if node.id == id:
return node
def average_known_people():
"""Prints the average number of people known by one person"""
print 'Knows', np.mean([sum(list(np.ravel(adjacency_matrix[i])))
... | code_fim | hard | {
"lang": "python",
"repo": "MartinThoma/akademie-graph",
"path": "/create_nodes_and_edges.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lzjzx1122/FaaSFlow path: /test/asplos/component_overhead/run.py
import psutil
import sys
import getopt
def analyze(pid):
manager = psutil.Process(pid)
mem_percent = manager.memory_percent()
cpu_percent = manager.cpu_percent(interval=1)
mem_mb = mem_percent * 61.9 * 1024 * 0.01
... | code_fim | medium | {
"lang": "python",
"repo": "lzjzx1122/FaaSFlow",
"path": "/test/asplos/component_overhead/run.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>.txt", 'w') as f:
f.write(f'mem_usage: {mem_mb} MB\n')
f.write(f'cpu_usage: {cpu_core} core\n')
if __name__ == '__main__':
opts, args = getopt.getopt(sys.argv[1:],'',['pid='])
for name, value in opts:
if name == '--pid':
pid = value
analyze(int(pid))<|fim_p... | code_fim | medium | {
"lang": "python",
"repo": "lzjzx1122/FaaSFlow",
"path": "/test/asplos/component_overhead/run.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def setUp(self):
self.pubnub = MagicMock(
spec=PubNub,
config=pnconf,
sdk_name=sdk_name,
uuid=None,
_get_token=lambda: None
)
self.pubnub.uuid = "UUID_GetStateTest"
self.pubnub._telemetry_manager = TelemetryMan... | code_fim | hard | {
"lang": "python",
"repo": "pubnub/python",
"path": "/tests/functional/test_get_state.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_get_state_single_group(self):
self.get_state.channel_groups('gr')
self.assertEqual(self.get_state.build_path(), GetState.GET_STATE_PATH % (pnconf.subscribe_key,
",",
... | code_fim | hard | {
"lang": "python",
"repo": "pubnub/python",
"path": "/tests/functional/test_get_state.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pubnub/python path: /tests/functional/test_get_state.py
import unittest
from pubnub.endpoints.presence.get_state import GetState
try:
from mock import MagicMock
except ImportError:
from unittest.mock import MagicMock
from pubnub.pubnub import PubNub
from tests.helper import pnconf, sdk... | code_fim | hard | {
"lang": "python",
"repo": "pubnub/python",
"path": "/tests/functional/test_get_state.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: webrtcman/speech_analytics path: /src/utils.py
from pathlib import Path
def validate_dir(path: Path):
return path.exists() and path.is_dir()
<|fim_suffix|> for child in path.iterdir():
if child.is_file():
child.unlink(missing_ok=True)
else:
clear... | code_fim | easy | {
"lang": "python",
"repo": "webrtcman/speech_analytics",
"path": "/src/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def clear_dir(path: Path):
for child in path.iterdir():
if child.is_file():
child.unlink(missing_ok=True)
else:
clear_dir(child)<|fim_prefix|># repo: webrtcman/speech_analytics path: /src/utils.py
from pathlib import Path
def validate_dir(path: Path):
<|fim_m... | code_fim | easy | {
"lang": "python",
"repo": "webrtcman/speech_analytics",
"path": "/src/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gistable/gistable path: /all-gists/455a68a79173fff1d890/snippet.py
import numpy as np
import matplotlib.pyplot as plt
# それっぽいデータを作る処理
from datetime import datetime, timedelta
import scipy
import scipy.stats
def create_dummy_data(days):
x = np.linspace(2, 2 + days, days)
y = scipy.stats.n... | code_fim | medium | {
"lang": "python",
"repo": "gistable/gistable",
"path": "/all-gists/455a68a79173fff1d890/snippet.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Ticks
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
minorLocator = MultipleLocator(5)
ax.xaxis.set_minor_locator(dates.DayLocator())
ax.xaxis.set_minor_formatter(dates.DateFormatter('%d'))
ax.xaxis.set_major_locator(dates.MonthLocator())
ax.xaxis.set_major_formatter(dates.DateFormatt... | code_fim | hard | {
"lang": "python",
"repo": "gistable/gistable",
"path": "/all-gists/455a68a79173fff1d890/snippet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8, 4))
# プロットの作成
# データによって色が変わってしまうのを回避するため、最大値を指定
im = ax.pcolor(X, Y, Z, vmax=0.6)
# タイトル
ax.set_title(u'Launch Retention')
# y軸
ax.set_ylabel(u'Past Days')
ax.set_ylim(bottom=1)
# x軸
ax.set_xlim(x[0], x[-1])
# カラーバー
plt.colorbar(im)
# Ticks
from matp... | code_fim | hard | {
"lang": "python",
"repo": "gistable/gistable",
"path": "/all-gists/455a68a79173fff1d890/snippet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass
def clear(self):
pass<|fim_prefix|># repo: Kageshimasu/blues path: /blues/metrics/classification/accuracy.py
from ...base.base_metric import BaseMetric
class Accuracy(BaseMetric):
<|fim_middle|> def __init__(self):
pass
def compute_value_for_one_batch(self, te... | code_fim | medium | {
"lang": "python",
"repo": "Kageshimasu/blues",
"path": "/blues/metrics/classification/accuracy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kageshimasu/blues path: /blues/metrics/classification/accuracy.py
from ...base.base_metric import BaseMetric
class Accuracy(BaseMetric):
def __init__(self):
<|fim_suffix|> pass
def get_name(self) -> str:
pass
def clear(self):
pass<|fim_middle|> pass
... | code_fim | medium | {
"lang": "python",
"repo": "Kageshimasu/blues",
"path": "/blues/metrics/classification/accuracy.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not exists(projpath):
# e.g myapp/js/lib -> wq.app/js
symlink(wqpath, projpath)
elif exists(join(wqpath, 'wq')) and not exists(join(projpath, 'wq')):
# e.g myapp/js/lib/wq -> wq.app/js/wq
symlink(join(wqpath, 'wq'), join(projpath, 'wq'))<|... | code_fim | medium | {
"lang": "python",
"repo": "pombredanne/wq.app",
"path": "/build/init.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pombredanne/wq.app path: /build/init.py
from os.path import exists, join, dirname
from os import symlink
def init(conf, indir):
<|fim_suffix|> if not exists(projpath):
# e.g myapp/js/lib -> wq.app/js
symlink(wqpath, projpath)
elif exists(join(wqpath, 'wq')... | code_fim | hard | {
"lang": "python",
"repo": "pombredanne/wq.app",
"path": "/build/init.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: longniao/pointer_worker path: /old/models/ticker.py
# -*- coding: utf-8 -*-
import copy
import arrow
DEFAULT_DATA = dict(
ex='',
contract='',
last=0,
change_percentage=0,
funding_rate=0,
funding_rate_indicative=0,
mark_price=0,
index_price=0,
total_size=0,
... | code_fim | medium | {
"lang": "python",
"repo": "longniao/pointer_worker",
"path": "/old/models/ticker.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
格式化数据
:param data:
:return:
'''
new_data = copy.deepcopy(DEFAULT_DATA)
new_data['ex'] = str(data['ex'])
new_data['contract'] = str(data['contract']).lower()
new_data['last'] = float(data['last'])
new_data['change_percentag... | code_fim | medium | {
"lang": "python",
"repo": "longniao/pointer_worker",
"path": "/old/models/ticker.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tksuoran/Vulkan-CPPTemplate path: /scripts/update_subprojects.sh
#!/usr/bin/env python3
#!/usr/bin/env bash
<|fim_suffix|>subprojects = ['fmt', 'GSL', 'tinyxml2']
for subproject in subprojects:<|fim_middle|># subprojects=(fmt GSL tinyxml2)
# for subproject in "${subprojects[@]}"
# do
# pus... | code_fim | hard | {
"lang": "python",
"repo": "tksuoran/Vulkan-CPPTemplate",
"path": "/scripts/update_subprojects.sh",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>subprojects = ['fmt', 'GSL', 'tinyxml2']
for subproject in subprojects:<|fim_prefix|># repo: tksuoran/Vulkan-CPPTemplate path: /scripts/update_subprojects.sh
#!/usr/bin/env python3
#!/usr/bin/env bash
# subprojects=(fmt GSL tinyxml2)
# for subproject in "${subprojects[@]}"
# do
# pushd "subproject... | code_fim | easy | {
"lang": "python",
"repo": "tksuoran/Vulkan-CPPTemplate",
"path": "/scripts/update_subprojects.sh",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # the final crowding distance result
crowding = np.zeros(n_points)
# sort each column and get index
I = np.argsort(F, axis=0, kind='mergesort')
# now really sort the whole array
F = F[I, np.arange(n_obj)]
# get the distance to the last element in ... | code_fim | hard | {
"lang": "python",
"repo": "LulucaChen/pymoo",
"path": "/pymoo/operators/survival/rank_and_crowding.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> dist_to_next = np.copy(dist)
for i, j in reversed(list(zip(*index_dist_is_zero))):
dist_to_next[i, j] = dist_to_next[i + 1, j]
# normalize all the distances
norm = np.max(F, axis=0) - np.min(F, axis=0)
norm[norm == 0] = np.nan
dist_to_last, dist... | code_fim | hard | {
"lang": "python",
"repo": "LulucaChen/pymoo",
"path": "/pymoo/operators/survival/rank_and_crowding.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LulucaChen/pymoo path: /pymoo/operators/survival/rank_and_crowding.py
import numpy as np
from pymoo.model.survival import Survival, split_by_feasibility
from pymoo.util.mathematics import Mathematics
from pymoo.util.non_dominated_sorting import NonDominatedSorting
from pymoo.util.randomized_args... | code_fim | hard | {
"lang": "python",
"repo": "LulucaChen/pymoo",
"path": "/pymoo/operators/survival/rank_and_crowding.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: abdullahsalah96/Udacity-Machine-Learning-Engineer-Nanodegree path: /Project 3 - Dog Breed Classifier/dog_app.py
from sklearn.datasets import load_files
from keras.utils import np_utils
import numpy as np
from glob import glob
# define function to load train, test, and validation datasets
def l... | code_fim | hard | {
"lang": "python",
"repo": "abdullahsalah96/Udacity-Machine-Learning-Engineer-Nanodegree",
"path": "/Project 3 - Dog Breed Classifier/dog_app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
### TODO: Define your architecture.
Xception_model = Sequential()
Xception_model.add(GlobalAveragePooling2D(input_shape = ( 7, 7, 2048)))
Xception_model.add(Dropout(0.3))
Xception_model.add(Dense(512, activation = 'relu'))
Xception_model.add(Dropout(0.3))
Xception_model.add(Dense(len(dog_names), activat... | code_fim | hard | {
"lang": "python",
"repo": "abdullahsalah96/Udacity-Machine-Learning-Engineer-Nanodegree",
"path": "/Project 3 - Dog Breed Classifier/dog_app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> list_of_tensors = [path_to_tensor(img_path) for img_path in tqdm(img_paths)]
return np.vstack(list_of_tensors)
from keras.applications.resnet50 import preprocess_input, decode_predictions
#
# def ResNet50_predict_labels(img_path):
# # returns prediction vector for image located at img_path... | code_fim | hard | {
"lang": "python",
"repo": "abdullahsalah96/Udacity-Machine-Learning-Engineer-Nanodegree",
"path": "/Project 3 - Dog Breed Classifier/dog_app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: standag/pytest-recording path: /src/pytest_recording/network.py
import socket
import sys
from contextlib import contextmanager
import attr
try:
import pycurl
@attr.s(slots=True)
class Curl(object):
"""Proxy to real pycurl.Curl.
If `perform` is called then it will r... | code_fim | hard | {
"lang": "python",
"repo": "standag/pytest-recording",
"path": "/src/pytest_recording/network.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Block connections via socket and pycurl.
NOTE:
Only connections to remotes are blocked in `socket`.
Local servers are not touched since it could interfere with live servers needed for tests (e.g. pytest-httpbin)
"""
block()
try:
yield
finally:
# ... | code_fim | hard | {
"lang": "python",
"repo": "standag/pytest-recording",
"path": "/src/pytest_recording/network.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unblock_pycurl()
unblock_socket()
@contextmanager
def blocking_context():
"""Block connections via socket and pycurl.
NOTE:
Only connections to remotes are blocked in `socket`.
Local servers are not touched since it could interfere with live servers needed for tests (e.g... | code_fim | hard | {
"lang": "python",
"repo": "standag/pytest-recording",
"path": "/src/pytest_recording/network.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if info.count(":") > 1:
log.parsing_error_preamble(path, line_num, line)
log.write(f"Too many ':'s in '{info}'")
log.error("")
attr_name, attr_val = info.split(":")
if attr_name == "":
... | code_fim | hard | {
"lang": "python",
"repo": "pmret/papermario",
"path": "/tools/splat/util/relocs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> attr_name, attr_val = info.split(":")
if attr_name == "":
log.parsing_error_preamble(path, line_num, line)
log.write(
f"Missing attribute name in '{info}', is there extra whitespace?"
)
... | code_fim | hard | {
"lang": "python",
"repo": "pmret/papermario",
"path": "/tools/splat/util/relocs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pmret/papermario path: /tools/splat/util/relocs.py
from dataclasses import dataclass
from typing import Dict
import spimdisasm
import tqdm
from intervaltree import Interval, IntervalTree
from util import log, options, symbols
@dataclass
class Reloc:
rom_address: int
reloc_type: str
... | code_fim | hard | {
"lang": "python",
"repo": "pmret/papermario",
"path": "/tools/splat/util/relocs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: asdf2014/algorithm path: /Codes/Liam/5353_bulb_switcher_III.py
# 执行用时:124 ms
# 内存消耗:18.9 MB
# 方案:所有的亮灯都连续排列在数组最左边,没有间断; 那么本题目转化为:判断 当前时刻亮灯的最大编号 是否 等于亮灯的数量
<|fim_suffix|> # 所有的亮灯都连续排列在数组最左边,没有间断
# 判断 当前时刻亮灯的最大编号 是否 等于亮灯的数量
rst, maxx = 0, 0
for idx, on_light in enum... | code_fim | medium | {
"lang": "python",
"repo": "asdf2014/algorithm",
"path": "/Codes/Liam/5353_bulb_switcher_III.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def numTimesAllBlue(self, light: List[int]) -> int:
# 所有的亮灯都连续排列在数组最左边,没有间断
# 判断 当前时刻亮灯的最大编号 是否 等于亮灯的数量
rst, maxx = 0, 0
for idx, on_light in enumerate(light):
maxx = max(maxx, on_light)
if maxx == idx + 1:
rst += 1
return... | code_fim | easy | {
"lang": "python",
"repo": "asdf2014/algorithm",
"path": "/Codes/Liam/5353_bulb_switcher_III.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 所有的亮灯都连续排列在数组最左边,没有间断
# 判断 当前时刻亮灯的最大编号 是否 等于亮灯的数量
rst, maxx = 0, 0
for idx, on_light in enumerate(light):
maxx = max(maxx, on_light)
if maxx == idx + 1:
rst += 1
return rst<|fim_prefix|># repo: asdf2014/algorithm path: /Cod... | code_fim | easy | {
"lang": "python",
"repo": "asdf2014/algorithm",
"path": "/Codes/Liam/5353_bulb_switcher_III.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>result = 0
right_num_T = 0
for i in range(len(s)-1,-1,-1):
if s[i] == 'T': right_num_T += 1
elif s[i] == 'A': result = (result + left_cnt_P[i]*right_num_T) % MAGIC_NUM
print(result)<|fim_prefix|># repo: StrayDragon/OJ-Solutions path: /PTA/PAT_B/Python3/B1040_AC.py
MAGIC_NUM = 1000000007
left_cn... | code_fim | medium | {
"lang": "python",
"repo": "StrayDragon/OJ-Solutions",
"path": "/PTA/PAT_B/Python3/B1040_AC.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: StrayDragon/OJ-Solutions path: /PTA/PAT_B/Python3/B1040_AC.py
MAGIC_NUM = 1000000007
left_cnt_P = [0 for _ in range(100010)]
<|fim_suffix|>result = 0
right_num_T = 0
for i in range(len(s)-1,-1,-1):
if s[i] == 'T': right_num_T += 1
elif s[i] == 'A': result = (result + left_cnt_P[i]*right... | code_fim | medium | {
"lang": "python",
"repo": "StrayDragon/OJ-Solutions",
"path": "/PTA/PAT_B/Python3/B1040_AC.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sourcefile, destfile, hashphrase, prefix = args
sourcefd = open(sourcefile, 'r')
destfd = open(destfile, 'w')
omap = encrypt(sourcefd, destfd, hashphrase, prefix, options.striplinenumbers)
sourcefd.close()
destfd.close()
w = csv.writer(sys.stdout)
for e, name in omap.iter... | code_fim | hard | {
"lang": "python",
"repo": "bsmedberg/breakpad-symbol-encryption",
"path": "/symbolencryption.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bsmedberg/breakpad-symbol-encryption path: /symbolencryption.py
import hmac, hashlib, sys, re
numfinder = re.compile('[0-9a-f]+$')
def encrypt(infd, outfd, hashphrase, prefix, striplinenumbers=False):
"""
Read a breakpad .sym file from infd. Using the given hashphrase,
one-way-hash ... | code_fim | hard | {
"lang": "python",
"repo": "bsmedberg/breakpad-symbol-encryption",
"path": "/symbolencryption.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
from optparse import OptionParser
import csv
o = OptionParser(usage="usage: %prog [options] sourcefile destfile hashphrase prefix")
o.add_option('-s', '--strip-line-numbers', action="store_true", dest="striplinenumbers", default=False)
options, args = o.par... | code_fim | hard | {
"lang": "python",
"repo": "bsmedberg/breakpad-symbol-encryption",
"path": "/symbolencryption.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>_cfi import *
from CalibTracker.SiPixelESProducers.siPixelGainCalibrationForHLTGPU_cfi import *
gpu.toReplaceWith(siPixelClustersPreSplitting, _siPixelClustersHeterogeneous.clone())<|fim_prefix|># repo: bkilian15/cmssw path: /RecoLocalTracker/SiPixelClusterizer/python/SiPixelClusterizerPreSplitting_cfi.p... | code_fim | hard | {
"lang": "python",
"repo": "bkilian15/cmssw",
"path": "/RecoLocalTracker/SiPixelClusterizer/python/SiPixelClusterizerPreSplitting_cfi.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bkilian15/cmssw path: /RecoLocalTracker/SiPixelClusterizer/python/SiPixelClusterizerPreSplitting_cfi.py
import FWCore.ParameterSet.Config as cms
from CondTools.SiPixel.SiPixelGainCalibrationService_cfi import *
from RecoLocalTracker.SiPixelClusterizer.SiPixelClusterizer_cfi import s<|fim_suffix|... | code_fim | medium | {
"lang": "python",
"repo": "bkilian15/cmssw",
"path": "/RecoLocalTracker/SiPixelClusterizer/python/SiPixelClusterizerPreSplitting_cfi.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Chris3Arcadia/BlackFlyPy path: /BlackFlyPy.py
# # Python Class for FLIR Systems' Blackfly USB Camera
#
# By Chris Arcadia (2021/01/11)
#
# Intended for use with the Blackfly S USB3 Camera
#
# Inspired by the following Repositories:
# * "Acquisition.py" (from "Spinnaker-Python3-Examples" by FL... | code_fim | hard | {
"lang": "python",
"repo": "Chris3Arcadia/BlackFlyPy",
"path": "/BlackFlyPy.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.notify('Starting image acquisition.')
camera.BeginAcquisition()
try:
image = camera.GetNextImage(round(timeout*1e3))
if image.IsIncomplete():
self.notify('Image incomplete ... | code_fim | hard | {
"lang": "python",
"repo": "Chris3Arcadia/BlackFlyPy",
"path": "/BlackFlyPy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def about_cameras(self):
info = {'count':0,'name':[],'index':[],'vendor':[]}
if self.loaded and self.cameras:
info['count'] = self.cameras.GetSize()
info['index'] = list(range(info['count']))
for camera in self.cameras:
... | code_fim | hard | {
"lang": "python",
"repo": "Chris3Arcadia/BlackFlyPy",
"path": "/BlackFlyPy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
import argparse
parser = argparse.ArgumentParser(description='An easy interface for evaluate various segmentation methods')
parser.add_argument('-ts', '--setting_folder_path', required=False, type=str,
default=None,
help='path of the fol... | code_fim | hard | {
"lang": "python",
"repo": "uncbiag/easyreg",
"path": "/demo/demo_for_seg_eval.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> args = parser.parse_args()
print(args)
file_txt_path = args.file_txt_path
image_list = args.image_list
limage_list = args.limage_list
image_label_list = []
assert file_txt_path is not None or image_list is not None, "either file_txt_path or source/target_list should be provide... | code_fim | hard | {
"lang": "python",
"repo": "uncbiag/easyreg",
"path": "/demo/demo_for_seg_eval.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: uncbiag/easyreg path: /demo/demo_for_seg_eval.py
import matplotlib as matplt
matplt.use('Agg')
import os, sys
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('../easy_reg'))
import tools.module_parameters as pars
from abc im... | code_fim | hard | {
"lang": "python",
"repo": "uncbiag/easyreg",
"path": "/demo/demo_for_seg_eval.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> summarizer = SumBasicSummarizer(stemmer.lemmatize)
summarizer.stop_words = STOP_WORDS
parser = PlaintextParser.from_string(text, Tokenizer('english'))
summary = summarizer(parser.document, config['summary_length'])
return ' '.join([str(s) for s in summary])<|fim_prefix|># repo: sweetST... | code_fim | medium | {
"lang": "python",
"repo": "sweetSTEAM/NewsSummarizer",
"path": "/app/analyzer/nlp/sum_basic.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sweetSTEAM/NewsSummarizer path: /app/analyzer/nlp/sum_basic.py
from sumy.nlp.tokenizers import Tokenizer
from sumy.summarizers.sum_basic import SumBasicSummarizer
from sumy.parsers.plaintext import PlaintextParser
from .normalization import STOP_WORDS, stemmer
<|fim_suffix|> summarizer = SumB... | code_fim | medium | {
"lang": "python",
"repo": "sweetSTEAM/NewsSummarizer",
"path": "/app/analyzer/nlp/sum_basic.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
pprint(get_weather(city))
except Exception:
e, info = sys.exc_info()
sys.stderr.write(f'''Error occurred: {e}
{info}
''')
sys.exit(1)<|fim_prefix|># repo: krigar1184/weather-cli path: /weather.py
#!/usr/bin/env python3
import sys
from ppr... | code_fim | medium | {
"lang": "python",
"repo": "krigar1184/weather-cli",
"path": "/weather.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: krigar1184/weather-cli path: /weather.py
#!/usr/bin/env python3
import sys
from pprint import pprint
from src import get_weather
<|fim_suffix|> city, *_ = sys.argv[1:]
try:
pprint(get_weather(city))
except Exception:
e, info = sys.exc_info()
sys.stderr.writ... | code_fim | medium | {
"lang": "python",
"repo": "krigar1184/weather-cli",
"path": "/weather.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @abc.abstractmethod
def send_obj(self, key, tag, nid, obj, serial):
pass
@abc.abstractmethod
def send_binary_tensor(self, key, tag, nid, tensor):
pass<|fim_prefix|># repo: zhihaolyu/malib path: /malib/rpc/ExperimentManager/base_client.py
import abc
from malib.utils.typing... | code_fim | hard | {
"lang": "python",
"repo": "zhihaolyu/malib",
"path": "/malib/rpc/ExperimentManager/base_client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhihaolyu/malib path: /malib/rpc/ExperimentManager/base_client.py
import abc
from malib.utils.typing import Any
class BaseClient(abc.ABC):
def info(self, level: str, message: str, nid: str):
pass
@abc.abstractmethod
def create_table(self, primary: str, secondary: str, nid: ... | code_fim | medium | {
"lang": "python",
"repo": "zhihaolyu/malib",
"path": "/malib/rpc/ExperimentManager/base_client.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @abc.abstractmethod
def send_binary_tensor(self, key, tag, nid, tensor):
pass<|fim_prefix|># repo: zhihaolyu/malib path: /malib/rpc/ExperimentManager/base_client.py
import abc
from malib.utils.typing import Any
class BaseClient(abc.ABC):
def info(self, level: str, message: str, nid:... | code_fim | medium | {
"lang": "python",
"repo": "zhihaolyu/malib",
"path": "/malib/rpc/ExperimentManager/base_client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def generate_fields(self):
for x in super(TimeToSampleBox, self).generate_fields():
yield x
yield ("entry count", self.entry_count)
for entry in self.entries:
yield ("sample count", entry[0])
yield ("sample delta", entry[1])
class SampleToC... | code_fim | hard | {
"lang": "python",
"repo": "toshic/mp4viewer",
"path": "/src/isobmff/movie.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: toshic/mp4viewer path: /src/isobmff/movie.py
next_track_id = buf.readint32()
def generate_fields(self):
for x in super(MovieHeader, self).generate_fields():
yield x
from utils import get_utc_from_seconds_since_1904
yield ("creation time", self.creation_tim... | code_fim | hard | {
"lang": "python",
"repo": "toshic/mp4viewer",
"path": "/src/isobmff/movie.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def generate_fields(self):
for x in super(SampleToChunkBox, self).generate_fields():
yield x
yield ("entry count", self.entry_count)
for entry in self.entries:
yield ("first chunk", entry[0])
yield ("samples per chunk", entry[1])
... | code_fim | hard | {
"lang": "python",
"repo": "toshic/mp4viewer",
"path": "/src/isobmff/movie.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: orb1t-ua/SimpleGPU path: /demo_scripts/Texture_format.py
import numpy
from scipy import misc
def get_picture(paths):
address = 0
fo = open("texture","w")
for path in paths:
image = misc.imread(path,mode="RGBA")
the_shape = image.shape
new_shape = (the_shape[0]... | code_fim | hard | {
"lang": "python",
"repo": "orb1t-ua/SimpleGPU",
"path": "/demo_scripts/Texture_format.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>_repr(image[the_shape[0] - i - 1][j][1],width=8))
fo.write(numpy.binary_repr(image[the_shape[0] - i - 1][j][2],width=8))
fo.write("\n")
fo.close()
if __name__ == "__main__":
get_picture(["5_Target.png","5_Target.png"])<|fim_prefix|># repo: orb1t-ua/SimpleGP... | code_fim | hard | {
"lang": "python",
"repo": "orb1t-ua/SimpleGPU",
"path": "/demo_scripts/Texture_format.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> global output_response
output_response = ""
def log_to_var(message):
global output_response
output_response = "{}{}\n".format(output_response, message)
logger_ = mock.MagicMock()
logger_.log = log_to_var
input_dict = {
... | code_fim | medium | {
"lang": "python",
"repo": "Paperspace/paperspace-python",
"path": "/tests/unit/test_base.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Paperspace/paperspace-python path: /tests/unit/test_base.py
from collections import OrderedDict
import mock
from paperspace.commands.common import CommandBase
output_response = ""
<|fim_suffix|> global output_response
output_response = ""
def log_to_var(message):
... | code_fim | medium | {
"lang": "python",
"repo": "Paperspace/paperspace-python",
"path": "/tests/unit/test_base.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> input_dict = {
"foo": {
'bar': {
"baz": "faz"
}
}
}
expected_string = """foo:
bar:
baz:
faz
"""
command = CommandBase(logger_=logger_)
command._print_dict_recursive(OrderedDict(... | code_fim | hard | {
"lang": "python",
"repo": "Paperspace/paperspace-python",
"path": "/tests/unit/test_base.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>e('$______________________________________________\n')
mergedfile.write('$______________________________________________\n')
skip_flag = False
for i in nastranlines:
if i[:5]=='PARAM': continue
if startnext==True:
if i.find(',') > -1:
mergedfile.writ... | code_fim | hard | {
"lang": "python",
"repo": "compmech/structmanager",
"path": "/structmanager/optimization/sol200/files.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: compmech/structmanager path: /structmanager/optimization/sol200/files.py
def merge_temp_files(self):
"""Merge temporary files
"""
#merging NASTRAN and GENESIS .dat files
self.genesisfile.close()
self.genesisfile = open(self.genesisfile.name, 'r')
genfile = self.genesisfil... | code_fim | hard | {
"lang": "python",
"repo": "compmech/structmanager",
"path": "/structmanager/optimization/sol200/files.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: acdh-oeaw/ner-annotator path: /annotations/utils.py
import ast
import pandas as pd
import requests
import json
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ObjectDoesNotExist
from . models import NerSample
def create_ner_samples_from_csv(file, ... | code_fim | hard | {
"lang": "python",
"repo": "acdh-oeaw/ner-annotator",
"path": "/annotations/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def create_ner_samples_from_list(ner_list, limit=10):
for row in ner_list:
if len(row[0]) > limit:
ner = NerSample.objects.get_or_create(
text=row[0], entity_json=row[1]
)
def create_ner_sample_from_qs(app_label, model_label, textfield, endpoint, star... | code_fim | hard | {
"lang": "python",
"repo": "acdh-oeaw/ner-annotator",
"path": "/annotations/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if idade > 18:
saldo = idade - 18
print('Você já deveria ter se alistado há {} anos, pois seu alistamento foi em {}.'
.format(saldo, corrente - saldo))
elif idade < 18:
saldo = 18 - idade
print('Ainda faltam {} anos para o alistamento, que será em {}.'
.format(saldo, co... | code_fim | medium | {
"lang": "python",
"repo": "fabiocoutoaraujo/CursoVideoPython",
"path": "/mundo-02/aula12-ex039.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fabiocoutoaraujo/CursoVideoPython path: /mundo-02/aula12-ex039.py
from datetime import date
corrente = date.today().year
nascimento = int(input('Ano de nascimento: '))
idade = corrente - nascimento
<|fim_suffix|>if idade > 18:
saldo = idade - 18
print('Você já deveria ter se alistado há ... | code_fim | medium | {
"lang": "python",
"repo": "fabiocoutoaraujo/CursoVideoPython",
"path": "/mundo-02/aula12-ex039.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: evamaina/StackOverflow-lite path: /app/common/validation.py
from app.app import *
from validate_email import validate_email
def validate_user_registration(json):
if not(json["first_name"].strip()):
return jsonify({'Message':
'First name is required'}), 401
... | code_fim | hard | {
"lang": "python",
"repo": "evamaina/StackOverflow-lite",
"path": "/app/common/validation.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return True
def validate_answer(json):
if not(json["answer_body"].strip()):
return jsonify({'Message':
'Answer body is required'}), 401
return True<|fim_prefix|># repo: evamaina/StackOverflow-lite path: /app/common/validation.py
from app.app import *
from... | code_fim | hard | {
"lang": "python",
"repo": "evamaina/StackOverflow-lite",
"path": "/app/common/validation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JuneMuoti/personal-blog path: /manage.py
from app import create_app,db
from flask_script import Manager,Server
from app.models import User,Posts,Comments
from flask_migrate import Migrate,MigrateCommand
app=create_app('development')
manager=Manager(app)
manager.add_command('server',Server)
mig... | code_fim | easy | {
"lang": "python",
"repo": "JuneMuoti/personal-blog",
"path": "/manage.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return dict(app=app,db=db,User=User,Posts=Posts,Comments=Comments)
if __name__ == '__main__':
manager.run()<|fim_prefix|># repo: JuneMuoti/personal-blog path: /manage.py
from app import create_app,db
from flask_script import Manager,Server
from app.models import User,Posts,Comments
from flask_mi... | code_fim | hard | {
"lang": "python",
"repo": "JuneMuoti/personal-blog",
"path": "/manage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> owned_by=models.CharField(max_length=100)
keywds=models.CharField(max_length=1000)<|fim_prefix|># repo: stanicaa/News path: /reader_project/newsapp/models.py
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class rss_field(models.Model):
fe... | code_fim | medium | {
"lang": "python",
"repo": "stanicaa/News",
"path": "/reader_project/newsapp/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stanicaa/News path: /reader_project/newsapp/models.py
from django.db import models
from django.contrib.auth.models import User
<|fim_suffix|> title=models.CharField(max_length=400)
summary=models.CharField(max_length=400)
link=models.CharField(max_length=400)
feed_link=models.Char... | code_fim | medium | {
"lang": "python",
"repo": "stanicaa/News",
"path": "/reader_project/newsapp/models.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Danchesko/mobdev-telegram-bot path: /src/db_guard/db_manager.py
import sqlite3
DB_PATH = "../../db/users.db"
def create_table(conn):
conn.cursor().execute('''CREATE TABLE IF NOT EXISTS users
(id UNIQUE, username text, firstname text , lastname text)''')
<|fim_suffix... | code_fim | hard | {
"lang": "python",
"repo": "Danchesko/mobdev-telegram-bot",
"path": "/src/db_guard/db_manager.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def set_connection(db_path = DB_PATH):
db_conn = sqlite3.connect(db_path)
return db_conn<|fim_prefix|># repo: Danchesko/mobdev-telegram-bot path: /src/db_guard/db_manager.py
import sqlite3
DB_PATH = "../../db/users.db"
def create_table(conn):
conn.cursor().execute('''CREATE TABLE IF ... | code_fim | hard | {
"lang": "python",
"repo": "Danchesko/mobdev-telegram-bot",
"path": "/src/db_guard/db_manager.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stellaGK/stella path: /post_processing/stella_plots.py
# -*- coding: utf-8 -*-
## some coding for commonly used plots
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rcParams
# setup some plot defaults
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.rc(... | code_fim | hard | {
"lang": "python",
"repo": "stellaGK/stella",
"path": "/post_processing/stella_plots.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fig = plt.figure(figsize=(12,8))
x,y = np.meshgrid(xin,yin)
im = plt.imshow(z[0,:,:], cmap=cmp, vmin=zmin[0], vmax=zmax[0],
extent=[x.min(),x.max(),y.min(),y.max()],
interpolation='nearest', origin='lower', aspect='auto')
plt.colorbar()
plt.xlabel(xlab)
... | code_fim | hard | {
"lang": "python",
"repo": "stellaGK/stella",
"path": "/post_processing/stella_plots.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.RemoveField(
model_name='documentconvert',
name='place',
),
migrations.RemoveField(
model_name='documentconvert',
name='place_convert',
),
]<|fim_prefix|># repo: bigdae/pangkyogo path: /myapp... | code_fim | medium | {
"lang": "python",
"repo": "bigdae/pangkyogo",
"path": "/myapp/migrations/0011_auto_20190724_2331.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.