text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: pedromaia02/ls_deploy path: /financeiro/src/posts/views.py
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render,get_object_or_404,redirect
from django.contrib import messages
from django.db.models import Sum
import json
# from django.views.generic.edit im... | code_fim | hard | {
"lang": "python",
"repo": "pedromaia02/ls_deploy",
"path": "/financeiro/src/posts/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Artistwithsword/Fiance path: /project/strategy/pingan_ma5.py
# /*
# * @Author: PCChris: https://github.com/PCChris1995/Fiance
# * @Date: 2018-09-20 10:27:09
# * @Last Modified by: PCChris
# * @Last Modified time: 2018-09-20 10:27:09
# */
#
import matplotlib.pyplot as plt
from pandas i... | code_fim | hard | {
"lang": "python",
"repo": "Artistwithsword/Fiance",
"path": "/project/strategy/pingan_ma5.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> record_stock_dict = dict()
df_capital = dict()
rest_cash = CASH
hold_stock_dict = dict()
hold_date = set()
capital = CASH
for date in df_daily.index:
price = df_daily.loc[date]['close']
if df_daily.loc[date]['buy_signal']:
# price = df_daily.loc[dat... | code_fim | hard | {
"lang": "python",
"repo": "Artistwithsword/Fiance",
"path": "/project/strategy/pingan_ma5.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> df_daily = df_daily[df_daily['buy_signal'] | df_daily['sell_signal']]
record_stock_dict = dict()
df_capital = dict()
rest_cash = CASH
hold_stock_dict = dict()
hold_date = set()
capital = CASH
for date in df_daily.index:
price = df_daily.loc[date]['close']
... | code_fim | hard | {
"lang": "python",
"repo": "Artistwithsword/Fiance",
"path": "/project/strategy/pingan_ma5.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> allow_empty = True
model = CampusSustainabilityOfficer
queryset = CampusSustainabilityOfficer.objects.order_by('organization__picklist_name')<|fim_prefix|># repo: rerb/django-irc path: /rc/resources/apps/officers/views.py
from django.views.generic.list import ListView
from rc.resources.apps.o... | code_fim | easy | {
"lang": "python",
"repo": "rerb/django-irc",
"path": "/rc/resources/apps/officers/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rerb/django-irc path: /rc/resources/apps/officers/views.py
from django.views.generic.list import ListView
from rc.resources.apps.officers.models import *
from rc.resources.views import ResourceItemListView
<|fim_suffix|> allow_empty = True
model = CampusSustainabilityOfficer
queryset ... | code_fim | easy | {
"lang": "python",
"repo": "rerb/django-irc",
"path": "/rc/resources/apps/officers/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: weilaidb/python_dd path: /16/using_sys.py
#!/usr/bin/python
#Filename:using_sys.py
import sys
#print 'sys argument nums:',count(sys.argv)
print '<|fim_suffix|> print i
print '\n\nThe PYTHONPATH is',sys.path,'\n'<|fim_middle|>The command line arguments are:'
for i in sys.argv:
| code_fim | easy | {
"lang": "python",
"repo": "weilaidb/python_dd",
"path": "/16/using_sys.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: weilaidb/python_dd path: /16/using_sys.py
#!/usr/bin/python
#Filename:using_sys.py
import sys<|fim_suffix|>The command line arguments are:'
for i in sys.argv:
print i
print '\n\nThe PYTHONPATH is',sys.path,'\n'<|fim_middle|>
#print 'sys argument nums:',count(sys.argv)
print ' | code_fim | easy | {
"lang": "python",
"repo": "weilaidb/python_dd",
"path": "/16/using_sys.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print i
print '\n\nThe PYTHONPATH is',sys.path,'\n'<|fim_prefix|># repo: weilaidb/python_dd path: /16/using_sys.py
#!/usr/bin/python
#Filename:using_sys.py
import sys<|fim_middle|>
#print 'sys argument nums:',count(sys.argv)
print 'The command line arguments are:'
for i in sys.argv:
| code_fim | medium | {
"lang": "python",
"repo": "weilaidb/python_dd",
"path": "/16/using_sys.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mrbig0503/Tensorflow_projects path: /Simples/SimpleRandomUniform/run.py
from __future__ import division, absolute_import, print_function
import numpy as np
import tensorflow as tf
<|fim_suffix|>with tf.Session() as sess:
print(sess.run(output, feed_dict={inputs:data}))
tf.train.write_gra... | code_fim | medium | {
"lang": "python",
"repo": "mrbig0503/Tensorflow_projects",
"path": "/Simples/SimpleRandomUniform/run.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>with tf.Session() as sess:
print(sess.run(output, feed_dict={inputs:data}))
tf.train.write_graph(tf.get_default_graph(), "my-model", "SimpleRandomUniform.pb", as_text=False)<|fim_prefix|># repo: mrbig0503/Tensorflow_projects path: /Simples/SimpleRandomUniform/run.py
from __future__ import divisio... | code_fim | medium | {
"lang": "python",
"repo": "mrbig0503/Tensorflow_projects",
"path": "/Simples/SimpleRandomUniform/run.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> g()
driver.quit()
def g():
path = os.path.expanduser('~/Downloads')
mylist = os.listdir(path)
mylist = [os.path.join(path, file) for file in mylist]
abstractfile = max(mylist, key=os.path.getmtime)
print open(abstractfile).read()
getACMBibTeX()<|fim_prefix|># repo: staceyirawan/PaperCloud path... | code_fim | hard | {
"lang": "python",
"repo": "staceyirawan/PaperCloud",
"path": "/project2/app/Http/Controllers/site-packages/getACMBibTeX.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: staceyirawan/PaperCloud path: /project2/app/Http/Controllers/site-packages/getACMBibTeX.py
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selen... | code_fim | hard | {
"lang": "python",
"repo": "staceyirawan/PaperCloud",
"path": "/project2/app/Http/Controllers/site-packages/getACMBibTeX.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> time.sleep(1)
g()
driver.quit()
def g():
path = os.path.expanduser('~/Downloads')
mylist = os.listdir(path)
mylist = [os.path.join(path, file) for file in mylist]
abstractfile = max(mylist, key=os.path.getmtime)
print open(abstractfile).read()
getACMBibTeX()<|fim_prefix|># repo: staceyirawan/... | code_fim | hard | {
"lang": "python",
"repo": "staceyirawan/PaperCloud",
"path": "/project2/app/Http/Controllers/site-packages/getACMBibTeX.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("输入的字符串为:", sourceStr)
#a提取字符串中的数字组成新串
numStr = "".join(re.findall('[\d+]', sourceStr))
print("提取的数字字符串为:",numStr)
"""
#b.统计字符串中的字母出现的次数,输出字典
"""
#提取非数字的字符并转换为小写字母
notNumList = [ch.lower() for ch in re.findall('[^\d+]', sourceStr)]
#统计各个字母出现... | code_fim | hard | {
"lang": "python",
"repo": "Negen9527/Python",
"path": "/1029/1029.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
#b.统计字符串中的字母出现的次数,输出字典
"""
#提取非数字的字符并转换为小写字母
notNumList = [ch.lower() for ch in re.findall('[^\d+]', sourceStr)]
#统计各个字母出现的次数并按字母升序排列
result = sorted(Counter(notNumList).items(), key=lambda k:k[0], reverse=False)
countNumDic = {k:v for k,v in result}
p... | code_fim | hard | {
"lang": "python",
"repo": "Negen9527/Python",
"path": "/1029/1029.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Negen9527/Python path: /1029/1029.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File : 1029.py
# @Author: Negen
# @Date : 2018/10/29/029
# @Desc :
from random import randint
from collections import Counter
import re
"""
统计一百个0-9之间的随机整数各自出现的次数,返回字典
结果:{6: 18, 3: 7, 1: 7, 9: 10, 2: 9, ... | code_fim | hard | {
"lang": "python",
"repo": "Negen9527/Python",
"path": "/1029/1029.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: a5830017/account-web-app path: /account/urls.py
from django.conf.urls import url
from . import views
app_name = 'account'
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'), #first page -- index
url(r'^accountsetting/$', views.AccSetting, name='accountsetting'), #accoun... | code_fim | hard | {
"lang": "python",
"repo": "a5830017/account-web-app",
"path": "/account/urls.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>l(r'^(?P<pk>[0-9]+)/sellisttodel/$', views.SelDelList.as_view(), name='seldellist'),
url(r'^(?P<account_id>[0-9]+)/sellisttodel/deletelist/$', views.dellist, name='dellist'),
url(r'^(?P<account_id>[0-9]+)/showtotalmoney/$', views.caltotal, name='showtotal'),
]<|fim_prefix|># repo: a5830017/account... | code_fim | hard | {
"lang": "python",
"repo": "a5830017/account-web-app",
"path": "/account/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: himanthis/GitDemo path: /functionsdemo.py
# function declaration
def GreetMe(name):
<|fim_suffix|># AddIntegers(2, 3)
print(AddIntegers(2,3))<|fim_middle|> print("Good Morning" + name)
def AddIntegers(a, b):
# print(a + b)
return a+b
# function call
GreetMe("Himanthi Siriwardane")... | code_fim | medium | {
"lang": "python",
"repo": "himanthis/GitDemo",
"path": "/functionsdemo.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: himanthis/GitDemo path: /functionsdemo.py
# function declaration
<|fim_suffix|>
# function call
GreetMe("Himanthi Siriwardane")
# AddIntegers(2, 3)
print(AddIntegers(2,3))<|fim_middle|>def GreetMe(name):
print("Good Morning" + name)
def AddIntegers(a, b):
# print(a + b)
return a+b... | code_fim | medium | {
"lang": "python",
"repo": "himanthis/GitDemo",
"path": "/functionsdemo.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># function call
GreetMe("Himanthi Siriwardane")
# AddIntegers(2, 3)
print(AddIntegers(2,3))<|fim_prefix|># repo: himanthis/GitDemo path: /functionsdemo.py
# function declaration
def GreetMe(name):
print("Good Morning" + name)
<|fim_middle|>def AddIntegers(a, b):
# print(a + b)
return a+b
... | code_fim | easy | {
"lang": "python",
"repo": "himanthis/GitDemo",
"path": "/functionsdemo.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bryan-menendez/mvn_suggestion_box path: /box/urls.py
from django.urls import path
from django.conf.urls import include
from . import views
urlpat<|fim_suffix|>sug/add', views.SuggestionCreate.as_view()),
]<|fim_middle|>terns = [
path('', views.index),
path(' | code_fim | easy | {
"lang": "python",
"repo": "bryan-menendez/mvn_suggestion_box",
"path": "/box/urls.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>sug/add', views.SuggestionCreate.as_view()),
]<|fim_prefix|># repo: bryan-menendez/mvn_suggestion_box path: /box/urls.py
from django.urls import path
from django.conf.urls import include
from . import views
urlpat<|fim_middle|>terns = [
path('', views.index),
path(' | code_fim | easy | {
"lang": "python",
"repo": "bryan-menendez/mvn_suggestion_box",
"path": "/box/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Alfredogomes/LabBio_Trabalho path: /src/uniprot.py
#!/usr/bin/env python3
"""
Uniprot
=======
For a given protein file, fetches from Uniprot the accession, keywords and go
of each protein.
Usage:
$ ./uniprot proteins -o uniprot.csv
"""
import argparse
import csv
import sys
import re
impor... | code_fim | medium | {
"lang": "python",
"repo": "Alfredogomes/LabBio_Trabalho",
"path": "/src/uniprot.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser = argparse.ArgumentParser()
parser.add_argument("proteins", type=argparse.FileType('r'),
default=PROTEINS, nargs='?',
help="File containing a list of proteins")
parser.add_argument("-o", "--outfile", type=argparse.FileType('w'),
... | code_fim | medium | {
"lang": "python",
"repo": "Alfredogomes/LabBio_Trabalho",
"path": "/src/uniprot.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Dihfahsih1/church_system path: /accounts/views.py
= EditProfileForm(instance=request.user)
args = {'form': form}
return render(request, 'accounts/edit_profile.html', args)
@login_required
def change_password(request):
if request.method == 'POST':
form = PasswordChang... | code_fim | hard | {
"lang": "python",
"repo": "Dihfahsih1/church_system",
"path": "/accounts/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> context = {'archived_reports': archived_reports,
'months': months,
'years': years,
'expenses':salary,
'total_amount': total_amount,
'today': today,
'report_year': report_year,
... | code_fim | hard | {
"lang": "python",
"repo": "Dihfahsih1/church_system",
"path": "/accounts/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Dihfahsih1/church_system path: /accounts/views.py
talsundry,
}
return Render.render('accounts/sundrypdf.html', sundrycontext)
##################################
# This produces the general financial report for all drivers
##################################
def driver_general_... | code_fim | hard | {
"lang": "python",
"repo": "Dihfahsih1/church_system",
"path": "/accounts/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kristinatub/MIS-Projects path: /icecream.py
import desserts
class Icecream (desserts.Desserts):
#define attributes
def __init__(self,name,kind):
super().__init__(name,kind)
self.__size=""
self.__price=0
#return size
def get_size(self):
return self._... | code_fim | medium | {
"lang": "python",
"repo": "kristinatub/MIS-Projects",
"path": "/icecream.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.__size == "S":
self.__price=1.49
elif self.__size=="M":
self.__price=1.99
else:
self.__price=2.49
return True
#define calculate cost
def calculate_cost(self):
total = self.__price * self... | code_fim | hard | {
"lang": "python",
"repo": "kristinatub/MIS-Projects",
"path": "/icecream.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Translates a matched URL to an ORM row, which becomes the context.
"""
# This yields the "context", which should be the row object
try:
q = model.session.query(self.sqla_table)
q = self.filter_sqlalchemy_query(q, request)
return q.one()
... | code_fim | hard | {
"lang": "python",
"repo": "setheus/floof",
"path": "/floof/routing.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Administration
r('admin.dashboard', '/admin')
r('admin.log', '/admin/log')
# Debugging
r('debug.blank', '/debug/blank')
r('debug.crash', '/debug/crash')
r('debug.mako-crash', '/debug/mako-crash')
r('debug.status.303', '/debug/303')
r('debug.status.400', '/debug/400')... | code_fim | hard | {
"lang": "python",
"repo": "setheus/floof",
"path": "/floof/routing.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: setheus/floof path: /floof/routing.py
"""Routing configuration, broken out separately for ease of consultation
without going through the whole app config everything.
Some useful helpers are at the bottom. Be familiar with them!
"""
import re
import floof.model as model
from floof.resource impo... | code_fim | hard | {
"lang": "python",
"repo": "setheus/floof",
"path": "/floof/routing.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hindusteve/safefamilies path: /needs/admin.py
# Django imports...
from django.contrib import admin
# Local imports...
from .models import Commitment, Need, Recipient, RecipientNeed
@admin.register(Commitment)
class CommitmentAdmin(admin.ModelAdmin):
fields = ('user', 'recipient_need', 'sta... | code_fim | hard | {
"lang": "python",
"repo": "hindusteve/safefamilies",
"path": "/needs/admin.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fields = ('recipient', 'need', 'quantity', 'status', 'created', 'updated')
list_display = ('recipient', 'need', 'quantity', 'status', 'created', 'updated')
raw_id_fields = ('recipient', 'need')
list_select_related = ('recipient', 'need')
autocomplete_lookup_fields = {
'fk': ('r... | code_fim | hard | {
"lang": "python",
"repo": "hindusteve/safefamilies",
"path": "/needs/admin.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>@admin.register(Recipient)
class RecipientAdmin(admin.ModelAdmin):
fields = ('first_name', 'last_name', 'phone_number', 'address_1', 'address_2', 'city', 'state', 'zip_code')
list_display = ('first_name', 'last_name', 'phone_number', 'address_1', 'address_2', 'city', 'state', 'zip_code')
@admin.... | code_fim | medium | {
"lang": "python",
"repo": "hindusteve/safefamilies",
"path": "/needs/admin.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Coordinates have to be flipped in order to work in overpass
if geometry.geom_type == 'Polygon':
west, south, east, north = geometry.bounds
return BoundingBox(south, west, north, east)
elif geometry.geom_type == 'MultiPolygon':
bboxs = (Bounding... | code_fim | hard | {
"lang": "python",
"repo": "astrosat/cOSMos",
"path": "/cosmos/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> geocoder = Nominatim()
location = geocoder.geocode(name, geometry='geojson')
try:
geometry = shape(location.raw['geojson'])
# Coordinates have to be flipped in order to work in overpass
if geometry.geom_type == 'Polygon':
west, south, east, north = geometr... | code_fim | hard | {
"lang": "python",
"repo": "astrosat/cOSMos",
"path": "/cosmos/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Result Table placeholder
st.subheader('Search result')
result_table = st.empty()
# Map displaying search results
display_map = st.sidebar.radio('Display Map', ('Yes', 'No'), index=1)
if display_map == 'Yes':
st.write('')
st.subheader('Map')
geo_df = geo.get_coords(result['Name'])
st.map... | code_fim | medium | {
"lang": "python",
"repo": "KidMarten/travel_app",
"path": "/app/travel_app.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KidMarten/travel_app path: /app/travel_app.py
import streamlit as st
import pandas as pd
import numpy as np
from utils import conf, frontend, geo
from ml.search import query
from PIL import Image
frontend.set_max_width(1200)
# Wallpaper at the top of the page
wallpaper = Image.open('static_data... | code_fim | medium | {
"lang": "python",
"repo": "KidMarten/travel_app",
"path": "/app/travel_app.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># Filter on number of search results
num_results = st.sidebar.slider("Number of search results", min_value=3, max_value=20, value=10)
# Decision box of recommendation model
model_name = st.sidebar.selectbox(
'Chose the search algorithm',
('Tf-Idf', 'LDA', 'Doc2Vec')
)
# Request Dataframe
resul... | code_fim | medium | {
"lang": "python",
"repo": "KidMarten/travel_app",
"path": "/app/travel_app.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """p4_coderjoes = model.Project("CoderJoes Store", url_for('p4_coderjoes_bp.index'), "/static/img/p4_coderjoes.png",
"P4 Guessers",
["Lola Bulkin", "Grace Le", "Ryan Moghaddas", "William Cherres", "Brayden Basinger"],
... | code_fim | hard | {
"lang": "python",
"repo": "colin-szeto/flask-idea-portfolio",
"path": "/data_p4.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: colin-szeto/flask-idea-portfolio path: /data_p4.py
"""Data file for Period 4"""
import model # projects definitions are placed in different file
from flask import url_for
def setup():
"""EXAMPLE = model.Project("Example", url_for('teacher_bp.index'), "/static/img/teacher.png", "Team Teach... | code_fim | hard | {
"lang": "python",
"repo": "colin-szeto/flask-idea-portfolio",
"path": "/data_p4.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nileshbhadana/pyautomaxprocs path: /automaxprocs/cgroups/cgroup.py
# -*- coding: utf-8 -*-
import os
class CGroup:
def __init__(self, path):
<|fim_suffix|> def param_path(self, param):
return os.path.join(self.path, param)
def read_first_line(self, param):
file_path... | code_fim | medium | {
"lang": "python",
"repo": "nileshbhadana/pyautomaxprocs",
"path": "/automaxprocs/cgroups/cgroup.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> file_path = self.param_path(param)
with open(file_path, "r") as reader:
for row in reader:
if row:
return row.strip()
def read_int(self, param):
try:
first_row = self.read_first_line(param)
except FileNotFound... | code_fim | medium | {
"lang": "python",
"repo": "nileshbhadana/pyautomaxprocs",
"path": "/automaxprocs/cgroups/cgroup.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: azulth/project-euler path: /002.py
# Find the sum of even valued Fibonacci sequence numbers under four million.
<|fim_suffix|>if __name__ == "__main__":
print(solve())<|fim_middle|>def solve():
term1 = 1
term2 = 2
answer = 0
while term2 < 4000000:
if term2 % 2... | code_fim | hard | {
"lang": "python",
"repo": "azulth/project-euler",
"path": "/002.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
print(solve())<|fim_prefix|># repo: azulth/project-euler path: /002.py
# Find the sum of even valued Fibonacci sequence numbers under four million.
def solve():
term1 = 1
term2 = 2
answer = 0
while term2 < 4000000:
if term2 % 2 == 0:
... | code_fim | easy | {
"lang": "python",
"repo": "azulth/project-euler",
"path": "/002.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: raquelsouto/python path: /uri-online-judge/1134.py
cont3 = 0
cont2 = 0
cont1 = 0
codigo = 1
while codigo != 4:
codigo = int(inp<|fim_suffix|>Alcool: %d' %(cont1))
print('Gasolina: %d' %(cont2))
print('Diesel: %d' %(cont3))<|fim_middle|>ut())
if codigo == 1:
cont1 += 1
elif cod... | code_fim | medium | {
"lang": "python",
"repo": "raquelsouto/python",
"path": "/uri-online-judge/1134.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> += 1
elif codigo == 3:
cont3 += 1
print('MUITO OBRIGADO')
print('Alcool: %d' %(cont1))
print('Gasolina: %d' %(cont2))
print('Diesel: %d' %(cont3))<|fim_prefix|># repo: raquelsouto/python path: /uri-online-judge/1134.py
cont3 = 0
cont2 = 0
cont1 = 0
codigo = 1
while codigo != 4:
codigo ... | code_fim | medium | {
"lang": "python",
"repo": "raquelsouto/python",
"path": "/uri-online-judge/1134.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def checkIntegrity(self):
controle = 0
controle += int(self.taille,16)
controle += int(self.org,16)
controle += int(self.data[0:2],16)
controle += int(self.data[2:4],16)
controle += int(self.data[4:6],16)
controle += int(self.data[6:8],16)
controle += int(self.id[0:2],16)
controle += i... | code_fim | hard | {
"lang": "python",
"repo": "Mogier/ghome",
"path": "/client_trame/Trame.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Mogier/ghome path: /client_trame/Trame.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime
import utils
import analyseur as a
class Trame:
def __init__(self, taille, org, data, id, status, checksum):
self.taille = taille
self.org = org
self.data = data
self.id = id
self... | code_fim | hard | {
"lang": "python",
"repo": "Mogier/ghome",
"path": "/client_trame/Trame.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def get_hist_bars(
self,
security: Security,
bar_size: pd.Timedelta,
start_date: pd.Timestamp,
end_date: Optional[pd.Timestamp] = None,
) -> Union[pd.DataFrame, type(NotImplemented)]:
# validate security
if not isinstance(security, Stoc... | code_fim | hard | {
"lang": "python",
"repo": "webclinic017/aqua",
"path": "/src/aqua/market_data/polygon/polygon.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: webclinic017/aqua path: /src/aqua/market_data/polygon/polygon.py
"""
Polygon.io market data
"""
import asyncio
import logging
import os
import urllib.parse
from typing import Any, Mapping, Optional, Union
import aiohttp
import pandas as pd
from dotenv import load_dotenv
from aqua.market_data im... | code_fim | hard | {
"lang": "python",
"repo": "webclinic017/aqua",
"path": "/src/aqua/market_data/polygon/polygon.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: minhtuev/euler path: /problem77.py
from numlib import get_next_prime, is_prime
from utilities import memoize
<|fim_suffix|>def main():
n = 50
m = compute_prime_sum(n, 2)
while (m <= 5000):
n += 1
m = compute_prime_sum(n, 2)
print n, m
main()<|fim_middle|>def compute_prime_sum(n, min_pri... | code_fim | hard | {
"lang": "python",
"repo": "minhtuev/euler",
"path": "/problem77.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> n = 50
m = compute_prime_sum(n, 2)
while (m <= 5000):
n += 1
m = compute_prime_sum(n, 2)
print n, m
main()<|fim_prefix|># repo: minhtuev/euler path: /problem77.py
from numlib import get_next_prime, is_prime
from utilities import memoize
def compute_prime_sum(n, min_prime):
<|fim_middle|> if n <... | code_fim | hard | {
"lang": "python",
"repo": "minhtuev/euler",
"path": "/problem77.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> current = head
while current:
print(current.data,end=' ')
current = current.next
def removeDuplicates(self,head):
"""
counterNode = it travels on linked list for duplicate data.
currentNode = it shows actual node to compare count... | code_fim | hard | {
"lang": "python",
"repo": "aesavas/HackerRank",
"path": "/30 Days of Code/Day 24 - More Linked Lists/solution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aesavas/HackerRank path: /30 Days of Code/Day 24 - More Linked Lists/solution.py
"""
author : Ali Emre SAVAS
Link : https://www.hackerrank.com/challenges/30-linked-list-deletion/problem
"""
class Node:
def __init__(self,data):
self.data = data
self.next = None
class ... | code_fim | hard | {
"lang": "python",
"repo": "aesavas/HackerRank",
"path": "/30 Days of Code/Day 24 - More Linked Lists/solution.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> last=1
acc+=1
if(acc==peek):
peek+=1
ans+=1
ans+=acc
return int(ans)<|fim_prefix|># repo: juanfesba/PracticeProgramming path: /LeetCode/Hard/Greedy/problem135.py
class Solution:
... | code_fim | hard | {
"lang": "python",
"repo": "juanfesba/PracticeProgramming",
"path": "/LeetCode/Hard/Greedy/problem135.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: juanfesba/PracticeProgramming path: /LeetCode/Hard/Greedy/problem135.py
class Solution:
def candy(self, arr: List[int]) -> int:
for e in range(len(arr)):
if e==0:
ans=1
peek=1
last=1
<|fim_suffix|> last=1
... | code_fim | hard | {
"lang": "python",
"repo": "juanfesba/PracticeProgramming",
"path": "/LeetCode/Hard/Greedy/problem135.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: R083rtKr01/PythonBasic path: /P39.py
#ćwiczenie 39
WordToNums={}
WordToNums["jeden"] = 1
WordToNums["dwa"] = 2
WordToNums["trzy"] = 3
WordToNums["cztery"] = 4
WordToNums["pięć"] = 5
wybrany=input("Podaj cyfre słownie z zakresu (1-5)").lower()
#print(WordToNums.values())
#print(WordToNums.keys())
... | code_fim | easy | {
"lang": "python",
"repo": "R083rtKr01/PythonBasic",
"path": "/P39.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if(wybrany in WordToNums):
print(WordToNums[wybrany])
else:
print("Podałeś zły numer")<|fim_prefix|># repo: R083rtKr01/PythonBasic path: /P39.py
#ćwiczenie 39
WordToNums={}
WordToNums["jeden"] = 1
WordToNums["dwa"] = 2
WordToNums["trzy"] = 3
WordToNums["cztery"] = 4
WordToNums["pięć"] = 5
wybrany... | code_fim | easy | {
"lang": "python",
"repo": "R083rtKr01/PythonBasic",
"path": "/P39.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># 4. break 退出循环
# continue 退出本次循环 继续下一次循环
num = 0
while num < 100:
num += 1
if num % 10 == 0:
# break # 退出循环
continue # 退出本次循环 接着下一次循环
print(num)
else:
print("循环结束") # 循环中如果使用了break else分支是不执行的
print("done")<|fim_prefix|># repo: huiba7i/Mycode path: /python/class code... | code_fim | medium | {
"lang": "python",
"repo": "huiba7i/Mycode",
"path": "/python/class code/code4.19/code/while.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: huiba7i/Mycode path: /python/class code/code4.19/code/while.py
"""
while 循环
while 循环条件:
循环内容
"""
# 1.从1 + ... + 100
num = 1 # 定义一个变量存放要 加的数字
sum = 0 # 保存和
while num <= 100:
sum += num
num += 1
print("1+...+100=", sum)
"""
练习1 打印以下图案
*
**
***
****
*****
"""
line = 1 #... | code_fim | hard | {
"lang": "python",
"repo": "huiba7i/Mycode",
"path": "/python/class code/code4.19/code/while.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jacobturjeman/Snake path: /food.py
from turtle import Turtle
import random
class Food(Turtle):
def __init__(self):
<|fim_suffix|> """
once the snake make contact with food it appear
on a different part of the screen
"""
x_cor = random.randint(-270, 270... | code_fim | hard | {
"lang": "python",
"repo": "jacobturjeman/Snake",
"path": "/food.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
once the snake make contact with food it appear
on a different part of the screen
"""
x_cor = random.randint(-270, 270)
y_cor = random.randint(-270, 270)
self.goto(x_cor, y_cor)<|fim_prefix|># repo: jacobturjeman/Snake path: /food.py
from turtle... | code_fim | hard | {
"lang": "python",
"repo": "jacobturjeman/Snake",
"path": "/food.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>s")
elif((a+b+c)==180)and (a!=b and b!=c and a!=c):
print("Scalene")<|fim_prefix|># repo: gimyoni/BaekJoon path: /Python/BronzeIV/10101.py
a = int(input())
b = int(input())
c = int(input())
if((a+b+c)!=180):
print("Error")
elif(a==60 and b==60 and c==60):
print("Equilater<|fim_middle|>al")
elif((a... | code_fim | medium | {
"lang": "python",
"repo": "gimyoni/BaekJoon",
"path": "/Python/BronzeIV/10101.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gimyoni/BaekJoon path: /Python/BronzeIV/10101.py
a = int(input())
b = int(input())
c = int(input())
if((a+b+c)!=180):<|fim_suffix|>s")
elif((a+b+c)==180)and (a!=b and b!=c and a!=c):
print("Scalene")<|fim_middle|>
print("Error")
elif(a==60 and b==60 and c==60):
print("Equilateral")
elif((a... | code_fim | medium | {
"lang": "python",
"repo": "gimyoni/BaekJoon",
"path": "/Python/BronzeIV/10101.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: russells-crockpot/rollit path: /src/rollit/ast/elements.py
"""
"""
import enum
from collections import namedtuple
from contextlib import suppress
from .base import (ElementSpecs, ModelEnumElement, ModelElement, SingleValueElement,
ConstantElement, PredicatedElementMixIn)
from ... | code_fim | hard | {
"lang": "python",
"repo": "russells-crockpot/rollit",
"path": "/src/rollit/ast/elements.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
"""
def __new__(cls, value, *, codeinfo):
with suppress(ValueError):
return SpecialReference(value)
#pylint: disable=too-many-function-args
return super().__new__(cls, value, codeinfo=codeinfo)
Reference.register(SpecialReference)
class OperationSid... | code_fim | hard | {
"lang": "python",
"repo": "russells-crockpot/rollit",
"path": "/src/rollit/ast/elements.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> final_paths = []
previous_paths = initialisation(routes)
while not(all_paths_bool(previous_paths)):
new_multiple_paths = []
for path in previous_paths:
for option in routes:
if path[-1][0] == option[0]:
virgin_path = list(p... | code_fim | hard | {
"lang": "python",
"repo": "matpich94/What-are-the-odds-",
"path": "/read_data.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matpich94/What-are-the-odds- path: /read_data.py
# This function takes the path of the universe.db file
# and transforms it into a list which can be easily processed
def read_routes(path):
import sqlite3
connection = sqlite3.connect(path)
cursor = connection.cursor()
c... | code_fim | hard | {
"lang": "python",
"repo": "matpich94/What-are-the-odds-",
"path": "/read_data.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # net = wdnn.WaypointDistributionNN(4, 0.01) # learns mu, not sigma
net = wdnn.WaypointDistributionNN(1, 0.001, 1e2)
nsamples = 100
x = np.ones(1)
count = 0
while count < 1000:
count += 1
mu, S = net(x)
print(mu)
#print(S[0,:])
print(np.sum(S... | code_fim | hard | {
"lang": "python",
"repo": "ut-amrl/WaypointLearning",
"path": "/TestWaypointLearner.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> best_costs = float('inf')*np.ones([10,10,5])
best_values = np.zeros([10,10,5,8])
hyper = np.zeros([10,10,5,3])
for clamp_idx in range(len(clamp_values)):
for lr_idx in range(len(lr_values)):
for ss_idx in range(len(ss_values)):
clamp = clamp_values[clamp... | code_fim | hard | {
"lang": "python",
"repo": "ut-amrl/WaypointLearning",
"path": "/TestWaypointLearner.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ut-amrl/WaypointLearning path: /TestWaypointLearner.py
import DataHandler as dh
import WaypointDistributionNN as wdnn
import WaypointBaselineNN as wbnn
import numpy as np
import csv
from numpy.random import multivariate_normal as mltnrm
import torch
#from PlotTrajectory import PlotTraj
import mat... | code_fim | hard | {
"lang": "python",
"repo": "ut-amrl/WaypointLearning",
"path": "/TestWaypointLearner.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
data = sys.stdin.readlines()
data = ''.join(data)
tweets = json.loads(data)
for tweet in tweets:
r.db('aggregator').table('trimmed').insert(tweet).run()<|fim_prefix|># repo: npmcdn-to-unpkg-bot/stat-track path: /rethink-prototype/done_with_jq.py
# This script delivers the trimmed tweets back to re... | code_fim | medium | {
"lang": "python",
"repo": "npmcdn-to-unpkg-bot/stat-track",
"path": "/rethink-prototype/done_with_jq.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: npmcdn-to-unpkg-bot/stat-track path: /rethink-prototype/done_with_jq.py
# This script delivers the trimmed tweets back to rethink
<|fim_suffix|>for tweet in tweets:
r.db('aggregator').table('trimmed').insert(tweet).run()<|fim_middle|>import rethinkdb as r
import sys
import json
from conn imp... | code_fim | medium | {
"lang": "python",
"repo": "npmcdn-to-unpkg-bot/stat-track",
"path": "/rethink-prototype/done_with_jq.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for tweet in tweets:
r.db('aggregator').table('trimmed').insert(tweet).run()<|fim_prefix|># repo: npmcdn-to-unpkg-bot/stat-track path: /rethink-prototype/done_with_jq.py
# This script delivers the trimmed tweets back to rethink
import rethinkdb as r
import sys
import json
from conn import conn
<|f... | code_fim | medium | {
"lang": "python",
"repo": "npmcdn-to-unpkg-bot/stat-track",
"path": "/rethink-prototype/done_with_jq.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: devonfw-forge/spark-data-and-ci-showcase path: /employment/Unemployment.py
from pyspark.sql import SparkSession, functions as F
from pyspark.sql.types import DoubleType,IntegerType
import plotly.graph_objects as go
import pandas as pd
from typing import Dict
from pyspark.sql.types import DataTyp... | code_fim | hard | {
"lang": "python",
"repo": "devonfw-forge/spark-data-and-ci-showcase",
"path": "/employment/Unemployment.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def group_data(self, data: DataType, years:list) -> DataType:
dicc = {}
for year in range(years[0], years[-1]+1):
dicc[str(year)] = 'sum'
for column in data.columns[1:-1]:
data = data.withColumn(column, F.regexp_replace(column,',','.'))
... | code_fim | hard | {
"lang": "python",
"repo": "devonfw-forge/spark-data-and-ci-showcase",
"path": "/employment/Unemployment.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('distribution', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='course',
name='levelname',
field=models.CharField(blank=True, max_length=512, null=True),
),
]<|fim_prefix|># repo: esdvFootloos... | code_fim | easy | {
"lang": "python",
"repo": "esdvFootloose/FootlooseStudents",
"path": "/distribution/migrations/0002_course_levelname.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('distribution', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='course',
name='levelname',
field=models.CharField(blank=True, max_length=512, null=True),
),
]<|fim_prefix|># repo: esdvFootloo... | code_fim | medium | {
"lang": "python",
"repo": "esdvFootloose/FootlooseStudents",
"path": "/distribution/migrations/0002_course_levelname.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: esdvFootloose/FootlooseStudents path: /distribution/migrations/0002_course_levelname.py
# Generated by Django 2.2.4 on 2019-08-10 11:48
from django.db import migrations, models
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
migrations.AddField(
mod... | code_fim | medium | {
"lang": "python",
"repo": "esdvFootloose/FootlooseStudents",
"path": "/distribution/migrations/0002_course_levelname.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SoniaB77/Locating_Elements_Selenium_Test path: /test_1_google.py
from driver_initialiser import driver_finder
import time
from selenium.webdriver.common.keys import Keys
driver = driver_finder()
driver.get("https://www.google.com")
driver.maximize_window()
time.sleep(5)
<|fim_suffix|>search_bo... | code_fim | easy | {
"lang": "python",
"repo": "SoniaB77/Locating_Elements_Selenium_Test",
"path": "/test_1_google.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>driver.get("https://www.google.com")
driver.maximize_window()
time.sleep(5)
agree = driver.find_element_by_id("L2AGLb").click()
search_box = driver.find_element_by_name("q").send_keys("Selenium")
driver.find_element_by_name("q").send_keys(Keys.RETURN)
time.sleep(5)
driver.quit()<|fim_prefix|># repo: So... | code_fim | easy | {
"lang": "python",
"repo": "SoniaB77/Locating_Elements_Selenium_Test",
"path": "/test_1_google.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>search_box = driver.find_element_by_name("q").send_keys("Selenium")
driver.find_element_by_name("q").send_keys(Keys.RETURN)
time.sleep(5)
driver.quit()<|fim_prefix|># repo: SoniaB77/Locating_Elements_Selenium_Test path: /test_1_google.py
from driver_initialiser import driver_finder
import time
from sele... | code_fim | medium | {
"lang": "python",
"repo": "SoniaB77/Locating_Elements_Selenium_Test",
"path": "/test_1_google.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># test gradX output
# cv2.imshow("GradX output", gradX)
# cv2.waitKey(0)
# apply a closing operation using the rectangular kernel to help
# cloes gaps in between data
gradX = cv2.morphologyEx(gradX, cv2.MORPH_CLOSE, rectKernel)
# test gradX output
# cv2.imshow("GradX output", gradX)
# cv2.waitKey(0)
# ... | code_fim | hard | {
"lang": "python",
"repo": "indrango/ktm-ocr",
"path": "/ktm_ocr.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: indrango/ktm-ocr path: /ktm_ocr.py
# import the necessary packages
from imutils import contours
import numpy as np
import argparse
import imutils
import cv2
import pytesseract
from PIL import Image, ImageFilter
import os
# construct the argument parser and parse the arguments
ap = argparse.Argum... | code_fim | hard | {
"lang": "python",
"repo": "indrango/ktm-ocr",
"path": "/ktm_ocr.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def gradient( theta, X, y, lamda ):
nfeatures = X.shape[1]
nsamples = X.shape[0]
grad = np.zeros(shape=(nfeatures,1))
for i in range(nsamples):
hx = sigmoid( X[i,:].dot(theta) )
grad[0] = grad[0] + (hx - y[i]) * X[i,0]/nsamples
for j in range(1,nfeatures):
for i... | code_fim | hard | {
"lang": "python",
"repo": "zhenliu2012/coursera-ml",
"path": "/ex2_week3.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhenliu2012/coursera-ml path: /ex2_week3.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 11 17:21:40 2017
@author: zhenliu
"""
import numpy as np
import pandas as pd
import scipy.optimize as op
import matplotlib.pyplot as plt
#def color(x):
# if (x == 1.0):
# ... | code_fim | hard | {
"lang": "python",
"repo": "zhenliu2012/coursera-ml",
"path": "/ex2_week3.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: urucaro/recept path: /src/script/index.py
#!/usr/bin/python
#-*- coding: utf8 -*-
import argparse
import rcpt.livsmedel
import xapian
def index (database_obj):
count = 0
xap_db_path = database_obj.xap_db_path
# create or open the the database
db = xapian.WritableDatabase(... | code_fim | hard | {
"lang": "python",
"repo": "urucaro/recept",
"path": "/src/script/index.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#-----------------------------------------------------------------------------------------------------------
if __name__=='__main__':#gör att det bara körs om det är huvudprogrammet
parser = argparse.ArgumentParser('Index the food names')
parser.add_argument('-p' ,'--pref... | code_fim | hard | {
"lang": "python",
"repo": "urucaro/recept",
"path": "/src/script/index.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#-----------------------------------------------------------------------------------------------------------
if __name__=='__main__':#gör att det bara körs om det är huvudprogrammet
parser = argparse.ArgumentParser('Index the food names')
parser.add_argument('-p' ... | code_fim | hard | {
"lang": "python",
"repo": "urucaro/recept",
"path": "/src/script/index.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: llimllib/CMUA path: /cmua/urls.py
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^register/', include('cmua.registration.urls')),
(r'^report_score/', "... | code_fim | medium | {
"lang": "python",
"repo": "llimllib/CMUA",
"path": "/cmua/urls.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> (r'^directions$', direct_to_template, {'template': "directions.html"}),
(r'^admin/(?P<app_label>[\d\w]+)/(?P<model_name>[\d\w]+)/csv/', 'cmua.csv_view.actions.admin_list_export'),
(r'^admin/', include(admin.site.urls)),
(r'^blog/', include("cmua.nassau.urls")),
(r'^$', "cmua.nassau.v... | code_fim | hard | {
"lang": "python",
"repo": "llimllib/CMUA",
"path": "/cmua/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chiragnagpal/google-research path: /deep_cox_mixtures/dcm/plots.py
# coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the Lic... | code_fim | hard | {
"lang": "python",
"repo": "chiragnagpal/google-research",
"path": "/deep_cox_mixtures/dcm/plots.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> roc_auc = {}
ctds_mean = {}
brss_mean = {}
j = 0
for group in list(groups) + ['all']:
all_fpr = np.unique(np.concatenate([fprs[group][i] for i in set(folds)]))
# The ROC curves are interpolated at these points.
mean_tprs = []
for i in set(folds):
mean_tprs.append(np... | code_fim | hard | {
"lang": "python",
"repo": "chiragnagpal/google-research",
"path": "/deep_cox_mixtures/dcm/plots.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> t_tr_max = np.max([t_[1] for t_ in str_train])
t_ = np.array([t_[1] for t_ in str_test])
clean = (t_<=t_tr_max)
str_test = str_test[t_<=t_tr_max]
ate = ate[t_<=t_tr_max]
scores_f = scores[fold][clean]
for group in groups:
te_protg = (ate ... | code_fim | hard | {
"lang": "python",
"repo": "chiragnagpal/google-research",
"path": "/deep_cox_mixtures/dcm/plots.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # MODEL
# Perform an Ordinary least squares Linear Regression.
lm_tmp = linear_model.LinearRegression()
model_tmp = lm_tmp.fit(ts_tmp, ys_tmp, sample_weight=weights)
# Coefficients of the linear model, y = mx + q
m_tmp = model_tmp.coef_
q_tmp = model_tmp.intercept_
# PREDI... | code_fim | hard | {
"lang": "python",
"repo": "raven-97/glucose-prediction",
"path": "/linear_regr_prediction.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> tp_pred[i-2] = tp
yp_pred[i-2] = yp
print("mean square error : ")
print(mean_squared_error(ys1[1:],yp_pred))
#%% PLOT
# Hypoglycemia threshold vector.
t_tot = [l for l in range(int(ts.min()), int(tp_pred.max())+1)]
hypo = 70*np.ones(len(t_tot))
fig, ax = plt.subplots()
fig.suptitle('Glucose pre... | code_fim | hard | {
"lang": "python",
"repo": "raven-97/glucose-prediction",
"path": "/linear_regr_prediction.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.