text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: marianasargsyan/ml-learning path: /pythonproblems/Recursion/factorial.py
def factorial(n):
<|fim_suffix|>for n in range(1, 100):
print(factorial(n))<|fim_middle|> global val
if n < 1:
return 1
else:
val = n * factorial(n - 1)
return val
| code_fim | medium | {
"lang": "python",
"repo": "marianasargsyan/ml-learning",
"path": "/pythonproblems/Recursion/factorial.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>for n in range(1, 100):
print(factorial(n))<|fim_prefix|># repo: marianasargsyan/ml-learning path: /pythonproblems/Recursion/factorial.py
def factorial(n):
<|fim_middle|> global val
if n < 1:
return 1
else:
val = n * factorial(n - 1)
return val
| code_fim | medium | {
"lang": "python",
"repo": "marianasargsyan/ml-learning",
"path": "/pythonproblems/Recursion/factorial.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @classmethod
def Cancel(cls, executionId: int):
execution = cls.Find(executionId)
if execution is not None:
Log.I(f'Cancelling execution {execution.Id}')
execution.Cancel()
else:
Log.W(f'Cannot cancel execution {executionId}: Not found')
... | code_fim | hard | {
"lang": "python",
"repo": "5genesis/ELCM",
"path": "/Status/experiment_queue.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> executionId = Status.NextId()
execution = ExperimentRun(executionId, params)
cls.queue.appendleft(execution)
Log.I(f'Created Execution {execution.Id}')
return execution
@classmethod
def Delete(cls, executionId):
execution = cls.Find(executionId)
... | code_fim | hard | {
"lang": "python",
"repo": "5genesis/ELCM",
"path": "/Status/experiment_queue.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 5genesis/ELCM path: /Status/experiment_queue.py
from collections import deque
from Experiment import ExperimentRun, ExperimentStatus
from typing import Deque, Optional, List, Dict
from Helper import Log
from .status import Status
class ExecutionQueue:
queue: Deque[ExperimentRun] = deque()
... | code_fim | hard | {
"lang": "python",
"repo": "5genesis/ELCM",
"path": "/Status/experiment_queue.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>+ 5*I(t).diff(t) + 6*I(t), 10*sin(t)), I(t))
print(sol)<|fim_prefix|># repo: DrStephenLynch/dynamical-systems-with-applications-using-python path: /Anaconda-files/Program_02g.py
# Program 02g: A second order ODE.
from sympy import symbols, dsolve, Function, Eq, sin
t = symbols('t')
I = sy<|fim_middle|>... | code_fim | easy | {
"lang": "python",
"repo": "DrStephenLynch/dynamical-systems-with-applications-using-python",
"path": "/Anaconda-files/Program_02g.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DrStephenLynch/dynamical-systems-with-applications-using-python path: /Anaconda-files/Program_02g.py
# Program 02g: A second order ODE.
from sympy import symbols, dsolve, Function, Eq, sin
t = symbols('t')
I = sy<|fim_suffix|>+ 5*I(t).diff(t) + 6*I(t), 10*sin(t)), I(t))
print(sol)<|fim_middle|>... | code_fim | easy | {
"lang": "python",
"repo": "DrStephenLynch/dynamical-systems-with-applications-using-python",
"path": "/Anaconda-files/Program_02g.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IFRCGo/go-api path: /dref/views.py
event_map",
"cover_image",
"budget_file",
"assessment_report",
)
.prefetch_related(
"dref",
"planned_interventions",
"needs_identified",
... | code_fim | hard | {
"lang": "python",
"repo": "IFRCGo/go-api",
"path": "/dref/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> permission_class = [permissions.IsAuthenticated]
serializer_class = DrefFileSerializer
def get_queryset(self):
if self.request is None:
return DrefFile.objects.none()
return DrefFile.objects.filter(created_by=self.request.user)
@action(
detail=False,
... | code_fim | hard | {
"lang": "python",
"repo": "IFRCGo/go-api",
"path": "/dref/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_queryset(self):
user = self.request.user
queryset = DrefFinalReport.objects.filter(is_published=True).order_by("-created_at").distinct()
return filter_dref_queryset_by_user_access(user, queryset)
class ActiveDrefOperationsViewSet(viewsets.ReadOnlyModelViewSet):
se... | code_fim | hard | {
"lang": "python",
"repo": "IFRCGo/go-api",
"path": "/dref/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return (
session["distinct_id"] == session_recording["distinct_id"]
and session["start_time"] <= session_recording["end_time"]
and session["end_time"] >= session_recording["start_time"]
)<|fim_prefix|># repo: 1060460048/posthog path: /posthog/queries/session_recording.py
f... | code_fim | hard | {
"lang": "python",
"repo": "1060460048/posthog",
"path": "/posthog/queries/session_recording.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for session in sessions_results:
session["session_recording_ids"] = [
recording["properties__$session_id"] for recording in session_recordings if matches(session, recording)
]
return sessions_results
def matches(session: Any, session_recording: Any) -> bool:
retur... | code_fim | hard | {
"lang": "python",
"repo": "1060460048/posthog",
"path": "/posthog/queries/session_recording.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 1060460048/posthog path: /posthog/queries/session_recording.py
from typing import Any, Dict, List
from django.db.models import F, Max, Min
from posthog.models import Event, Filter, Team
from posthog.queries.base import BaseQuery
class SessionRecording(BaseQuery):
<|fim_suffix|># :TRICKY: This... | code_fim | hard | {
"lang": "python",
"repo": "1060460048/posthog",
"path": "/posthog/queries/session_recording.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fig, (axs1, axs2) = plt.subplots(1, 2)
axs1.plot(range(len(fidelities)), fidelities)
axs1.set_xlabel('Epoch')
axs1.set_ylabel('Fidelity between real and fake states')
axs2.plot(range(len(losses)), losses)
axs2.set_xlabel('Epoch')
axs2.set_ylabel('Wasserstein Loss')
plt.tig... | code_fim | medium | {
"lang": "python",
"repo": "CQCL/qWGAN",
"path": "/tools/plot_hub.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CQCL/qWGAN path: /tools/plot_hub.py
#!/usr/bin/env python
"""
plot_hub.py: the plot tool
"""
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
<|fim_suffix|>
fig, (axs1, axs2) = plt.subplots(1, 2)
axs1.plot(range(len(fidelities)), fidelities)
axs1.set_xla... | code_fim | medium | {
"lang": "python",
"repo": "CQCL/qWGAN",
"path": "/tools/plot_hub.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return clean(all=True)
def autoclean():
return clean(auto=True)
def clean(all=False,auto=False):
"""
NAME:
clean
PURPOSE:
clean out the cache: removes all cached files that follow the standard datetime_hash.pkl filename format; renamed files will be retained
INPUT:
... | code_fim | hard | {
"lang": "python",
"repo": "jobovy/gaia_tools",
"path": "/gaia_tools/query/cache.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jobovy/gaia_tools path: /gaia_tools/query/cache.py
# gaia_tools.query.cache: tools for caching the results from queries
import os, os.path
import datetime
import glob
import hashlib
import shutil
import pickle
import dateutil.parser
from gaia_tools.util import save_pickles
_CACHE_DIR= os.path.jo... | code_fim | hard | {
"lang": "python",
"repo": "jobovy/gaia_tools",
"path": "/gaia_tools/query/cache.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>isit_ajax', name='count-visit-ajax'),
)<|fim_prefix|># repo: Anushma/django-visits path: /visits/urls.py
from django.conf.urls import patterns, url
urlpatterns = patterns('visits.vie<|fim_middle|>ws',
url(r'^visits/add/$', 'count_v | code_fim | easy | {
"lang": "python",
"repo": "Anushma/django-visits",
"path": "/visits/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Anushma/django-visits path: /visits/urls.py
from django.conf.urls import patterns, <|fim_suffix|>ws',
url(r'^visits/add/$', 'count_visit_ajax', name='count-visit-ajax'),
)<|fim_middle|>url
urlpatterns = patterns('visits.vie | code_fim | easy | {
"lang": "python",
"repo": "Anushma/django-visits",
"path": "/visits/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ws',
url(r'^visits/add/$', 'count_visit_ajax', name='count-visit-ajax'),
)<|fim_prefix|># repo: Anushma/django-visits path: /visits/urls.py
from django.conf.urls import patterns, <|fim_middle|>url
urlpatterns = patterns('visits.vie | code_fim | easy | {
"lang": "python",
"repo": "Anushma/django-visits",
"path": "/visits/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('CO2 emission factor for gas in kg/kWh for ' + str(year))
print(emission.get_co2_emission_factors(type='gas'))
if __name__ == '__main__':
run_example()<|fim_prefix|># repo: RWTH-EBC/pyCity_calc path: /pycity_calc/examples/example_co2emissions.py
# coding=utf-8
"""
Example script for em... | code_fim | hard | {
"lang": "python",
"repo": "RWTH-EBC/pyCity_calc",
"path": "/pycity_calc/examples/example_co2emissions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Generate emission object
emission = co2.Emissions(year=year)
print('CO2 emission factor for electricity in kg/kWh for ' + str(year))
print(emission.get_co2_emission_factors(type='el_mix'))
print('CO2 emission factor for gas in kg/kWh for ' + str(year))
print(emission.get_co2_e... | code_fim | medium | {
"lang": "python",
"repo": "RWTH-EBC/pyCity_calc",
"path": "/pycity_calc/examples/example_co2emissions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RWTH-EBC/pyCity_calc path: /pycity_calc/examples/example_co2emissions.py
# coding=utf-8
"""
Example script for emissions class
"""
from __future__ import division
import pycity_calc.environments.co2emissions as co2
def run_example():
<|fim_suffix|> print('CO2 emission factor for electricity ... | code_fim | medium | {
"lang": "python",
"repo": "RWTH-EBC/pyCity_calc",
"path": "/pycity_calc/examples/example_co2emissions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, operation: str, addr: int, what: str):
assert operation in ['pc',
'narrow load', 'narrow store',
'wide load', 'wide store']
self.operation = operation
self.addr = addr
self.what = what
def... | code_fim | hard | {
"lang": "python",
"repo": "vanand1/opentitan",
"path": "/hw/ip/otbn/dv/otbnsim/sim/alert.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vanand1/opentitan path: /hw/ip/otbn/dv/otbnsim/sim/alert.py
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
from typing import Optional
# A copy of the list of error codes. This also appears in th... | code_fim | medium | {
"lang": "python",
"repo": "vanand1/opentitan",
"path": "/hw/ip/otbn/dv/otbnsim/sim/alert.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mtianyan/VueDjangoAntdProBookShop path: /apps/user_operation/signals.py
# encoding: utf-8
__author__ = 'mtianyan'
__date__ = '2018/3/9 0009 09:29'
<|fim_suffix|> # 是否新建,因为update的时候也会进行post_save
if created:
goods = instance.goods
goods.fav_num += 1
goods.save()
# ... | code_fim | hard | {
"lang": "python",
"repo": "mtianyan/VueDjangoAntdProBookShop",
"path": "/apps/user_operation/signals.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># 参数一接收哪种信号,参数二是接收哪个model的信号
@receiver(post_delete, sender=UserFav)
def del_user_fav(sender, instance=None, created=False, **kwargs):
goods = instance.goods
goods.fav_num -= 1
goods.save()<|fim_prefix|># repo: mtianyan/VueDjangoAntdProBookShop path: /apps/user_operation/signals.py
# encoding:... | code_fim | hard | {
"lang": "python",
"repo": "mtianyan/VueDjangoAntdProBookShop",
"path": "/apps/user_operation/signals.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Write to a cif
:Parameters:
atoms : list
List of atomic symbols.
coords : numpy array (2D)
Atomic coordinates.
text : str
Text to be added to the beginning of the cif.
filename : str
Namestring for cif to ... | code_fim | hard | {
"lang": "python",
"repo": "RealPolitiX/fedpy",
"path": "/fedpy/io.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RealPolitiX/fedpy path: /fedpy/io.py
# -*- coding: utf-8 -*-
from __future__ import division
import numpy as np
import pandas as pd
# File I/O
def readcif(filename, **kwds):
"""
Read a cif and parse structural parameters
:Parameters:
filename : str
filename ... | code_fim | hard | {
"lang": "python",
"repo": "RealPolitiX/fedpy",
"path": "/fedpy/io.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: inducer/boxtree path: /test/test_tools.py
__copyright__ = "Copyright (C) 2012 Andreas Kloeckner \
Copyright (C) 2017 Matt Wala \
Copyright (C) 2018 Hao Gao"
__license__ = """
Permission is hereby granted, free of charge, to any person obtaining a copy
of this so... | code_fim | hard | {
"lang": "python",
"repo": "inducer/boxtree",
"path": "/test/test_tools.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> from boxtree.tools import DeviceDataRecord
array = np.arange(60).reshape((3, 4, 5))
obj_array = np.empty((3,), dtype=object)
for i in range(3):
obj_array[i] = np.arange((i + 1) * 40).reshape(5, i + 1, 8)
record = DeviceDataRecord(
array=array,
obj_array=obj_ar... | code_fim | hard | {
"lang": "python",
"repo": "inducer/boxtree",
"path": "/test/test_tools.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jkvoulgaridis/KnowledgeBase_transportation path: /cast_to_rdf.py
import pandas as pd
import sys
import os
import itertools
def append_namespace():
print('@prefix :<http://www.semanticweb.org/johnvoul/ontologies/2020/6/transport#> .')
print('@prefix owl:<http://www.w3.org/2002/07/owl#... | code_fim | hard | {
"lang": "python",
"repo": "jkvoulgaridis/KnowledgeBase_transportation",
"path": "/cast_to_rdf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
with open("stops.ttl", "a", encoding='utf-8') as f:
sys.stdout = f
try:
stops = pd.read_csv("stops.txt", encoding='utf-8')
except:
stops = pd.read_csv("stops.csv",encoding='utf-8')
stops.fillna("UNK", inplace=True)
stops.head()
append_namespace()
for index, row in stops.iterrows()... | code_fim | hard | {
"lang": "python",
"repo": "jkvoulgaridis/KnowledgeBase_transportation",
"path": "/cast_to_rdf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
with open("trips.ttl", "a", encoding='utf-8') as f:
sys.stdout = f
try:
trips = pd.read_csv("trips.txt", encoding='utf-8')
except:
trips = pd.read_csv("trips.csv", encoding = 'utf-8')
trips.fillna("UNK", inplace=True)
trips.head()
append_namespace()
for index, row in trips.iterrows()... | code_fim | hard | {
"lang": "python",
"repo": "jkvoulgaridis/KnowledgeBase_transportation",
"path": "/cast_to_rdf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>process.MessageLogger.cerr.FwkReport.reportEvery = 5
if hasattr(process,'MessageLogger'):
process.MessageLogger.categories.append('HGCalValid')
process.MessageLogger.categories.append('HGCalGeom')
process.MessageLogger.cerr.FwkReport.reportEvery = 100
process.source = cms.Source("PoolSource",
... | code_fim | hard | {
"lang": "python",
"repo": "IzaakWN/cmssw",
"path": "/Validation/HGCalValidation/test/runHGCGeomCheck_cfg.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IzaakWN/cmssw path: /Validation/HGCalValidation/test/runHGCGeomCheck_cfg.py
import FWCore.ParameterSet.Config as cms
#from Configuration.Eras.Era_Phase2C4_timing_layer_bar_cff import Phase2C4_timing_layer_bar
#process = cms.Process('HGCGeomAnalysis',Phase2C4_timing_layer_bar)
#process.load('Conf... | code_fim | hard | {
"lang": "python",
"repo": "IzaakWN/cmssw",
"path": "/Validation/HGCalValidation/test/runHGCGeomCheck_cfg.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>process.TFileService = cms.Service("TFileService",
fileName = cms.string('hgcGeomCheckV10.root'),
closeFileFast = cms.untracked.bool(True)
)
SimpleMemoryCheck = cms.Service("SimpleMemoryCheck",ignoreTotal = cms.untracked.int32(1) )
process.p = cms.Path(process.hgc... | code_fim | hard | {
"lang": "python",
"repo": "IzaakWN/cmssw",
"path": "/Validation/HGCalValidation/test/runHGCGeomCheck_cfg.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: a4242762/Novel-recommendation-system path: /webapp/App/urls.py
"""qidian URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import ... | code_fim | medium | {
"lang": "python",
"repo": "a4242762/Novel-recommendation-system",
"path": "/webapp/App/urls.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>app_name = 'App'
urlpatterns = [
url('^home/', views.home,name='home'),
url('^register/', views.register,name='register'),
url('^login/', views.login,name='login'),
url('^unlogin/', views.unlogin, name='unlogin'),
url('^upload_info/', views.upload_info, name='upload_info'),
url('^u... | code_fim | medium | {
"lang": "python",
"repo": "a4242762/Novel-recommendation-system",
"path": "/webapp/App/urls.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jarieloc/robotic-framework path: /scripts/testingTf.py
#!/usr/bin/env python
import rospy
import random
import math
import time
import numpy as np
from std_msgs.msg import Float64
from std_srvs.srv import Empty
from gazebo_msgs.msg import LinkStates
from gazebo_msgs.srv import *
# from gazebo_m... | code_fim | hard | {
"lang": "python",
"repo": "jarieloc/robotic-framework",
"path": "/scripts/testingTf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Path planning parameters
# TODO: Put parameters into datastructures to simplify readability and flexibility.
p0x, pfx = trans[0], 0.3
p0y, pfy = trans[1], 0.3
p0z, pfz = trans[2], 0.926
duration = 10.0
# hz = 100.0
dx = 1.0/hz
samples = duration*hz
samples = int(... | code_fim | hard | {
"lang": "python",
"repo": "jarieloc/robotic-framework",
"path": "/scripts/testingTf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: martinoravsky/ryu path: /scripts/mininet/smaller.py
#!/usr/bin/python
from subprocess import call
from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSController
from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch, Use... | code_fim | hard | {
"lang": "python",
"repo": "martinoravsky/ryu",
"path": "/scripts/mininet/smaller.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> info('*** Starting switches\n')
net.get('s1').start([c0])
net.get('s2').start([c0])
net.get('s3').start([c0])
net.get('s4').start([c0])
net.get('s5').start([c0])
net.get('s6').start([c0])
net.get('s7').start([c0])
net.get('s8').start([c0])
net.get('s9').start([c0])
net.get('s10').start([c0])
n... | code_fim | hard | {
"lang": "python",
"repo": "martinoravsky/ryu",
"path": "/scripts/mininet/smaller.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> net = Mininet(topo=None, build=False, link=TCLink)
info('*** Adding controller\n')
c0 = net.addController(name='c0', controller=RemoteController, protocol='tcp', ip='127.0.0.1', port=6633)
info('*** Add switches\n')
s1 = net.addSwitch('s1', cls=OVSKernelSwitch, protocols='OpenFlow13')
s2 = net.add... | code_fim | hard | {
"lang": "python",
"repo": "martinoravsky/ryu",
"path": "/scripts/mininet/smaller.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eemcmullan/pygmt path: /pygmt/src/histogram.py
"""
Histogram - Create a histogram
"""
from pygmt.clib import Session
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias
<|fim_suffix|> Full option list at :gmt-docs:`histogram.html`
{aliases}
Param... | code_fim | hard | {
"lang": "python",
"repo": "eemcmullan/pygmt",
"path": "/pygmt/src/histogram.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> {aliases}
Parameters
----------
table : str, list, or 1d array
A data file name, list, or 1d numpy array. This is a required argument.
{J}
{R}
{B}
{CPT}
{G}
{W}
{c}
label : str
Add a legend entry for the symbol or line being plotted.
{p}... | code_fim | hard | {
"lang": "python",
"repo": "eemcmullan/pygmt",
"path": "/pygmt/src/histogram.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tdhd/data-science-retreat-svm path: /01_perceptron/sample_perceptron.py
import numpy as np
class Perceptron(object):
def __init__(self):
self.theta = None
def fit(self, X, y):
"""
Learns parameter vector self.theta from data X and binary labels y.
<|fim_suffix|... | code_fim | hard | {
"lang": "python",
"repo": "tdhd/data-science-retreat-svm",
"path": "/01_perceptron/sample_perceptron.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.theta = np.random.randn(X.shape[1], 1)
theta_updated = True
while theta_updated:
theta_updated = False
for i in range(X.shape[0]):
x, yy = X[i, :], y[i]
# if label yy and sign of decision function do not agree
... | code_fim | hard | {
"lang": "python",
"repo": "tdhd/data-science-retreat-svm",
"path": "/01_perceptron/sample_perceptron.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Occuliner/ThisHackishMess path: /modules/stockfunctions/picklestuff.py
# Copyright (c) 2013 Connor Sherson
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Per... | code_fim | hard | {
"lang": "python",
"repo": "Occuliner/ThisHackishMess",
"path": "/modules/stockfunctions/picklestuff.py",
"mode": "psm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Add all ze entities.
if not (networkClient is None):
givenState.networkNode = networkClient
givenState.networkingStarted = True
givenState.isClient = True
networkClient.playStateRef = weakref.ref( givenState )
for eachGhost in stateTuple.entityGhostList:
... | code_fim | hard | {
"lang": "python",
"repo": "Occuliner/ThisHackishMess",
"path": "/modules/stockfunctions/picklestuff.py",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Create a new playState
givenState = state.PlayState()
givenState.justEditing = justEditing
givenState.devMenuRef = devMenuRef
#Create the groups.
givenState.addGroup( EntityGroup(), name="levelWarpGroup" )
givenState.addGroup( EntityGroup(), isPlayerGroupBool=True )
given... | code_fim | hard | {
"lang": "python",
"repo": "Occuliner/ThisHackishMess",
"path": "/modules/stockfunctions/picklestuff.py",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: toasterco/gae-secure-scaffold-python path: /secure_scaffold/factories.py
import json
import os
from flask import Flask
from secure_scaffold import config
from secure_scaffold import xsrf
class AppFactory:
"""
Factory to generate a Flask app that includes the security config
"""
... | code_fim | hard | {
"lang": "python",
"repo": "toasterco/gae-secure-scaffold-python",
"path": "/secure_scaffold/factories.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> This method is meant to be overridden in the case
that a Flask app needs extra configuration.
By default it sets the app Secret Key.
:param Flask app: The Flask app that requires configuring.
:return: The configured Flask app.
:rtype: Flask
"""
... | code_fim | hard | {
"lang": "python",
"repo": "toasterco/gae-secure-scaffold-python",
"path": "/secure_scaffold/factories.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rociobeatrizc/plotly-dash-boilerplate path: /ex1_class.py
import dash
import dash_html_components as html
import dash_core_components as dcc
import plotly.graph_objects as go
import pandas as pd
import time
import seaborn as sns
import os
import plotly.express as px
# Info
# https://dash.plotly... | code_fim | hard | {
"lang": "python",
"repo": "rociobeatrizc/plotly-dash-boilerplate",
"path": "/ex1_class.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>> Molto bella
```python
import pandas as pd
path ="https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-andamento-nazionale/dpc-covid19-ita-andamento-nazionale.csv"
df_nazionale = pd.read_csv(path)
df_nazionale["data"] = pd.to_datetime(df_nazionale["data"]).dt.date
lista = ["data","ricoverati_c... | code_fim | hard | {
"lang": "python",
"repo": "rociobeatrizc/plotly-dash-boilerplate",
"path": "/ex1_class.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> __This will also be bold__
_You **can** combine them_
[Nome del link](https://www.youtube.com/?hl=it&gl=IT)
```python
import
```
''', highlight_config=dict(theme='light')),
], className="pretty_container"),
... | code_fim | hard | {
"lang": "python",
"repo": "rociobeatrizc/plotly-dash-boilerplate",
"path": "/ex1_class.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Naereen/notebooks path: /Generating_permutations_with_Python.py
t in OCaml](http://typeocaml.com/2015/05/05/permutation/),
# - [The documentation for itertools.permutations](https://docs.python.org/3/library/itertools.html#itertools.permutations).
#
# ## About
# - *Date:* 06/02/2017.
# - *Author... | code_fim | hard | {
"lang": "python",
"repo": "Naereen/notebooks",
"path": "/Generating_permutations_with_Python.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Find the largest movable element."""
def aux(acc, i):
if i >= len(a):
return acc
else:
if not is_movable(a, i):
return aux(acc, i + 1)
else:
x, _ = a[i]
if acc is None:
return... | code_fim | hard | {
"lang": "python",
"repo": "Naereen/notebooks",
"path": "/Generating_permutations_with_Python.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Then we need a function to scan the array `a`, from its beginning, to find the largest movable element.
# This can cost upto a time of $O(n)$ (if $n = \#a$), but it could hardly be improved.
# In[47]:
def scan_largest_movable(a):
"""Find the largest movable element."""
def aux(acc, i):
... | code_fim | hard | {
"lang": "python",
"repo": "Naereen/notebooks",
"path": "/Generating_permutations_with_Python.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if cmd in cmd_switch:
retval = cmd_switch[cmd]()
sys.exit(retval)
else:
sys.stdout.write("{} command not found\n".format(cmd))
sys.exit(1)<|fim_prefix|># repo: ekorian/deploypl path: /scripts/deploypl
#!/usr/bin/env python3
"""
deloypl
deploypl UNIX script
@author: K.Edeline
"""
import s... | code_fim | medium | {
"lang": "python",
"repo": "ekorian/deploypl",
"path": "/scripts/deploypl",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ekorian/deploypl path: /scripts/deploypl
#!/usr/bin/env python3
"""
deloypl
deploypl UNIX script
<|fim_suffix|>if cmd in cmd_switch:
retval = cmd_switch[cmd]()
sys.exit(retval)
else:
sys.stdout.write("{} command not found\n".format(cmd))
sys.exit(1)<|fim_middle|>@author: K.Edelin... | code_fim | hard | {
"lang": "python",
"repo": "ekorian/deploypl",
"path": "/scripts/deploypl",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>6230ac01'},
'Type': 'container',
'from': 'python:3.6.0b2',
'id': '343aaf89b2d6dc0e38c3a6bc6f44f96e50235f442970891586d87cd06230ac01',
'status': 'resize',
'time': 1479926693,
'timeNano': 1479926693526105094},
{'Action': 'die',
'Actor': {'Attributes': {'exitCode': '0',
'im... | code_fim | hard | {
"lang": "python",
"repo": "dimaqq/logah",
"path": "/foo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dimaqq/logah path: /foo.py
import requests_unixsocket
prefix = "http+unix://%2Fvar%2Frun%2Fdocker.sock"
s = requests_unixsocket.Session()
r = s.get(prefix + "/events")
events = r.iter_lines()
next(events)
next(events)
next(events)
next(events)
"""
[{'Action': 'create',
'Actor': {'Attributes':... | code_fim | hard | {
"lang": "python",
"repo": "dimaqq/logah",
"path": "/foo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> t = 0.678910
fmt = "%(ms).%(us)ms"
# According to the code, the number that replaces (ms) is *rounded*,
# so this formt should give "679.910ms". (See the next test case for the
# correct way to do this.)
result = strftimeEx(fmt, t)
expected = "679.910ms"
assert result == e... | code_fim | hard | {
"lang": "python",
"repo": "msarahan/chaco",
"path": "/chaco/scales/tests/test_formatters.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: msarahan/chaco path: /chaco/scales/tests/test_formatters.py
from chaco.scales.formatters import strftimeEx, TimeFormatter
#----------------------------------------------------------------
# strftimeEx tests
#----------------------------------------------------------------
def test_strftimeEx_... | code_fim | hard | {
"lang": "python",
"repo": "msarahan/chaco",
"path": "/chaco/scales/tests/test_formatters.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_strftimeEx_06():
"""Test rounding that affects the seconds."""
t = 7.9996
fmt = "%S %(ms)"
result = strftimeEx(fmt, t)
expected = "08 000"
print 'result = "%s" expected = "%s"' % (result, expected)
assert result == expected
def test_strftimeEx_07():
"""Test round... | code_fim | hard | {
"lang": "python",
"repo": "msarahan/chaco",
"path": "/chaco/scales/tests/test_formatters.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: a0barth/prance path: /prance/__init__.py
# -*- coding: utf-8 -*-
"""
Prance implements parsers for Swagger/OpenAPI 2.0 and 3.0.0 API specs.
See https://openapis.org/ for details on the specification.
Included is a BaseParser that reads and validates swagger specs, and a
ResolvingParser that add... | code_fim | hard | {
"lang": "python",
"repo": "a0barth/prance",
"path": "/prance/__init__.py",
"mode": "psm",
"license": "MITNFA",
"source": "the-stack-v2"
} |
<|fim_suffix|> from openapi_spec_validator import validate_v2_spec, validate_v3_spec
from jsonschema.exceptions import ValidationError as JSEValidationError
from jsonschema.exceptions import RefResolutionError
# Validate according to detected version. Unsupported versions are
# already caught outsid... | code_fim | hard | {
"lang": "python",
"repo": "a0barth/prance",
"path": "/prance/__init__.py",
"mode": "spm",
"license": "MITNFA",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __set_version(self, prefix, version):
self.version_name = prefix
self.version_parsed = version
import semver
self.semver = str(semver.VersionInfo(*version))
stringified = self.semver
if prefix == BaseParser.SPEC_VERSION_2_PREFIX:
stringified = '%d.%d' % (version[0], ve... | code_fim | hard | {
"lang": "python",
"repo": "a0barth/prance",
"path": "/prance/__init__.py",
"mode": "spm",
"license": "MITNFA",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: egemose/DroneVideoMeasure path: /projects/video_gallery.py
import json
import os
import random
import re
import subprocess
import logging
import flask
import ffmpeg
from app_config import data_dir, get_random_filename, celery, Task, Project, Video, db
from helper_functions import save_annotation... | code_fim | hard | {
"lang": "python",
"repo": "egemose/DroneVideoMeasure",
"path": "/projects/video_gallery.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@video_gallery_view.route('/videos/<project_id>/video_gallery')
def video_gallery(project_id):
videos = Video.query.filter_by(project_id=project_id).all()
random_int = random.randint(1, 10000000)
logger.debug(f'Render video_gallery for {project_id}')
return flask.render_template('video_ga... | code_fim | hard | {
"lang": "python",
"repo": "egemose/DroneVideoMeasure",
"path": "/projects/video_gallery.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def captureFunc():
count = 0
while(cap.isOpened()):
ret, frame = cap.read()
if ret == True:
cv2.imshow('frame', frame)
count = count + 1
if count == ratio:
cv2.imwrite("img.jpg", frame)
sendFile("img.jpg")
count = 0
if cv2.waitKey(1) & 0xFF == ord('q'):
break
... | code_fim | hard | {
"lang": "python",
"repo": "Rose-Hulman-Rover-Team/Rover-2019-2020",
"path": "/pi2/send.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Rose-Hulman-Rover-Team/Rover-2019-2020 path: /pi2/send.py
import numpy as np
import cv2
from socket import *
cap = cv2.VideoCapture(0)
FPS = cap.get(5)
setFPS = 10
ratio = int(FPS)/setFPS
host = "192.168.1.99"
port = 4096
addr = (host, port)
buf = 1024
def sendFile(fName):
... | code_fim | medium | {
"lang": "python",
"repo": "Rose-Hulman-Rover-Team/Rover-2019-2020",
"path": "/pi2/send.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Test Class for InvitedUser
"""
def test_invited_user_serialization(self):
"""
Test serialization/deserialization for InvitedUser
"""
# Construct a json representation of a InvitedUser model
invited_user_model_json = {}
invited_user_mode... | code_fim | hard | {
"lang": "python",
"repo": "KRuelY/platform-services-python-sdk",
"path": "/test/unit/test_user_management_v1.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KRuelY/platform-services-python-sdk path: /test/unit/test_user_management_v1.py
in req_param_dict.keys():
req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()}
with pytest.raises(ValueError):
service.update_user_profile... | code_fim | hard | {
"lang": "python",
"repo": "KRuelY/platform-services-python-sdk",
"path": "/test/unit/test_user_management_v1.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KRuelY/platform-services-python-sdk path: /test/unit/test_user_management_v1.py
responses.add(responses.PATCH,
url,
status=204)
# Set up parameter values
account_id = 'testString'
iam_id = 'testString'
firstname = ... | code_fim | hard | {
"lang": "python",
"repo": "KRuelY/platform-services-python-sdk",
"path": "/test/unit/test_user_management_v1.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> num_living_neighbors = 2
self.assertEqual(cell.is_alive(num_living_neighbors), False)
num_living_neighbors = 3
self.assertEqual(cell.is_alive(num_living_neighbors), True)
if __name__ == '__main__':
unittest.main()<|fim_prefix|># repo: cdated/conway-curses path: /test... | code_fim | hard | {
"lang": "python",
"repo": "cdated/conway-curses",
"path": "/tests/cell_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cdated/conway-curses path: /tests/cell_test.py
#!/usr/bin/env python
import unittest
from ..cell import Cell
class Test_Cell(unittest.TestCase):
def setUp(self):
self.cell = Cell(alive=True, position=(-1,-1), bounds=(-5,0))
def test_cell_position_on_init(self):
new_cel... | code_fim | medium | {
"lang": "python",
"repo": "cdated/conway-curses",
"path": "/tests/cell_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def shape(self):
return self.height, self.width, 3
def imshow(self, image: np.ndarray):
cv2.imshow(self.name, image)
cv2.waitKey(self.delay)
cv2.waitKey(self.delay) # magic
def destroyWindow(self):
cv2.destroyWindow(self.name)<|fim_prefi... | code_fim | hard | {
"lang": "python",
"repo": "elerac/fullscreen",
"path": "/fullscreen/cv2_fullscreen.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: elerac/fullscreen path: /fullscreen/cv2_fullscreen.py
import numpy as np
import cv2
import screeninfo # https://github.com/rr-/screeninfo
class FullScreen:
"""Full-screen with OpenCV High-level GUI backend"""
delay: int = 1 # internal delay time after imshow
<|fim_suffix|> def im... | code_fim | hard | {
"lang": "python",
"repo": "elerac/fullscreen",
"path": "/fullscreen/cv2_fullscreen.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> year = models.IntegerField(default=0)
demography = models.ForeignKey(Demography, related_name='question_year_permutations', null=True)
question = models.ForeignKey(Question, related_name='demog_year_permutations', null=True)
class Meta:
unique_together = ('year', 'demography', 'qu... | code_fim | medium | {
"lang": "python",
"repo": "the-fool/atat",
"path": "/atat/responses/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: the-fool/atat path: /atat/responses/models.py
from django.db import models
from atat.questions.models import Question
from django.contrib.postgres.fields import HStoreField, JSONField
class Demography(models.Model):
<|fim_suffix|> year = models.IntegerField(default=0)
demography = models... | code_fim | hard | {
"lang": "python",
"repo": "the-fool/atat",
"path": "/atat/responses/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iammanish17/CP-templates path: /templates/dynamic programming/lis.py
from math import inf
from bisect import bisect_left
def get_lis(a):
"""Returns the length of the longest increasing subsequence of array!"""
dp = [0]*len(a)
aux = [inf]*(len(a)+1)
aux[0] = -inf
high = 0
... | code_fim | medium | {
"lang": "python",
"repo": "iammanish17/CP-templates",
"path": "/templates/dynamic programming/lis.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Returns an increasing subsequence of array of length k (if found)."""
if k > len(a):
return None
dp = [0] * len(a)
aux = [inf] * (k + 1)
aux[0] = -inf
high = 0
for i in range(len(a)):
dp[i] = bisect_left(aux, a[i])
aux[dp[i]] = min(aux[dp[i]], a[i])
... | code_fim | medium | {
"lang": "python",
"repo": "iammanish17/CP-templates",
"path": "/templates/dynamic programming/lis.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> grid = QGridLayout()
self.setLayout(grid)
grid.addWidget(btn, 0, 0)
grid.addWidget(qbtn, 1, 0)
def make_ebook_button(self):
name, ftype = QFileDialog.getOpenFileName(self, filter="EPUB (*.epub)")
if name:
q = queue.Queue(maxsize=1)
... | code_fim | hard | {
"lang": "python",
"repo": "zachary822/ebook_translator",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zachary822/ebook_translator path: /main.py
import queue
import sys
import threading
from PyQt5.QtWidgets import QApplication, QFileDialog, QGridLayout, QPushButton, QWidget
from ebooklib import epub
from ebook_converter import book_to_traditional
class ConvertBook(threading.Thread):
def _... | code_fim | hard | {
"lang": "python",
"repo": "zachary822/ebook_translator",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.is_residual = use_skip_connection and (in_size == out_size)
self.block = nn.Sequential(
nn.Conv2d(in_size, out_size, kernel_size=3, padding=1),
ReparametrizedBatchNorm2d(out_size) if use_bn else Identity(),
activation(),
Identity() if (... | code_fim | hard | {
"lang": "python",
"repo": "mmrahman21/loss-patterns",
"path": "/src/models/conv_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mmrahman21/loss-patterns path: /src/models/conv_model.py
from typing import List
import torch.nn as nn
from firelab.config import Config
from src.model_zoo.layers import Flatten, Identity
from src.models.layers import ReparametrizedBatchNorm2d
class ConvModel(nn.Module):
def __init__(self,... | code_fim | hard | {
"lang": "python",
"repo": "mmrahman21/loss-patterns",
"path": "/src/models/conv_model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>_delta = until_date_delta[1].split(":")
else:
until_date_delta_days = 0
until_date_delta = until_date_delta[0].split(":")
if int(until_date_delta_days) != 0:
until_date_text += " "
until_date_text += str(int(until_date_delta_days))
if str(int(until_date_delta_days))[-1] in... | code_fim | hard | {
"lang": "python",
"repo": "NexonSU/telegram-python-chatbot",
"path": "/commands/ban.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NexonSU/telegram-python-chatbot path: /commands/ban.py
member = update.effective_chat.get_member(update.message.from_user.id)
if (member.can_restrict_members) or (member.status == "creator") or (member.user.name in config.telegram_admins) or (member.user.name in config.telegram_moders):
if (len(... | code_fim | hard | {
"lang": "python",
"repo": "NexonSU/telegram-python-chatbot",
"path": "/commands/ban.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>ут"
elif str(int(until_date_delta[1]))[-1] in ["2", "3", "4"]:
until_date_text += " минуты"
else:
until_date_text += " минуту"
if int(until_date_delta[2]) != 0:
until_date_text += " "
until_date_text += str(int(until_date_delta[2]))
if str(int(until_date_delta[2]))... | code_fim | hard | {
"lang": "python",
"repo": "NexonSU/telegram-python-chatbot",
"path": "/commands/ban.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jhandley/pyvcproj path: /examples/fix_link_incremental_edit_and_continue_mismatch.py
#!/usr/bin/python
# Fixes the following warning:
# warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO'
# specification
# Pass in path to solution file.
# For any project that has debu... | code_fim | medium | {
"lang": "python",
"repo": "jhandley/pyvcproj",
"path": "/examples/fix_link_incremental_edit_and_continue_mismatch.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(argv) < 2:
print("Usage: " + argv[0] + " <solution file>")
sys.exit(2)
solution_path = argv[1]
solution_dir = os.path.dirname(solution_path)
solution = vcproj.solution.parse(solution_path)
for project_file in solution.project_files():
project = vcproj.project.parse(os.path... | code_fim | medium | {
"lang": "python",
"repo": "jhandley/pyvcproj",
"path": "/examples/fix_link_incremental_edit_and_continue_mismatch.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main(argv):
if len(argv) < 2:
print("Usage: " + argv[0] + " <solution file>")
sys.exit(2)
solution_path = argv[1]
solution_dir = os.path.dirname(solution_path)
solution = vcproj.solution.parse(solution_path)
for project_file in solution.project_files():
project = vcproj.proje... | code_fim | medium | {
"lang": "python",
"repo": "jhandley/pyvcproj",
"path": "/examples/fix_link_incremental_edit_and_continue_mismatch.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> for p in paths:
print(p)
if __name__ == '__main__':
main()<|fim_prefix|># repo: johanbenzi/LibraryService path: /deploy/k8s/tools/get-deps
#!/usr/bin/env python3
import argparse
import os.path
def main():
parser = argparse.ArgumentParser()
parser.add_argument('dirs', metavar=... | code_fim | medium | {
"lang": "python",
"repo": "johanbenzi/LibraryService",
"path": "/deploy/k8s/tools/get-deps",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: johanbenzi/LibraryService path: /deploy/k8s/tools/get-deps
#!/usr/bin/env python3
import argparse
import os.path
def main():
parser = argparse.ArgumentParser()
parser.add_argument('dirs', metavar='DIR', nargs='+')
args = parser.parse_args()
paths = list(args.dirs)
queue = ... | code_fim | medium | {
"lang": "python",
"repo": "johanbenzi/LibraryService",
"path": "/deploy/k8s/tools/get-deps",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def _parse_commit(data):
def parse_contribution(data):
time = data.get('time')
if time is not None: # pragma: no branch
time = parse_time(time)
return Contribution(
name=data.get('name'),
email=data.get('email'),
time=time)
return Commit(
sha=data['co... | code_fim | hard | {
"lang": "python",
"repo": "luci/luci-py",
"path": "/appengine/components/components/gitiles.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: luci/luci-py path: /appengine/components/components/gitiles.py
# Copyright 2014 The LUCI Authors. All rights reserved.
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.
"""Gitiles functions for GAE environment."""
import base64
... | code_fim | hard | {
"lang": "python",
"repo": "luci/luci-py",
"path": "/appengine/components/components/gitiles.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: janelia-flyem/flyemflows path: /tests/workflows/test_decimatemeshes.py
import os
import pickle
import tempfile
import textwrap
from io import StringIO
import pytest
from ruamel.yaml import YAML
import numpy as np
import pandas as pd
from scipy.ndimage import distance_transform_edt
from neuclea... | code_fim | hard | {
"lang": "python",
"repo": "janelia-flyem/flyemflows",
"path": "/tests/workflows/test_decimatemeshes.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> df = pd.DataFrame( np.load(f'{stats_dir}/mesh-stats.npy', allow_pickle=True) )
assert len(df) == (len(subset_labels) + len(skipped_labels))
df.set_index('body', inplace=True)
for label in subset_labels:
assert df.loc[label, 'result'] == 'success'
# Here's where our t... | code_fim | hard | {
"lang": "python",
"repo": "janelia-flyem/flyemflows",
"path": "/tests/workflows/test_decimatemeshes.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.