text stringlengths 65 6.05M | lang stringclasses 8
values | type stringclasses 2
values | id stringlengths 64 64 |
|---|---|---|---|
import _plotly_utils.basevalidators
class TitleValidator(_plotly_utils.basevalidators.TitleValidator):
def __init__(self, plotly_name="title", parent_name="pie", **kwargs):
super(TitleValidator, self).__init__(
plotly_name=plotly_name,
parent_name=parent_name,
data_clas... | Python | CL | 52d53ffe28ed681420d448908dbdbb92b993c59f2023e0d9e88825f68d93a84a |
from hashlib import sha256
from cache_helper import settings
from cache_helper.exceptions import CacheKeyCreationError
from cache_helper.interfaces import CacheHelperCacheable
def get_function_cache_key(func_name, func_args, func_kwargs):
args_string = build_args_string(*func_args, **func_kwargs)
key = "{fun... | Python | CL | 7681a72a96d094281e0e03480ce813d0a5f7db7923e84b00082aad869e76d6f7 |
#---------------------------
# Import Libraries
#---------------------------
import os
import sys
import json
import ctypes
import time
sys.path.append(os.path.join(os.path.dirname(__file__), "lib")) #point at lib folder for classes / references
import clr
clr.AddReference("IronPython.SQLite.dll")
clr.Ad... | Python | CL | 62a5bb928ea8865f817a791a7d65f431cce28f142bf552a83ed92ea6d845b573 |
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from sigqc import sigqc_primitives
import os
import csv
import matplotlib.cm
#####################################################################################################################################
# sigqc_pca.py
# Austin Cole... | Python | CL | 1b4788deb4b58cb9cb0f25452d721e8ba27573f49d20a415e4044c75d059911a |
# Copyright (c) 2021 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 app... | Python | CL | d879f199cd0f4349b1a6da288f9f3da326b3ab54d7bd9b1bba956326fb6f5533 |
from evaluation.classifiers import FCNet, LGR, EKNN, CNN1, \
SVM, SGD, DTREE, EKNN, QDA, \
RFOREST, GP
from evaluation.data_sampler import WSampler, make_tier_idx
import json
import numpy as np
import pickle
import random
import itertools
import ray
... | Python | CL | 2e8aa803fb017ba610a07a797192b64d43da076f05329fa6146350be1cb154fe |
#!/usr/bin/python2.7
#main.py
#the import section
import webapp2
import jinja2
import io
import os
import json
from google.appengine.api import urlfetch
'''
from google.cloud import vision
from google.cloud.vision import types
'''
# this initializes the jinja2 environment
the_jinja_env = jinja2.Environment(
loa... | Python | CL | ed005ef28d7f2f40165821b78200342f8a70f5909fc9ae1e91f69b09849ac7b8 |
import json
# This small program creates a cheat List only containing the character names
# You can load the generated `hero_adresses.json` file into Game Conqueror
# And it should show all the Names of the Heroes as values
# The Address list can then be used again to generate the base addresses
# for `generate_cheat_l... | Python | CL | c0e8135da87d27c6f998b8d680c6270108921659906c695fd46e94f1ffb7433c |
import datetime
import helpers.db as db
import helpers.utils as utils
from controllers.organisation import set_active_org_project
from flask import redirect, render_template, request, url_for
from flask.views import MethodView
from helpers.decorators import check_valid_org_and_project, login_required
class... | Python | CL | 7101e8b881d68672621440e11aede6c59ab85482ab41b5e0ec40e6ee8b24222b |
# Remove duplicate documents
import os
from typing import List, Dict, Tuple
# Input: Ranked List, SWTT
# Output: Ranked List
from arg.counter_arg_retrieval.build_dataset.data_prep.duplicate_removal import remove_duplicates
from arg.counter_arg_retrieval.build_dataset.run5.path_helper import load_swtt_jsonl_per_query_a... | Python | CL | 2fd22b484c92ace8d9c6afb8a6f7033c8bfa148c8098b3879d7e88fc2571432d |
"""Privacy-related template tags."""
from django import template
from django.utils.html import format_html
from djblets.privacy.pii import build_pii_safe_page_url_for_request
register = template.Library()
@register.simple_tag(takes_context=True)
def pii_safe_page_url(context):
"""Inject the current page URL w... | Python | CL | 26ea47791c37d08580dbe616e046364a811c14495818cbd448083e9ca3d4e30f |
from rest_framework.generics import ListCreateAPIView, RetrieveUpdateAPIView
from rest_framework.decorators import api_view
from rest_framework.response import Response
from .serializers import (
BookSerializer,
BookUpdateSerializer,
LibrarySerializer
)
from library.models import Book
from drf_autodocs.de... | Python | CL | 4007892b677ab87f0552ecd4dacea5bf1404c1bd164728f54a652f85d1470f5e |
#!/usr/local/bin/python
'''
<<Description>>
<<Summary>>
'''
__author__ = 'Marc Balducci'
__version__ = '$Revision$'[11:-2]
__date__ = '$Date$'[7:26]
################################################################################
# I M P O R T L I B R A R I E S
##########################... | Python | CL | 3e4f099b866ae42005f28a07e10efbcda2a81c3c66da14069bd2dfa388994eb4 |
# Generated by Django 3.1.3 on 2020-12-02 17:24
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('quiz', '0001_initial'),
migrations.swappable_depen... | Python | CL | 0fc015cb23a01e05cd6a63834b40d37a0eef79e934ff069f8d333160ebd00f80 |
import pandas as pd
import matplotlib.pyplot as plt
from numpy import mean
from numpy import std
# from tkinter import *
import numpy as np
from pandas.plotting import scatter_matrix
import seaborn as sns
from sklearn.feature_selection import f_regression
from scipy.stats import pearsonr
from scipy.stats import spearma... | Python | CL | 8de9ca54c2143608dbbd160bcf9bbbe3cd24b5e12a368c48e165cd34e5d82576 |
import asyncssh
import asyncio
from subprocess import PIPE
class BaseResult(object):
def __init__(self):
pass
async def wait(self):
pass
async def recv_stdin(self):
pass
def return_code(self):
pass
class BaseConnection(object):
def __init__(self, config=None, pr... | Python | CL | 57e46780ec377fa3781463681e5324b450c90ff36871d64689356f49bc3ab393 |
#!/usr/bin/env python3
# Maintainer: SAITO Fuyuki <saitofuyuki@jamstec.go.jp>
# 'Time-stamp: <2020/08/02 17:42:34 fuyuki evacuate.py>'
# import psitex as psi
import psitex
import sys
import getopt
import os.path
import string
import re
import pprint as ppr
import pyparsing as pp
class ParserMirocDoc(psitex.ParserStd... | Python | CL | 5d485b46dffdee04c8f5fa8fcfc4c4b7edb76298ab7393a98e855ab0559edaa2 |
import pickle
import subprocess
import time
from datetime import datetime as dt
import pandas as pd
import csv
import threading
from os import path
from SeisNode import SeisNode
class NodeManager:
"""
[In progress]
"""
def __init__(self):
self.node_path = "/home/pi/SeisNode"
self.... | Python | CL | 68b3cfa8bb482d905d08fe3e49944bfa558a67ffcfb90ad6b2cd8d67187e3260 |
# -*- coding: utf-8 -*-
'''
Manage the shadow file
.. important::
If you feel that Salt should be using this module to manage passwords on a
minion, and it is using a different module (or gives an error similar to
*'shadow.info' is not available*), see :ref:`here
<module-provider-override>`.
'''
# Impo... | Python | CL | 614b190868c11af258ea8c755aad1e8d4f8442f272df50c55e793d76aaedea11 |
from keras.optimizers import Adam
from keras.callbacks import TensorBoard, ModelCheckpoint
from keras.layers import MaxPooling2D, Activation, Dropout, Flatten, Dense, SeparableConv2D,Conv2D ,initializers
from keras.models import Sequential
from keras.layers.normalization import BatchNormalization
from utility import *
... | Python | CL | bfc7ab711bab3306cf5671c33a0f47c2600cd2c10d2ed685a4fb457a147b7985 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This is a python implementation of rnnlm.cpp
"""
import sys
import os.path
import argparse
import rnnlm
def main(argv):
argc = len(argv)
parser = argparse.ArgumentParser()
parser.add_argument('-debug')
parser.add_argument('-train')
parser.add_arg... | Python | CL | 1836e3da1e2740e3cc7f8f03c296308991416ca89b7ec555c61c50ec1e431b8b |
import itertools
from modelstore.elasticstore import KWType
from api.apiutils import compute_field_id as id_from
from api.apiutils import Operation
from api.apiutils import OP
from api.apiutils import Relation
from api.apiutils import DRS
from api.apiutils import DRSMode
from api.apiutils import Hit
from api.annotati... | Python | CL | f4f7072ca3b8bf69b27ce6e16bd8fe8577908d6c7fd400bf1b326f6d5bd28840 |
# -*-coding:utf-8-*-
# 作者: Taylor
# 文件名: 文件自动归类.py
# 日期时间:2021/8/11,19:50
import os
import glob
import shutil
from gooey import Gooey, GooeyParser
# 定义一个文件字典,不同的文件类型,属于不同的文件夹,一共9个大类。
file_suffix_dict = {
'图片': ['jpg', 'png', 'jpeg', 'gif', 'webp'],
'视频': ['mp4', 'avi', 'mkv', 'flv', 'ts'],
"音频": ['wave... | Python | CL | 58ae6712c50105dbbfb07619a48aa9a30c991c6b04561620d4258352c7e9ed07 |
from __future__ import absolute_import
from myhdl import Signal, intbv
from rhea.system import ControlStatus
from . import prbs_generate
from . import prbs_check
class PRBSControlStatus(ControlStatus):
# global control signals
enable = Signal(bool(0))
# generator control signals
inject_error = Sig... | Python | CL | 77ce027d0d7d70e9e33fd0dc2996f9cc8e3e2ad06133783b41a542cd17163306 |
from __future__ import absolute_import
import argparse
import logging
import re
import apache_beam as beam
from apache_beam.options.pipeline_options import PipelineOptions
import os
# set GOOGLE_APPLICATION_CREDENTIALS environment variable in Python code to the path key.json file
os.environ['GOOGLE_APPLICATION_CREDENT... | Python | CL | 9e6c947ef653f015feb304cfc8188c9d69a83febcb92c6fa886ff2ff009b63ea |
# first neural network with keras - predictions
from numpy import loadtxt
from keras.models import Sequential
from keras.layers import Dense
from keras.models import model_from_json
import os
import numpy as np
import time
#varNames = ['inning', 'vis score', 'home score', 'erahome', 'eraAway', 'bbhome', 'bbaway', 'hr... | Python | CL | 6e6d18f4465ce2a904ac16aae805b0ae08cd9b6d8ba0f7152c22a2abd9b9ce3c |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.db.models.deletion
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operati... | Python | CL | f1439507653ff57871ce388abe46eb6f6367a6e09de553584c159f33a1459ef2 |
###############################################################################
# This program will write down every file (other than .dll) #
# in the specified directory if currentSnapshot.1og is blank or non-existant. #
# If it does exist, it will only write down files that have been modified #
... | Python | CL | 893b938d68f902b2fb23f789aa42e244e93ed5e13364efdfb403480a39f92b45 |
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module provides classes to perform grouping of stars.
"""
import numpy as np
__all__ = ['SourceGrouper']
class SourceGrouper:
"""
Class to group sources into clusters based on a minimum separation
distance.
This class uses the... | Python | CL | d402eb4eb0eb8de38cbca2ec008b20f2e24efb86d0fe2b93fda1524e61ed4312 |
#!/usr/bin/env python
# coding: utf-8
# # Task 3
#
# The question given was:
#
# Please write a simple compiler – program, which translates one quantum circuit into another, using a restricted set of gates.
#
# You need to consider just the basic gates for the input circuit, such as (I, H, X, Y, Z, RX, RY, RZ, CNOT... | Python | CL | 54c15eddeda525bbe0f39bda219d9a181f529402b88b50712f551e1d9628fc44 |
#CONSTANTS:
genetypesensor=10
geneteypeneuron=20
genetypeorgan=30
class Gene:
def __init__(self,genetype):
self.type=genetype
class Creature:
def Transcribe():
Sort_Genes()
Wire_Brain()
Wire_Organs()
def Sort_Genes():
self.sensors=[]
self.neu... | Python | CL | 5d7e97014d6551eea5c6436219c234f689e72f0301b8e4a29835e274e31d6a21 |
#!/usr/bin/env ipython
"""Basic example
Sets up a transformer that computes a result based on two inputs
The input and the transformation code is edited live in a GUI
"""
from seamless import context, cell, pythoncell, transformer
from seamless.lib import edit, display
ctx = context()
# Create 3 int cells: a=2, b=... | Python | CL | 5ae83ffb8ae06b36730884d7b358fcf68adbee9e8a58f93d871b99304ed30982 |
import os
import pickle
import sys
import utils
import numpy as np
from scipy.stats import pearsonr
from scipy.stats import spearmanr
EXP1_PARTS = ["M01", "M02", "M03", "M04", "M05", "M06", "M07", "M08", "M09",
"M10", "M13", "M14", "M15", "M16", "M17", "P01"]
EXP2_PARTS = ["M02", "M04", "M07", "M08", "M... | Python | CL | d6a47a1aacf70f3110b89550a14eb491c3501ef2c7d3773a825dc273244b2224 |
"""
This module offers some basic functionality for getting, putting and
transforming the data. This module is very much written with chart.js
in mind
"""
from datetime import datetime, timedelta
from airtable import airtable
import requests
from sortedcontainers import SortedSet
from flask import current_app as app
... | Python | CL | a88855ef40b95d91a8aa579fc4a9d6eb904fd61915c9ea7fe8d75f2878c348de |
#!/usr/bin/env python
import os, sys
#import sys.argv
from stat import *
from os.path import expandvars
from icecube import dataio
from I3Tray import *
load("libdataclasses")
load("libdataio")
load("liblinefit")
load("libgulliver")
load("libgulliver-modules")
load("liblilliput")
load("libphys-services")
load("lib... | Python | CL | 194622b19e22b4962ee86b4a1c9030ae862c40fa1534da63145fd3d424afcb7b |
from random import randint
from retrying import retry
from apysc import Number
from apysc.display.line_alpha_interface import LineAlphaInterface
from apysc.expression import expression_file_util
class TestLineAlphaInterface:
@retry(stop_max_attempt_number=15, wait_fixed=randint(10, 3000))
def t... | Python | CL | e219919dd3fe2bf7044451eeee85627c0174a12014a59bc921f4999cfc5043b9 |
import random
class Ability:
'''An ability is an action that has a damage value.
name: str
max_damage: int
'''
def __init__(self, name, max_damage):
self.name = name
self.max_damage = max_damage
def attack(self):
'''Return a random value between 0 and the initialized ... | Python | CL | d96ae8b16c1460943d18dbdd1e5605b0bc15b1b8616708b5b1978b5f87c91b4d |
from locust import task, between
from locust.contrib.fasthttp import FastHttpUser
# (Only first time) Install @locust, open a terminal & run: pip3 install locust
# Open terminal & run: locust -f latam_pg.py
# Open address: http://localhost:8089/
# Insert the Number of total users to simulate
# Insert the Spawn rate (u... | Python | CL | d7384fc02f15e4660ef3476241f54127c8da115feb70bb745ea52efea30186dc |
import datetime
import logging
from apscheduler.events import EVENT_JOB_ERROR, EVENT_JOB_ADDED, EVENT_JOB_EXECUTED
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.triggers.cron import CronTrigger
from apscheduler.triggers.interval import IntervalTrigger
from config import config as ... | Python | CL | 089c502bf51add0350b8229df2771b6b3ab530e4e0df2553efd3558d885b9969 |
"""
Module dedicated to logging the simulations and networks generated via the
library.
Depending on the settings in `$HOME/.nngt.conf`, the data will either be stored
in a in a SQL database or in CSV files.
Content
=======
"""
from .db_main import db
#--------------------------------------------------------------... | Python | CL | 5c77b9de97873a4c765c3d6aefe17630bb997dbcfb935fe78c194fa169132c87 |
# ----------------------------------------------------------------------
# Clickhouse query engine
# ----------------------------------------------------------------------
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
# Pyth... | Python | CL | 9f82d43301f2bc2e021588167d3e2a117ca169b7f504b72543cd5ce0a75b10d4 |
from typing import Dict, Optional
from django.conf import settings
from django.db import models
from model_utils.models import TimeStampedModel
from geonames_place.models import Place
from radical_translations.core.models import Resource
from radical_translations.utils.models import (
Date,
EditorialClassific... | Python | CL | a2892c25476ba2d8c4c0e0574282a1297a04cf56c3468640e9fbc495bab834e6 |
import sys
import re
import os
# keep track of how classes are defined in C++ and make sure it matches LISP_CLASS definitions
CurrentPackage = None
CurrentNamespaceStack = []
NamespaceForPackage = { None: "::", }
PackageForNamespace = { "": None }
cppClassDefinitionBases = {}
def enum(**enums):
return type('Enum... | Python | CL | b48c01cc7888edcf920054b6053ae370664c9d031887c36aecbfe65f5f38cfd8 |
!#/usr/local/bin/python
"""
The Simplified Whiskas Model Python Formulation for the PuLP Modeller
Authors: Antony Phillips, Dr Stuart Mitchell 2007
"""
# Import PuLP modeler functions
from pulp import *
| Python | CL | bbb1f9feae1d727936ea85b9b398fd679f444c2a5920fefa6737c95f7d666662 |
#!/usr/bin/python
from pynt import task
import subprocess
import shutil
import sys
import os
CUR_DIR = os.getcwd()
BACKEND_DIR = CUR_DIR + "/backend"
BACKEND_REPORT_DIR = CUR_DIR + "/reports/backend"
FRONTEND_DIR = CUR_DIR + "/frontend"
FRONTEND_REPORT_DIR = CUR_DIR + "/reports/frontend"
SUPER_EMAIL = "superuser@emai... | Python | CL | f18e37348f5910ab478b22a165ec12bfced56abcf6e63e4de50ce3db40546f1f |
"""
Helper functions that will eventually be added to the official api in some form.
Or alternate implementations that address bugs in the originals.
"""
import numpy as np
from lcmtypes.skills import ui_input_axis_t as Axis
# TODO(matt): fix the phone API
def safe_get_key(phone_api, key):
# This queries the va... | Python | CL | c70b7ba4a2d700e97f5ca021df7739a556c3ac0fffad8f49d9452d075ea7e05c |
#!/usr/bin/env python
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'GPL v3'
__copyright__ = '2019, Jim Miller'
__docformat__ = 'restructuredtext en'
from functools import partial
import s... | Python | CL | 7db8b74b767688e4910fece55f54bb9766ea6700acde5a8153efc141cd6306ea |
# Copyright 2020 VEXXHOST, 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 wr... | Python | CL | 2370e3a26153e616a3b24d713dbbbde0da85909a74d742c4b8a30e3192705fa8 |
# Copyright Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license" fil... | Python | CL | 6cdf733c24f7b87d6d176bf4bf21dee2a30c6050a13d321483128b2ce6b383d8 |
from typing import List
import os.path
dirname = os.path.dirname(__file__)
from aws_cdk import core, aws_iam as iam, aws_lambda as _lambda
from aws_cdk.core import CustomResource
import aws_cdk.custom_resources as cr
class ScpAttachmentResource(core.Construct):
def __init__(
self,
scope: core... | Python | CL | b69e082c10aa977fe4e934b80ca7755e2075678fa7cdbed71ac08eca7bf6cd1c |
"""
===========
05. Run SSP
===========
SSP
"""
import os.path as op
import mne
from mne.parallel import parallel_func
import config
from mne.preprocessing import compute_proj_ecg, compute_proj_eog
def run_ssp(subject):
print("processing subject: %s" % subject)
meg_subject_dir = op.join(config.meg_dir, su... | Python | CL | 2fe834d89c65c314c0f08dcf8f16dfb6ba277342fb2e361ce2c6a5878c85b00f |
"""
Utils for working with CALIOP data, particularly bit fields such as the Atmospheric_Volume_Description.
The flag conversion functions were essentially copied from https://github.com/vnoel/pycode/blob/master/calipso/level2.py
It doesn't have a license but the author appears to allow free use in his readme.
"""
... | Python | CL | 6df45d76efc6cdba81a6078a8f69211f88dd654d09250e47d5a70be900f4904f |
from __future__ import division
from random import shuffle
import numpy as np
def softmax(y):
max_of_rows = np.max(y, 1)
m = np.array([max_of_rows, ] * y.shape[1]).T
y = y - m
y = np.exp(y)
return y / (np.array([np.sum(y, 1), ] * y.shape[1])).T
def load_data():
"""
Loads the MNIST data... | Python | CL | 04ec4646b783f25921683dafa1a0e2008818e9cd176578346f40ce0aa1b06776 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @copyright 2016 TUNE, Inc. (http://www.tune.com)
# @namespace tune_mv_integration
import logging
import httplib2
import urllib
log = logging.getLogger(__name__)
from requests_mv_integrations.support.safe_cast import (
safe_int
)
def is_valid_url_exists(url):
... | Python | CL | 7cf31bd01fc952433a40434015f9ace664cde5d6cb216de67bd7469ad8cf224f |
import os
import librosa
import pysrt
from pysrt import SubRipTime
import sys
from pathlib import Path
import re
from datetime import timedelta
import chardet
from moviepy.editor import *
import numpy as np
from ffmpeg import Transcode
class Media:
"""
The Media class represents a media file to be retrieved and ... | Python | CL | 0b7d17699ad2477b07b26d0f56f1a755250ec2688153cecfba51f02c9dd38f6b |
# %%
# CALCULATOR: MASSES & RADII
# Cifuentes et al. 2020
# Stefan-Boltzmann L-R
# Schweitzer et al. 2019 M-R
import numpy as np
Mother_version = '01'
# Radius: Stefan-Boltzmann (SB)
def Radius_SB(Lbol, Lberr, Teff, eTeff):
"""Stellar radius and its error from the Stefan–Boltzmann law under the black body ap... | Python | CL | ed817ec1651f4c2eee070179da302ec20c63facd0da2e6e989b27d2676d92746 |
#!/usr/bin/env python
# Copyright (C) 2015-2018 Red Hat, Inc. <http://www.redhat.com>
#
# 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 2 of the License, or
# any later vers... | Python | CL | 665cde0960643e3870ba1d409f614d300208536331493f57b62c1329bf08f4ce |
from pathlib import Path
import json
from typing import Dict, Any
import requests
from urllib.parse import urljoin
from cachecontrol import CacheControl # type: ignore
from .errors import BadRequest
def get_data_model() -> Dict:
""" Return a dictionary representation of the data model """
root = Path(__file__... | Python | CL | a5aa61f0c6e6c6004cc0ab044580fed85dd9111407c4cef228a61b366a3c75c7 |
import numpy as np
states = {}
################
# Human Choice #
################
def humanDecision(state, verbose=False):
"""
Function to make a human choice
:param state: The state of the game on wich we want to get the best choice and score.
:type state: StateGame
:return: Retur... | Python | CL | 3d9fc9229be9f6be5c75342ef40266b418dad43cc2a0e5366b0abb20446fa620 |
from collections import Iterable
class BaseManager(object):
# you must initialise self.resource_env in __init__
fields = None
class Meta:
abstract = True
def _is_iterable(self, ids):
if isinstance(ids, str) or not isinstance(ids, Iterable):
ids = [ids, ]
return ... | Python | CL | f68c0efb593689f62246b4c6e5ad7fe1f28a833d8848444871e538ed68ac211d |
"""
Archiving old Modmail pre-deletion
"""
from dotenv import load_dotenv
import logging
import os
# from pprint import pprint
import praw
import sqlite3
from sqlite3 import Error
import sys
SUBREDDIT = "Hermitcraft"
FILENAME = "oldmodmail_bak.db"
USERAGENT = "Git Backup Test Version"
def main(conn):
global SUB... | Python | CL | 77621350966ac8e72651616ec150c5b10da2295d28792f37bf4a4af75aa4f05e |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author:Benjamin
# date:2020.11.18 21:06
# 面向对象的含义不多做赘述
# 类和实例:
# class关键字后面表示类名,在后面的括号中表示该类继承自那个类,也就是这个类的父类。
class Student(object):
def __init__(self, name, score):
self.name = name
self.score = score
def print_score(self):
print '%s: %s... | Python | CL | 32c004147d7bca50c779c7f1674279fb69dc01eadc27166cbf693c4bdbb96f79 |
"""Methods for processing data.
"""
from typing import List
def sum(num: int, num_list: List[int]) -> int:
"""Methods for calculating the sum of an intger and a list of integer.
Args:
num: An integer. The current sum.
num_list: A list of integer. The new set of data to be added to sum.
R... | Python | CL | 31e664d403bf21f7318def78973cd0c300ae99bdc9aed5bc8bbda357d75598a6 |
#======================
# Classe per file CSV
#======================
class CSVTimeSeriesFile:
def __init__(self, name):
# Setto il nome del file
self.name = name
def get_data(self):
#provo ad aprire il file in modalita lettura
try:
my_file = open(self.n... | Python | CL | 5b22e1a6c8fd9a80837266f1103bb9c766a725b6023f13a1e598eed19b953590 |
from __future__ import print_function
from dataflow import ports
def add(x): # Returns a callable object
return lambda y: x + y
# Event example code
e_source = ports.EventSource()
e_terminal = ports.EventTerminal()
# 1 shall be added to the value fired from the source, then forwarded to the terminal
e_source ... | Python | CL | 8ec9425b5aa9994b4318dd93b6198755357051b27dd3889ae27b5d5c3c0e410c |
# -*- Mode: Python -*-
# Demonstrates use of the auth and put handlers to support publishing
# web pages via HTTP.
# It is also possible to set up the ftp server to do essentially the
# same thing.
# Security Note: Using HTTP with the 'Basic' authentication scheme is
# only slightly more secure than using F... | Python | CL | 572b65e2431cf365d54057f6fa5117915aa31396a29011aa20d741edb43f8fb5 |
import json
import torch
from torch import nn
from torch.autograd.function import Function
import torch.nn.functional as F
import numpy as np
from detectron2.modeling.roi_heads.fast_rcnn import fast_rcnn_inference
from detectron2.modeling.roi_heads.roi_heads import ROI_HEADS_REGISTRY, StandardROIHeads
from detectron2.... | Python | CL | f083b5f91de23efcd3089c7a48e8dee50a053efd7b2ce750a2fad7b786789e41 |
#!/usr/bin/env python3
# we will be using nltk.lm
# imports
# %%
import nltk
from nltk.lm.models import Laplace
from nltk.lm import Vocabulary
from nltk.util import flatten, ngrams
import re
import json
import csv
import os
from nltk.stem.snowball import SnowballStemmer
import random
import math
from nltk.lm import M... | Python | CL | c7a79a4d594de74e075505c318a6808dafd884dcd5bfc7f456e2ac2415062d08 |
import torch
import numpy as np
import matplotlib.pyplot as plt
from datasets.custom_transforms import unNormalize, decode_segmap
def visualize(model, data_loader, save_path:str, device, cls_num:int=19, disp_num:int=10):
"""
It display pairs of the original image,the ground truth mask and prediction mask ... | Python | CL | 21a188c9bc201f20f270ed714fe60a549dcbf8ae03a795fd8982df8377498df3 |
import pprint
import luigi
import ujson
import numpy as np
from numpy.random import RandomState
from scipy.sparse import dok_matrix
import pandas as pd
from sklearn.externals import joblib
from lightfm import LightFM
from ..models import FitModel, PredictModel
from ..clean_data import Products
class LightFMv2(objec... | Python | CL | a3cef697168b79a25a4d8e8e15f4e6103c678178056978332f20a96f5accdd46 |
import pandas as pd
df = pd.read_table("smsspamcollection/SMSSpamCollection",
sep = "\t",
header = None,
names=["label", "sms_message"])
df['label'] = df.label.map({'ham':0, 'spam':1})
from sklearn.feature_extraction.text import CountVectorizer
from sklea... | Python | CL | fb2d302afddef59c9ece0b1237dbcc4d5f5c71e6384f0b20f42ec6f2af4309f5 |
"""
Copyright (c) 2012, Tyler Voskuilen
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the foll... | Python | CL | 178846333c12cd22ab9932d370eedac5cf0cd6d6a81b4853314cc91463564908 |
from conservoceanAPI import makeWater, makeHuman, makeFish, validateArgs, filterHuman, filterWater, filterFish
from unittest import main, TestCase
from database import Fish, BodiesOfWater, HumanImpact
class TestAPI(TestCase):
# Test fish entry 1 for correctness
def testMakeFish1(self):
fish = Fish.qu... | Python | CL | 3b3abb07bb3d9b001161f3cabfa528427e5c7d11919b1079847eaea99d9f61b9 |
from cadCAD.configuration import Experiment
from cadCAD.configuration.utils import config_sim
from .state_variables import initial_state
from .partial_state_update_block import partial_state_update_block
from .sys_params import params , initial_values
from .sim_setup import SIMULATION_TIME_STEPS, MONTE_CARLO_RUNS
from ... | Python | CL | 875768acc0b3467d3f2a4fe5f0c28513a4329bc5d12d52fa9ed141299f6d189b |
#!/usr/bin/env python2
"""
Original code from https://github.com/vbajpai/atsquery
Modified to suit the needs of this specific tool
"""
import os
import requests
import datetime
import time
import hmac
import hashlib
import base64
import collections
import xml.etree.ElementTree as ET
import yaml
import argpars... | Python | CL | e10a8e93f1a16e0c0247e0e0127bb34280a644705dc49dbc4e717e3a15a37514 |
# TODO: This must be broken into at least two separate classes, if not more. Also, data like recipe book can be put
# into a metadata file.
import pygame
import sys
from ks_environment import Background, Grid, ActiveImage, Button, ResultBox, DetectEvents
from craft_compendium import CraftCompendium
# if setting-stat... | Python | CL | f897afc9dd514010c1d72825fedf74a5099edf86594cad89331de3559a69742c |
"""ASCII board representation."""
from gomill import boards
from gomill.common import column_letters
def render_grid(point_formatter, size):
"""Render a board-shaped grid as a list of strings.
point_formatter -- function (row, col) -> string of length 2.
Returns a list of strings.
"""
column_he... | Python | CL | 374bfc9119a92b065a1783ef7f71239380d8581975da12eddd45adfc9e88304a |
import sys, os
from time import gmtime, strftime
_H2O_IP_ = "127.0.0.1"
_H2O_PORT_ = 54321
_H2O_EXTRA_CONNECT_ARGS_ = dict()
_ON_HADOOP_ = False
_HADOOP_NAMENODE_ = None
_IS_IPYNB_ = False
_IS_PYDEMO_ = Fals... | Python | CL | f17f3582c0c23689ebaea089d8aa0cf60b3779de085ff514976fec2eaab117a2 |
import gdal, ogr
import os
from flt import classify as classifier, flttotif, polygonize
from util import reprojectShp
'''
分级:
0 0.013435 1
0.013435 0.037422 2;0.037422 0.080247 3
0.080247 0.156709 4;0.156709 0.293223 5
0.293223 0.536956 6;0.536956 0.972118 7
0.972118 1.749056 8;1.749056 3.136204 9
3.136204 5.612822 10... | Python | CL | 3dd95b2693c0b48a90aad9de356a8a7f0208466ac729954e3384773c15bca000 |
# Copyright 2017 Neural Networks and Deep Learning lab, MIPT
#
# 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 applicab... | Python | CL | 0e1fac72a4b154d522702738f088459003cbbebc4a28e5caf32c8229b313c2b7 |
from __future__ import division
import pandas as pd
import numpy as np
from datetime import datetime
from multiprocessing import Pool
from functools import partial
from pathos import pools as pp
from multiprocessing import Pool
import pickle
from validators import check_empty
'''
This class implements content centric ... | Python | CL | 7e2ee8f079e11af42a9f5cdaf3a4ea57a86797ee0c889cedad380dcf7a62cc74 |
import numpy as np
import pandas as pd
import infra.constants
import infra.dask
import infra.pd
import infra.platform
def anonymize_rare_orgs(client, flows, checkpoint_path=None):
print("Anonymizing orgs")
user_counts_per_org = flows[["user", "org", "bytes_up"]].groupby(["user", "org"]).first().dropna().rese... | Python | CL | ebd113ab24a9a0331f54122fd3b2401e36baba0d297778e1adef3c183c78f8bf |
import os.path as osp
import numpy as np
import torch
from tabulate import tabulate
from panoptic.pan_eval import pq_compute_single_img, PQStat
class Metric(object):
def __init__(self, num_classes, trainId_2_catName=None):
"""
Args:
window_size: the number of batch of visuals stated he... | Python | CL | dd27289ae811e63b4cac881fe4bcddeeb027be2633ebd02f62d0faa941c88d18 |
#!/usr/bin/env python
# coding=utf-8
import time
import datetime
import numpy as np
import pyqtgraph as pg
from pyqtgraph.Qt import QtGui
from settings import config
from utils import calculateDensity
class TimeAxisItem(pg.AxisItem):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)... | Python | CL | af981c5f1c4ea7e07cd91e830dbc6a54ad697c07f3420ee0874c97cc82fadaa5 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''training
Usage:
$ module load python/gnu/3.6.5
$ module load spark/2.4.0
$ spark-submit evaluate.py hdfs:/user/hj1399/test.parquet hdfs:/user/hj1399/ds_best_pipeline
'''
import sys
from pyspark.sql import SparkSession
#spark.ml packages
from pyspark.ml impo... | Python | CL | 9e730c22a9376ac3a105910a1ea60c7ec00f86bf961ebc903b14015927fc1f1a |
import uuid
from http import HTTPStatus
import urllib
from web3.exceptions import TransactionNotFound
from box import Box
import requests
from libtrustbridge.websub.domain import Pattern
from libtrustbridge.websub.constants import (
MODE_ATTR_SUBSCRIBE_VALUE,
TOPIC_ATTR_KEY,
MODE_ATTR_KEY,
LEASE_SECONDS... | Python | CL | e5fcc911d90e7822aee03a09890b937347ce6927d45a1fef969cdf292b50b1a7 |
#!/usr/bin/python3
#
#***************************************************************************
# MIT License
#
# Copyright (c) 2017 Ng Chiang Lin
#
# 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 th... | Python | CL | 8fef49551df18c883a88691b041c6a6b21bfce3a2c10c790aa62fb4de5326387 |
# -*- coding: utf-8 -*-
"""
Tests for dnsimple updater. Since we rely on an external library implementing
the actual interfacing with the remote service, the tests in here merely check
the behavior of the Dyndnsc wrapper class.
"""
import unittest
try:
import unittest.mock as mock
except ImportError:
import m... | Python | CL | 1b3c933d79e6cdcbea9042e9fd8c6721a643624ddbc58c39b05f9fd8a4be5617 |
#Import the modules that you’ll be using in this project:
import codecademylib3_seaborn
from matplotlib import pyplot as plt
import pandas as pd
import seaborn as sns
#Inspect the raw CSV files that you will be using in this project by selecting them in the file navigator.
#Inspect the raw CSV files that you will be ... | Python | CL | 771c967b43266766f72831013a9281aa847b1e87077ae2a7dd7ad2a99d2cbb07 |
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 10 00:06:48 2014
Project : A simple implementation of ARQ (http://www.wikiwand.com/en/Automatic_repeat_reqxuest)
Version :0.0.1
@author :macrobull (http://github.com/macrobull)
"""
import asyncio
from binascii import crc32
WAIT_STEP = 0.001
def iterFile(f, chunk_size):... | Python | CL | 8b146bc3ed3119c27ab310f13fc9ac5f6298a0fc9777f1b4ff92f7c1ff397581 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Note: To use the 'upload' functionality of this file, you must:
# $ pip install twine
import io
import os
import re
from setuptools import find_packages, setup
# Package meta-data.
NAME = "bridgestream"
DESCRIPTION = "Packet Serializer "
URL = "https://gitlab.com/gn... | Python | CL | 9fff5835362c9be5d94502c27dc76e23942ae04aaaa0a58cc916764717b96492 |
============================= test session starts ==============================
platform darwin -- Python 3.7.4, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /tmp
collected 2 items
../../../../../tmp .F [100%]
=================================== FAILURES =========... | Python | CL | f98d22ffb39011c1fe0a461179bfc49e417c0b5b10b28fba22830a7621331b5f |
import os
import re
import numpy as np
import pandas as pd
from ms2pip.ms2pip_tools.spectrum_output import SpectrumOutput
TEST_DIR = os.path.dirname(__file__)
class TestSpectrumOutput:
def test_integration(self):
def compare_line(test_line, target_line):
"""Assert if two lin... | Python | CL | 7a0359a1a5005d3e78f953a1b0e2a767999e75bbac3c4a3bfb2ffc65588a9747 |
# !/usr/bin/env python
# encoding: utf-8
"""
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors.
See also https://github.com/seed-platform/seed/main/LICENSE.md
"""
from datetime import datetime
from pathlib import Path
from django.test import TestCase
from django.utils.timez... | Python | CL | 27e4dfda2376e80703ff72f795bdb6b6aea00d5a6f1045a77bbac6ca7f69d77d |
# !/usr/bin/python3
# -*- coding: utf-8 -*-
__version__ = "1.4.2"
from confapp import conf
conf += 'pybpodgui_plugin_session_history.settings'
conf += 'pybpodgui_plugin_session_history.resources'
import loggingbootstrap
# setup different loggers but output to single file
loggingbootstrap.create_double_logger("pyb... | Python | CL | ecf2403197a93d49ae5b7fff638830cff4bf4aa6347d61b6b8d3920838807ed5 |
# Rehaan, Brian
# The following code is a numpy (cupy for gpu) implementation of a ConvLSTM built
# for forecasting the next image in a sequence of antecedent NDVI and rain. The
# ConvLSTM also takes in a cloudmasks, and only trained on sufficiently high
# quality pixels. If it is a particularly cloudy day, the ConvLS... | Python | CL | 1269a475d3fd1b314ff0cdc8909d485ab74a0f3c7b941d537f489c57595f4405 |
#!/usr/bin/env python
import os
from RouToolPa.Tools.BLAST import Windowmasker
from RouToolPa.Tools.RepeatMasking import TRF, RepeatMasker
from RouToolPa.Tools.Bedtools import MaskFasta
from Pipelines.Filtering import FilteringPipeline
class RepeatAnnotation(FilteringPipeline):
def __init__(self):
Filter... | Python | CL | faf6bb18faa2699408a6ad04597b3305d0fe5b7ace6f9e073bb630be6664167d |
# ensemble bayesian network
import torch
from torch import nn
from robot.utils import AgentBase
import numpy as np
import torch.nn.functional as F
from robot.utils.normalizer import Normalizer
from robot.utils import as_input
def swish(x):
return x * torch.sigmoid(x)
from scipy.stats import truncnorm
truncnorm =... | Python | CL | 17c78db023ca10dac8a2ba9d2881289da32a8228a73e40c0d74a442da365555d |
import subprocess
import nbformat
import json, os
import random
import datetime
class KaggleBot():
## initialize the notebook parameters
def __init__(self, config):
self.nb = nbformat.v4.new_notebook()
self.nb['cells'] = []
self.config = config
self.content_meta = 'templates/'... | Python | CL | 10c1fe49aa4b2f8a5630eb00c74818eba96afb20dccf0221aad0b3aef9ce4c62 |
"""
Simulation of function calls
----------------------------
The purpose of this module is to simulate function calls
in the call-graph of a program, to gather information
about frequencies of transitions between functions.
The following SimNode/SimGraph classes show an example of the
simulation performed. They can... | Python | CL | 91a1cac1cbbe0a351e5c70594963647542b5fb8c8deb783f58ee5573fb359e47 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.