diff --git "a/4706.jsonl" "b/4706.jsonl" new file mode 100644--- /dev/null +++ "b/4706.jsonl" @@ -0,0 +1,673 @@ +{"seq_id":"419966038","text":"from hefunctions import *\r\n\r\nturtle.bgcolor(\"pink\")\r\nturtle.colormode(255)\r\nturtle.tracer(False)\r\nbob=turtle.Turtle\r\nturtle.speed(0)\r\nturtle.shape(\"triangle\")\r\n\r\n\r\n\r\n\r\nfor time in range(12):\r\n spikeFlower(36-time * 10)\r\n spike(200-time * 10)\r\n turtle.penup()\r\n turtle.home()\r\n turtle.pendown()\r\n turtle.right(time * 36)\r\nturtle.tracer(True)\r\n","sub_path":"11223.py","file_name":"11223.py","file_ext":"py","file_size_in_byte":360,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"11"} +{"seq_id":"408161016","text":"\ntexto_usuario = input(\"¿Que frase quieres descomponer en vocales?\")\n\nfrase = []\nvocales = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n\nfor indice in texto_usuario:\n if indice in vocales:\n frase.append(indice)\n\nprint(frase)\n","sub_path":"vocales_mostradas.py","file_name":"vocales_mostradas.py","file_ext":"py","file_size_in_byte":217,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"11"} +{"seq_id":"512560730","text":"from os import makedirs\nfrom os.path import join, exists\nfrom datetime import datetime\nfrom dateutil import parser\n\nimport json\nimport requests\nDATA_DIR = 'mydata'\nmakedirs(DATA_DIR, exist_ok=True)\nSOURCE_URL = 'http://www.saferproducts.gov/RestWebServices/Recall'\nDATA_FILENAME = join('mydata', 'saferproducts-recalls-2016.json')\n\n\n\ndef get_data():\n if not exists(DATA_FILENAME):\n print(\"Downloading\", SOURCE_URL, 'and saving to', DATA_FILENAME)\n resp = requests.get(SOURCE_URL, params={'format': 'json', 'RecallDateStart': 2016})\n with open(DATA_FILENAME, 'w') as wf:\n wf.write(resp.text)\n txt = resp.text\n else:\n with open(DATA_FILENAME, 'r') as rf:\n txt = rf.read()\n return clean_data(txt)\n\n\ndef prettify_date_string(datetxt):\n dt = parser.parse(datetxt)\n return dt.strftime(\"%Y-%m-%d\")\n\ndef clean_data(txt):\n datarows = json.loads(txt)\n xrows = []\n for row in datarows:\n x = {}\n x['title'] = row['Title']\n x['url'] = row['URL']\n x['recall_date'] = prettify_date_string(row['RecallDate'])\n if row['Images']:\n x['image_url'] = row['Images'][0]['URL']\n if row['Injuries']:\n x['injuries'] = row['Injuries'][0]['Name']\n if 'None' in x['injuries']:\n x['has_injuries'] = False\n else:\n x['has_injuries'] = True\n\n # injuries\n if row['Injuries']:\n x['injuries'] = row['Injuries'][0]['Name']\n if 'None' in x['injuries']:\n x['has_injuries'] = False\n else:\n x['has_injuries'] = True\n else:\n x['injuries'] = 'N/A'\n x['has_injuries'] = False\n # product type\n if row['Products']:\n x['product_type'] = row['Products'][0]['Type']\n x['product_id'] = row['Products'][0]['CategoryID']\n else:\n x['product_type'] = 'N/A'\n x['product_id'] = 'None'\n xrows.append(x)\n\n return xrows\n\n\n\n","sub_path":"source/files/flask-recalls/code/recalls/flaskapps/05/datafoo.py","file_name":"datafoo.py","file_ext":"py","file_size_in_byte":2046,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"11"} +{"seq_id":"3584861","text":"# coding: utf-8\n\nfrom cardio_clean.metadata import *\n\n\ndef test_conv():\n fs = 250\n smp = fs\n\n assert ms_to_samples(samples_to_ms(smp, fs), fs) == smp\n assert samples_to_ms(fs, fs) == 1000.0\n","sub_path":"cardio-clean/test/test_algos.py","file_name":"test_algos.py","file_ext":"py","file_size_in_byte":202,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"11"} +{"seq_id":"19224344","text":"from vpython import*\r\n\r\n\r\nclass Reflection():\r\n def __init__(self):\r\n\r\n\r\n mirror = box(pos=vector(0,-2,0),size=vector(7,0.1,7),color=vector(0.75,0.75,0.75))\r\n #get_sides(mirror)\r\n\r\n red_light = sphere(pos=vector(-1.9,4,0),radius=0.1,color=color.red,vel=vector(1,-2,0),make_trail=True,trail_type=\"points\")\r\n\r\n green_light = sphere(pos=vector(1.9,4,0),radius=0.1,color=color.green,vel=vector(-1,-2,0),make_trail=True,trail_type=\"points\")\r\n\r\n time = 0\r\n dt = 0.1\r\n while(time<4):\r\n rate(10)\r\n red_light.pos += red_light.vel*dt\r\n green_light.pos += green_light.vel*dt\r\n if (red_light.pos.y .\\n\"\n \"@prefix owl: .\\n\"\n \"@prefix rdfs: .\\n\"\n \"\\n\"\n \"atwas: a owl:Ontology ;\\n\"\n ' rdfs:comment \"All the world’s a stage.\"@en ;\\n'\n ' owl:versionInfo \"0.1.0\"@en .\\n'\n \"\\n\"\n )\n\n\n# \n\n\n# \n# \n# \n# \n# \n# \n# ]>\n\n\n# \n# \n","sub_path":"test/test_polti.py","file_name":"test_polti.py","file_ext":"py","file_size_in_byte":1995,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"11"} +{"seq_id":"349303162","text":"# coding=utf-8\n'''\n从二叉树的节点A出发,可以向上或者向下走,但是沿途的节点只能经过一次,\n当到达节点B时,路上的节点数叫做A到B的距离\n\n该问题等价于\n\n二叉树中经过某一节点的最大路径长度\n'''\n\nclass TreeNode:\n def __init__(self, val):\n self.val = val\n self.left, self.right = None, None\n\n\ndef process_length(root, max_length):\n '''\n 二叉树中经过某一节点的最大路径长度\n '''\n left_length, right_length = 0, 0\n if root.left:\n # 1为root到root.left之间的边的权值\n left_length = process_length(root.left, max_length) + 1\n if root.right:\n # 1为root到root.right之间的边的权值\n right_length = process_length(root.right, max_length) + 1\n total_length = left_length + right_length\n max_length[0] = total_length if total_length > max_length[0] else max_length[0]\n # 返回值为单结点深度,即只能为左子树或右子树的深度\n return left_length if left_length >= right_length else right_length\n\n\ndef process_sum(root, max_sum):\n '''\n 二叉树中经过某一节点的最大路径和\n '''\n left_sum, right_sum = 0, 0\n if root.left:\n left_sum = process_sum(root.left, max_sum) + root.left.val\n if root.right:\n right_sum = process_sum(root.right, max_sum) + root.right.val\n total_sum = left_sum + right_sum + root.val\n max_sum[0] = total_sum if total_sum > max_sum[0] else max_sum[0]\n return left_sum if left_sum >= right_sum else right_sum\n\n\ndef maxPath(root):\n if not root:\n return -1\n max_length = [0]\n process_length(root, max_length)\n max_sum = [0]\n process_sum(root, max_sum)\n return max_length[0], max_sum[0]\n\n\nif __name__ == '__main__':\n '''\n 构造树\n 1\n 2\n 3 4\n 5\n 10 6\n 最长路径:3 -> 2 -> 4 -> 5 -> 6/10,共有4条边\n 最长路径和:3 -> 2 -> 4 -> 5 -> 10,和为3+2+4+5+10=24\n '''\n node1 = TreeNode(1)\n node2 = TreeNode(2)\n node3 = TreeNode(3)\n node4 = TreeNode(4)\n node5 = TreeNode(5)\n node6 = TreeNode(6)\n node10 = TreeNode(10)\n node1.left = node2\n node2.left = node3\n node2.right = node4\n node4.left = node5\n node5.left = node10\n node5.right = node6\n print(maxPath(node1))\n","sub_path":"程序员面试指南/第三章-二叉树/20-二叉树节点间的最大距离.py","file_name":"20-二叉树节点间的最大距离.py","file_ext":"py","file_size_in_byte":2379,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"11"} +{"seq_id":"335119650","text":"import cPickle\r\nimport gzip\r\nimport os\r\nimport sys\r\nimport time\r\nimport copy\r\nimport scipy.io as sio\r\nimport numpy\r\nimport random\r\nimport theano\r\nimport theano.tensor as T\r\nfrom theano.tensor.signal import downsample\r\nfrom theano.tensor.nnet import conv\r\n\r\nclass ConvPoolLayer(object):\r\n\r\n def __init__(self, rng, input, image_shape, filter_shape, pool_shape, W=None, b=None):\r\n# assert image_shape[1] == filter_shape[1]\r\n filter_shape = 5\r\n fan_in = numpy.prod(filter_shape[1:])\r\n fan_out = (filter_shape[0] * numpy.prod(filter_shape[2:]) / numpy.prod(pool_shape))\r\n if W == None:\r\n self.W = theano.shared(numpy.asarray(rng.uniform(low=-numpy.sqrt(6. / (fan_in + fan_out)), \r\n high=+numpy.sqrt(6. / (fan_in + fan_out)), \r\n size=filter_shape),\r\n dtype=theano.config.floatX),\r\n name='W', borrow=True)\r\n else:\r\n self.W = theano.shared(W, name='W', borrow=False)\r\n if b == None:\r\n self.b = theano.shared(value=numpy.zeros((filter_shape[0],), \r\n dtype=theano.config.floatX), \r\n name='b', borrow=True)\r\n else:\r\n self.b = theano.shared(b, name='b', borrow=False)\r\n\r\n conv_out = conv.conv2d(input=input, filters=self.W, \r\n image_shape=image_shape, filter_shape=filter_shape)\r\n pool_out = downsample.max_pool_2d(input=conv_out, \r\n ds=pool_shape, ignore_border=True)\r\n self.output = T.tanh(pool_out + self.b.dimshuffle('x', 0, 'x', 'x'))\r\n self.params = [self.W, self.b]\r\n\r\nclass FullLayer(object):\r\n\r\n def __init__(self, rng, input, n_in, n_out, W=None, b=None):\r\n if W == None:\r\n self.W = theano.shared(value=numpy.asarray(rng.uniform(low =-numpy.sqrt(6. / (n_in + n_out)), \r\n high=+numpy.sqrt(6. / (n_in + n_out)), \r\n size=(n_in, n_out)), \r\n dtype=theano.config.floatX), \r\n name='W', borrow=True)\r\n else:\r\n self.W = theano.shared(W, name='W', borrow=False)\r\n if b == None:\r\n self.b = theano.shared(value=numpy.zeros((n_out,), \r\n dtype=theano.config.floatX), \r\n name='b', borrow=True)\r\n else:\r\n self.b = theano.shared(b, name='b', borrow=False)\r\n\r\n self.output = T.tanh(T.dot(input, self.W) + self.b)\r\n self.params = [self.W, self.b]\r\n\r\nclass SoftmaxLayer(object):\r\n\r\n def __init__(self, rng, input, n_in, n_out, W=None, b=None):\r\n if W == None:\r\n self.W = theano.shared(value=numpy.asarray(rng.uniform(low =-numpy.sqrt(6. / (n_in + n_out)), \r\n high=+numpy.sqrt(6. / (n_in + n_out)), \r\n size=(n_in, n_out)), \r\n dtype=theano.config.floatX), \r\n name='W', borrow=True)\r\n else:\r\n self.W = theano.shared(W, name='W', borrow=False)\r\n if b == None:\r\n self.b = theano.shared(value=numpy.zeros((n_out,),\r\n dtype=theano.config.floatX),\r\n name='b', borrow=True)\r\n else:\r\n self.b = theano.shared(b, name='b', borrow=False)\r\n self.output = T.nnet.softmax(T.dot(input, self.W) + self.b)\r\n self.y_pred = T.argmax(self.output, axis=1)\r\n self.params = [self.W, self.b]\r\n\r\n def negative_log_likelihood(self, y):\r\n return -T.mean(T.log(self.output)[T.arange(y.shape[0]), y]) # + lambda / 2.0 * T.dot(self.W, self.W) / self.W.shape[0] / self.W.shape[1]\r\n\r\n def errors(self, y):\r\n if y.ndim != self.y_pred.ndim:\r\n raise TypeError('y should have the same shape as self.y_pred',\r\n ('y', target.type, 'y_pred', self.y_pred.type))\r\n if y.dtype.startswith('int'):\r\n return T.mean(T.neq(self.y_pred, y))\r\n else:\r\n raise NotImplementedError()\r\n","sub_path":"HSICNN/CNN-python/ours/our_other_based/theano-based-4-neighbor-real/layer.py","file_name":"layer.py","file_ext":"py","file_size_in_byte":4577,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"11"} +{"seq_id":"89618295","text":"# -*- coding: utf-8 -*-\nfrom odoo import api, models\n\n\nclass InitScript(models.Model):\n\n _name = 'init.script'\n _description = 'Init Script'\n\n @api.model\n def create(self, vals):\n\n self = self.with_context(dict(active_test=False))\n projects = self.env['project.project'].search([('key', '=', False)])\n for project in projects:\n project.key = \"\".join(project.name.split())[:3].upper()\n for task in self.env['project.task'].search([('project_id', '=', project.id)], order='create_date'):\n task.number = project.get_next_task_number()\n\n return super(InitScript, self).create(vals)\n","sub_path":"project_helpdesk/models/init_script.py","file_name":"init_script.py","file_ext":"py","file_size_in_byte":655,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"11"} +{"seq_id":"147079651","text":"# -*- coding: utf-8 -*-\n\nfrom odoo import api, fields, models\n\n\nclass Product(models.Model):\n _inherit = 'product.template'\n\n rent_disc_available = fields.Boolean(\"Discount Available\")\n rent_disc = fields.Integer(\"Discount\")\n rent_disc_price = fields.Float(compute=\"_compute_rent_disc_price\", string=\"Final Price\", store=True)\n\n @api.depends('rent_disc_available', 'rent_disc')\n def _compute_rent_disc_price(self):\n for product in self:\n product.rent_disc_price = product.rent_price - ((product.rent_price * product.rent_disc) / 100)\n","sub_path":"beta-dev1/modifier_honos_theme/models/product.py","file_name":"product.py","file_ext":"py","file_size_in_byte":570,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"11"} +{"seq_id":"608404270","text":"#list is a collections\n\n# Create lists manually\nlist1234=[1,2,3,4]\nprint(list1234)\n\n# Create lists using Dictionary\n\n\n# Create lists using Tuple\n\n\n# Create lists using Stack\n\n\n# Create lists using Queue\n\n# Array\n# Arrays is a list with indexing\nlist=[1,2,3]\nlist[0]\n\n# %%\nlen(list)\n\n# %%\nlist_pointer=list\n\n# %%\nempty_list=[]\n\n# %%\nlist2=['hello world','how are you doing']\n\n# %%\nlist+list2\n\n# %%\nitems=[0,1,2,3,5]\n\n# %%\nsum=0\nfor item in items:\n sum+=item\n print (sum)\n\n# %%\nif 0 in items:\n print (\"Hey\")\n\n# %%\nstring=\"Hello\"\n\n# %%\nfor character in string:\n print (character)\n\n# %%\nrange(10)\n\n# %%\nrange_numbers=range(10)\n\n# %%\nprint (range_numbers)\n\n# %%\nfor item in range_numbers:\n print (item)\n\n# %%\nlist1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13]\n\n# %%\ni=0\nwhile i<=len(list1):\n print (list1[i])\n i=i+3\n\n# %%\n\"\"\"\n### List methods\n\"\"\"\n\n# %%\nlist1.append(3)\n\n# %%\nprint(list1)\n#adds teh element at the end of the list\n\n# %%\nlist1.insert(1,100)\n\n# %%\nprint (list1)\n\n# %%\nlist2=[100,200,300]\n\n# %%\nlist1.extend(list2)\n\n# %%\nlist1\n\n# %%\nlist1+list2\n\n# %%\n#Sort\n\n# %%\nlist1.sort()\n\n# %%\nlist1\n\n# %%\n#Find the index of an element in the list\n\n# %%\nlist1.index(200)\n\n# %%\nlist1.remove(100)\n\n# %%\nlist1\n\n# %%\nlist1.insert(4,400)\n\n# %%\nlist1\n\n# %%\nlist1.remove(400)\n\n# %%\nlist1\n\n# %%\nlist1.reverse()\n\n# %%\nlist1\n\n# %%\nlist1.pop()\n\n# %%\nlist1.pop(4)\n\n# %%\nempty_list=[]\n\n# %%\nempty_list.append(4)\n\n# %%\nempty_list\n\n# %%\nlist1\n\n# %%\nlist1[2:]\n\n# %%\nlist1[2:3]\n\n# %%\nlen(list1)\n\n# %%\n\"\"\"\n# 2D array\n\"\"\"\n\n# %%\n#!/bin/python3\nimport math\nimport os\nimport random\nimport re\nimport sys\n\n# Complete the hourglassSum function below.\ndef hourglassSum(arr):\n result=[sum(arr[i-1][j-1:j+2] + [arr[i][j]] + arr[i+1][j-1:j+2]) for j in range(1, 5) for i in range(1, 5)]\n print (result)\n return max(result)\n\nif __name__ == '__main__':\n arr = []\n for _ in range(6):\n arr.append(list(map(int, input().rstrip().split())))\n result = hourglassSum(arr)\n print((str(result) + '\\n'))\n\n# %%\narr[0][0:3]\n\n# %%\narr[1][1]\n\n# %%\narr[2][0:3]\n\n# %%\nlen(arr)\n\n# %%\nlen(arr[0])\n\n# %%\nrange(5)\n\n# %%\nlst=[]\nfor i in range(len(arr)-1):\n for j in range(len(arr[0])-1):\n res=[sum(arr[i][j:j+3]+arr[i+1][j+1]+arr[i+2][j:j+3])]\n print(res)\n lst.append(res)\n\n\n# %%\na = [1,2,3,4]\nb = [x*x for x in a]\n\n# %%\na\n\n# %%\nb\n\n# %%\nfor item in b:\n print (item)\n\n# %%\nsum([1,2]+[2,3])\n\n# %%\n","sub_path":"lists.py","file_name":"lists.py","file_ext":"py","file_size_in_byte":2403,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"11"} +{"seq_id":"320666087","text":"from flask import Flask, send_file\nfrom flask_cors import CORS\n\napp = Flask(__name__)\nCORS(app)\n\n@app.route(\"/\")\ndef helloWorld():\n try:\n img = open(\"../latest.jpg\")\n return send_file(\"../latest.jpg\", mimetype=\"image/jpg\")\n except:\n return \"Image doesn't exist!\"\n\napp.run(host= '0.0.0.0')","sub_path":"demo3/server-app.py","file_name":"server-app.py","file_ext":"py","file_size_in_byte":315,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"11"} +{"seq_id":"526298704","text":"#!/usr/bin/env python\n'''\nMakes nice plots with ratio from histograms made using makeHistos.py\nAuthor: T.M.Perry UW\n'''\nimport ROOT\nfrom ROOT import THStack,TH1F,TFile\nfrom ROOT import TLegend,TCanvas,TPad,TLatex,TLine\nfrom ROOT import gROOT,gStyle\nimport histoRange as hr\nimport cmsPrelim as cpr\nimport TheParameters as p\n \n# scale factors : sf_qcd = 1 + (data-allMC)/qcd in 0