src stringlengths 721 1.04M |
|---|
from webtest import TestApp
import bottle
from bottle import route, template
import bugsnag
from bugsnag.wsgi.middleware import BugsnagMiddleware
from tests.utils import IntegrationTest
class TestBottle(IntegrationTest):
def setUp(self):
super(TestBottle, self).setUp()
bugsnag.configure(endpoint=... |
# -*- coding:utf-8 -*-
from numpy import save
#SURVEILLANT_FEE=0.0002 #buy and sell,证券监管费
#TRADE_HANDLE_FEE_A=0.000487 #buy and sell,沪深交易所,交易经手费
#TRADE_TRANSFER_FEE_A=0.0002 #buy and sell, 中国结算公司,交易过户费
#TRADE_FEE_B=0.000001 #buy and sell
#TRADE_FEE_FUND=0.0000975 #buy and sell
#TRADE_FEE_QUANZHENG=... |
# vim:tw=50
"""Generators for Refactoring
Now that we know how to make our own generators,
let's do some refactoring to make use of this idea
and clean up the code a bit. We'll start by
splitting out the |clean_lines| function, which
basically just skips blank lines and comments,
stripping unnecessary space.
This no... |
# -*- coding: utf-8 -*-
from distutils.core import setup
setup(
name='iktomi',
version='0.4.4',
packages=['iktomi',
'iktomi.utils',
'iktomi.forms',
'iktomi.web',
'iktomi.templates',
'iktomi.templates.jinja2',
'iktomi... |
from django.db import models
from django import forms
from django.contrib.auth.models import User
from django.utils import timezone
from easy_thumbnails.fields import ThumbnailerImageField
#A User's Personal Info
class Profile(models.Model):
user = models.OneToOneField(User)
photo = ThumbnailerImageField(upl... |
# -*- coding: utf-8 -*-
"""
Spiking neural net of LIF/SRM neurons with AI firing
written by Aditya Gilra (c) July 2015.
"""
from brian2 import * # also does 'from pylab import *'
from embedded_consts import *
import random
## Cannot make this network a Class,
## since brian standalone mode wants all Brian ob... |
'''
FUNC: read a xml file(database) and transfer it to a list of dictionary type
note: no case sensitive
I will make a rule about the database in xml form
ex.
____________________________
Student |name | ID | score | and ID is a key
|aa | 1 | 10 |
|bb | 2 | 20 |
in XML file, I will use som... |
from flask import Flask, request, abort
import os
import time
import random
import requests
app = Flask("microservice")
service_name = os.environ["SERVICE_NAME"]
log = open("/var/log/micro/" + service_name + ".log", "w+")
requestID_counter = 1
def busy_wait(seconds):
dt = time.strptime(str(seconds), "%S")
... |
# -*- coding: utf-8 -*-
u"""db configuration
:copyright: Copyright (c) 2019 RadiaSoft LLC. All Rights Reserved.
:license: http://www.apache.org/licenses/LICENSE-2.0.html
"""
from __future__ import absolute_import, division, print_function
from pykern import pkconfig
from pykern import pkinspect
from pykern import pki... |
'''
Created on 2015-01-23
@author: Andrew Roth
'''
from __future__ import division
import gzip
import numpy as np
import os
import pandas as pd
import yaml
from scg.doublet import VariationalBayesDoubletGenotyper
from scg.singlet import VariationalBayesSingletGenotyper
from scg.utils import load_labels
def run_doub... |
#!/usr/bin/python
"""**************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
**
** You may use ... |
from zope.interface import implements #@UnresolvedImport
from twisted.internet.protocol import ReconnectingClientFactory
from txredis.protocol import Redis, RedisSubscriber, defer
from twisted.internet import interfaces
import uuid
import itertools
from txthoonk.types import Feed
try:
from collection import Ord... |
"""
Code to help with managing a TVTK data set in Pythonic ways.
"""
# Author: Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
# Copyright (c) 2008, Enthought, Inc.
# License: BSD Style.
from enthought.traits.api import (HasTraits, Instance, Array, Str,
Property, Dict)
from enthought.tvtk.api im... |
'''
This is mostly a convenience module for testing with ctypes.
'''
from llvm.core import Type, Module
import llvm.ee as le
import ctypes as ct
MAP_CTYPES = {
'void' : None,
'bool' : ct.c_bool,
'char' : ct.c_char,
'uchar' : ct.c_ubyte,
'short' : ct.c_short,
'ushort' : ct.c... |
import lightgbm as lgb
import pandas as pd
import numpy as np
import sys
from datetime import datetime
from pathlib import Path
from sklearn.model_selection import StratifiedKFold
from sklearn.model_selection import RepeatedStratifiedKFold
path=Path("data/")
train=pd.read_csv(path/"train.csv").drop("ID_code",axis=1)
... |
# Copyright (c) 2013 Rackspace, Inc.
# Copyright (c) 2015 Catalyst IT Ltd.
#
# 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 require... |
"""Module with util functions to use with Monsoon."""
import usb.core
from math import isclose
from Monsoon import Operations
import click
def _device_matcher(device):
"""Check if device is monsoon.
Method copied from official Monsoon API.
"""
# pylint: disable=bare-except
try:
return dev... |
# Copyright (c) 2018 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... |
#!/usr/bin/env python
# Copyright (c) 2013, 2014 Intel Corporation. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
Parse JSON-format manifest configuration file and
provide the specific fields, which have to be integrated with
packaging t... |
#!/usr/bin/env python
# --------------------------------------------------------
# Test regression propagation on ImageNet VID video
# Modified by Kai KANG (myfavouritekk@gmail.com)
# --------------------------------------------------------
"""Test a Fast R-CNN network on an image database."""
import argparse
import... |
from io import StringIO
import numpy as np
import pytest
from pandas import DataFrame, date_range, read_csv
from pandas.util import _test_decorators as td
from pandas.util.testing import assert_frame_equal
from pandas.io.common import is_gcs_url
def test_is_gcs_url():
assert is_gcs_url("gcs://pandas/somethinge... |
"""
Django settings for dj project.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import ... |
"""CLI tests for logging.
:Requirement: Logging
:CaseAutomation: Automated
:CaseLevel: Acceptance
:CaseComponent: Logging
:Assignee: shwsingh
:TestType: Functional
:CaseImportance: Medium
:Upstream: No
"""
import re
import pytest
from fauxfactory import gen_string
from nailgun import entities
from robottelo i... |
import math
import os
import sys
from functools import lru_cache
from typing import Optional, Union # noqa
import urwid
from mitmproxy import contentviews
from mitmproxy import exceptions
from mitmproxy import export
from mitmproxy import http
from mitmproxy.net.http import Headers
from mitmproxy.net.http import sta... |
"""Implementation of JSONDecoder
"""
from __future__ import absolute_import
import re
import sys
import struct
from .compat import fromhex, b, u, text_type, binary_type, PY3, unichr
from .scanner import make_scanner, JSONDecodeError
def _import_c_scanstring():
try:
from ._speedups import scanstr... |
#!/usr/bin/python
# Importing Twython
from twython import Twython
# Importing Wolfram
import urllib
import wolframalpha
import urllib2
from xml.etree import ElementTree as etree
import sys
import time
#Setting variables for Twitter
app_key = "*****YOUR APP KEY******"
app_secret = "****YOUR APP SECRET*****"
oauth_tok... |
from rest_framework import serializers
from server import settings
from .models import Article
from team.serializers import MemberShortSerializer
from gallery.serializers import AlbumSerializer
class ArticleSerializer(serializers.ModelSerializer):
card_sm_image = serializers.SerializerMethodField()
card_mat... |
# -*- coding: utf-8 -*-
#
# Dataverse Documentation build configuration file, created by
# sphinx-quickstart on Wed Apr 16 09:34:18 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
#... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# A Solution to "Counting fractions" – Project Euler Problem No. 72
# by Florian Buetow
#
# Sourcecode: https://github.com/fbcom/project-euler
# Problem statement: https://projecteuler.net/problem=72
def get_distinct_prime_factors(n):
ret = []
if n > 1:
... |
import math
from ortools.constraint_solver import pywrapcp
from ortools.constraint_solver import routing_enums_pb2
import dataIMC
# def distance(x1, y1, x2, y2):
# # Manhattan distance
# dist = abs(x1 - x2) + abs(y1 - y2)
#
# return dist
# Distance callback
class CreateDistanceCallback(object):
"""Cr... |
# 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.
#---------------------------------------------------------------------... |
from PyQt5.QtWidgets import QWidget, QComboBox, QStackedWidget
from PyQt5.QtCore import pyqtSignal
from peacock.base.MooseWidget import MooseWidget
from peacock.utils import WidgetUtils
from ParamsByGroup import ParamsByGroup
class ParamsByType(QWidget, MooseWidget):
"""
Has a QComboBox for the different allow... |
##################################################################################################
# Copyright (c) 2012 Brett Dixon
#
# 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 without ... |
from geopy.exc import GeopyError
import re
from geopy.geocoders import Nominatim
from geopy import units
_geo_locator = Nominatim(user_agent="photomanager")
def gps_info_to_degress(value):
pattern = '(.*?)\|\[(\d+).*?(\d+).*?(\d+)\/(\d+)'
match = re.match(pattern, value)
if match:
letter, radians,... |
# -*- coding: utf-8 -*-
from openerp import models,fields,api,SUPERUSER_ID
from openerp.tools.translate import _
from openerp.exceptions import Warning
import datetime
import xmlrpclib
#TODO :
#- DEB importation
#- Ajouter un bouton pour accèder aux lignes de la synthese quand la fiche est terminé
class is_deb(mod... |
"""A setuptools based setup module.
See:
https://packaging.python.org/en/latest/distributing.html
https://github.com/pypa/sampleproject
"""
from setuptools import setup, find_packages
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'READ... |
#!/usr/bin/python
"""
assembles raw cuts into final, titles, tweaks audio, encodes to format for upload.
"""
import re
import os
import sys
import subprocess
import xml.etree.ElementTree
from mk_mlt import mk_mlt
import pprint
from process import process
from main.models import Client, Show, Location, Episode, Raw_... |
# -*- coding: utf-8 -*-
"""A plugin to generate a list of domains visited."""
import sys
if sys.version_info[0] < 3:
import urlparse
else:
from urllib import parse as urlparse # pylint: disable=no-name-in-module
from plaso.analysis import interface
from plaso.analysis import manager
from plaso.containers import... |
# coding=utf-8
"""
This factory creates BattleshipProtocol() instances for every
connected users. If number of connected users reach the value max_clients then this factory creates instance
of ErrorBattleshipProtocol() for new users.
Also this class, on own initialization, creates instance of the... |
#!/usr/bin/env python
"""SciPy: Scientific Library for Python
SciPy (pronounced "Sigh Pie") is open-source software for mathematics,
science, and engineering. The SciPy library
depends on NumPy, which provides convenient and fast N-dimensional
array manipulation. The SciPy library is built to work with NumPy
arrays, a... |
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from collections import OrderedDict
class CustomPagination(PageNumberPagination):
def get_paginated_posts(self, data, request):
result = OrderedDict([
('count', self.page.paginator.count),
... |
import sys
import serial
import struct
import numpy
import time
import math
import random
class DMXDevice(object):
DEBUG = False
def __init__(self, start, length):
self.start, self.length = start, length
if start < 1:
print "DMX Channels must start at least at 1!"
self.start = 1
self.blacko... |
# Rekall Memory Forensics
# Copyright 2014 Google Inc. All Rights Reserved.
#
# 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 (at
# your option) any later ver... |
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'Variation'
db.create_table(u'products_variation', (
... |
"""PyXB stands for Python U{W3C XML
Schema<http://www.w3.org/XML/Schema>} Bindings, and is pronounced
"pixbee". It enables translation between XML instance documents and
Python objects following rules specified by an XML Schema document.
This is the top-level entrypoint to the PyXB system. Importing this
gets you al... |
# Copyright (C) 2013 Red Hat, 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 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in ... |
# -*- coding: utf-8 -*-
from openerp import _, api, fields, models
import random
from urlparse import urljoin
class EventEvent(models.Model):
_inherit = 'event.event'
token = fields.Char(string="Token", readonly=True)
event_attendance_url = fields.Char(string="Event attendance url", r... |
import sys, os
sys.path = [os.path.join(os.getcwd(), "..", "..") ] + sys.path
from flapp.app import App
from flapp.glRenderer2D import glRenderer2D
from flapp.texture import Texture, EasyTexture
from flapp.pmath.rect import Rect
from flapp.pmath.vec2 import Vec2
from OpenGL.GL import *
from OpenGL.GLU import *
def r... |
import re
import codecs
import os
"""
[1] Main Function
"""
def main():
directory = os.getcwd() + '/InputDataType1'
filename = 'BTHO0437.txt'
filename = os.path.join(directory, filename)
f = open(filename, 'r', encoding='utf-16')
is_inside = False
line_counter = 0
OUT_FILENAME = "OutputDat... |
import time
from typing import (List, Dict, Optional)
import ray
from ray._raylet import PlacementGroupID, ObjectRef
bundle_reservation_check = None
# We need to import this method to use for ready API.
# But ray.remote is only available in runtime, and
# if we define this method inside ready method, this function... |
#!/usr/bin/python
GPIO_CAPABLE = False
import time
from functools import partial
import signal
import sys
import pyo
try:
import RPi.GPIO as GPIO
GPIO_CAPABLE = True
except ImportError:
pass
if GPIO_CAPABLE:
import gpiocontrol
import bridge
import configparser
import jackserver
import flanger
impor... |
# Copyright (c) 2008-2016 Szczepan Faber, Serhiy Oplakanets, Herr Kaste
#
# 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 without restriction, including without limitation the rights
# to use... |
# 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 ... |
"""Implements spectral biclustering algorithms.
Authors : Kemal Eren
License: BSD 3 clause
"""
from abc import ABCMeta, abstractmethod
import numpy as np
from scipy.sparse import dia_matrix
from scipy.sparse import issparse
from sklearn.base import BaseEstimator, BiclusterMixin
from sklearn.externals import six
fr... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# vim: set ft=python:
#
# python password generator for customers
#
# Depend: pwqgen
#
# Usage:
# ./customers_passwords.py customers_top pillarpath/to/customers.sls pillarpath/user_passwords.yaml
#
# Output: Int, the number of created passwords in pillarpath/user_passwords.sls... |
# Majic
# Copyright (C) 2014 CEH
#
# 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
# (at your option) any later version.
#
# This progra... |
import subprocess
import status
import shlex
from commands_extra import *
def mAdd(images_table, template_header, out_image, img_dir=None,
no_area=False, type=None, exact=False, debug_level=None,
status_file=None, mpi=False, n_proc=8):
'''
Coadd the reprojected images in an input list to fo... |
# -*- coding: utf-8 -*-
# Copyright 2020 Google LLC
#
# 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... |
#!/usr/bin/python3
# This script performs a backup of all user data:
# 1) System services are stopped.
# 2) An incremental encrypted backup is made using duplicity.
# 3) The stopped services are restarted.
# 4) STORAGE_ROOT/backup/after-backup is executd if it exists.
import os, os.path, shutil, glob, re, datetime, s... |
#!/usr/bin/python3
"""
NMEA Utils
"""
def tpv_to_json(report):
if report is None:
return {"class": "TPV", "mode": 0}
tpv = {
'class': report['class'],
'mode': report['mode'],
}
for field in ['device', 'status', 'time', 'altHAE', 'altMSL', 'alt',
'climb', 'datum', 'de... |
import contextlib
import threading
import time
from .test_utils import (
TempDirectoryTestCase,
skip_unless_module,
restartable_pulsar_app_provider,
)
from pulsar.manager_endpoint_util import (
submit_job,
)
from pulsar.managers.stateful import ActiveJobs
from pulsar.client.amqp_exchange_factory import... |
import os
from .queueHelper import *
from .workerJob import WorkerJob
class JobManager:
"""
Helper class to enqueue and dequeue jobs to the job queue.
"""
def __init__(self, connectionStringKey):
"""
Instantiates the job manager.
'connectionStringKey' : name of environment va... |
# ===============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of eos.
#
# eos is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, ... |
import unittest
from unittest.mock import patch, Mock
import discord
import datetime
from commands import RemoveBanCommand
from serverobjects.server import DiscordServer
class TestRemoveBanCommand(unittest.TestCase):
def setUp(self):
self.command = RemoveBanCommand()
def test_is_command_authorized__no_permission... |
#!/usr/bin/python
"""
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you... |
import cStringIO
import hashlib
import json
import mimetypes
import os
import random
import sys
import urllib
from datetime import datetime
from django.core.files.uploadedfile import InMemoryUploadedFile
from django.db.models import get_model, DateField, DateTimeField, FileField, \
ImageField
from django.db.mo... |
from categorize_clusters import categorize_clusters
import tensorflow as tf
from random import choice, shuffle
import numpy as np
import pickle
def main():
num_clusters = 3
with open('normal_hashes.obj', 'rb') as fHandler:
normal_hashes = pickle.load(fHandler)
with open('malware_hashes.obj', '... |
from . import FixtureTest
class EarlyStep(FixtureTest):
def test_steps_with_regional_route(self):
self.load_fixtures([
'https://www.openstreetmap.org/way/24655593',
'https://www.openstreetmap.org/relation/2260059',
], clip=self.tile_bbox(12, 653, 1582))
self.assert... |
# -*- coding: utf8 -*-
list = [
{
'name' : u'Spanish',
'langcode': u'spa',
'description' : u'',
'url' : u'http://www.ethnologue.com/show_language.asp?code=spa'
},
{
'name' : u'English',
'langcode': u'eng',
'description' : u'',
... |
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed unde... |
from spatial_transformer import *
from mixtureDensityNetwork import *
from distanceExamples import *
from architectures import architectures
from batch import BatchIterator
from language import *
from render import render,animateMatrices
from utilities import *
from distanceMetrics import blurredDistance,asymmetricBlur... |
#!/usr/bin/env python
# coding: utf-8
import re
import django
from django.conf import settings
from django.core import urlresolvers
from .models import MaintenanceMode
if django.VERSION[:2] <= (1, 3):
from django.conf.urls import defaults as urls
else:
from django.conf import urls
from maintenancemode.con... |
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... |
# Copyright 2016-2018 Tal Liron
#
# 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... |
from acr122l import acr122l
import time
acr122l = acr122l()
true = True
def read_card():
global true
true = False
key = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
print acr122l.TAG_Authenticate(0x00, key)
print 'Starting read data'
readed = acr122l.TAG_Read(0x01)
if readed:
acr122l.LCD_Clear()
acr122l.LED_control... |
# # # EXAMPLE RUN SINGLE MODEL
def run_model( fn, command ):
import os, subprocess
head = '#!/bin/sh\n' + \
'#SBATCH --ntasks=32\n' + \
'#SBATCH --nodes=1\n' + \
'#SBATCH --ntasks-per-node=32\n' + \
'#SBATCH --account=snap\n' + \
'#SBATCH --mail-type=FAIL\n' + \
'#SBATCH --mail-user=malindgren@alask... |
# Django settings for example project.
# Setup a ``project_dir`` function
import os
from dj_settings_helpers import create_project_dir
project_dir = create_project_dir(os.path.join(os.path.dirname(__file__),
'..', '..'))
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@example.c... |
#!/usr/bin/env python2.5
#
# Copyright 2011 the Melange 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 applic... |
import os
import re
import logging
from subprocess import check_call, check_output, CalledProcessError, PIPE
from abc import ABCMeta, abstractmethod, abstractproperty
import platform
from .exceptions import SystemPackageManagerHandlerException
logger = logging.getLogger(__name__)
def register(name, determiner):
... |
#! /usr/bin/env python3
"""
The MIT License
Copyright (c) 2017 by Anthony Westbrook, University of New Hampshire <anthony.westbrook@unh.edu>
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... |
"""Default formatting class for Flake8."""
from flake8.formatting import base
class SimpleFormatter(base.BaseFormatter):
"""Simple abstraction for Default and Pylint formatter commonality.
Sub-classes of this need to define an ``error_format`` attribute in order
to succeed. The ``format`` method relies o... |
"""
Given an array of n integers where n > 1, nums, return an array output such
that output[i] is equal to the product of all the elements of nums except
nums[i].
Solve it without division and in O(n).
For example, given [1,2,3,4], return [24,12,8,6].
Follow up:
Could you solve it with constant space complexity? (N... |
'''
Copyright 2017, Fujitsu Network Communications, 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 w... |
import time
import requests
##############################################################
############## REQUESTS MANAGEMENT/ LINKS ####################
##############################################################
headers = {'User-Agent' : 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52... |
##########################################################################
#
# Copyright (c) 2011, John Haddon. All rights reserved.
# Copyright (c) 2011-2013, Image Engine Design Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided ... |
from __future__ import print_function
from dolfin import *
from dolfin_adjoint import *
import sys
dolfin.set_log_level(ERROR)
n = 10
mesh = UnitIntervalMesh(n)
V = FunctionSpace(mesh, "CG", 2)
ic = project(Expression("sin(2*pi*x[0])", degree=1), V)
u = ic.copy(deepcopy=True)
def main(nu):
u_next = Function(V)... |
# =============================================================================
# Federal University of Rio Grande do Sul (UFRGS)
# Connectionist Artificial Intelligence Laboratory (LIAC)
# Renato de Pontes Pereira - rppereira@inf.ufrgs.br
# =============================================================================
... |
#
# Copyright (c), 2016-2020, SISSA (International School for Advanced Studies).
# All rights reserved.
# This file is distributed under the terms of the MIT License.
# See the file 'LICENSE' in the root directory of the present
# distribution, or http://opensource.org/licenses/MIT.
#
# @author Davide Brunato <brunato@... |
#fontmetrics.py - part of PDFgen - copyright Andy Robinson 1999
"""This contains pre-canned text metrics for the PDFgen package, and may also
be used for any other PIDDLE back ends or packages which use the standard
Type 1 postscript fonts.
Its main function is to let you work out the width of strings; it exposes a
s... |
# Generated by Django 3.0.5 on 2020-06-12 14:38
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Writer',
fields=[
... |
# -*- coding: utf-8 -*-
"""
This is my module brief line.
This is a more complete paragraph documenting my module.
- A list item.
- Another list item.
This section can use any reST syntax.
"""
A_CONSTANT = 1000
"""This is an important constant."""
YET_ANOTHER = {
'this': 'that',
'jam': 'eggs',
'yet': {... |
'''
Handle connections from a client greeter. Provide information such as
sub-servers and news.
'''
import asyncore
import socket
import struct
class Handler(asyncore.dispatcher_with_send):
def handle_read(self):
data = self.recv(1)
if data == b'\x00':
# TODO: load alternate server nam... |
from distutils.core import setup
setup(
name='BioClasses',
version='0.1.6',
packages=["BioClasses"],
data_files=[("genetic_codes", \
["data/genetic_codes/euplotid_genetic_code.txt", \
"data/genetic_codes/human_genetic_code.txt", \
"data/genetic_codes/tetrahymena_genetic_code.txt"]), \
("CAI_tables", \
["data/CAI_t... |
# Copyright 2014-2015 Spectra Logic Corporation. 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 "lic... |
from baluster import Baluster, placeholders
class CompositeRoot(Baluster):
@placeholders.factory
def value(self, root):
return 2
class subns(Baluster):
_closed = False
@placeholders.factory
def value(self, root):
return 1
@value.close
def cl... |
import numpy as np
from matchzoo.data_generator.callbacks import Callback
class DynamicPooling(Callback):
""":class:`DPoolPairDataGenerator` constructor.
:param fixed_length_left: max length of left text.
:param fixed_length_right: max length of right text.
:param compress_ratio_left: the length cha... |
# ==============================================================================
# Copyright (C) 2011 Diego Duclos
# Copyright (C) 2011-2018 Anton Vorobyov
#
# This file is part of Eos.
#
# Eos is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as publi... |
# 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 ... |
from icc.studprogs.common import *
class Loader(BaseLoader):
"""Loads text and divides it on [paragraph] lokens.
"""
def lines(self):
"""
•
-
"""
linequeue=[]
for line in self.file:
if self._skip>0:
self._skip-... |
# Copyright (C) 2013 by Kevin L. Mitchell <klmitch@mit.edu>
#
# 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
# License, or (at your option) any later version.
#
# This p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.