diff --git "a/3532.jsonl" "b/3532.jsonl" new file mode 100644--- /dev/null +++ "b/3532.jsonl" @@ -0,0 +1,634 @@ +{"seq_id":"644406453","text":"# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Mar 12 16:48:43 2020\n\n@author: Espen\n\"\"\"\n\nimport matplotlib.pyplot as plt\nplt.rcParams[\"figure.figsize\"]=(7,4)\n\n\nfile = open(\"C:/Users/Espen/OneDrive – NTNU/TFY4235 Numfys/Assignment 2/Results/Task 9/MetadataMultisys0.01-5.0-100avgs.txt\",\"r\")\n\ndtMult = []\ntauMult = []\ndeltaUMult = []\nkBTMult = []\nendPosMult = []\ndriftVelsMult = []\ndegeneracy = int(file.readline().split()[-1])\n\nfor line in file.readlines():\n ll = line.split()\n dtMult.append(float(ll[1]))\n tauMult.append(float(ll[2]))\n deltaUMult.append(float(ll[6]))\n kBTMult.append(float(ll[7]))\n endPosMult.append(float(ll[8]))\n driftVelsMult.append(float(ll[9]))\n\nfile.close()\n\navgDriftVel = sum(driftVelsMult)/len(driftVelsMult)\n\nprint(avgDriftVel, \"um/s\")\n##For plotting the average drift velocities as a function of tau\n\n##Average over the degeneracy\nfig = plt.figure()\ndriftVelAvg = []\n#degeneracy = 100 #How many trials per choice of tau? \ntempSum = driftVelsMult[0]\nfor i in range(1, len(tauMult)+1):\n if i%degeneracy != 0:\n tempSum += driftVelsMult[i]\n elif i%degeneracy ==0:\n driftVelAvg.append((tempSum/degeneracy))\n if i < len(tauMult):\n tempSum = driftVelsMult[i]\n\nz = tauMult[::degeneracy]\n\n\nprint(f\"Max velocity is {max(driftVelAvg)} µm/s, which occurs at tau = {z[driftVelAvg.index(max(driftVelAvg))]}\")\n\nplt.plot(z,driftVelAvg)\nplt.title(\"Drift velocity vs. time periodicity of ratchet\")\nplt.xlabel(r\"$\\tau$ [s]\")\nplt.ylabel(r\"$\\langle v_{drift} \\rangle$ [µm/s]\")\n\nplt.show()\n","sub_path":"Assignment 2/MultisysPlot.py","file_name":"MultisysPlot.py","file_ext":"py","file_size_in_byte":1554,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"25"} +{"seq_id":"433441876","text":"import signal\nfrom argparse import ArgumentParser\n\nfrom wom.corpgen import ConfigMap, DEFAULT_SETTINGS, CorpusGenerator\nfrom wom.util import basic_logger as log\n\n\ndef main():\n\n # handle interrupts\n def sigint_handler(input_signal, frame):\n log.info(\"received stop signal SIGINT\")\n cg.stop()\n\n # register sigint handler\n signal.signal(signal.SIGINT, sigint_handler)\n\n # set up an command line option parser\n parser = ArgumentParser()\n parser.add_argument(\n \"--config\",\n required=True,\n action=\"store\",\n dest=\"config_file\",\n metavar=\"FILE\",\n help=\"specify a path to a configuration\",\n )\n\n # parse command line options\n args = parser.parse_args()\n\n # create a central configuration source\n config = ConfigMap()\n # apply default configurations\n config.apply_map(DEFAULT_SETTINGS)\n # apply input configuration\n config.apply_file(args.config_file)\n\n # initialize and run the corpus generator\n cg = CorpusGenerator(config)\n cg.start()\n\n\nif __name__ == \"__main__\":\n main()\n","sub_path":"wom/corpgen/__main__.py","file_name":"__main__.py","file_ext":"py","file_size_in_byte":1081,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"25"} +{"seq_id":"543264794","text":"#https://www.jianshu.com/p/d9f1a5d15de8\nimport requests\nimport json\nimport time\n\nwith open(r'C:\\Users\\Administrator\\Desktop\\xag\\xag.csv','w+',encoding='utf-8') as f:\n for a in range(3):\n url = \"https://movie.douban.com/j/new_search_subjects?sort=T&range=0,10&tags=%E5%8A%B1%E5%BF%97&start={}\".format(20*3)\n #这里跟之前的不一样,因为返回的是 json 文件\n #之前我们用的 .text 是需要网页返回文本的信息,而这里返回的是 json文件所以用 .json()\n file = requests.get(url).json()\n time.sleep(2)\n # print(len(file['data']))\n for index in range(20):\n #取出字典中 'data' 下第 [i] 部电影的信息;取出字典中的值,需要在方括号中指明值对应的键\n dict = file['data'][index]\n #电影链接\n href = dict['url']\n #标题\n title = dict['title']\n #评分\n rate=dict['rate']\n #主演\n cast=dict['casts']\n #因为有多名演员,这里用了 join() 函数,在字符串中间加入空格分隔。\n# print('{} {} {} {}\\n'.format(title,rate,' '.join(cast),url))\n# f.write('{} {} {} {}\\n'.format(title,rate,' '.join(cast),url))\n f.write('{},{},{},{}\\n'.format(title,rate,' '.join(cast),url))\n \nprint('写入完成')\n \n ","sub_path":"Python/爬虫/DEMO/爬虫基本7课【xpath】/example7 爬JSON数据网站并保存到本地.py","file_name":"example7 爬JSON数据网站并保存到本地.py","file_ext":"py","file_size_in_byte":1401,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"25"} +{"seq_id":"25653525","text":"\"\"\"\nThis file is part of Buttonwood.\n\nButtonwood is a python software package created to help quickly create, (re)build, or\nanalyze markets, market structures, and market participants. \n\nMIT License\n\nCopyright (c) 2016-2020 Peter F. Nabicht\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\"\"\"\n\nFAR = 1\nFOK = 2\nFAK = 3\n\nTIME_IN_FORCE_STRINGS = {FAR: \"FAR\",\n FOK: \"FOK\",\n FAK: \"FAK\",\n }\n\nTIME_IN_FORCE_STR_TO_INT = {v: k for k, v in TIME_IN_FORCE_STRINGS.items()}\n\ndef time_in_force_str(int_id):\n assert isinstance(int_id, int)\n if int_id not in TIME_IN_FORCE_STRINGS:\n raise Exception(\"%d is an unknown time in force identifier\")\n return TIME_IN_FORCE_STRINGS[int_id]\n\nLIMIT = 100\nMARKET = 101\n\nORDER_TYPE_STRINGS = {LIMIT: \"Limit\",\n MARKET: \"Market\",\n }","sub_path":"buttonwood/MarketObjects/Events/OrderEventConstants.py","file_name":"OrderEventConstants.py","file_ext":"py","file_size_in_byte":1857,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"25"} +{"seq_id":"532641639","text":"import pandas as pd\r\nimport numpy as np\r\nfrom sklearn.feature_extraction.text import CountVectorizer\r\nfrom sklearn.metrics.pairwise import cosine_similarity\r\n\r\n# functions \r\ndef get_title_from_index(index):\r\n\treturn df[df.index == index][\"title\"].values[0]\r\n\r\ndef get_index_from_title(title):\r\n\treturn df[df.title == title][\"index\"].values[0]\r\n\r\n\r\n#Step 1: Read File\r\ndf=pd.read_csv(\"movie_dataset.csv\") \r\n\r\n\r\n#Step 2: Select Features\r\nfeatures = ['keywords','cast','genres','director']\r\nfor feature in features:\r\n\tdf[feature] = df[feature].fillna('')\r\n\r\n\r\n#Step 3:combining all features\r\ndef combine_features(row): \r\n\t\treturn row[\"keywords\"] +\" \"+row[\"cast\"] +\" \"+row[\"genres\"] +\" \"+row[\"director\"] \r\ndf[\"combined_features\"] = df.apply(combine_features,axis=1)\r\n\r\n\r\n#Step 4: extracting features from dataset\r\ncv=CountVectorizer()\r\ncount_matrix=cv.fit_transform(df[\"combined_features\"])\r\n\r\n#Step 5: using cosine similarity\r\ncosine_sim = cosine_similarity(count_matrix)\r\n\r\n\r\n# Step 6: Get index of this movie from its title\r\nmovie_user_likes = \"The Wood\"\r\nmovie_index = get_index_from_title(movie_user_likes)\r\n\r\n\r\n#Step 7: generate the similar movie matrix and sorted in descending order(similarity score)\r\nsimilar_movies = list(enumerate(cosine_sim[movie_index]))\r\nsorted_similar_movies = sorted(similar_movies,key=lambda x:x[1],reverse=True)\r\n\r\n\r\n#Step 8: printing the similar movies\r\ni=0\r\nprint(\"Top 10 similar movies to \"+movie_user_likes+\" are:\\n\")\r\nfor movie in sorted_similar_movies:\r\n\tprint(get_title_from_index(movie[0]))\r\n\ti=i+1\r\n\tif i>10:\r\n\t\tbreak\r\n\r\nprint(\"\\n\")\t\r\n","sub_path":"movie_recommendation.py","file_name":"movie_recommendation.py","file_ext":"py","file_size_in_byte":1575,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"25"} +{"seq_id":"95303198","text":"# -*- coding: utf-8 -*-\nimport httplib, urllib, json\nHOST_NAME = \"front-end\"\nPORT = 8079\ntest_count = 0\ntable_content = \"\"\n\ndef testResult(count,description,expected_value,actual_value):\n if(expected_value == actual_value):\n result = \"Passed\"\n class_result = \"table-success\"\n else:\n result = \"Failed\"\n class_result = \"table-danger\"\n content = \"
| # | \\\nDescription | \\\nExpected | \\\nActual | \\\nResult | \\\n
|---|