text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: pxcx/ambar-backend path: /config.py
import os
from flask import Flask, jsonify
from flask_cors import CORS
from flask_sqlalchemy import SQLAlchemy
<|fim_suffix|>#configurando o database
project_dir = os.path.dirname(os.path.abspath(__file__))
database_file = "sqlite:///{}".format(os.path.join(pr... | code_fim | medium | {
"lang": "python",
"repo": "pxcx/ambar-backend",
"path": "/config.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#configurando o database
project_dir = os.path.dirname(os.path.abspath(__file__))
database_file = "sqlite:///{}".format(os.path.join(project_dir, "database.db"))
app.config["SQLALCHEMY_DATABASE_URI"] = database_file
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)<|fim_prefix|># r... | code_fim | medium | {
"lang": "python",
"repo": "pxcx/ambar-backend",
"path": "/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: facebookresearch/CrypTen path: /crypten/mpc/primitives/binary.py
is the number of parties present in the protocol (world_size).
"""
def __init__(
self, tensor=None, size=None, broadcast_size=False, src=0, device=None
):
"""
Creates the shared tensor from the ... | code_fim | hard | {
"lang": "python",
"repo": "facebookresearch/CrypTen",
"path": "/crypten/mpc/primitives/binary.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: facebookresearch/CrypTen path: /crypten/mpc/primitives/binary.py
"
Creates the shared tensor from the input `tensor` provided by party `src`.
The other parties can specify a `tensor` or `size` to determine the size
of the shared tensor object to create. In this case, all ... | code_fim | hard | {
"lang": "python",
"repo": "facebookresearch/CrypTen",
"path": "/crypten/mpc/primitives/binary.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.eq(y) ^ 1
def lt(self, y):
return circuit.lt(self, y)
def le(self, y):
return circuit.le(self, y)
def gt(self, y):
return circuit.gt(self, y)
def ge(self, y):
return circuit.ge(self, y)
def __setitem__(self, index, value):
... | code_fim | hard | {
"lang": "python",
"repo": "facebookresearch/CrypTen",
"path": "/crypten/mpc/primitives/binary.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ket.error:
return False
if len(ad) > 1:
# ":" not followed by a port number?
if len(ad[1])>0:
try:
_ = int(ad[1])
return True
except:
return False
# IP address without a port number.
return False<|f... | code_fim | medium | {
"lang": "python",
"repo": "cbonello/kv-store",
"path": "/python/ip.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cbonello/kv-store path: /python/ip.py
import socket
# Good enough for my test project. Check https://stackoverflow.com/questions/319279/how-to-validate-ip-address-in-python
# if you want to go further.
def isValidIP(ip):
ad = ip.split(":")
if len(ad) > 2:
return False
try:
... | code_fim | medium | {
"lang": "python",
"repo": "cbonello/kv-store",
"path": "/python/ip.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ronaldoussoren/pyobjc path: /pyobjc-framework-Quartz/Examples/TLayer/TLayerView.py
import Cocoa
import objc
import Quartz
from Circle import Circle
from Extras import makeRandomPointInRect
from objc import super
gCircleCount = 3
class NSEvent(objc.Category(Cocoa.NSEvent)):
def locationInVi... | code_fim | hard | {
"lang": "python",
"repo": "ronaldoussoren/pyobjc",
"path": "/pyobjc-framework-Quartz/Examples/TLayer/TLayerView.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dx = 2 * abs(self.shadowOffset.width) + 2 * self.shadowRadius
dy = 2 * abs(self.shadowOffset.height) + 2 * self.shadowRadius
return Cocoa.NSInsetRect(circle.bounds(), -dx, -dy)
def dragCircleAtIndex_withEvent_(self, index, event):
circle = self.circles[index]
d... | code_fim | hard | {
"lang": "python",
"repo": "ronaldoussoren/pyobjc",
"path": "/pyobjc-framework-Quartz/Examples/TLayer/TLayerView.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def main(_):
"""
Main function
"""
# Print all Flags to confirm parameter settings
print_flags()
# Make directories if they do not exists yet
if not tf.gfile.Exists(FLAGS.log_dir):
tf.gfile.MakeDirs(FLAGS.log_dir)
if not tf.gfile.Exists(FLAGS.data_dir):
tf... | code_fim | hard | {
"lang": "python",
"repo": "QingheGao/deep_learning-1",
"path": "/lab1/train_mlp_tf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: QingheGao/deep_learning-1 path: /lab1/train_mlp_tf.py
"""
This module implements training and evaluation of a multi-layer perceptron in TensorFlow.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import tensorflow a... | code_fim | hard | {
"lang": "python",
"repo": "QingheGao/deep_learning-1",
"path": "/lab1/train_mlp_tf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Training set
if _step % 13 == 0 and write_logs: # write summary
fetches += [summary_op]
_, train_loss, train_accuracy, train_summary = session.run(fetches=fetches, feed_dict=train_feed)
train_log_writer.add_summary(train_summary, _step)
else:
... | code_fim | hard | {
"lang": "python",
"repo": "QingheGao/deep_learning-1",
"path": "/lab1/train_mlp_tf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wook3024/fsdl-text-recognizer-2021-labs path: /lab5/text_recognizer/data/iam.py
"""Class for loading the IAM dataset, which encompasses both paragraphs and lines, with associated utilities."""
from pathlib import Path
from typing import Dict, List
import argparse
import os
import xml.etree.Elemen... | code_fim | hard | {
"lang": "python",
"repo": "wook3024/fsdl-text-recognizer-2021-labs",
"path": "/lab5/text_recognizer/data/iam.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def _get_line_regions_from_xml_file(filename: str) -> List[Dict[str, int]]:
"""Get the line region dict for each line."""
xml_root_element = ElementTree.parse(filename).getroot() # nosec
xml_line_elements = xml_root_element.findall("handwritten-part/line")
return [_get_line_region_from_x... | code_fim | hard | {
"lang": "python",
"repo": "wook3024/fsdl-text-recognizer-2021-labs",
"path": "/lab5/text_recognizer/data/iam.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhongtouwang2019/alphaBetaLab path: /test/testAbSingleCellBetaEstimator.py
import numpy as np
import math
import unittest
from shapely import geometry as g
from alphaBetaLab import abSingleCellAlphaEstimator
from alphaBetaLab import abSingleCellBetaEstimator
from alphaBetaLab.abSingleCellBetaEst... | code_fim | hard | {
"lang": "python",
"repo": "zhongtouwang2019/alphaBetaLab",
"path": "/test/testAbSingleCellBetaEstimator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> xoff = 30.
yoff = 40.
highResCellGrid = np.ones((5, 4))
highResCellGrid[0, 0] = 0
highResCellGrid[1, 1] = 0
highResCellGrid[2, 2] = 0
highResCellGrid[4, 3] = 0
highResCellGrid = highResCellGrid.transpose()
xs = np.array(range(5)) + xoff
ys = np.array(range(4)) + yo... | code_fim | hard | {
"lang": "python",
"repo": "zhongtouwang2019/alphaBetaLab",
"path": "/test/testAbSingleCellBetaEstimator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # redirect to the login page
return redirect(url_for('classes.index'))
else:
return render_template('classes/credit.html', create=True, form = form)
@classes.route('/<int:class_id>/edit', methods=['GET', 'POST'])
@login_required
def edit(class_id):
classObj = Class().query.get(class_id);
form = ... | code_fim | hard | {
"lang": "python",
"repo": "ngambmicheal/pythonsms",
"path": "/app/classes/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return redirect(url_for('classes.index'))
@classes.route('/<int:class_id>/assign_courses')
@login_required
def assign_courses(class_id):
return redirect(url_for('classes.index'))<|fim_prefix|># repo: ngambmicheal/pythonsms path: /app/classes/views.py
# app/classes/views.py
from flask import flash, r... | code_fim | medium | {
"lang": "python",
"repo": "ngambmicheal/pythonsms",
"path": "/app/classes/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ngambmicheal/pythonsms path: /app/classes/views.py
# app/classes/views.py
from flask import flash, redirect, render_template, url_for
from flask_login import login_required, login_user, logout_user
from . import classes
from forms import CrudForm
from .. import db
from ..models import Class
@c... | code_fim | hard | {
"lang": "python",
"repo": "ngambmicheal/pythonsms",
"path": "/app/classes/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.fixture
def simulate_train_test():
x, eta = scmodes.dataset.simulate_pois(n=200, p=300, rank=1, eta_max=3)
train, test = scmodes.benchmark.train_test_split(x)
return train, test, eta
@pytest.fixture
def test_data():
x = pd.read_csv(os.path.join(os.path.dirname(__file__), 'data', 'counts.t... | code_fim | hard | {
"lang": "python",
"repo": "aksarkar/scmodes",
"path": "/tests/benchmark/fixtures.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> x = pd.read_csv(os.path.join(os.path.dirname(__file__), 'data', 'counts.txt.gz'), sep='\t', index_col=0)
return x
@pytest.fixture
def test_adata():
x = pd.read_csv(os.path.join(os.path.dirname(__file__), 'data', 'counts.txt.gz'), sep='\t', index_col=0)
y = anndata.AnnData(ss.csr_matrix(x.values),... | code_fim | hard | {
"lang": "python",
"repo": "aksarkar/scmodes",
"path": "/tests/benchmark/fixtures.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aksarkar/scmodes path: /tests/benchmark/fixtures.py
import anndata
import numpy as np
import os
import pandas as pd
import pytest
import scipy.sparse as ss
import scmodes
@pytest.fixture
def dims():
# Data (n, p); latent representation (n, d)
n = 50
p = 1000
d = 20
stoch_samples = 10
... | code_fim | hard | {
"lang": "python",
"repo": "aksarkar/scmodes",
"path": "/tests/benchmark/fixtures.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if mime == 'text/plain':
return 'public.utf8-plain-text'
parts = mime.split('charset=', 1)
if len(parts) > 1:
charset = parts[1].split(';', 1)[0]
if charset == 'system':
return 'public.utf8-plain-text'
if charset in ('iso-106464-ucs-2', 'utf16'):
return 'public.utf16-plain-text'
... | code_fim | medium | {
"lang": "python",
"repo": "pixpil/gii",
"path": "/lib/gii/qt/Qt5Fix.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if flavor == 'public.utf8-plain-text':
return 'text/plain'
if flavor == 'public.utf16-plain-text':
return 'text/plain;charset=utf16'
return None
def convertFromMime(self, mime, data, flavor):
if flavor == 'public.utf8-plain-text':
return [data.encode('utf-8')]
if flavor == 'public.utf1... | code_fim | hard | {
"lang": "python",
"repo": "pixpil/gii",
"path": "/lib/gii/qt/Qt5Fix.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pixpil/gii path: /lib/gii/qt/Qt5Fix.py
##----------------------------------------------------------------##
from PyQt5.QtMacExtras import QMacPasteboardMime
class MacClipboardFix( QMacPasteboardMime ):
"""
Work around QTBUG-61562 on Mac, which can be reproduced as follows:
from PyQt5.QtWidg... | code_fim | hard | {
"lang": "python",
"repo": "pixpil/gii",
"path": "/lib/gii/qt/Qt5Fix.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> R.get(self.url, headers=h)
if rr.status_code == 200:
print ("Ok")
except R.exceptions.ConnectionError:
print ("Retrying...")
except R.exceptions.Timeout:
print ('')
exce... | code_fim | hard | {
"lang": "python",
"repo": "larrywach/YT_View_Bot",
"path": "/viewbot.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: larrywach/YT_View_Bot path: /viewbot.py
#!/usr/bin/python3
import requests as R
import random
class test:
def __init__(self, proxy, url):
self.proxy = proxy
self.url = url
def test(self):
a = R.get(self.proxy)
b = a.content.decode('utf-8')
... | code_fim | hard | {
"lang": "python",
"repo": "larrywach/YT_View_Bot",
"path": "/viewbot.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: neineit/angrop path: /setup.py
from setuptools import find_packages, setup
setup(
name='angrop',
version='9.0.gitrolling',
description='The rop chain builder based <|fim_suffix|> 'progressbar',
'tqdm',
'angr==9.0.gitrolling',
],
)<|fim_middle|>off of angr',
p... | code_fim | medium | {
"lang": "python",
"repo": "neineit/angrop",
"path": "/setup.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> 'progressbar',
'tqdm',
'angr==9.0.gitrolling',
],
)<|fim_prefix|># repo: neineit/angrop path: /setup.py
from setuptools import find_packages, setup
setup(
name='angrop',
version='9.0.gitrolling',
description='The rop chain builder based <|fim_middle|>off of angr',
p... | code_fim | medium | {
"lang": "python",
"repo": "neineit/angrop",
"path": "/setup.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: edge-analytics/fpga-sleep-tracker path: /fpga/source/nn/keras_to_sv.py
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PUR... | code_fim | hard | {
"lang": "python",
"repo": "edge-analytics/fpga-sleep-tracker",
"path": "/fpga/source/nn/keras_to_sv.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _generate_nn_layers_sv_entry(neurons_per_layer: List[int]) -> str:
sv_nn_layers = ""
num_layers = len(neurons_per_layer)
for i, num_neurons in enumerate(neurons_per_layer):
entry_delimiter = ",\n" if i < num_layers - 1 else ""
sv_nn_layers += "\t8\'d" + str(num_neurons) + e... | code_fim | hard | {
"lang": "python",
"repo": "edge-analytics/fpga-sleep-tracker",
"path": "/fpga/source/nn/keras_to_sv.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Keras to System Verilog code generator.")
parser.add_argument("-input", "-i", required=True,
help="Path to the .h5 keras fully connected model")
parser.add_argument("-output", "-o", required=True,
... | code_fim | hard | {
"lang": "python",
"repo": "edge-analytics/fpga-sleep-tracker",
"path": "/fpga/source/nn/keras_to_sv.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nsbgit/IIT-S21-CS-484 path: /Old Materials/Additional Github/dvtate/cs484/in-class/Week 3 Association Rule.py
import pandas
ToyAssoc = pandas.read_csv('C:\\Users\\minlam\\Documents\\IIT\\Machine Learning\\Data\\AssociationRuleToyExample.csv',
delimiter=',')
# Convert ... | code_fim | medium | {
"lang": "python",
"repo": "nsbgit/IIT-S21-CS-484",
"path": "/Old Materials/Additional Github/dvtate/cs484/in-class/Week 3 Association Rule.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Discover the association rules
assoc_rules = association_rules(frequent_itemsets, metric = "confidence", min_threshold = 0.5)<|fim_prefix|># repo: nsbgit/IIT-S21-CS-484 path: /Old Materials/Additional Github/dvtate/cs484/in-class/Week 3 Association Rule.py
import pandas
ToyAssoc = pandas.read_csv('C:\... | code_fim | medium | {
"lang": "python",
"repo": "nsbgit/IIT-S21-CS-484",
"path": "/Old Materials/Additional Github/dvtate/cs484/in-class/Week 3 Association Rule.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not isinstance(_function, FunctionType):
print(3)
return None, None
return _function, vars
if __name__ == '__main__':
eqn = "max(0, 1)"
print(parse_equation_01(eqn)[0]())<|fim_prefix|># repo: mjredmond/FEMApp path: /fem/utilities/equations/_equation_01.py
"""
Projec... | code_fim | medium | {
"lang": "python",
"repo": "mjredmond/FEMApp",
"path": "/fem/utilities/equations/_equation_01.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> vars_ = list(vars)
for var in vars_:
if var in _builtins:
vars.remove(var)
eqn_str = """from math import *\ndef %s%s:\n return %s""" % (func_name, str(tuple(vars)).replace("'", ""), eqn_str)
# print(eqn_str)
try:
compiled = compile(eqn_str, '', 'exec'... | code_fim | hard | {
"lang": "python",
"repo": "mjredmond/FEMApp",
"path": "/fem/utilities/equations/_equation_01.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mjredmond/FEMApp path: /fem/utilities/equations/_equation_01.py
"""
Project.x
Author: Michael Redmond
"""
from __future__ import print_function, absolute_import
from six import iteritems
from six.moves import range
import ast
from types import ModuleType, FunctionType
# noinspection PyUnre... | code_fim | hard | {
"lang": "python",
"repo": "mjredmond/FEMApp",
"path": "/fem/utilities/equations/_equation_01.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
self._count += value
except AttributeError:
self._count = 0
@CallCount
def hello(name):
print(f"Hello {name}")
if __name__ == "__main__":
hello("Ana")
hello("Annabelle")
hello("Miguel")
hello("Tony")
print(f"The function hello has bee... | code_fim | medium | {
"lang": "python",
"repo": "tonper19/PythonDemos",
"path": "/beyond_the_basics/03.closures_an_decorators/demo08_classes_as_decorators.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tonper19/PythonDemos path: /beyond_the_basics/03.closures_an_decorators/demo08_classes_as_decorators.py
"""Using a class as a decorator demo.
Count the number of times a function is called.
"""
class CallCount:
def __init__(self, function):
<|fim_suffix|>if __name__ == "__main__":
hello(... | code_fim | hard | {
"lang": "python",
"repo": "tonper19/PythonDemos",
"path": "/beyond_the_basics/03.closures_an_decorators/demo08_classes_as_decorators.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Abhijit-Code/pdf-table-extractor path: /src/scripts/DecisionBlock.py
from tika import parser
from pdfminer.pdfinterp import PDFResourceManager
from pdfminer.pdfdevice import PDFDevice
from PDF2PNG_w_GUI import pdf2png_gui
from Table_Crop import table_crop
# def make_decision(filepath):
# Open a ... | code_fim | hard | {
"lang": "python",
"repo": "Abhijit-Code/pdf-table-extractor",
"path": "/src/scripts/DecisionBlock.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#raise PDFTextExtractionNotAllowed
#CODE BLOCK FOR SCANNED PDF
#Step1. Goes to PDF2PNG
#Step2. Table_crop
#Step3. OCR
#Step4. Extract tabular data using tabula
#Done
else:
print ('SEARCHABLE PDF')
#CODE BLOCK FOR SEARCHABLE... | code_fim | medium | {
"lang": "python",
"repo": "Abhijit-Code/pdf-table-extractor",
"path": "/src/scripts/DecisionBlock.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: esajaa/mbl-tools path: /mbl-release-manager/cli.py
#!/usr/bin/env python3
# Copyright (c) 2018, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""
Entry point.
This script can be called from command line, or used from the mbl-tools.
In short:
* It ... | code_fim | medium | {
"lang": "python",
"repo": "esajaa/mbl-tools",
"path": "/mbl-release-manager/cli.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # update all files MBL_LINKED_REPOSITORIES_REPO_PATH in repositories
# MBL_LINKED_REPOSITORIES_REPO_NAME
rm.update_mbl_linked_repositories_conf()
# Commit MBL_LINKED_REPOSITORIES_REPO_NAME and MBL_MANIFEST_REPO_NAME
# and push to remote
rm.mbl_manifest_repo... | code_fim | hard | {
"lang": "python",
"repo": "esajaa/mbl-tools",
"path": "/mbl-release-manager/cli.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TobiaMarcucci/sos4hjb path: /sos4hjb/optimization/sos_program.py
from sos4hjb.polynomials import Polynomial
class SosProgramParent:
'''
Derived classes must implement the following methods:
- add_variables(size, name)
- add_psd_variable(size, name)
- add_linear_co... | code_fim | hard | {
"lang": "python",
"repo": "TobiaMarcucci/sos4hjb",
"path": "/sos4hjb/optimization/sos_program.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return poly, gram, cons
def add_sos_constraint(self, p, name='Q'):
# Raise error if polynomial has odd degree.
if p.degree() % 2:
raise ValueError(f'SOS polynomials must have even degree, got degree {p.degree()}.')
# Construct basis for auxiliary ... | code_fim | hard | {
"lang": "python",
"repo": "TobiaMarcucci/sos4hjb",
"path": "/sos4hjb/optimization/sos_program.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for timestamp, name, level, text in self.snapshot():
date = time.strftime('%a, %d %b %Y %H:%M:%S',timestamp)
yield '%s %s %-13s %s' % (date, name, Level.name(level), text)
def History (size=1000):
if not _History._log:
_History._log = _History(size)
return _History._log
def Errors (size=1000... | code_fim | hard | {
"lang": "python",
"repo": "Exa-Networks/exaproxy",
"path": "/lib/exaproxy/util/log/history.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Exa-Networks/exaproxy path: /lib/exaproxy/util/log/history.py
import time
import logging
from collections import deque
class Level:
class value:
DEBUG = logging.DEBUG
INFO = logging.INFO
WARNING = logging.WARNING
ERROR = logging.ERROR
CRITICAL = logging.CRITICAL
<|fim_suffix|>def Hi... | code_fim | hard | {
"lang": "python",
"repo": "Exa-Networks/exaproxy",
"path": "/lib/exaproxy/util/log/history.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nguy/artview path: /artview/core/core.py
"""
core.py
Class instance to create Variables and establish change signals.
"""
# Load the needed packages
# this should the only place with reference to PyQt4
try:
from PyQt4 import QtGui, QtCore
QtWidgets = QtGui
except:
from PyQt5 import... | code_fim | hard | {
"lang": "python",
"repo": "nguy/artview",
"path": "/artview/core/core.py",
"mode": "psm",
"license": "LGPL-2.1-or-later",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
Initialize the class.
Parameters
----------
[Optional]
name : string
Display window name.
parent : PyQt instance
Parent instance to associate to Component. If None, then Qt owns,
otherwise associated with pare... | code_fim | hard | {
"lang": "python",
"repo": "nguy/artview",
"path": "/artview/core/core.py",
"mode": "spm",
"license": "LGPL-2.1-or-later",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.list.__getitem__(key)
def __setitem__(self, key, value):
self.list.__setitem__(key, value)
def __len__(self):
return len(self.list)
def __repr__(self):
return self.list.__repr__()
componentsList = ComponentsList()
def suggestName(comp):
'''... | code_fim | hard | {
"lang": "python",
"repo": "nguy/artview",
"path": "/artview/core/core.py",
"mode": "spm",
"license": "LGPL-2.1-or-later",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brucehe3/TorCMS path: /tester/test_model/test_log.py
# -*- coding:utf-8 -*-
from torcms.core import tools
from torcms.model.log_model import MLog
class TestMLog():
def setup(self):
print('setup 方法执行于本类中每条用例之前')
self.uid = tools.get_uu4d()
self.userid = '11111'
... | code_fim | medium | {
"lang": "python",
"repo": "brucehe3/TorCMS",
"path": "/tester/test_model/test_log.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> MLog.count_of_current_url('')
assert True
def test_total_number(self):
MLog.total_number()
assert True
def test_count_of_certain(self):
MLog.count_of_certain(self.userid)
assert True
def test_count_of_certain_pageview(self):
MLog.count... | code_fim | medium | {
"lang": "python",
"repo": "brucehe3/TorCMS",
"path": "/tester/test_model/test_log.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>iterator = doc.ParameterBindings.ForwardIterator()
while iterator.MoveNext():
for cat in iterator.Current.Categories:
i = 0
for search_id in search_ids:
if cat.Id.IntegerValue == search_id:
names[i].append(iterator.Key.Name)
vag[i].append(iterator.Key.VariesAcrossGroups)
pgs[i].append(... | code_fim | hard | {
"lang": "python",
"repo": "andydandy74/ClockworkForDynamo",
"path": "/nodes/2.x/python/Document.ProjectParametersByCategory.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: andydandy74/ClockworkForDynamo path: /nodes/2.x/python/Document.ProjectParametersByCategory.py
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import Autodesk
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
sea... | code_fim | hard | {
"lang": "python",
"repo": "andydandy74/ClockworkForDynamo",
"path": "/nodes/2.x/python/Document.ProjectParametersByCategory.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RyMaDe/Complete-Amazon-Scraper path: /AmazonScraper/main.py
from scrapy.crawler import CrawlerProcess
from scrapy.utils.project import get_project_settings
from AmazonScraper.AmazonScraper.spiders import Search
from AmazonScraper.AmazonScraper.spiders import ASIN
from AmazonScraper.AmazonScraper... | code_fim | hard | {
"lang": "python",
"repo": "RyMaDe/Complete-Amazon-Scraper",
"path": "/AmazonScraper/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def Deals_List(dom = None, feed = None, pages = None, dep=None):
if feed == "csv":
settings.update({'FEED_FORMAT' : 'csv', 'FEED_URI' : 'deals.csv'})
elif feed == "json":
settings.update({'FEED_FORMAT' : 'json', 'FEED_URI' : 'deals.json'})
elif feed == "xml":
settings.u... | code_fim | hard | {
"lang": "python",
"repo": "RyMaDe/Complete-Amazon-Scraper",
"path": "/AmazonScraper/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def execute_crawling(q):
process.crawl(ASIN.AsinSpider, q, url_term = asin, dom=dom)
process.start()
q = Queue()
p = Process(target=execute_crawling, args=(q,))
p.start()
p.join()
results = [q.get() for i in range(q.qsize())]
return results
def Reviews(asin, d... | code_fim | hard | {
"lang": "python",
"repo": "RyMaDe/Complete-Amazon-Scraper",
"path": "/AmazonScraper/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Return the scan information for this image. There may be
no timestamps in there..."""
exposure_time = float(self._header_dictionary["TIME"])
epoch = 0
osc_start = float(self._header_dictionary["OSC_START"])
osc_range = float(self._header_dictionary["OSC_... | code_fim | hard | {
"lang": "python",
"repo": "cctbx/dxtbx",
"path": "/src/dxtbx/format/FormatSMVADSCSNAPSID19.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cctbx/dxtbx path: /src/dxtbx/format/FormatSMVADSCSNAPSID19.py
"""
An implementation of the SMV image reader for ADSC images. Inherits from
FormatSMVADSC, customised for example on APS ID19 SN 458 and 914
which have reversed phi.
"""
from __future__ import annotations
import sys
from dxtbx.form... | code_fim | hard | {
"lang": "python",
"repo": "cctbx/dxtbx",
"path": "/src/dxtbx/format/FormatSMVADSCSNAPSID19.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # some provider like AWS uses dotted hostname,
# e.g. ip-172-31-24-54.ec2.internal
if all(HOSTNAME_RE.match(v) for v in value.split(".")):
return value
raise ValueError(
"{} is not a valid value for {} parameter".format(value, name))
provider_req = reqparse.RequestParser... | code_fim | medium | {
"lang": "python",
"repo": "hasanmehmood/gluu-flask",
"path": "/gluuapi/reqparser/provider.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hasanmehmood/gluu-flask path: /gluuapi/reqparser/provider.py
# The MIT License (MIT)
#
# Copyright (c) 2015 Gluu
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software witho... | code_fim | hard | {
"lang": "python",
"repo": "hasanmehmood/gluu-flask",
"path": "/gluuapi/reqparser/provider.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sumesh1/burn-mapping path: /BurnCube/burn_mapping_tiles.py
import os,glob
import time
import geopandas as gpd
import xarray as xr
from BurnCube import BurnCube
bc = BurnCube()
import argparse
import numpy as np
from BurnCube import create_attributes
def create_empty_dataset(bc,filename,method)... | code_fim | hard | {
"lang": "python",
"repo": "sumesh1/burn-mapping",
"path": "/BurnCube/burn_mapping_tiles.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># merge tiles
def merge_tiles(filelist,mapyear,method, x0, y0,outdir):
if len(filelist)==4:
print("Merge the following files: %s" %filelist)
datasets = [xr.open_dataset(file) for file in filelist]
merged = xr.merge(datasets)
fname = outdir+'BurnMapping_'+str(mapyea... | code_fim | hard | {
"lang": "python",
"repo": "sumesh1/burn-mapping",
"path": "/BurnCube/burn_mapping_tiles.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # RANGE CHECK
if choice.isdigit():
if int(choice) in acceptable_range:
within_range = True
else:
within_range = False
print("Sorry you are out of acceptable range")
return int(choice)
print(user_choice())<|fim_pr... | code_fim | hard | {
"lang": "python",
"repo": "TasosVellis/Zero",
"path": "/7.Milestone_Project_1/3_ValidateUserInput.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TasosVellis/Zero path: /7.Milestone_Project_1/3_ValidateUserInput.py
def user_choice():
# VARIABLES
# Initial
choice = 'WRONG'
acceptable_range = range(0, 11)
within_range = False
<|fim_suffix|> choice = input("Pleae enter a number (0 - 10): ")
# DIGIT Check
... | code_fim | medium | {
"lang": "python",
"repo": "TasosVellis/Zero",
"path": "/7.Milestone_Project_1/3_ValidateUserInput.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> choice = input("Pleae enter a number (0 - 10): ")
# DIGIT Check
if choice.isdigit() == False:
print("Sorry that is not a digit")
# RANGE CHECK
if choice.isdigit():
if int(choice) in acceptable_range:
within_range = True
... | code_fim | medium | {
"lang": "python",
"repo": "TasosVellis/Zero",
"path": "/7.Milestone_Project_1/3_ValidateUserInput.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> discs = []
for tens in batched_tens:
disc = []
for i, elem in enumerate(tens):
if elem > .5:
disc.append(id2label[i])
if not disc:
max_v = -1
for i, elem in enumerate(tens):
if elem > max_v:
max_v = elem
max_index = i
disc.append(... | code_fim | hard | {
"lang": "python",
"repo": "AnonymousSubmissionAccount/CIKM2021anonymousSubmission",
"path": "/adapter_entity_typing/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_sentences(lines, max_context_side_size = -1, max_entity_size = -1):
if max_context_side_size == -1:
return [' '.join(l['left_context_token']) + ' [SEP] ' + l['mention_span'] + ' [SEP] ' + ' '.join(l['right_context_token']) for l in lines]
else:
print('... formatting sentences ...')
... | code_fim | hard | {
"lang": "python",
"repo": "AnonymousSubmissionAccount/CIKM2021anonymousSubmission",
"path": "/adapter_entity_typing/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AnonymousSubmissionAccount/CIKM2021anonymousSubmission path: /adapter_entity_typing/utils.py
from adapter_entity_typing.datasets_classes.bertDatasets import BertDataset, BertDatasetWithStringLabels
import json
import pickle
import torch
import numpy as np
from tqdm import tqdm
import time
import ... | code_fim | hard | {
"lang": "python",
"repo": "AnonymousSubmissionAccount/CIKM2021anonymousSubmission",
"path": "/adapter_entity_typing/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: smartdatalab-interns-2019/Interns-2019-2 path: /temp.py
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 10 11:11:55 2019
@author: Administrator
"""
import argparse
import torch
import torch.nn as nn
from pathlib import Path
import os.path
import pickle
import create_data_for_deeplea... | code_fim | hard | {
"lang": "python",
"repo": "smartdatalab-interns-2019/Interns-2019-2",
"path": "/temp.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> train_input, validation_input, train_label, validation_label, data_type_train, data_type_test = \
train_test_split(data_T, label_T, data_type, test_size = 0.2)
else:
if RNN_DATASET:
no_mass_index = create_no_mass_index(data_mode ... | code_fim | hard | {
"lang": "python",
"repo": "smartdatalab-interns-2019/Interns-2019-2",
"path": "/temp.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>DATA_ORGANIZATION = 'partial_combination'
N_FILE_TYPE = 2
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
###############################################################################
# Load data
#############################################################################... | code_fim | hard | {
"lang": "python",
"repo": "smartdatalab-interns-2019/Interns-2019-2",
"path": "/temp.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def stop_dive(dive_name):
"""
Stop a dive
:param dive_name:
:return:
"""
print "Stopping dive %s" % dive_name
if settings.XGDS_VIDEO_ON:
stop_video_recording(get_active_dive())
end_group_flight(dive_name, timezone.now())
if __name__ == '__main__':
parser = a... | code_fim | hard | {
"lang": "python",
"repo": "xgds/xgds_subsea",
"path": "/apps/xgds_subsea_app/scripts/dive_controls.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser = argparse.ArgumentParser()
parser.add_argument('-s', '--stop', action='store_true', help='Stop dive')
parser.add_argument('-n', '--name', help='Name of the dive, ie H1745')
args, unknown = parser.parse_known_args()
with open('/root/xgds_subsea/apps/xgds_subsea_app/importer/red... | code_fim | hard | {
"lang": "python",
"repo": "xgds/xgds_subsea",
"path": "/apps/xgds_subsea_app/scripts/dive_controls.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xgds/xgds_subsea path: /apps/xgds_subsea_app/scripts/dive_controls.py
#!/usr/bin/env python
# __BEGIN_LICENSE__
# Copyright (c) 2015, United States Government, as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All rights reserved.
#
# The xGDS platform... | code_fim | hard | {
"lang": "python",
"repo": "xgds/xgds_subsea",
"path": "/apps/xgds_subsea_app/scripts/dive_controls.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if isinstance(self.current_turret_state, AttackState):
enemy, next_heading = self.current_turret_state.getEnemyAndHeading()
if self.current_turret_state.isReadyToFire(enemy, next_heading):
return 0.5 + self.base_priority
else:
ret... | code_fim | medium | {
"lang": "python",
"repo": "Yasmojam/DoYouHaveTheGuts2019",
"path": "/src/states/stopstate.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Yasmojam/DoYouHaveTheGuts2019 path: /src/states/stopstate.py
from .state import State
from .attackstate import AttackState
class StopState(State):
def __init__(self, turret_controls, body_controls, status, priority):
<|fim_suffix|> self.current_base_state = base_state
self.cu... | code_fim | hard | {
"lang": "python",
"repo": "Yasmojam/DoYouHaveTheGuts2019",
"path": "/src/states/stopstate.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: galaxy-iuc/parsec path: /parsec/commands/dataset_collections/download_dataset_collection.py
import click
from parsec.cli import pass_context, json_loads
from parsec.decorators import custom_exception, json_output
@click.command('download_dataset_collection')
@click.argument("dataset_collection_... | code_fim | medium | {
"lang": "python",
"repo": "galaxy-iuc/parsec",
"path": "/parsec/commands/dataset_collections/download_dataset_collection.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> .. note::
This method downloads a ``zip`` archive for Galaxy 21.01 and later.
For earlier versions of Galaxy this method downloads a ``tgz`` archive.
This method is only supported by Galaxy 18.01 or later.
"""
return ctx.gi.dataset_collections.download_dataset... | code_fim | medium | {
"lang": "python",
"repo": "galaxy-iuc/parsec",
"path": "/parsec/commands/dataset_collections/download_dataset_collection.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kubernetes-client/python path: /examples/ingress_create.py
# Copyright 2019 The Kubernetes 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 License at
#
# http://www.a... | code_fim | hard | {
"lang": "python",
"repo": "kubernetes-client/python",
"path": "/examples/ingress_create.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def create_ingress(networking_v1_api):
body = client.V1Ingress(
api_version="networking.k8s.io/v1",
kind="Ingress",
metadata=client.V1ObjectMeta(name="ingress-example", annotations={
"nginx.ingress.kubernetes.io/rewrite-target": "/"
}),
spec=client.... | code_fim | hard | {
"lang": "python",
"repo": "kubernetes-client/python",
"path": "/examples/ingress_create.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>(?P<user_id>\d+)/add/$', 'add_event_to_user'),
#(r'^users/(?P<user_id>\d+)/$', 'view_user'),
#(r'^users/(?P<user_id>\d+)/agenda/$', 'view_agenda_of_user'),
#(r'^users/(?P<user_id>\d+)/(?P<year>\d+)/(?P<month>\d+)/$', 'view_month_for_user'),
)
authentication.add_patterns(urlpatterns, Event)
no... | code_fim | hard | {
"lang": "python",
"repo": "boxed/curia",
"path": "/calendars/urls.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>iew_group'),
(r'^agenda/$', 'view_agenda_of_group'),
(r'^(?P<year>\d+)/(?P<month>\d+)/$', 'view_month_for_group'),
(r'^groups/(?P<group_id>\d+)/$', 'view_group'),
(r'^groups/(?P<group_id>\d+)/agenda/$', 'view_agenda_of_group'),
(r'^groups/(?P<group_id>\d+)/(?P<year>\d+)/(?P<month>\d+)/... | code_fim | hard | {
"lang": "python",
"repo": "boxed/curia",
"path": "/calendars/urls.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: boxed/curia path: /calendars/urls.py
from django.conf.urls import *
from django.conf import settings
from curia import labels, authentication, notifications
from curia.calendars.models import Event
urlpatterns = patterns('curia.calendars.views',
(r'^events/(?P<event_id>\d+)/$', 'view_event')... | code_fim | hard | {
"lang": "python",
"repo": "boxed/curia",
"path": "/calendars/urls.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ebroecker/canmatrix path: /stubs/xlrd/formula.pyi
# Stubs for xlrd.formula (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from .timemachine import *
from typing import Any, Optional
FMLA_TYPE_CELL: int
FMLA_TYPE_SHARED: int
FMLA_TYPE_ARRAY: int
FMLA_TYP... | code_fim | medium | {
"lang": "python",
"repo": "ebroecker/canmatrix",
"path": "/stubs/xlrd/formula.pyi",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def evaluate_name_formula(bk: Any, nobj: Any, namex: Any, blah: int = ..., level: int = ...) -> None: ...
def decompile_formula(bk: Any, fmla: Any, fmlalen: Any, fmlatype: Optional[Any] = ..., browx: Optional[Any] = ..., bcolx: Optional[Any] = ..., blah: int = ..., level: int = ..., r1c1: int = ...): ...
... | code_fim | medium | {
"lang": "python",
"repo": "ebroecker/canmatrix",
"path": "/stubs/xlrd/formula.pyi",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ariannasg/python3-training path: /essentials/hello-class.py
#! usr/bin/env python3
class Duck:
_sound = 'Quaaack!'
_walking = 'Walking like a duck.'
# functions that are associated with a class are called methods.
# self makes the method an object method. is a reference to the ... | code_fim | hard | {
"lang": "python",
"repo": "ariannasg/python3-training",
"path": "/essentials/hello-class.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self._name
def sound(self):
return self._sound
class Animal3:
def __init__(self, **kwargs):
# all this vars are using encapsulation, meaning they belong to the object and not to the class.
# we shouldn't access them outside the class methods. that's why th... | code_fim | hard | {
"lang": "python",
"repo": "ariannasg/python3-training",
"path": "/essentials/hello-class.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> luigi.build([task], local_scheduler=True)
''' ...................... you may edit code above ........................'''
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Calling miniHive.')
parser.add_argument('--O', action='store_true', help='toggle... | code_fim | hard | {
"lang": "python",
"repo": "miniHive/assignment",
"path": "/milestone4/miniHive.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: miniHive/assignment path: /milestone4/miniHive.py
import argparse
import glob
import luigi
import os
import radb
import sqlparse
import costcounter
import sql2ra
import raopt
import ra2mr
# You may want to add your own imports here.
def clear_local_tmpfiles():
files = glob.glob('./*.tmp')
... | code_fim | hard | {
"lang": "python",
"repo": "miniHive/assignment",
"path": "/milestone4/miniHive.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> errno = lsp.DiagnosticSeverity.Error if severity == 'error' else lsp.DiagnosticSeverity.Information
diag = {
'source': 'mypy',
'range': {
'start': {'line': lineno - 1, 'character': offset - 1},
# There may be a better solution, but mypy does not provide end
... | code_fim | hard | {
"lang": "python",
"repo": "matangover/mypyls",
"path": "/mypyls/mypy_server.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matangover/mypyls path: /mypyls/mypy_server.py
import logging
import os
import re
from collections import defaultdict
from . import uris
from mypy.dmypy_server import Server
from mypy.dmypy_util import DEFAULT_STATUS_FILE
from mypy.options import Options
from mypy.main import parse_config_file
f... | code_fim | hard | {
"lang": "python",
"repo": "matangover/mypyls",
"path": "/mypyls/mypy_server.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return diagnostics
documents_with_diagnostics: Set[str] = set()
def publish_diagnostics(workspace, mypy_output):
diagnostics_by_path = parse_mypy_output(mypy_output)
previous_documents_with_diagnostics = documents_with_diagnostics.copy()
documents_with_diagnostics.clear()
for path, ... | code_fim | hard | {
"lang": "python",
"repo": "matangover/mypyls",
"path": "/mypyls/mypy_server.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jnrsgsig/python_time_series_models path: /models_for_1d_risk_factor/ma_1_model.py
"""MA(1) model: Order 1 moving average model
x_1 = mu + epsilon_1 + theta * epsilon_0
"""
from pprint import pprint
import numpy as np
from statsmodels.tsa.arima.model import ARIMA
from time_series_model... | code_fim | hard | {
"lang": "python",
"repo": "jnrsgsig/python_time_series_models",
"path": "/models_for_1d_risk_factor/ma_1_model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
# np.random.seed(0)
dt = 1./252
ma_ = Ma1(const=1, ma_l1=0.1, volatility=50)
t = np.arange(0, 5, dt)
x = ma_.simulate(x0=1, t_=t)
pprint(ma_.parameters)
ma_.fit_parameters(dt, x)
pprint(ma_.parameters)<|fim_prefix|># repo: jnrsgsig/python_... | code_fim | hard | {
"lang": "python",
"repo": "jnrsgsig/python_time_series_models",
"path": "/models_for_1d_risk_factor/ma_1_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('account', '0016_auto_20161101_1648'),
]
operations = [
migrations.CreateModel(
name='Payment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
... | code_fim | medium | {
"lang": "python",
"repo": "aronekob34/PythonGuru",
"path": "/account/migrations/0017_auto_20161101_2216.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.CreateModel(
name='Payment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created', models.DateTimeField(auto_now_add=True)),
('amo... | code_fim | medium | {
"lang": "python",
"repo": "aronekob34/PythonGuru",
"path": "/account/migrations/0017_auto_20161101_2216.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aronekob34/PythonGuru path: /account/migrations/0017_auto_20161101_2216.py
# -*- coding: utf-8 -*-
# Generated by Django 1.10.2 on 2016-11-01 22:16
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
<|fim_suffix|>
dependencies ... | code_fim | medium | {
"lang": "python",
"repo": "aronekob34/PythonGuru",
"path": "/account/migrations/0017_auto_20161101_2216.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ikhomkodes/ChiSquare-Test-in-5-different-languages path: /chiSquare-testPython.py
# -*- coding: ikhomkodes -*-
"""
Created on Saturday, April 17, 2021
@author: Khom Raj Thapa Magar
#ikhomkodes
kyzen khom
<|fim_suffix|>linestyles = [':', '--', '-.', '-']
deg_of_freedom = [1, 4, 7, 6]
for df, ls ... | code_fim | hard | {
"lang": "python",
"repo": "ikhomkodes/ChiSquare-Test-in-5-different-languages",
"path": "/chiSquare-testPython.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>linestyles = [':', '--', '-.', '-']
deg_of_freedom = [1, 4, 7, 6]
for df, ls in zip(deg_of_freedom, linestyles):
ax.plot(x, stats.chi2.pdf(x, df), linestyles=ls)
plt.xlim(0, 10)
plt.ylim(0, 0.4)
plt.xlabel('Value')
plt.ylabel('Frequency')
plt.title('Chi-Square Distribution')
plt.legend()
plt.show()... | code_fim | hard | {
"lang": "python",
"repo": "ikhomkodes/ChiSquare-Test-in-5-different-languages",
"path": "/chiSquare-testPython.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.