text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|># grad_model = Gradient_Boosting_Classifier(X_train, y_train, 0.1, 100) # accuracy, precision, recall = get_model_errors(grad_model, X_train, y_train) # returns R^2, MSE def MSE_R2(model): R2 = cross_val_score(model, X_train, y_train).mean() MSE = abs(cross_val_score(model, X_train, y_train, sco...
code_fim
hard
{ "lang": "python", "repo": "tibrado/case-study-driver-churn-rate", "path": "/src/models.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: tibrado/case-study-driver-churn-rate path: /src/models.py import pandas as pd import numpy as np from sklearn.metrics import accuracy_score, precision_score, r2_score, recall_score from sklearn.ensemble import GradientBoostingClassifier, RandomForestClassifier from sklearn.tree import Decis...
code_fim
hard
{ "lang": "python", "repo": "tibrado/case-study-driver-churn-rate", "path": "/src/models.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>""" “”“ Time O(N) Space O(1) 先统计数组中各个任务出现的次数。优先安排次数最多的任务。次数最多的任务安排完成之后所需的时间间隔为(max(次数)-1)*(n+1)+ p(频率最高出现的p个数p>=1)。其余任务直接插空即可。 https://www.youtube.com/watch?v=YCD_iYxyXoo 特殊情况:如果不需要插入任何idle就能把所有task安排完,那么返回的就是task的长度 ””“ class Solution(object): def leastInterval(self, tasks, n): counts = [0]...
code_fim
hard
{ "lang": "python", "repo": "lixuanhong/LeetCode", "path": "/621. Task Scheduler.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: lixuanhong/LeetCode path: /621. Task Scheduler.py """ Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks.Tasks could be done without original order. Each task could be done in one interval. For each interval, ...
code_fim
hard
{ "lang": "python", "repo": "lixuanhong/LeetCode", "path": "/621. Task Scheduler.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>class Solution(object): def leastInterval(self, tasks, n): counts = [0] * 26 p = 0 for i in tasks: counts[ord(i) - ord('A')] += 1 max_count = max(counts) for count in counts: if count == max_count: p += 1 ans = (ma...
code_fim
hard
{ "lang": "python", "repo": "lixuanhong/LeetCode", "path": "/621. Task Scheduler.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: cdimoush/mirage_rpi path: /screens/weather_screen.py # commented out the clock super(Screen, self).__init__(**kwargs) self.setup() def setup(self): x, y, col_sp, row_sp, x_list, y_list = grid_function(self.cols, self.rows) with self.canvas.before: ...
code_fim
hard
{ "lang": "python", "repo": "cdimoush/mirage_rpi", "path": "/screens/weather_screen.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.c.text = self.high_list[0].text + 'F / ' + self.low_list[0].text + 'F' self.e.text = 'Chance of Precipitation: ' + self.pop_list[0].text + '%' self.e1.text = 'Avg Wind Speed: ' + str(self.for_data['forecast']['simpleforecast']['forecastday'][0]['avewi...
code_fim
hard
{ "lang": "python", "repo": "cdimoush/mirage_rpi", "path": "/screens/weather_screen.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # Current Temp self.b.text = str(self.current_data['current_observation']['temp_f']) + 'F' self.i0 = self.current_data['current_observation']['icon_url'] with open('images/w_icon.png', 'wb') as f: f.write(requests.get...
code_fim
hard
{ "lang": "python", "repo": "cdimoush/mirage_rpi", "path": "/screens/weather_screen.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> prev = cur cur = s for arr in MyIter(): print(arr) # 이터레이터: 사용하는 사람이 도중에 중단 가능 if sum(arr) > 50: break<|fim_prefix|># repo: skku-overflow/python-2020-2 path: /week3/homework/answer1.py class MyIter: def __iter__(self): <|fim_middle|> arr = [1] ...
code_fim
medium
{ "lang": "python", "repo": "skku-overflow/python-2020-2", "path": "/week3/homework/answer1.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: skku-overflow/python-2020-2 path: /week3/homework/answer1.py class MyIter: def __iter__(self): <|fim_suffix|> for arr in MyIter(): print(arr) # 이터레이터: 사용하는 사람이 도중에 중단 가능 if sum(arr) > 50: break<|fim_middle|> arr = [1] yield arr prev = 0 cur...
code_fim
hard
{ "lang": "python", "repo": "skku-overflow/python-2020-2", "path": "/week3/homework/answer1.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: m03/lfucache path: /tests/unit/fixtures/all.py # -*- coding: utf-8 -*- # vim: ft=python <|fim_suffix|># Imports to others. __all__ = [] FREQUENCY = { 1: deque([2, 3]), 2: deque([1]), } NOT_FOUND = -1<|fim_middle|>""" Pytest fixtures for all lfulib tests. """ # Import Python Libs. from ...
code_fim
medium
{ "lang": "python", "repo": "m03/lfucache", "path": "/tests/unit/fixtures/all.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>FREQUENCY = { 1: deque([2, 3]), 2: deque([1]), } NOT_FOUND = -1<|fim_prefix|># repo: m03/lfucache path: /tests/unit/fixtures/all.py # -*- coding: utf-8 -*- # vim: ft=python <|fim_middle|>""" Pytest fixtures for all lfulib tests. """ # Import Python Libs. from __future__ import absolute_import f...
code_fim
medium
{ "lang": "python", "repo": "m03/lfucache", "path": "/tests/unit/fixtures/all.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: Saafke/java-pommerman path: /py/query.py import math import pandas as pd import matplotlib.pyplot as plt import numpy as np import scipy.stats data = pd.read_pickle("data.pkl") # print(str(data)) # columns=["game_mode", "observability", "agents", "game_seed", "instance", "event_id", "event_data"...
code_fim
hard
{ "lang": "python", "repo": "Saafke/java-pommerman", "path": "/py/query.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>def plot_event_count(event_name, mode=0): plot_data = [[] for _ in range(len(agent_mapping))] std_err_data = [[] for _ in range(len(agent_mapping))] for agent in agents: for o in obs_options: events_per_game, std_err = event_count_query(event_name, game_mode=mode, observabi...
code_fim
hard
{ "lang": "python", "repo": "Saafke/java-pommerman", "path": "/py/query.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> team_kill_count = [] ngames = 0 # Number of games in which this agent dies suicides = 0 # Number of games in which this agent commits suicide events_per_sample = [] team_kills = 0 # Iterate through selected game data for index, row in selection.iterrows(): if agent i...
code_fim
hard
{ "lang": "python", "repo": "Saafke/java-pommerman", "path": "/py/query.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: wjy199708/DataBaseSpider path: /MongoDb2Csv/MongodbToCsv.py # coding:utf-8 from MongoDb2Csv.MongoBaseDao import MongoBaseDao import pandas as pd class MongodbToCsv: """ 将MongoDB中的数据按照一定的条件取出,删除部分后再存为Csv格式 """ <|fim_suffix|> """ 实例化一个操作mongo的对象 """ se...
code_fim
medium
{ "lang": "python", "repo": "wjy199708/DataBaseSpider", "path": "/MongoDb2Csv/MongodbToCsv.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> """ 实例化一个操作mongo的对象 """ self.__mongo = MongoBaseDao('192.168.65.119', 27017, 'spider') def read_delete_by_time_save_to_csv(self, col_name): """ 根据时间读取表中所有数据 :param col_name: 在哪个collection中查找 :param datetime: date_time列格式化为datetime对象数组 ...
code_fim
medium
{ "lang": "python", "repo": "wjy199708/DataBaseSpider", "path": "/MongoDb2Csv/MongodbToCsv.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> @staticmethod def main(): a = MongodbToCsv() a.read_delete_by_time_save_to_csv('美术设计师2d3d') MongodbToCsv.main()<|fim_prefix|># repo: wjy199708/DataBaseSpider path: /MongoDb2Csv/MongodbToCsv.py # coding:utf-8 from MongoDb2Csv.MongoBaseDao import MongoBaseDao import pandas as pd ...
code_fim
hard
{ "lang": "python", "repo": "wjy199708/DataBaseSpider", "path": "/MongoDb2Csv/MongodbToCsv.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: RoboBrainCode/Backend path: /rest_api/views.py # Create your views here. from rest_framework import status from rest_framework.decorators import api_view from rest_framework.response import Response from feed.models import JsonFeeds from rest_api.serializer import FeedSerializer from datetime imp...
code_fim
hard
{ "lang": "python", "repo": "RoboBrainCode/Backend", "path": "/rest_api/views.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #List all snippets, or create a new snippet. if request.method == 'GET': feeds = JsonFeeds.objects.all()[:25] serializer = FeedSerializer(feeds, many=True) return Response(serializer.data) elif request.method == 'POST': serializer = FeedSerializer(data=request....
code_fim
medium
{ "lang": "python", "repo": "RoboBrainCode/Backend", "path": "/rest_api/views.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>## 运算 ## sess = tf.InteractiveSession() # 初始化所有变量!!!!!!!!!!!!!!!!!!!!!!很容易忘记 ops = tf.global_variables_initializer() sess.run(ops) print(sess.run(y)) sess.close()<|fim_prefix|># repo: zzbb1199/TensorFlowLearning path: /google_tensorflow_practise/chapter3/forward_neruo.py """ 神经网络前向传播算法 """ import tensor...
code_fim
medium
{ "lang": "python", "repo": "zzbb1199/TensorFlowLearning", "path": "/google_tensorflow_practise/chapter3/forward_neruo.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: zzbb1199/TensorFlowLearning path: /google_tensorflow_practise/chapter3/forward_neruo.py """ 神经网络前向传播算法 """ import tensorflow as tf # 定义w1,w2两个变量 w1 = tf.Variable(tf.random_normal([2,3],stddev=1,seed=1)) w2 = tf.Variable(tf.random_normal([3,1],stddev=1,seed=1)) <|fim_suffix|>## 运算 ## sess = tf...
code_fim
medium
{ "lang": "python", "repo": "zzbb1199/TensorFlowLearning", "path": "/google_tensorflow_practise/chapter3/forward_neruo.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>lst = ["hey this is bhavana","i am in mumbai"] getCapital = lambda sent: sent.upper() newList = map(lambda sent: sent.upper(), lst) print(list(newList))<|fim_prefix|># repo: OrrayBhavana/Python-Batch-7 path: /day_5_python_b7.py # -*- coding: utf-8 -*- """Day 5 Python B7.ipynb Automatically generated ...
code_fim
hard
{ "lang": "python", "repo": "OrrayBhavana/Python-Batch-7", "path": "/day_5_python_b7.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Malikeh97/ai-spring-97-4 path: /univariate_regression.py import numpy as np import matplotlib.pyplot as plt COLNUM = (0, 2, 13) # def univariate_regression(): def read_file(): with open('housing.data') as f: content = f.readlines() content = [x.strip().split() for x in content...
code_fim
hard
{ "lang": "python", "repo": "Malikeh97/ai-spring-97-4", "path": "/univariate_regression.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> plt.figure(2) plt.title('Tax') plt.subplot(211) plt.axis([0, x2.max(), 0, y.max()]) x_arr = np.array(x2)[0] y_arr = np.array(y)[0] plt.plot(x_arr, y_arr, 'bo', x_arr, m2 * x_arr + b2, 'r') plt.subplot(212) plt.axis([0, num_of_iter, 0, errors2[0]]) plt.xlabel('iter'...
code_fim
hard
{ "lang": "python", "repo": "Malikeh97/ai-spring-97-4", "path": "/univariate_regression.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Satyam-Bhalla/Text_Classification_Multiple_Methods path: /Binary Text Classification Movie Reviews/Binary Text Classification.py #!/usr/bin/env python # coding: utf-8 # In[1]: import numpy as np import re import nltk from sklearn.datasets import load_files # nltk.download('stopwords') ...
code_fim
hard
{ "lang": "python", "repo": "Satyam-Bhalla/Text_Classification_Multiple_Methods", "path": "/Binary Text Classification Movie Reviews/Binary Text Classification.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> document = [stemmer.lemmatize(word) for word in document] document = ' '.join(document) documents.append(document) # In[6]: vectorizer = CountVectorizer(max_features=1500, min_df=5, max_df=0.7, stop_words=stopwords.words('english')) X = vectorizer.fit_transform(documents).toarray() tfid...
code_fim
hard
{ "lang": "python", "repo": "Satyam-Bhalla/Text_Classification_Multiple_Methods", "path": "/Binary Text Classification Movie Reviews/Binary Text Classification.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: gokou00/python_programming_challenges path: /testing/per.py import itertools test = [5, 2, 1, 9, 50, 56] test2 = list(itertools.permutations(test)) #print(test2) <|fim_suffix|>for x in test2: l = list(x) for j in l: strBuilder += str(j) strNum = int(strBuilder) strBuil...
code_fim
easy
{ "lang": "python", "repo": "gokou00/python_programming_challenges", "path": "/testing/per.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>strBuilder = "" temp = 0 strNum = 0 for x in test2: l = list(x) for j in l: strBuilder += str(j) strNum = int(strBuilder) strBuilder = "" if strNum > temp: temp = strNum print(temp)<|fim_prefix|># repo: gokou00/python_programming_challenges path: /testing/per.py imp...
code_fim
easy
{ "lang": "python", "repo": "gokou00/python_programming_challenges", "path": "/testing/per.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while True: option=input(">>") try: if option=='1': id=input("ID= ") if id.isdigit()==False: raise ClientException("ID must be an integer") id=int(id) pri...
code_fim
hard
{ "lang": "python", "repo": "dary82/Projects", "path": "/BookRental/ui.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: dary82/Projects path: /BookRental/ui.py from Book import * from Client import * from Rental import * from BookRepo import * from ClientRepo import * from RentalRepo import * from Service import * from UndoController import * import datetime class UI: def __init__(self,BookRepo,ClientRepo,Rent...
code_fim
hard
{ "lang": "python", "repo": "dary82/Projects", "path": "/BookRental/ui.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def rent_book_ui(self): id = input("ID rental: ") idc=input("ID Client: ") idb=input("ID book: ") day=input("Day the rental took place: ") month=input("Month the rental took place(number): ") year=input("Year the rental took place: ") print(self...
code_fim
hard
{ "lang": "python", "repo": "dary82/Projects", "path": "/BookRental/ui.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: xueweipeng/server_framework path: /main/api/upgrade_interface.py from flask import jsonify from flask import Blueprint from flask import request upgrade = Blueprint("upgrade", __name__) <|fim_suffix|> version = request.args.get('version') data = { "data": { "version"...
code_fim
medium
{ "lang": "python", "repo": "xueweipeng/server_framework", "path": "/main/api/upgrade_interface.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> @upgrade.route('/check', methods=['GET']) def check_upgrade(): version = request.args.get('version') data = { "data": { "version": 1111, "url": "aaaaaa" }, "code": 200, "message": "success" } return jsonify(data)<|fim_prefix|># repo:...
code_fim
easy
{ "lang": "python", "repo": "xueweipeng/server_framework", "path": "/main/api/upgrade_interface.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self, alphabet, m, b): """ multiply mx + b """ # We're cheating here by not actually having the decryption method use the "inverse" argument transformed = alphabet.affinal(m, b) super(AffineCipher, self).__init__(alphabet, transformed)<|fim_prefix|># repo: ...
code_fim
medium
{ "lang": "python", "repo": "thunder8olt/hotel-juliet", "path": "/hj/ciphers/substitution/monoalphabetic/affine.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: thunder8olt/hotel-juliet path: /hj/ciphers/substitution/monoalphabetic/affine.py #!/usr/bin/python # -*- coding: utf-8 -*- <|fim_suffix|> def __init__(self, alphabet, m, b): """ multiply mx + b """ # We're cheating here by not actually having the decryption method use the "inv...
code_fim
medium
{ "lang": "python", "repo": "thunder8olt/hotel-juliet", "path": "/hj/ciphers/substitution/monoalphabetic/affine.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: volauvent/legendary path: /server/dbUtility.py import os import sys from PIL import Image from shutil import copyfile import imagehash class utility: labels = ['None', 'amusement', 'awe', 'contentment', 'anger', 'disgus...
code_fim
hard
{ "lang": "python", "repo": "volauvent/legendary", "path": "/server/dbUtility.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pathSet=set() for root, dirs, files in os.walk(self.filePath+"/images"): path = root.split(os.sep) for file in files: if file != ".DS_Store": pathSet.add(root+os.sep+file) return pathSet def getAllModelList(self): ...
code_fim
hard
{ "lang": "python", "repo": "volauvent/legendary", "path": "/server/dbUtility.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: diana-hep/rejig path: /reinterpreted-python/tests/test_syntax.py t')),))) check('''[3]''', Suite((Call('return', Call('list', Const(3))),))) check('''[3,]''', Suite((Call('return', Call('list', Const(3))),))) check('''[3, 4]''', Suite((Call('return', Call('list', Const(3), Const(4))),))) check(''...
code_fim
hard
{ "lang": "python", "repo": "diana-hep/rejig", "path": "/reinterpreted-python/tests/test_syntax.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>check('''a[1]''', Suite((Call('return', Call('[.]', Name('a'), Const(1))),))) check('''a["hey"]''', Suite((Call('return', Call('[.]', Name('a'), Const('hey'))),))) check('''a[1:2]''', Suite((Call('return', Call('[.]', Name('a'), Call('slice', Const(1), Const(2), Const(None)))),))) check('''a[:]''', Suite(...
code_fim
hard
{ "lang": "python", "repo": "diana-hep/rejig", "path": "/reinterpreted-python/tests/test_syntax.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: diana-hep/rejig path: /reinterpreted-python/tests/test_syntax.py ', Suite((Call('return', Call('==', Call('tuple', Name('x'), Const(None)), Name('y'))),))) check('''(x, None) >= y''', Suite((Call('return', Call('>=', Call('tuple', Name('x'), Const(None)), Name('y'))),))) check('''(x, None) <= y''...
code_fim
hard
{ "lang": "python", "repo": "diana-hep/rejig", "path": "/reinterpreted-python/tests/test_syntax.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: yoktys/bbs_django path: /apps/forum/models.py # -*- coding: utf-8 -*- from django.db import models from django.contrib.auth.models import User from django.db.models.signals import post_save class Forum(models.Model): title = models.CharField('分かりにくい場合はここに説明を入れる', max_length=60) def __...
code_fim
hard
{ "lang": "python", "repo": "yoktys/bbs_django", "path": "/apps/forum/models.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def __unicode__(self): return u"%s - %s - %s" % (self.creator, self.thread, self.title) def short(self): """ 日付 """ return u"%s - %s\n%s" % (self.creator, self.title, self.created.strftime("%b %d, %I:%M %p")) short.allow_tags = True def profile_dat...
code_fim
hard
{ "lang": "python", "repo": "yoktys/bbs_django", "path": "/apps/forum/models.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>nums[i]] = 1 else: return nums[i]<|fim_prefix|># repo: GagoilKim/Leetcode path: /findDuplicate.py class Solution: def findDuplicate(self, nums: List[int]) -> int: dic = {} for i in range(len(nums)): <|fim_middle|> if nums[i] not in dic.keys(): ...
code_fim
hard
{ "lang": "python", "repo": "GagoilKim/Leetcode", "path": "/findDuplicate.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: GagoilKim/Leetcode path: /findDuplicate.py class Solution: def findDuplicate(self, nums: List[int]) -> int: dic = {} for i in range(len(nums)): <|fim_suffix|>nums[i]] = 1 else: return nums[i]<|fim_middle|> if nums[i] not in dic.keys(): ...
code_fim
hard
{ "lang": "python", "repo": "GagoilKim/Leetcode", "path": "/findDuplicate.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>class StatisticAPIView(ListAPIView): """ API View for get statistic. """ queryset = NumberCounter.objects.all() serializer_class = NumberCounterSerializer<|fim_prefix|># repo: arseniysychev/numbers_api path: /applications/number_counters/views.py from rest_framework.generics import Li...
code_fim
medium
{ "lang": "python", "repo": "arseniysychev/numbers_api", "path": "/applications/number_counters/views.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> """ API View for get statistic. """ queryset = NumberCounter.objects.all() serializer_class = NumberCounterSerializer<|fim_prefix|># repo: arseniysychev/numbers_api path: /applications/number_counters/views.py from rest_framework.generics import ListAPIView, CreateAPIView from .model...
code_fim
medium
{ "lang": "python", "repo": "arseniysychev/numbers_api", "path": "/applications/number_counters/views.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: arseniysychev/numbers_api path: /applications/number_counters/views.py from rest_framework.generics import ListAPIView, CreateAPIView <|fim_suffix|>class UnpairedAPIView(CreateAPIView): """ API View for send data list via POST method. """ serializer_class = UnpairedSerializer c...
code_fim
medium
{ "lang": "python", "repo": "arseniysychev/numbers_api", "path": "/applications/number_counters/views.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Xoozi/tchomework path: /ch00/section6/37.py #用参数做图法画出f(x) anti_f(x) 和 y = x #f(x) = arcsin(x), x = t, y = arcsin(t) # #anti_f(x) = sin(x), x = t, y = sin(t) def fx(t): return t def fy(t): return arcsin(t) def anti_fx(t): return t def anti_fy(t): return sin(t) def cx(t): <|fim_...
code_fim
medium
{ "lang": "python", "repo": "Xoozi/tchomework", "path": "/ch00/section6/37.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>x1 = fx(t) y1 = fy(t) x2 = anti_fx(t) y2 = anti_fy(t) x3 = cx(t) y3 = cy(t) xlabel('x') ylabel('y') plot(x1, y1, 'r-', x2, y2, 'g-', x3, y3, 'b-')<|fim_prefix|># repo: Xoozi/tchomework path: /ch00/section6/37.py #用参数做图法画出f(x) anti_f(x) 和 y = x #f(x) = arcsin(x), x = t, y = arcsin(t) # #anti_f(x) = s...
code_fim
medium
{ "lang": "python", "repo": "Xoozi/tchomework", "path": "/ch00/section6/37.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # servira a regler l'horloge du jeu horloge = pygame.time.Clock() # la boucle infinie dans laquelle on reste coince i=1; continuer=1 upstairsperso = 0 upstairsblob = 0 vartour = -1 dirbone = -1 while continuer: horloge.tick(30) i= i+1; #print (i) # on recupere l'etat...
code_fim
hard
{ "lang": "python", "repo": "mbardou/Gameproj", "path": "/Jeux Vidéo2/dd.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: mbardou/Gameproj path: /Jeux Vidéo2/dd.py import os import pygame #redblobgames pygame.init() #Création de la fenetre largeur = 1024 hauteur = 768 fenetre=pygame.display.set_mode((largeur,hauteur)) # lecture de l'image du perso #Dico des images--------------------------------------...
code_fim
hard
{ "lang": "python", "repo": "mbardou/Gameproj", "path": "/Jeux Vidéo2/dd.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: umluizlima/flask-pwa path: /app/controller/pwa.py from flask import ( Blueprint, make_response, send_from_directory ) bp = Blueprint('pwa', __name__, url_prefix='') <|fim_suffix|> @bp.route('/sw.js') def service_worker(): response = make_response(send_from_directory('static', 'sw.js'))...
code_fim
medium
{ "lang": "python", "repo": "umluizlima/flask-pwa", "path": "/app/controller/pwa.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@bp.route('/sw.js') def service_worker(): response = make_response(send_from_directory('static', 'sw.js')) response.headers['Cache-Control'] = 'no-cache' return response<|fim_prefix|># repo: umluizlima/flask-pwa path: /app/controller/pwa.py from flask import ( Blueprint, make_response, se...
code_fim
medium
{ "lang": "python", "repo": "umluizlima/flask-pwa", "path": "/app/controller/pwa.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @bp.route('/sw.js') def service_worker(): response = make_response(send_from_directory('static', 'sw.js')) response.headers['Cache-Control'] = 'no-cache' return response<|fim_prefix|># repo: umluizlima/flask-pwa path: /app/controller/pwa.py from flask import ( Blueprint, make_response, s...
code_fim
medium
{ "lang": "python", "repo": "umluizlima/flask-pwa", "path": "/app/controller/pwa.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return name def get_profile_url(game_id: str, realm: str, user_id: str) -> str: if game_id not in USER_PROFILE_URLS: logging.error('wgc_helper/get_profile_url: unknown game_id %s' % game_id) return None game_urls = USER_PROFILE_URLS[game_id] if realm not in game_urls: ...
code_fim
hard
{ "lang": "python", "repo": "MasterModeley/galaxy-integration-wargaming", "path": "/wgc/wgc_helper.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> kerneldll = ctypes.windll.kernel32 mutex_handle = kerneldll.OpenMutexW(MUTEX_ALL_ACCESS, 0, str(mutex_name)) if mutex_handle != 0: kerneldll.CloseHandle(mutex_handle) return True return False ### FS def scantree(path): """Recursively yield DirEntry objects for given ...
code_fim
hard
{ "lang": "python", "repo": "MasterModeley/galaxy-integration-wargaming", "path": "/wgc/wgc_helper.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: MasterModeley/galaxy-integration-wargaming path: /wgc/wgc_helper.py # (c) 2019-2020 Mikhail Paulyshka # SPDX-License-Identifier: MIT import ctypes import logging import os import platform from .wgc_constants import USER_PROFILE_URLS ### Platform def get_platform() -> str: system = platform...
code_fim
hard
{ "lang": "python", "repo": "MasterModeley/galaxy-integration-wargaming", "path": "/wgc/wgc_helper.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: moalfamaria/Google_Atelierul_Digital path: /pythonProject1/Dog.py from Animal import Animal class Dog(Animal): <|fim_suffix|># self = instanta curenta # instanta = un obiect de acel tip # obiect intr o variabila<|fim_middle|> @staticmethod def speak(): print("woof")
code_fim
easy
{ "lang": "python", "repo": "moalfamaria/Google_Atelierul_Digital", "path": "/pythonProject1/Dog.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># self = instanta curenta # instanta = un obiect de acel tip # obiect intr o variabila<|fim_prefix|># repo: moalfamaria/Google_Atelierul_Digital path: /pythonProject1/Dog.py from Animal import Animal class Dog(Animal): <|fim_middle|> @staticmethod def speak(): print("woof")
code_fim
easy
{ "lang": "python", "repo": "moalfamaria/Google_Atelierul_Digital", "path": "/pythonProject1/Dog.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # 이전까지의 가장 높은 확률과 현재 여자와 성공할 확률이 같다면 if woman_prob == probability: # 성공할 확률이 가장 높은 여자들을 저장하는 리스트 변수에 현재 여자의 이름을 넣어줍니다. selected_woman.append(woman_name) # 이전까지의 가장 높은 확률보다 현재 여자와 성공할 확률이 크다면 elif woman_prob > probability: # 성공할 확률이 가장 높은 여자들을 저장하는 리스트 변수들을 비워줍니다. ...
code_fim
hard
{ "lang": "python", "repo": "bright-night-sky/algorithm_study", "path": "/백준/Bronze/Bronze 2/1296번 ; 데이트.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: bright-night-sky/algorithm_study path: /백준/Bronze/Bronze 2/1296번 ; 데이트.py # https://www.acmicpc.net/problem/1296 # readline을 사용하기 위해 import합니다. from sys import stdin # 첫째 줄에 오민식의 영어 이름을 입력합니다. # 맨 끝의 \n은 떼어줍니다. ohminsik = stdin.readline().rstrip() # 둘째 줄에는 좋아하는 여자의 수 N을 입력합니다. # 50보다 작거나 같은 자연...
code_fim
hard
{ "lang": "python", "repo": "bright-night-sky/algorithm_study", "path": "/백준/Bronze/Bronze 2/1296번 ; 데이트.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: lzene/dangdangpc path: /dangdangpc/pipelines.py # -*- coding: utf-8 -*- # Define your item pipelines here # # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html import MySQLdb import logging from scrapy import log imp...
code_fim
hard
{ "lang": "python", "repo": "lzene/dangdangpc", "path": "/dangdangpc/pipelines.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> name = item['title'][0] price = item['price'][0] comment_num = item['comment_num'][0] url = item['link'] img_url = item['img_url'][0] print u'商品名称:'+name print u'商品评论:'+comment_num print u'商品价格:'+price print u'商品链接:'+url prin...
code_fim
hard
{ "lang": "python", "repo": "lzene/dangdangpc", "path": "/dangdangpc/pipelines.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: TheDiegoFrade/python_crash_course_2nd_ed path: /python_poll.py responses = {} # Set a flag to indicate that polling is active. polling_active = True while polling_active: # Prompt for the person's name and response. name = input("\nWhat is your name? ") response = input("Which are your...
code_fim
hard
{ "lang": "python", "repo": "TheDiegoFrade/python_crash_course_2nd_ed", "path": "/python_poll.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>print(f'Poll Dictionary: {responses}') print("\n--- Poll Results ---") for item in responses.items(): print(item)<|fim_prefix|># repo: TheDiegoFrade/python_crash_course_2nd_ed path: /python_poll.py responses = {} # Set a flag to indicate that polling is active. polling_active = True while polling_act...
code_fim
hard
{ "lang": "python", "repo": "TheDiegoFrade/python_crash_course_2nd_ed", "path": "/python_poll.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ''' generate_explanations(images = [ #'../../../data/wildcam_subset_denoised/test/raccoon/593a4e8a-23d2-11e8-a6a3-ec086b02610b.jpg', #'../../../data/wildcam_subset_denoised/test/raccoon/5879d289-23d2-11e8-a6a3-e...
code_fim
hard
{ "lang": "python", "repo": "fastforwardlabs/causal-experiments", "path": "/experiments/invariant-risk-minimization/wildcam/model_explanation.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: fastforwardlabs/causal-experiments path: /experiments/invariant-risk-minimization/wildcam/model_explanation.py import matplotlib import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec import numpy as np import os, json import torch import torch.nn as nn import torch.nn.functiona...
code_fim
hard
{ "lang": "python", "repo": "fastforwardlabs/causal-experiments", "path": "/experiments/invariant-risk-minimization/wildcam/model_explanation.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: OweN98/Crawler path: /DoubanNowplayingWordCloud/NowplayingMovieCrawler.py ''' NowplayingMovieCrawler.py 功能:获取正在上映电影的id和名字 ''' import requests, random from lxml import etree from settings import USER_AGENTS, NOW_PLAYING_URL # 从settings中获取正在上映电影的url def UrlManager(): url = NOW_PLAYING_...
code_fim
hard
{ "lang": "python", "repo": "OweN98/Crawler", "path": "/DoubanNowplayingWordCloud/NowplayingMovieCrawler.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>def Htmlparser(html): movie_list = [] try: html = etree.HTML(html) # 构造XPath解析对象并对HTML文本进行自动修正 except Exception as e: raise(e) print('can\'t get nowplaying page') print(e) exit(0) # 分析网页的HTML源代码结构,编写XPath表达式,返回符合结果的内容合并为的数组 Nowplayin...
code_fim
hard
{ "lang": "python", "repo": "OweN98/Crawler", "path": "/DoubanNowplayingWordCloud/NowplayingMovieCrawler.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>if __name__ == "__main__": captcha = [int(x) for x in read_data()] captcha.append(captcha[0]) print(sum([captcha[i] for i in range(1, len(captcha)) if captcha[i-1] == captcha[i]])) captcha = [int(x) for x in read_data()] total = 0 for i in range(len(captcha)): total += ro...
code_fim
medium
{ "lang": "python", "repo": "xpqz/aoc-17", "path": "/day1.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: xpqz/aoc-17 path: /day1.py def read_data(filename="data/input1.data"): with open(filename) as f: return f.read() <|fim_suffix|> total = 0 for i in range(len(captcha)): total += rot(captcha, i) print(total)<|fim_middle|> def rot(l, i): offset = len(l) // 2 ...
code_fim
hard
{ "lang": "python", "repo": "xpqz/aoc-17", "path": "/day1.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> captcha = [int(x) for x in read_data()] total = 0 for i in range(len(captcha)): total += rot(captcha, i) print(total)<|fim_prefix|># repo: xpqz/aoc-17 path: /day1.py def read_data(filename="data/input1.data"): with open(filename) as f: return f.read() def rot(l, i...
code_fim
hard
{ "lang": "python", "repo": "xpqz/aoc-17", "path": "/day1.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # Compute ion and electron velocities v_ex, v_ey, v_ez, v_ix, v_iy, v_iz = _calc_vei(m_i, wc_i, w_final, e_x, e_y, e_z) # Ratio of parallel and perpendicular to B speed vepar_perp = v_ez * np.conj(v_ez) vepar_perp /= (v_ex * np.conj(v...
code_fim
hard
{ "lang": "python", "repo": "zhang-chi-IGGCAS/irfu-python", "path": "/pyrfu/dispersion/disp_surf_calc.py", "mode": "spm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_suffix|> dn_e = dn_e_n * wp_e ** 2 k_dot_e = e_x * kc_x_mat + e_z * kc_z_mat k_dot_e = np.sqrt(k_dot_e * np.conj(k_dot_e)) # Build output dict extra_param = {"Degree of electromagnetism": np.log10(b_tot / e_tot), "Degree of longitudinality": np.abs(e_par) / e_tot, ...
code_fim
hard
{ "lang": "python", "repo": "zhang-chi-IGGCAS/irfu-python", "path": "/pyrfu/dispersion/disp_surf_calc.py", "mode": "spm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: zhang-chi-IGGCAS/irfu-python path: /pyrfu/dispersion/disp_surf_calc.py #!/usr/bin/env python # -*- coding: utf-8 -*- # # MIT License # # Copyright (c) 2020 - 2021 Louis Richard # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated docum...
code_fim
hard
{ "lang": "python", "repo": "zhang-chi-IGGCAS/irfu-python", "path": "/pyrfu/dispersion/disp_surf_calc.py", "mode": "psm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_suffix|>__all__.extend(optional_import("hcrystalball.wrappers._prophet", "ProphetWrapper", globals())) __all__.extend( optional_import("hcrystalball.wrappers._statsmodels", "ExponentialSmoothingWrapper", globals()) ) __all__.extend(optional_import("hcrystalball.wrappers._statsmodels", "SimpleSmoothingWrapper"...
code_fim
medium
{ "lang": "python", "repo": "pavelkrizek/hcrystalball", "path": "/src/hcrystalball/wrappers/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: pavelkrizek/hcrystalball path: /src/hcrystalball/wrappers/__init__.py from ._sklearn import get_sklearn_wrapper as get_sklearn_wrapper from sklearn import set_config from hcrystalball.utils import optional_import set_config(print_changed_only=False) <|fim_suffix|>__all__.extend(optional_import(...
code_fim
medium
{ "lang": "python", "repo": "pavelkrizek/hcrystalball", "path": "/src/hcrystalball/wrappers/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: philedius/Advent-of-Coding path: /04/advent04.py import hashlib is_valid = False number = 0 while is_valid<|fim_suffix|> m.hexdigest() print number is_valid = True number += 1<|fim_middle|> == False: m = hashlib.md5() m.update('iwrupvqb') m.update(str(number)) if m.hexdigest()[0:6] == ...
code_fim
medium
{ "lang": "python", "repo": "philedius/Advent-of-Coding", "path": "/04/advent04.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> m.hexdigest() print number is_valid = True number += 1<|fim_prefix|># repo: philedius/Advent-of-Coding path: /04/advent04.py import hashlib is_valid = False number = 0 while is_valid == False: m = hashlib.md5() m.update('iwrupvqb') m.upda<|fim_middle|>te(str(number)) if m.hexdigest()[0:6] == ...
code_fim
easy
{ "lang": "python", "repo": "philedius/Advent-of-Coding", "path": "/04/advent04.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def readBinaryMust(self, timeoutloop = 10): run = True loop = 1 while(run): try: temp = self.port.read() except: self.logger.error("readBinaryMust failed") return "ERROR" else: if len(temp) > 0: data = ord(temp) self.logger.debug("read hex data =" +str(data)) ...
code_fim
hard
{ "lang": "python", "repo": "polarisphotonics/pp_python", "path": "/py3lib/COMPort.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return find_com def writeBinary(self, data): #print("in") data_list = list([data]) #data_list.append('\n') self.port.write(data_list) self.logger.debug("write hex data="+str(data_list)) def writeList(self, datalist): self.port.write(datalist) def readBinary(self): try: temp = se...
code_fim
hard
{ "lang": "python", "repo": "polarisphotonics/pp_python", "path": "/py3lib/COMPort.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: polarisphotonics/pp_python path: /py3lib/COMPort.py import serial import serial.tools.list_ports import platform import logging import py3lib.QuLogger import numpy as np ft232_name_in = "0403:6001" arduino_name_in = "2341:0043" #ft232_name_in_mac = "0403:6001" #ft232_name_in_win = "VID_0403+PID_...
code_fim
hard
{ "lang": "python", "repo": "polarisphotonics/pp_python", "path": "/py3lib/COMPort.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> diff = (c - b) * dic_a.get(b, 0) if b in dic_a.keys(): dic_a[c] = dic_a.get(c, 0) + dic_a.get(b, 0) dic_a[b] = 0 answer += diff else: pass print(answer)<|fim_prefix|># repo: Aasthaengg/IBMdataset path: /Python_codes/p02630/s363208865.py n = int(input()) li_...
code_fim
medium
{ "lang": "python", "repo": "Aasthaengg/IBMdataset", "path": "/Python_codes/p02630/s363208865.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Aasthaengg/IBMdataset path: /Python_codes/p02630/s363208865.py n = int(input()) li_a = list(map(int, input().split())) dic_a = {} for a in li_a: dic_a[a] = dic_a.get(a, 0) + 1 <|fim_suffix|>for i in range(q): li_bc.append(tuple(map(int, input().split()))) answer = sum(li_a) for l in l...
code_fim
easy
{ "lang": "python", "repo": "Aasthaengg/IBMdataset", "path": "/Python_codes/p02630/s363208865.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: FirmianaPlatform/SourceCode path: /Firmiana Frontend/experiments/admin.py from django.contrib import admin from django.contrib.auth.models import * from experiments.models import * admin.site.register(Experimenter) admin.site.register(All_Company) admin.site.register(All_Laboratory) ''' class U...
code_fim
hard
{ "lang": "python", "repo": "FirmianaPlatform/SourceCode", "path": "/Firmiana Frontend/experiments/admin.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#Reagent Type Model admin.site.register(Antigen_species) admin.site.register(Antigen_clonal_type) admin.site.register(Antigen_modification) class AntigenAdmin(admin.ModelAdmin): list_display = ('gene_id', 'host_species', 'clonal_type', 'modification') #raw_id_fields = ('gene_id', 'host_species', '...
code_fim
hard
{ "lang": "python", "repo": "FirmianaPlatform/SourceCode", "path": "/Firmiana Frontend/experiments/admin.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: mindspore-ai/models path: /research/cv/ISyNet/eval.py # Copyright 2022 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apach...
code_fim
hard
{ "lang": "python", "repo": "mindspore-ai/models", "path": "/research/cv/ISyNet/eval.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # define loss, model if config.dataset == "imagenet2012": if not config.use_label_smooth: config.label_smooth_factor = 0.0 loss = CrossEntropySmooth(sparse=True, reduction='mean', smooth_factor=config.label_smooth_factor, num_classes=co...
code_fim
hard
{ "lang": "python", "repo": "mindspore-ai/models", "path": "/research/cv/ISyNet/eval.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.axes = self.get_axes() self.axes.x_axis.set_color(BLUE) self.axes.y_axis.set_color(GREEN) self.axes.z_axis.set_color(RED) # self.set_axes_labels() self.axes.shift(self.axes_center_point) self.add(self.axes) def init_paraboloid(self): paraboloid = self.paraboloid = ParaboloidPolar(**...
code_fim
hard
{ "lang": "python", "repo": "Abhigyan-Mishra/Quantum-Animation", "path": "/my_project/evolution_forces.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Abhigyan-Mishra/Quantum-Animation path: /my_project/evolution_forces.py from manimlib.imports import * """ TODO: [ ] fix arrow head size auto scale according to size? have a default size, but, if the arrow size is too short, then shrink the head [ ] slide the point according to the gradient ...
code_fim
hard
{ "lang": "python", "repo": "Abhigyan-Mishra/Quantum-Animation", "path": "/my_project/evolution_forces.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Akash049/cyclone-app-container path: /forecast/serializers.py from rest_framework import serializers from .models import * <|fim_suffix|> model = Forecast fields = ('place_name','cyclone_id','cyclone_name','image_link','time_of_last_forecast','created_at')<|fim_middle|>class Forec...
code_fim
medium
{ "lang": "python", "repo": "Akash049/cyclone-app-container", "path": "/forecast/serializers.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> class Meta(): model = Forecast fields = ('place_name','cyclone_id','cyclone_name','image_link','time_of_last_forecast','created_at')<|fim_prefix|># repo: Akash049/cyclone-app-container path: /forecast/serializers.py from rest_framework import serializers from .models import * <|fim_m...
code_fim
easy
{ "lang": "python", "repo": "Akash049/cyclone-app-container", "path": "/forecast/serializers.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>MongoDB allows us to store lists of items natively, so rather than having a link table, we can just store a list of tags in each post. 可以使用to_json或者to_mongo来显示document的内容: json.loads(post1.to_json()) {u'_cls': u'Post.TextPost', u'_id': {u'$oid': u'57ac28a0541ccf99ac3eb44a'}, u'author': {u'$oid': u'57ac...
code_fim
hard
{ "lang": "python", "repo": "largeriver/python-demos", "path": "/tumblelog/models2.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: largeriver/python-demos path: /tumblelog/models2.py # -*- coding: utf-8 -*- ''' 本文件参照 https://mongoengine-odm.readthedocs.io/tutorial.htm来编写 ''' from mongoengine import Document, StringField, ReferenceField, ListField, EmbeddedDocument, EmbeddedDocumentField, \ CASCADE <|fim_suffix|>''' An...
code_fim
medium
{ "lang": "python", "repo": "largeriver/python-demos", "path": "/tumblelog/models2.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> title = StringField(max_length=120, required=True) # reverse_delete_rule: To delete all the posts if a user is deleted set the rule: author = ReferenceField(User, reverse_delete_rule=CASCADE) tags = ListField(StringField(max_length=30)) comments = ListField(EmbeddedDocumentField(Comme...
code_fim
hard
{ "lang": "python", "repo": "largeriver/python-demos", "path": "/tumblelog/models2.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # 订单数量 res = orders['customer'].value_counts().to_dict() content['orders_by_companys'] = [{'name': k, 'value': v} for k, v in res.items()] content['total_order'] = sum(res.values()) # 状态 states = list(orders['state'].value_counts().to_dict().keys()) content['orders_by_states']...
code_fim
hard
{ "lang": "python", "repo": "liangxuCHEN/bi_sys", "path": "/anthony_bi/views.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # 按时间分类 new_order = orders.set_index('created') orders['updated'] = orders['updated'].apply(lambda x: x.strftime('%Y-%m-%d %H:%M:%S')) orders['created'] = orders['created'].apply(lambda x: x.strftime('%Y-%m-%d %H:%M:%S')) # 表格数据 content = { 'table_data': orders.to_dict(ori...
code_fim
hard
{ "lang": "python", "repo": "liangxuCHEN/bi_sys", "path": "/anthony_bi/views.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: liangxuCHEN/bi_sys path: /anthony_bi/views.py # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.shortcuts import render, get_object_or_404 from django.http import HttpResponse, HttpResponseRedirect, StreamingHttpResponse from anthony_bi.sql import Order_info, NewTable ...
code_fim
hard
{ "lang": "python", "repo": "liangxuCHEN/bi_sys", "path": "/anthony_bi/views.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> nodes_content = self.export_nodes().to_csv(sep=delimiter, index=False) edges_content = self.export_edges().to_csv(sep=delimiter, index=False) nodes_file_name = 'nodes.' + extention edges_file_name = 'edges.' + extention def add_to_tar(tar, filename, filecontent): ...
code_fim
hard
{ "lang": "python", "repo": "justaddcoffee/kgx", "path": "/kgx/pandas_transformer.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }