code stringlengths 10 805k | def_use_chains listlengths 0 667 |
|---|---|
# encoding: utf-8
import datetime
import re
import requests
from ckan.common import config
from ckan.common import asbool
from six import text_type, string_types
from ckan.common import _, json
import ckan.lib.maintain as maintain
log = __import__('logging').getLogger(__name__)
class License(object):
"""Doma... | [
[
[
26,
34
],
[
985,
993
]
],
[
[
42,
44
],
[
1013,
1015
]
],
[
[
53,
61
],
[
4592,
4600
],
[
4680,
4688
]
],
[
[
87,
93
],
[
3397,
... |
from sklearn.datasets import fetch_20newsgroups
from sklearn.naive_bayes import MultinomialNB
from sklearn.feature_extraction.text import TfidfTransformer
from sklearn.feature_extraction.text import CountVectorizer
# Define the category map
category_map = {'talk.politics.misc': 'Politics', 'rec.autos': 'Autos',
... | [
[
[
29,
47
],
[
463,
481
]
],
[
[
80,
93
],
[
1251,
1264
]
],
[
[
138,
154
],
[
818,
834
]
],
[
[
199,
214
],
[
641,
656
]
],
[
[
... |
from loguru import logger
from flask import request
from flasgger import swag_from
from flask_restful import Resource
from jwt.exceptions import ExpiredSignatureError
from ada_friend_app.modulo.cripto import Sha256
from ada_friend_app.modulo.jwt_auth import Token
from ada_friend_app.api.resposta_api import Resposta
fr... | [
[
[
19,
25
],
[
786,
792
],
[
1229,
1235
]
],
[
[
44,
51
],
[
483,
490
]
],
[
[
73,
82
],
[
405,
414
]
],
[
[
109,
117
],
[
389,
... |
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
#
# 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.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | [
[
[
634,
649
]
],
[
[
680,
681
]
],
[
[
696,
711
],
[
723,
738
]
],
[
[
713,
720
]
]
] |
import argparse
from rasa.cli.arguments.default_arguments import (
add_nlu_data_param,
add_out_param,
add_data_param,
add_domain_param,
)
def set_convert_arguments(parser: argparse.ArgumentParser):
add_data_param(parser, required=True, default=None, data_type="Rasa NLU ")
add_out_param(
... | [
[
[
7,
15
],
[
191,
199
],
[
767,
775
],
[
1246,
1254
]
],
[
[
72,
90
],
[
797,
815
]
],
[
[
96,
109
],
[
301,
314
],
[
1064,
1077
... |
import sys
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
class Simulation:
def __init__(self, init_investment, stock_returns, strategy, predicted_movements=None):
self.init_investment = init_investment
self.predicted_movements = predicted_movements
self.stock_retur... | [
[
[
7,
10
],
[
1259,
1262
]
],
[
[
18,
42
],
[
1852,
1855
],
[
2471,
2474
],
[
2598,
2601
]
],
[
[
50,
61
],
[
1782,
1784
],
[
2179,
... |
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------... | [
[
[
368,
382
]
],
[
[
391,
393
],
[
2817,
2819
],
[
2850,
2852
],
[
2869,
2871
],
[
2920,
2922
],
[
2965,
2967
],
[
3009,
3011
],
[
3024,
... |
from distutils.core import setup
setup(
name='yanccm',
packages=[
'controller',
'sot',
'ncservice',
'ncservice.configDb',
'ncservice.ncDeviceOps',
'ncservice.ncDeviceOps.threaded',
'view'],
version='0.0.2',
license='MIT',
description='''YANCCM... | [
[
[
27,
32
],
[
34,
39
]
]
] |
from terregex.mlr import Node, NodeList, Literal, NotLiteral, \
In, Negate, Range, Category, MinRepeat, MaxRepeat, \
SubPattern, Branch, Any, parse
from terregex.transform import Transformer | [
[
[
25,
29
]
],
[
[
31,
39
]
],
[
[
41,
48
]
],
[
[
50,
60
]
],
[
[
66,
68
]
],
[
[
70,
76
]
],
[
[
78,
83
]
],
[
[
85,
93
]
]... |
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class PrinseqLite(Package):
"""PRINSEQ will help you to preprocess your genomic or metagenomic
... | [
[
[
216,
217
],
[
238,
245
],
[
522,
529
],
[
620,
627
],
[
698,
708
],
[
733,
743
],
[
774,
784
],
[
820,
830
],
[
902,
908
],
[
... |
"""
Unit test for Linear Programming
"""
import sys
import numpy as np
from numpy.testing import (assert_, assert_allclose, assert_equal,
assert_array_less, assert_warns, suppress_warnings)
from pytest import raises as assert_raises
from scipy.optimize import linprog, OptimizeWarning
from sc... | [
[
[
48,
51
],
[
67310,
67313
]
],
[
[
60,
71
],
[
67271,
67273
],
[
2909,
2911
],
[
2969,
2971
],
[
3053,
3055
],
[
4287,
4289
],
[
4296,
... |
import unittest
from pyowm.agroapi10.polygon import Polygon, GeoPoint, GeoPolygon
class TestPolygon(unittest.TestCase):
geopoint= GeoPoint(34, -56.3)
geopolygon = GeoPolygon([
[[2.3, 57.32], [23.19, -20.2], [-120.4, 19.15], [2.3, 57.32]]
])
def test_polygon_fails_with_wrong_parameters(self):... | [
[
[
7,
15
],
[
102,
110
]
],
[
[
52,
59
],
[
364,
371
],
[
479,
486
],
[
586,
593
],
[
695,
702
],
[
809,
816
],
[
1004,
1011
],
... |
def convert_request_to_dictionary(request, fields):
emp = {}
for field in fields:
if field in request.json:
emp[field] = request.json[field]
del emp["identity"]
return emp | [
[
[
4,
33
]
]
] |
import os
from pydub import playback
from playsound import playsound
from simpleaudio import play_buffer
import winsound
from manuscript.tools.counter import Counter
def play_sound(sound, block=True):
if sound is not None:
prefix = "tmp"
with Counter(prefix) as counter:
tmp_file = os.... | [
[
[
7,
9
],
[
317,
319
]
],
[
[
29,
37
]
],
[
[
60,
69
],
[
415,
424
]
],
[
[
94,
105
]
],
[
[
113,
121
]
],
[
[
159,
166
],
[
... |
from telegram import ReplyKeyboardMarkup, KeyboardButton
def get_keyboard():
contact_button = KeyboardButton('Отправить контакты', request_contact=True)
location_button = KeyboardButton('Отправить локацию', request_location=True)
my_keyboard = ReplyKeyboardMarkup([['Анекдот', 'Начать'],
... | [
[
[
21,
40
],
[
262,
281
]
],
[
[
42,
56
],
[
102,
116
],
[
184,
198
]
],
[
[
64,
76
]
]
] |
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Also available under a BSD-style license. See LICENSE.
"""Queries the pytorch op registry and generates ODS and CC sourc... | [
[
[
360,
364
],
[
3286,
3290
],
[
7090,
7094
]
],
[
[
366,
374
],
[
7081,
7089
]
],
[
[
376,
382
],
[
27102,
27108
]
],
[
[
391,
399
],
[
... |
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or module... | [
[
[
684,
691
]
],
[
[
713,
722
]
],
[
[
746,
752
]
],
[
[
820,
827
]
],
[
[
1067,
1077
]
],
[
[
1158,
1172
]
],
[
[
1383,
1399
]
],
[
[
15... |
import spacy
from spacy.lang.en import English
from spacy.util import minibatch, compounding
from spacy.util import decaying
class ExperimentParam:
def __init__(self, TRAIN_DATA: list, max_batch_sizes: dict, model_type='ner',
dropout_start: float = 0.6, dropout_end: float = 0.2, interval: float =... | [
[
[
7,
12
]
],
[
[
39,
46
]
],
[
[
70,
79
],
[
1101,
1110
]
],
[
[
81,
92
],
[
1045,
1056
]
],
[
[
116,
124
],
[
1528,
1536
]
],
[
[... |
from example_system import serializer
from example_system.bike import Bike
from example_system.human import Human
def run_example() -> None:
krzysztof = Human(name="Krzysztof", age=37)
giant_bike = Bike(brand="Giant", model="Contend AR")
krzysztof_json = serializer.serialize(krzysztof)
print(krzyszto... | [
[
[
27,
37
],
[
270,
280
],
[
344,
354
],
[
428,
438
],
[
546,
556
]
],
[
[
70,
74
],
[
208,
212
]
],
[
[
108,
113
],
[
159,
164
... |
'''
Created by auto_sdk on 2020.11.25
'''
from dingtalk.api.base import RestApi
class OapiSmartdeviceBatcheventPostRequest(RestApi):
def __init__(self,url=None):
RestApi.__init__(self,url)
self.device_event_vos = None
def getHttpMethod(self):
return 'POST'
def getapiname(self):
return 'dingtalk.oapi.smartd... | [
[
[
72,
79
],
[
123,
130
],
[
165,
172
]
],
[
[
86,
122
]
]
] |
import pandas as pd
import io
from joblib import load
import logging
logging.getLogger().setLevel(logging.INFO)
def generate_data():
new_data = pd.DataFrame({
'Pclass':[3,2,1],
'Sex': ['male', 'female', 'male'],
'Age':[4, 22, 28]
})
return new_data
def load_model():
try:
... | [
[
[
7,
19
],
[
150,
152
]
],
[
[
27,
29
]
],
[
[
49,
53
],
[
331,
335
],
[
415,
419
]
],
[
[
61,
68
],
[
70,
77
],
[
99,
106
... |
from abc import ABC, abstractmethod
from datetime import datetime
from typing import Generic, Type, TypeVar, Union
from .devices import I2CDevice
from .parsers import RegisterParser
from .typing import RegisterState
BlockType = TypeVar("BlockType")
class RegisterBlock(Generic[BlockType], ABC):
"""
Abstract ... | [
[
[
16,
19
],
[
293,
296
]
],
[
[
21,
35
],
[
5303,
5317
],
[
5708,
5722
]
],
[
[
57,
65
],
[
7029,
7037
],
[
7754,
7762
],
[
7933,
... |
"""A flexible Python library for atomic structure generation."""
| [] |
import asyncio
import logging
import time
from datetime import datetime
from pathlib import Path
from typing import Callable, Dict, List, Optional, Tuple
from blspy import PrivateKey, G1Element
from seno.cmds.init_funcs import check_keys
from seno.consensus.block_rewards import calculate_base_farmer_reward
from seno.... | [
[
[
7,
14
],
[
15039,
15046
],
[
15576,
15583
],
[
16400,
16407
],
[
17093,
17100
]
],
[
[
22,
29
],
[
1682,
1689
]
],
[
[
37,
41
],
[
137... |
import torch
import torch.optim as optim
import torch.nn.functional as F
import torch.nn as nn
# import sys
# sys.path.append("../simulated_fqi/")
from simulated_fqi import NFQNetwork, ContrastiveNFQNetwork
import matplotlib.pyplot as plt
import numpy as np
def train(x, y, groups, network, optimizer):
predicted... | [
[
[
7,
12
]
],
[
[
20,
40
]
],
[
[
48,
72
],
[
372,
373
]
],
[
[
80,
94
]
],
[
[
174,
184
]
],
[
[
186,
207
]
],
[
[
215,
239
]
],... |
"""
WSGI config for tw project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_M... | [
[
[
225,
227
],
[
280,
282
]
],
[
[
258,
278
],
[
358,
378
]
],
[
[
344,
355
]
]
] |
import torch
def combine_masks_with_batch(masks, n_obj, th=0.5, return_as_onehot = False):
""" Combine mask for different objects.
Different methods are the following:
* `max_per_pixel`: Computes the final mask taking the pixel with the highest
probability for every object.
# ... | [
[
[
7,
12
],
[
584,
589
],
[
675,
680
],
[
691,
696
],
[
1008,
1013
],
[
1270,
1275
]
],
[
[
18,
42
]
]
] |
class Task(object):
def __init__(self,name):
self.name = name
pass
def run(self):
pass
| [
[
[
6,
10
]
]
] |
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "geekshop.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise Impor... | [
[
[
91,
93
],
[
123,
125
]
],
[
[
101,
104
],
[
578,
581
]
],
[
[
111,
115
],
[
621,
625
]
]
] |
"""
OpenVINO DL Workbench
Class for creation job for creating and exporting inference report
Copyright (c) 2020 Intel Corporation
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://... | [
[
[
678,
681
],
[
2467,
2470
]
],
[
[
689,
693
],
[
2292,
2296
]
],
[
[
701,
703
],
[
3689,
3691
],
[
3732,
3734
]
],
[
[
727,
734
],
[
... |
import sys
class KaffeError(Exception):
pass
def print_stderr(msg):
sys.stderr.write('%s\n' % msg)
| [
[
[
7,
10
],
[
78,
81
]
],
[
[
18,
28
]
],
[
[
55,
67
]
]
] |
# Copyright 2010 Google Inc.
#
# 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.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | [
[
[
639,
649
]
],
[
[
702,
706
],
[
1216,
1220
]
],
[
[
714,
719
],
[
1044,
1049
]
],
[
[
727,
733
],
[
971,
977
]
],
[
[
768,
774
],
[
... |
from chainer.backends import cuda
from chainer import function_node
from chainer.utils import type_check
class Copy(function_node.FunctionNode):
"""Copies the input variable onto the specified device."""
def __init__(self, out_device):
self.out_device = out_device
def check_type_forward(self, i... | [
[
[
29,
33
],
[
478,
482
],
[
569,
573
],
[
618,
622
]
],
[
[
54,
67
],
[
118,
131
]
],
[
[
94,
104
],
[
338,
348
]
],
[
[
113,
... |
# Copyright 2017 Rice University
#
# 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.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | [
[
[
614,
618
],
[
692,
696
]
],
[
[
667,
672
],
[
923,
928
]
],
[
[
681,
691
],
[
949,
959
]
]
] |
from datetime import date
from flask_wtf import FlaskForm
from wtforms import StringField
class ProducaoFinalizadasForm(FlaskForm):
nome = StringField('Nome:')
data_comeco = StringField('Data de início:')
data_coleta = StringField('Data de coleta:') | [
[
[
21,
25
]
],
[
[
48,
57
],
[
122,
131
]
],
[
[
78,
89
],
[
145,
156
],
[
184,
195
],
[
233,
244
]
],
[
[
98,
121
]
]
] |
# coding: utf-8
"""
Automox Console API
API for use with the Automox Console # noqa: E501
OpenAPI spec version: 2021-11-16
Contact: support@automox.com
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
import pprint
import re # noqa: F401
import six
class OneOfDeviceFilter... | [
[
[
253,
259
],
[
2032,
2038
]
],
[
[
267,
269
]
],
[
[
292,
295
],
[
1084,
1087
]
],
[
[
303,
336
],
[
1788,
1821
],
[
2272,
2305
]
]
] |
import ugame
import stage
import utils
GAME = None
#######################################################
# Game
class Game(stage.Stage):
"""Base class for a game and its display"""
# TODO: add game state machine
# TODO: make each screen a state, and make a transition between them when player overlaps with t... | [
[
[
7,
12
],
[
663,
668
],
[
2354,
2359
]
],
[
[
20,
25
],
[
128,
133
],
[
2778,
2783
],
[
4590,
4595
],
[
11318,
11323
],
[
11540,
1154... |
"""
TODO: Add doc what this file is doing
"""
from marshmallow import Schema, post_dump
class RootSchema(Schema):
SKIP_VALUES = [None]
@post_dump
def remove_skip_values(self, data, many, **kwargs):
return {
key: value for key, value in data.items()
if value not in self.SKI... | [
[
[
70,
76
],
[
107,
113
]
],
[
[
78,
87
],
[
147,
156
],
[
345,
354
]
],
[
[
96,
106
]
]
] |
import os
import io
import time
import base64
import functools
from PIL import Image
import numpy as np
import tensorflow as tf
import tensorflow_hub as hub
from helpers import *
os.environ["TFHUB_DOWNLOAD_PROGRESS"] = "True"
class PythonPredictor:
def __init__(self, config):
# Import TF-Hub module
... | [
[
[
7,
9
],
[
181,
183
]
],
[
[
17,
19
],
[
680,
682
]
],
[
[
27,
31
]
],
[
[
39,
45
],
[
752,
758
]
],
[
[
53,
62
]
],
[
[
80... |
# coding=utf-8
# Copyright 2018 The TF-Agents 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.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | [
[
[
1271,
1286
]
],
[
[
1310,
1318
]
],
[
[
1368,
1382
]
],
[
[
1403,
1411
],
[
2071,
2079
]
],
[
[
1413,
1417
],
[
2080,
2084
]
],
[
[
1426,
... |
from os import system
def comprar(comida, juguetes):
comprado = ""
while not comprado:
system("cls")
comprar = (input("Que quiere comprar? Alimentos | Juguetes : ")).lower()
if comprar == "alimento":
print(f"Carne: {comida['carne']['cantidad']}|Agua: {comida['agua']['cantidad']}|Huesos: {comida['hueso'... | [
[
[
15,
21
],
[
95,
101
]
],
[
[
27,
34
]
]
] |
"""
Third generation models implementation (VPIN)
"""
import pandas as pd
def get_vpin(volume: pd.Series, buy_volume: pd.Series, window: int = 1) -> pd.Series:
"""
Get Volume-Synchronized Probability of Informed Trading (VPIN) from bars, p. 292-293.
:param volume: (pd.Series) bar volume
:param buy_vo... | [
[
[
61,
73
],
[
151,
153
],
[
97,
99
],
[
120,
122
]
],
[
[
80,
88
]
]
] |
"""
github3.gists.comment
---------------------
Module containing the logic for a GistComment
"""
from github3.models import BaseComment
from github3.users import User
class GistComment(BaseComment):
"""This object represents a comment on a gist.
Two comment instances can be checked like so::
c1... | [
[
[
128,
139
],
[
191,
202
]
],
[
[
166,
170
],
[
802,
806
]
],
[
[
179,
190
],
[
552,
563
]
]
] |
import numpy as np
class NeuralNetwork(object):
def __init__(self, topology, epsilon, numLabels):
self.theta = []
self.topology = topology
self.numLabels = numLabels
self.gradientChecking = False
for layer in range(len(self.topology)):
if layer == 0:
... | [
[
[
7,
18
],
[
363,
365
],
[
1627,
1629
],
[
1721,
1723
],
[
1913,
1915
],
[
2412,
2414
],
[
2644,
2646
],
[
2933,
2935
],
[
2990,
2992
... |
"""“Write a for loop to print all the values in the half_lives list from Operations on Lists, all on a single line. half_lives refers to [87.74, 24110.0, 6537.0, 14.4, 376000.0]."""
half_lives = [87.74, 24110.0, 6537.0, 14.4, 376000.0]
for i in half_lives:
print(i , end=' ') | [
[
[
185,
195
],
[
248,
258
]
],
[
[
243,
244
],
[
270,
271
]
]
] |
#!/usr/bin/env python3
"""Read a correct swagger file and check whether it conforms to a style guide."""
import argparse
import pathlib
from typing import List
import sys
import swagger_to.intermediate
import swagger_to.style
import swagger_to.swagger
def main() -> int:
"""Execute the main routine."""
parse... | [
[
[
112,
120
],
[
324,
332
]
],
[
[
128,
135
],
[
999,
1006
]
],
[
[
155,
159
],
[
2370,
2374
],
[
2253,
2257
]
],
[
[
168,
171
],
[
3... |
# coding: utf-8
"""
Katib
Swagger description for Katib # noqa: E501
The version of the OpenAPI document: v1beta1-0.1
Generated by: https://openapi-generator.tech
"""
import pprint
import re # noqa: F401
import six
from kubeflow.katib.configuration import Configuration
class V1beta1Experiment... | [
[
[
196,
202
],
[
12272,
12278
]
],
[
[
210,
212
]
],
[
[
235,
238
],
[
11468,
11471
]
],
[
[
281,
294
],
[
2255,
2268
]
],
[
[
303,
324
],
... |
from collections import namedtuple
import os
import json
import numpy as np
from tqdm import tqdm
from data_generators.utils import load_image_rgb
# Copied from: https://github.com/mcordts/cityscapesScripts/blob/master/cityscapesscripts/helpers/labels.py
#
# Cityscapes labels
#
#-------------------------------------... | [
[
[
24,
34
],
[
504,
514
]
],
[
[
43,
45
],
[
3575,
3577
],
[
4252,
4254
],
[
4321,
4323
],
[
4387,
4389
],
[
4481,
4483
],
[
4607,
4609... |
"""PyMC4 continuous random variables for tensorflow."""
import tensorflow_probability as tfp
from pymc4.distributions import abstract
from pymc4.distributions.tensorflow.distribution import BackendDistribution
tfd = tfp.distributions
__all__ = [
"Beta",
"Cauchy",
"ChiSquared",
"Exponential",
"Gam... | [
[
[
63,
92
],
[
218,
221
],
[
4400,
4403
]
],
[
[
125,
133
],
[
635,
643
],
[
838,
846
],
[
1075,
1083
],
[
1268,
1276
],
[
1472,
1480
... |
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may ... | [
[
[
502,
515
]
],
[
[
545,
570
]
],
[
[
600,
611
]
],
[
[
641,
664
]
],
[
[
694,
713
]
],
[
[
743,
763
]
],
[
[
793,
809
]
],
[
[
839,
... |
# Copyright (c) 2018-2022 Micro Focus or one of its affiliates.
# Copyright (c) 2018 Uber Technologies, Inc.
#
# 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.apache.org/licen... | [
[
[
1908,
1922
]
],
[
[
1924,
1932
]
],
[
[
1934,
1949
]
],
[
[
1958,
1966
],
[
2334,
2342
]
],
[
[
1974,
1976
],
[
2519,
2521
]
],
[
[
1996,
... |
#!/usr/bin/python
from __future__ import (absolute_import, division, print_function)
# Copyright 2019 Fortinet, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the Lic... | [
[
[
42,
57
]
],
[
[
59,
67
]
],
[
[
69,
83
]
],
[
[
847,
860
]
],
[
[
869,
885
]
],
[
[
1009,
1022
]
],
[
[
2797,
2805
]
],
[
[
3262,
... |
import os
import posixpath
from enum import Enum
from fastapi import Path, HTTPException
from utils import security
class UploadPath(str, Enum):
default = "default"
UPLOAD_PATH_DICT = {
UploadPath.default: "default/"
}
def get_upload(upload_key: UploadPath = Path(..., description="上传文件块位置")):
"""
... | [
[
[
7,
9
],
[
526,
528
],
[
1148,
1150
]
],
[
[
17,
26
],
[
394,
403
],
[
886,
895
],
[
1029,
1038
],
[
1185,
1194
]
],
[
[
44,
48
... |
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class Repeatmodeler(Package):
"""RepeatModeler is a de-novo repeat family identification and mod... | [
[
[
216,
217
],
[
240,
247
],
[
503,
510
],
[
601,
611
],
[
647,
657
],
[
698,
708
],
[
748,
758
],
[
807,
817
],
[
850,
860
],
[
... |
import math
pi = math.pi
raio = float(input('Qual é o raio da esfera?: '))
volume_esf = 4/3*pi*math.pow(raio, 3)
litro = 1
lata = litro*5
precolata = 50.00
totaltinta = volume_esf *lata
totalpreco = totaltinta * precolata
print(f'O volume da esfera é {volume_esf: .2f}')
print(f'A quantidade de tinta necessária é... | [
[
[
9,
13
],
[
20,
24
],
[
98,
102
]
],
[
[
15,
17
],
[
95,
97
]
],
[
[
28,
32
],
[
107,
111
]
],
[
[
78,
88
],
[
175,
185
]... |
from datetime import datetime, timezone
from http import HTTPStatus
from json import dumps, load
from logging import getLogger
from os import environ
from unittest.mock import MagicMock, patch
from mypy_boto3_events import EventBridgeClient
from mypy_boto3_lambda import LambdaClient
from mypy_boto3_sns.type_defs impor... | [
[
[
21,
29
],
[
1661,
1669
]
],
[
[
31,
39
],
[
1746,
1754
]
],
[
[
57,
67
],
[
2221,
2231
],
[
4382,
4392
],
[
5259,
5269
],
[
9579,
... |
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 14 08:55:39 2020
@author: rolly
"""
import config
from twilio.rest import Client
#https://api.whatsapp.com/send?phone=14155238886&text=join%20actual-nor&source=&data=
def sendMsg(num,msg):
client = Client(config.account_sid, config.auth_token)
message = client.m... | [
[
[
91,
97
],
[
259,
265
],
[
279,
285
]
],
[
[
122,
128
],
[
252,
258
]
],
[
[
221,
228
]
]
] |
import logging
from typing import Any, Dict, List, Optional, Union
from ..models import SnsModel
from ..types import Model
from .base import BaseEnvelope
logger = logging.getLogger(__name__)
class SnsEnvelope(BaseEnvelope):
"""SNS Envelope to extract array of Records
The record's body parameter is a string... | [
[
[
7,
14
],
[
165,
172
]
],
[
[
34,
37
],
[
643,
646
],
[
649,
652
]
],
[
[
39,
43
],
[
633,
637
]
],
[
[
45,
49
],
[
673,
677
... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2015, Joseph Callen <jcallen () csc.com>
# Copyright: (c) 2018, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
... | [
[
[
256,
271
]
],
[
[
273,
281
]
],
[
[
283,
297
]
],
[
[
298,
311
]
],
[
[
320,
336
]
],
[
[
435,
448
]
],
[
[
1148,
1156
]
],
[
[
1711,
... |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.utils.timezone
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations ... | [
[
[
47,
63
]
],
[
[
87,
93
],
[
428,
434
],
[
546,
552
],
[
606,
612
],
[
652,
658
],
[
714,
720
],
[
822,
828
],
[
907,
913
],
... |
#!/usr/bin/env python
# Copyright 2014 Google Inc. All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of c... | [
[
[
1732,
1742
]
],
[
[
1791,
1797
],
[
1835,
1841
],
[
2126,
2132
],
[
2235,
2241
],
[
2346,
2352
],
[
2503,
2509
],
[
2612,
2618
],
[
2721,
... |
from pluto.control.modes import mode
from pluto.control.modes.processes import process_manager
from protos import broker_pb2_grpc
class LiveControlMode(mode.ControlCommandHandler):
def __init__(self, server, framework_url, process_factory):
super(LiveControlMode, self).__init__(framework_url, process_fact... | [
[
[
32,
36
],
[
154,
158
]
],
[
[
79,
94
],
[
455,
470
]
],
[
[
115,
130
],
[
333,
348
]
],
[
[
138,
153
],
[
261,
276
]
]
] |
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or module... | [
[
[
684,
691
]
],
[
[
711,
720
]
],
[
[
759,
765
]
],
[
[
848,
855
]
],
[
[
948,
958
]
],
[
[
1117,
1127
]
],
[
[
1208,
1222
]
],
[
[
1433... |
import pytest
jax = pytest.importorskip("jax", minversion="0.2")
jnp = jax.numpy
import numpy as np
import pennylane as qml
from pennylane.devices.default_qubit_jax import DefaultQubitJax
pytestmark = pytest.mark.usefixtures("tape_mode")
class TestQNodeIntegration:
"""Integration tests for default.q... | [
[
[
7,
13
],
[
23,
29
],
[
211,
217
],
[
6675,
6681
],
[
8238,
8244
],
[
11949,
11955
],
[
12024,
12030
],
[
14305,
14311
],
[
17481,
17487
... |
import pytest
from pytest_mock_resources.fixture.database.generic import assign_fixture_credentials
from pytest_mock_resources.fixture.database.relational.generic import EngineManager
from pytest_mock_resources.fixture.database.relational.postgresql import (
_create_clean_database,
get_sqlalchemy_engine,
)
fro... | [
[
[
7,
13
],
[
1268,
1274
]
],
[
[
74,
100
],
[
1501,
1527
]
],
[
[
171,
184
],
[
1930,
1943
]
],
[
[
264,
286
],
[
1373,
1395
]
],
[
[
... |
from __future__ import annotations
from typing import NoReturn
from . import LinearRegression
from ...base import BaseEstimator
import numpy as np
class PolynomialFitting(BaseEstimator):
"""
Polynomial Fitting using Least Squares estimation
"""
def __init__(self, k: int) -> PolynomialFitting:
... | [
[
[
23,
34
]
],
[
[
54,
62
],
[
680,
688
]
],
[
[
77,
93
],
[
572,
588
]
],
[
[
114,
127
],
[
173,
186
]
],
[
[
135,
146
],
[
650,... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from alipay.aop.api.constant.ParamConstants import *
class PriceInformation(object):
def __init__(self):
self._amount = None
self._type = None
@property
def amount(self):
return self._amount
@amount.setter
def am... | [
[
[
53,
57
]
],
[
[
110,
111
]
],
[
[
120,
136
],
[
1084,
1100
]
]
] |
# Copyright 2020 The StackStorm Authors.
# Copyright (C) 2020 Extreme Networks, Inc - All Rights Reserved
#
# 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.apache.org/license... | [
[
[
660,
663
],
[
1413,
1416
]
],
[
[
698,
712
],
[
3697,
3711
],
[
4312,
4326
]
],
[
[
746,
758
],
[
3622,
3634
],
[
4237,
4249
]
],
[
[
... |
import requests
import json
url = "https://www.cbr-xml-daily.ru/daily_json.js"
response = requests.get(url)
data = json.loads(response.text)
print(data)
| [
[
[
7,
15
],
[
91,
99
]
],
[
[
23,
27
],
[
116,
120
]
],
[
[
29,
32
],
[
104,
107
]
],
[
[
80,
88
],
[
127,
135
]
],
[
[
109,
... |
from django.db import models
from authors import settings
from authors.apps.articles.models import Article
from authors.apps.profiles.models import Profile
# Create your models here.
class ReportArticle(models.Model):
"""model for reporting an article"""
reporter = models.ForeignKey(Profile, on_delete=models.C... | [
[
[
22,
28
],
[
204,
210
],
[
275,
281
],
[
312,
318
],
[
342,
348
],
[
396,
402
],
[
436,
442
],
[
517,
523
],
[
593,
599
],
[
... |
# -*- coding: utf-8 -*-
import re
from six.moves import http_client
from six.moves import urllib
from wsgiref.headers import Headers
class Request(object):
def __init__(self, environ):
self.environ = environ
@property
def path(self):
return self.environ['PATH_INFO']
@property
de... | [
[
[
32,
34
],
[
1984,
1986
]
],
[
[
57,
68
],
[
1007,
1018
]
],
[
[
91,
97
],
[
386,
392
]
],
[
[
126,
133
],
[
732,
739
]
],
[
[
... |
#!/usr/bin/python
from __future__ import (absolute_import, division, print_function)
# Copyright 2019 Fortinet, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the Lic... | [
[
[
42,
57
]
],
[
[
59,
67
]
],
[
[
69,
83
]
],
[
[
755,
768
]
],
[
[
777,
793
]
],
[
[
917,
930
]
],
[
[
3667,
3675
]
],
[
[
4098,
... |
import torch
import torchvision
# An instance of your model.
model = torchvision.models.resnet18()
# An example input you would normally provide to your model's forward() method.
example = torch.rand(1, 3, 224, 224)
# Use torch.jit.trace to generate a torch.jit.ScriptModule via tracing.
traced_script_module = torch.... | [
[
[
7,
12
],
[
191,
196
],
[
314,
319
]
],
[
[
20,
31
],
[
70,
81
]
],
[
[
62,
67
],
[
330,
335
]
],
[
[
181,
188
],
[
337,
344
... |
import glob
import logging
import os
from typing import Any, Dict, List, Optional
from django.conf import settings
from zerver.lib.storage import static_path
# See https://jackstromberg.com/2013/01/useraccountcontrol-attributeflag-values/
# for docs on what these values mean.
LDAP_USER_ACCOUNT_CONTROL_NORMAL = '512'... | [
[
[
7,
11
],
[
853,
857
]
],
[
[
19,
26
],
[
2600,
2607
],
[
2668,
2675
],
[
2709,
2716
],
[
2768,
2775
]
],
[
[
34,
36
],
[
863,
86... |
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import AnonymousUser
from django.core.paginator import Paginator
from django.shortcuts import render, redirect, get_object_or_404
from django.contrib import messages
from django.views.decorators.cache import cache_page
from django... | [
[
[
43,
57
],
[
1698,
1712
],
[
4696,
4710
],
[
5493,
5507
],
[
6126,
6140
],
[
6391,
6405
]
],
[
[
97,
110
],
[
2464,
2477
]
],
[
[
145,
... |
from motor.motor_asyncio import AsyncIOMotorClient
from pymongo import MongoClient
__all__ = ['PymongoConnection', 'MotorConnection']
class PymongoConnection:
def __init__(self, host="127.0.0.1", port="27017", db="default", user=None, password=None):
"""Create database connection."""
if user and... | [
[
[
33,
51
],
[
1081,
1099
],
[
1189,
1207
],
[
1294,
1312
]
],
[
[
72,
83
],
[
360,
371
],
[
461,
472
],
[
559,
570
]
],
[
[
86,
93... |
import base64
import json
import os
import os.path
import shlex
import string
from datetime import datetime
from distutils.version import StrictVersion
from .. import errors
from .. import tls
from ..constants import DEFAULT_HTTP_HOST
from ..constants import DEFAULT_UNIX_SOCKET
from ..constants import DEFAULT_NPIPE
fr... | [
[
[
7,
13
],
[
841,
847
]
],
[
[
21,
25
],
[
909,
913
],
[
10589,
10593
]
],
[
[
33,
35
]
],
[
[
43,
50
],
[
9040,
9042
],
[
9661,
... |
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
#
# generated by datamodel-codegen:
# filename: airbyte_protocol.yaml
from __future__ import annotations
from enum import Enum
from typing import Any, Dict, List, Optional, Union
from pydantic import AnyUrl, BaseModel, Extra, Field
class Type(Enum):
... | [
[
[
157,
168
]
],
[
[
187,
191
],
[
311,
315
],
[
1097,
1101
],
[
1446,
1450
],
[
1664,
1668
],
[
1765,
1769
],
[
3524,
3528
],
[
3828,
... |
import os, collections, sqlite3
from flask import Flask, render_template
from flask.ext.bootstrap import Bootstrap
from AsciiDammit import asciiDammit
app = Flask(__name__)
bootstrap = Bootstrap(app)
import util as wpu
configDict = {}
appDataDirDict = {}
appName = "waypointapp"
@app.route('/')
def index():
appName... | [
[
[
7,
9
],
[
642,
644
],
[
1144,
1146
]
],
[
[
11,
22
],
[
1786,
1797
]
],
[
[
24,
31
],
[
1875,
1882
]
],
[
[
50,
55
],
[
158,
... |
"""
Created: 16 August 2018
Last Updated: 16 August 2018
Dan Marley
daniel.edison.marley@cernSPAMNOT.ch
Texas A&M University
-----
Class for performing deep learning in pytorch
Designed for running on desktop at TAMU
with specific set of software installed
--> not guaranteed to work in CMSSW environment!
D... | [
[
[
636,
640
]
],
[
[
648,
652
]
],
[
[
660,
668
]
],
[
[
676,
687
]
],
[
[
714,
726
],
[
1722,
1734
],
[
1807,
1819
],
[
2090,
2102
]
],
... |
import torch
import os.path as osp
import sys
from torch.autograd import Variable
cur_dir = osp.dirname(osp.abspath(__file__))
sys.path.insert(0, cur_dir)
import torch_nndistance as NND
p1 = torch.rand(10, 1000, 3)
p2 = torch.rand(10, 1500, 3)
points1 = Variable(p1, requires_grad=True)
points2 = p2
points1 = points1... | [
[
[
7,
12
],
[
194,
199
],
[
223,
228
],
[
450,
455
],
[
706,
711
]
],
[
[
20,
34
],
[
93,
96
],
[
105,
108
]
],
[
[
42,
45
],
... |
from geographiclib.geodesic import Geodesic
from pyproj import CRS, Transformer
from .geometry import Vector, Line
def azimuth(p1: Vector, p2: Vector):
""":return: azimuth of geodesic through p1 and p2 in p1 with WGS84"""
res = Geodesic.WGS84.Inverse(p1.y, p1.x, p2.y, p2.x)
return res['azi1']
def dist... | [
[
[
35,
43
],
[
239,
247
],
[
460,
468
]
],
[
[
63,
66
],
[
1308,
1311
],
[
1349,
1352
]
],
[
[
68,
79
],
[
1476,
1487
]
],
[
[
103,
... |
"""
Segment_tree creates a segment tree with a given array and function,
allowing queries to be done later in log(N) time
function takes 2 values and returns a same type value
"""
class SegmentTree:
def __init__(self, arr, function):
self.segment = [0 for x in range(3 * len(arr) + 3)]
self.arr = a... | [
[
[
188,
199
]
]
] |
import unittest
from rfapi.error import JsonParseError, MissingAuthError
class ApiClientTest(unittest.TestCase):
def test_json_parse_error(self):
resp = type('', (object,), {"content": ""})()
msg = "Could not parse"
e = JsonParseError(msg, resp)
self.assertEqual(str(e), msg)
d... | [
[
[
7,
15
],
[
95,
103
]
],
[
[
40,
54
],
[
250,
264
]
],
[
[
56,
72
],
[
366,
382
]
],
[
[
81,
94
]
]
] |
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE
from __future__ import absolute_import
import awkward as ak
np = ak.nplike.NumpyMetadata.instance()
def is_valid(array, exception=False):
pass
# """
# Args:
# array (#ak.Array, #ak.Record, #ak.layout.Conte... | [
[
[
112,
127
]
],
[
[
136,
149
],
[
156,
158
]
],
[
[
151,
153
]
],
[
[
197,
205
]
]
] |
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import numpy as np
import os,sys,inspect
import imageio
sys.path.insert(1, os.path.join(sys.path[0], '..')) #go up a dir to import
import CodePy2.funmath as funmath
#import imageio
n = 1.0
sizes = [i/n for i in range(33*int(n))]
xvals = sizes
filenames ... | [
[
[
8,
32
],
[
379,
382
],
[
665,
668
],
[
691,
694
],
[
710,
713
],
[
748,
751
],
[
789,
792
],
[
818,
821
],
[
872,
875
],
[
... |
import copy
import math
import matplotlib.pyplot as plt
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from utils.utils import clones
class LayerNormGoogle(nn.Module):
def __init__(self, features, epsilon=1e-6):
super(LayerNormGo... | [
[
[
7,
11
],
[
8980,
8984
]
],
[
[
19,
23
],
[
3834,
3838
],
[
5885,
5889
],
[
6371,
6375
]
],
[
[
32,
56
],
[
10758,
10761
],
[
10885,
... |
from tensorflow import keras
from constants import TRADING_DAYS_PER_WEEK, INDEX_RETURN_INDICATOR_NUMBER
from ..constants import *
MODEL_NAME = 'ifcp_model_ver1_2'
ROLLING_WINDOW_SIZE = TRADING_DAYS_PER_WEEK
def build_model():
fund1_return = keras.Input(shape=(ROLLING_WINDOW_SIZE, 1), name=FUND1_RETURN_NAME)
... | [
[
[
23,
28
],
[
249,
254
],
[
346,
351
],
[
443,
448
],
[
540,
545
],
[
643,
648
],
[
755,
760
],
[
867,
872
],
[
1008,
1013
],
[
... |
# flake8: noqa
from fugue.extensions.creator.creator import Creator
from fugue.extensions.creator.convert import creator, _to_creator
| [
[
[
60,
67
]
],
[
[
113,
120
]
],
[
[
122,
133
]
]
] |
# -*- coding: utf-8 -*-
__author__ = "苦叶子"
"""
公众号: 开源优测
Email: lymking@foxmail.com
"""
import os
import time
import tempfile
import subprocess
class Process:
def __init__(self, command):
self._command = command
self._process = None
self._error = None
self._out_file = None
... | [
[
[
25,
35
]
],
[
[
101,
103
],
[
1839,
1841
],
[
1965,
1967
]
],
[
[
111,
115
],
[
2078,
2082
]
],
[
[
123,
131
],
[
460,
468
]
],
[
[
... |
"""Inventory requests."""
from collections import defaultdict
from typing import Any, MutableMapping
import requests
from linnapi.request import LinnworksAPIRequest
class GetStockItemIDsBySKU(LinnworksAPIRequest):
"""Return the stock item ID for a SKU."""
URL = "https://eu-ext.linnworks.net/api/Inventory/... | [
[
[
51,
62
],
[
7181,
7192
]
],
[
[
82,
85
],
[
456,
459
],
[
468,
471
],
[
423,
426
],
[
438,
441
],
[
900,
903
],
[
912,
915
],
... |
from flask import Flask, render_template, request
from dashboard_forms import Dashform
#import create_pickle as p_j
import json
import os
app = Flask(__name__)
app.secret_key = 'dash_flask_key'
creddir = os.path.join(os.path.dirname(
os.path.dirname(os.path.realpath(__file__))), 'credentials/dash_id.json'... | [
[
[
18,
23
],
[
151,
156
]
],
[
[
25,
40
],
[
6443,
6458
],
[
8911,
8926
]
],
[
[
42,
49
],
[
3701,
3708
],
[
3774,
3781
],
[
3830,
... |
class BaseDatabaseClient:
"""Encapsulate backend-specific methods for opening a client shell."""
# This should be a string representing the name of the executable
# (e.g., "psql"). Subclasses must override this.
executable_name = None
def __init__(self, connection):
# connection is an inst... | [
[
[
6,
24
]
]
] |
"""
Unit tests for symupy.api.stream
"""
# ============================================================================
# STANDARD IMPORTS
# ============================================================================
import pytest
# ============================================================================
#... | [
[
[
232,
238
],
[
712,
718
],
[
777,
783
]
],
[
[
461,
470
],
[
903,
912
],
[
1017,
1026
],
[
1201,
1210
],
[
1301,
1310
],
[
1494,
1503... |
#
# Copyright 2016 Google Inc. All Rights Reserved.
#
# 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.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | [] |
exec(open("Modified_data/next_level.py").read())
| [] |
from .base import lr
from . import het
from .merge import merge
from .permutation import permutation
| [
[
[
18,
20
]
],
[
[
35,
38
]
],
[
[
58,
63
]
],
[
[
89,
100
]
]
] |
# encoding: utf-8
from datetime import datetime, timedelta
from django.conf import settings
from django.contrib.auth.models import Group
from django.core.management.base import BaseCommand
from dateutil.tz import tzlocal
from core.models import Event, Venue
from programme.models import ProgrammeEventMeta, TimeBlock... | [
[
[
40,
48
],
[
990,
998
],
[
1052,
1060
],
[
1846,
1854
],
[
1906,
1914
],
[
1994,
2002
],
[
2054,
2062
],
[
2433,
2441
]
],
[
[
50,
59... |
import svm as SVM
import numpy as np
data_dict = { -1:np.array( [[10,9,1],
[2,8,1],
[3,8,1],]),
1:np.array( [[5,1,1],
[6,-1,1],
[7,3,1],])}
svm = SVM.Support_Vector_Machine()
svm.fit(data=data_dict)
predict_us = [[0,10,1],
[1,3,1],
... | [
[
[
7,
17
],
[
224,
227
]
],
[
[
25,
36
],
[
55,
57
],
[
123,
125
]
],
[
[
38,
47
],
[
266,
275
]
],
[
[
218,
221
],
[
253,
256
... |
#!/usr/bin/python3
import configparser
config = configparser.ConfigParser()
config.read('eve-conf.ini')
def int_imp(inp):
while True:
try:
int(inp)
break
except ValueError:
print('Input has to be a number.')
inp = input('Select again: ')
return i... | [
[
[
26,
38
],
[
49,
61
]
],
[
[
40,
46
],
[
77,
83
],
[
3737,
3743
],
[
1505,
1511
],
[
1577,
1583
],
[
1648,
1654
]
],
[
[
110,
117... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.