content
stringlengths
1
1.05M
input_ids
listlengths
1
883k
ratio_char_token
float64
1
22.9
token_count
int64
1
883k
# -*- coding: utf-8 -*- ''' Created on 02.11.2017 @author: fstallmann ''' from __future__ import absolute_import from collections import deque import bkt from bkt import dotnet Drawing = dotnet.import_drawing() from . import helpers as pplib def button_get_label(self, index): try: return self.symbols[index][2] except: return "Zuletzt verwendet: Undefined" def button_get_visible(self, index): try: return self.symbols[index] is not None except: return False class LocpinGallery(bkt.ribbon.Gallery): class PositionGallery(bkt.ribbon.Gallery): # items: [label, position, reference] # position: [left, top, width, height] # values can be absolute or percentage # reference: CONTENTE / SLIDE / ABS # values are converted according to reference items = [ [u"Volle Flche", [ 0, 0, 1, 1], 'CONTENT'], [u"2/3 Links", [ 0, 0, 2./3, 1], 'CONTENT'], [u"2/3 Rechts", [1./3, 0, 2./3, 1], 'CONTENT'], [u"1/2 Links", [ 0, 0, .5, 1], 'CONTENT'], [u"1/2 Mitte", [.25, 0, .5, 1], 'CONTENT'], [u"1/2 Rechts", [ .5, 0, .5, 1], 'CONTENT'], [u"1/3 Links", [ 0, 0, 1./3, 1], 'CONTENT'], [u"1/3 Mitte", [1./3, 0, 1./3, 1], 'CONTENT'], [u"1/3 Rechts", [2./3, 0, 1./3, 1], 'CONTENT'], [u"1/6 Oben", [ 0, 0, 1, 1./6], 'CONTENT'], [u"1/6 Unten", [ 0, 5./6, 1, 1./6], 'CONTENT'] ] def on_action_indexed(self, selected_item, index, context, **kwargs): ''' reposition shapes according of settings in clicked element ''' item = self.items[index] position = item[1] reference = item[2] #self.change_position(selection, shapes, item[1]) # reference size if reference == 'CONTENT': ref_left,ref_top,ref_width,ref_height = pplib.slide_content_size(context.slide) else: # SLIDE / ABS page_setup = context.presentation.PageSetup ref_left,ref_top = 0, 0 ref_width,ref_height = page_setup.SlideWidth, page_setup.SlideHeight # target size left,top,width,height = self.rect_from_definition(position, ref_frame=[ref_left,ref_top,ref_width, ref_height]) frame = pplib.BoundingFrame.from_rect(left, top, width, height) if 'on_position_change' in self._callbacks: if context: return context.invoke_callback(self._callbacks['on_position_change'], target_frame=frame, **kwargs) # def get_enabled(self, shapes): # return True # def get_item_label(self, index): # item = self.items[index] # return "%s" % getattr(NumberedShapes, 'label_' + item['label'])[index%self.columns] def get_item_image(self, index, presentation): ''' creates an item image with target area according to settings in the specified item ''' # retrieve item-settings item = self.items[index] return self.create_image(item[1], item[2], presentation) ## userdefined area
[ 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 7061, 6, 198, 41972, 319, 7816, 13, 1157, 13, 5539, 198, 198, 31, 9800, 25, 277, 32989, 9038, 198, 7061, 6, 198, 198, 6738, 11593, 37443, 834, 1330, 4112, 62, 11748, ...
2.071746
1,575
from __future__ import annotations import warnings from typing import Any, Dict, List, Optional, Set, Tuple, Union, TYPE_CHECKING from .cache import property_immutable_cache, property_mutable_cache from .constants import ( transforming, IS_STRUCTURE, IS_LIGHT, IS_ARMORED, IS_BIOLOGICAL, IS_MECHANICAL, IS_MASSIVE, IS_PSIONIC, UNIT_BATTLECRUISER, UNIT_ORACLE, TARGET_GROUND, TARGET_AIR, TARGET_BOTH, IS_SNAPSHOT, IS_VISIBLE, IS_MINE, IS_ENEMY, IS_CLOAKED, IS_REVEALED, CAN_BE_ATTACKED, IS_CARRYING_MINERALS, IS_CARRYING_VESPENE, IS_CARRYING_RESOURCES, IS_ATTACKING, IS_PATROLLING, IS_GATHERING, IS_RETURNING, IS_COLLECTING, IS_CONSTRUCTING_SCV, IS_REPAIRING, IS_DETECTOR, UNIT_PHOTONCANNON, UNIT_COLOSSUS, ) from .data import Alliance, Attribute, CloakState, DisplayType, Race, TargetType, warpgate_abilities, TargetType, Target from .ids.ability_id import AbilityId from .ids.buff_id import BuffId from .ids.upgrade_id import UpgradeId from .ids.unit_typeid import UnitTypeId from .position import Point2, Point3 from .unit_command import UnitCommand warnings.simplefilter("once") if TYPE_CHECKING: from .bot_ai import BotAI from .game_data import AbilityData def target_in_range(self, target: Unit, bonus_distance: Union[int, float] = 0) -> bool: """ Checks if the target is in range. Includes the target's radius when calculating distance to target. :param target: :param bonus_distance: """ # TODO: Fix this because immovable units (sieged tank, planetary fortress etc.) have a little lower range than this formula if self.can_attack_ground and not target.is_flying: unit_attack_range = self.ground_range elif self.can_attack_air and (target.is_flying or target.type_id == UNIT_COLOSSUS): unit_attack_range = self.air_range else: return False return ( self._bot_object._distance_squared_unit_to_unit(self, target) <= (self.radius + target.radius + unit_attack_range + bonus_distance) ** 2 ) def in_ability_cast_range( self, ability_id: AbilityId, target: Union[Unit, Point2], bonus_distance: float = 0 ) -> bool: """ Test if a unit is able to cast an ability on the target without checking ability cooldown (like stalker blink) or if ability is made available through research (like HT storm). :param ability_id: :param target: :param bonus_distance: """ cast_range = self._bot_object._game_data.abilities[ability_id.value]._proto.cast_range assert cast_range > 0, f"Checking for an ability ({ability_id}) that has no cast range" ability_target_type = self._bot_object._game_data.abilities[ability_id.value]._proto.target # For casting abilities that target other units, like transfuse, feedback, snipe, yamato if ability_target_type in {Target.Unit.value, Target.PointOrUnit.value} and isinstance(target, Unit): return ( self._bot_object._distance_squared_unit_to_unit(self, target) <= (cast_range + self.radius + target.radius + bonus_distance) ** 2 ) # For casting abilities on the ground, like queen creep tumor, ravager bile, HT storm if ability_target_type in {Target.Point.value, Target.PointOrUnit.value} and isinstance( target, (Point2, tuple) ): return ( self._bot_object._distance_pos_to_pos(self.position_tuple, target) <= cast_range + self.radius + bonus_distance ) return False # TODO: a function that checks if this unit is facing another unit def is_facing_unit(self, other_unit: Unit, angle_error: float = 1e-3) -> bool: """ Function not completed yet :param other_unit: :param angle_error: """ pass # PROPERTIES BELOW THIS COMMENT ARE NOT POPULATED FOR SNAPSHOTS # PROPERTIES BELOW THIS COMMENT ARE NOT POPULATED FOR ENEMIES def is_using_ability(self, abilities: Union[AbilityId, Set[AbilityId]]) -> bool: """ Check if the unit is using one of the given abilities. Only works for own units. """ if not self.orders: return False if isinstance(abilities, AbilityId): abilities = {abilities} return self.orders[0].ability.id in abilities # Unit functions def has_buff(self, buff: BuffId) -> bool: """ Checks if unit has buff 'buff'. """ assert isinstance(buff, BuffId), f"{buff} is no BuffId" return buff in self.buffs def train(self, unit: UnitTypeId, queue: bool = False) -> UnitCommand: """ Orders unit to train another 'unit'. Usage: self.actions.append(COMMANDCENTER.train(SCV)) :param unit: :param queue: """ return self(self._bot_object._game_data.units[unit.value].creation_ability.id, queue=queue) def build(self, unit: UnitTypeId, position: Union[Point2, Point3] = None, queue: bool = False) -> UnitCommand: """ Orders unit to build another 'unit' at 'position'. Usage: self.actions.append(SCV.build(COMMANDCENTER, position)) :param unit: :param position: :param queue: """ return self(self._bot_object._game_data.units[unit.value].creation_ability.id, target=position, queue=queue) def research(self, upgrade: UpgradeId, queue: bool = False) -> UnitCommand: """ Orders unit to research 'upgrade'. Requires UpgradeId to be passed instead of AbilityId. :param upgrade: :param queue: """ return self(self._bot_object._game_data.upgrades[upgrade.value].research_ability.id, queue=queue) def warp_in(self, unit: UnitTypeId, position: Union[Point2, Point3]) -> UnitCommand: """ Orders Warpgate to warp in 'unit' at 'position'. :param unit: :param queue: """ normal_creation_ability = self._bot_object._game_data.units[unit.value].creation_ability.id return self(warpgate_abilities[normal_creation_ability], target=position) def attack(self, target: Union[Unit, Point2, Point3], queue: bool = False) -> UnitCommand: """ Orders unit to attack. Target can be a Unit or Point2. Attacking a position will make the unit move there and attack everything on its way. :param target: :param queue: """ return self(AbilityId.ATTACK, target=target, queue=queue) def gather(self, target: Unit, queue: bool = False) -> UnitCommand: """ Orders a unit to gather minerals or gas. 'Target' must be a mineral patch or a gas extraction building. :param target: :param queue: """ return self(AbilityId.HARVEST_GATHER, target=target, queue=queue) def return_resource(self, target: Unit = None, queue: bool = False) -> UnitCommand: """ Orders the unit to return resource. Does not need a 'target'. :param target: :param queue: """ return self(AbilityId.HARVEST_RETURN, target=target, queue=queue) def move(self, position: Union[Point2, Point3], queue: bool = False) -> UnitCommand: """ Orders the unit to move to 'position'. Target can be a Unit (to follow that unit) or Point2. :param position: :param queue: """ return self(AbilityId.MOVE_MOVE, target=position, queue=queue) def scan_move(self, *args, **kwargs) -> UnitCommand: """ Deprecated: This ability redirects to 'AbilityId.ATTACK' """ return self(AbilityId.SCAN_MOVE, *args, **kwargs) def hold_position(self, queue: bool = False) -> UnitCommand: """ Orders a unit to stop moving. It will not move until it gets new orders. :param queue: """ return self(AbilityId.HOLDPOSITION, queue=queue) def stop(self, queue: bool = False) -> UnitCommand: """ Orders a unit to stop, but can start to move on its own if it is attacked, enemy unit is in range or other friendly units need the space. :param queue: """ return self(AbilityId.STOP, queue=queue) def patrol(self, position: Union[Point2, Point3], queue: bool = False) -> UnitCommand: """ Orders a unit to patrol between position it has when the command starts and the target position. Can be queued up to seven patrol points. If the last point is the same as the starting point, the unit will patrol in a circle. :param position: :param queue: """ return self(AbilityId.PATROL, target=position, queue=queue) def repair(self, repair_target: Unit, queue: bool = False) -> UnitCommand: """ Order an SCV or MULE to repair. :param repair_target: :param queue: """ return self(AbilityId.EFFECT_REPAIR, target=repair_target, queue=queue) def __hash__(self): return self.tag def __eq__(self, other): try: return self.tag == other.tag except: return False def __call__(self, ability, target=None, queue: bool = False): return UnitCommand(ability, self, target=target, queue=queue)
[ 6738, 11593, 37443, 834, 1330, 37647, 198, 11748, 14601, 198, 6738, 19720, 1330, 4377, 11, 360, 713, 11, 7343, 11, 32233, 11, 5345, 11, 309, 29291, 11, 4479, 11, 41876, 62, 50084, 2751, 198, 198, 6738, 764, 23870, 1330, 3119, 62, 8608...
2.53898
3,707
from .load import load_data, NUTRI_COLS, load_clean_rel_to_nutri
[ 6738, 764, 2220, 1330, 3440, 62, 7890, 11, 399, 3843, 7112, 62, 25154, 50, 11, 3440, 62, 27773, 62, 2411, 62, 1462, 62, 14930, 380, 198 ]
2.5
26
# from .noise_gen import CGMNoiseGenerator from .noise_gen import CGMNoise import pandas as pd import logging logger = logging.getLogger(__name__) if __name__ == '__main__': pass
[ 2, 422, 764, 3919, 786, 62, 5235, 1330, 327, 15548, 2949, 786, 8645, 1352, 198, 6738, 764, 3919, 786, 62, 5235, 1330, 327, 15548, 2949, 786, 198, 11748, 19798, 292, 355, 279, 67, 198, 11748, 18931, 198, 198, 6404, 1362, 796, 18931, ...
2.671429
70
# Copyright 2013-2020 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 *
[ 2, 15069, 2211, 12, 42334, 13914, 45036, 3549, 2351, 4765, 11, 11419, 290, 584, 198, 2, 1338, 441, 4935, 34152, 13, 4091, 262, 1353, 12, 5715, 27975, 38162, 9947, 2393, 329, 3307, 13, 198, 2, 198, 2, 30628, 55, 12, 34156, 12, 33234,...
3.47619
63
#!/usr/bin/env python # # Copyright 2012-2016 VMware, 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 agreed to in writing, software # distributed under the License is distributed on an AS IS BASIS, without # warranties or conditions of any kind, EITHER EXPRESS OR IMPLIED. See the # License for the specific language governing permissions and limitations # under the License. # # Helper function that gets certificates from VMWare Certificate Authority # More details. If this module can be used as a main program, include usage information. """ certool.py : This is the standard library function for cloudVM/vcenterwindows first boot to integrate with VMCA Certificate Generation. if not running under a cloudVM, then it is assumed that the OS.Environment has the following defined. VMWARE_SKIP_VISL = True system.urlhostname vmdir.ldu-guid system.hostname.type vmca.cert.password vmca.cert.dir """ __copyright__ = "Copyright 2012, VMware Inc." __version__ = 0.1 __author__ = "VMware, Inc." import logging import os import subprocess def main(): """ Example Code Usage """ testComponent = 'sso' VmcaCertool = CerTool() VmcaCertool.GenCert(testComponent) print 'Generated a pfx file : %s' % VmcaCertool.GetPfxFileName() print 'Using Password : %s' % VmcaCertool.GetPassword() if __name__ == "__main__": main()
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 2, 198, 2, 15069, 220, 2321, 12, 5304, 37754, 11, 3457, 13, 220, 1439, 6923, 33876, 13, 198, 2, 198, 2, 49962, 739, 262, 24843, 13789, 11, 10628, 362, 13, 15, 357, 1169, 13789, 177...
3.237154
506
# coding=utf-8 # *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** # *** Do not edit by hand unless you're certain you know what you are doing! *** import warnings import pulumi import pulumi.runtime from typing import Any, Mapping, Optional, Sequence, Union, overload from .. import _utilities from . import outputs from ._inputs import * __all__ = ['NotificationConfigArgs', 'NotificationConfig'] class NotificationConfig(pulumi.CustomResource): def __init__(__self__, resource_name: str, *args, **kwargs): resource_args, opts = _utilities.get_resource_args_opts(NotificationConfigArgs, pulumi.ResourceOptions, *args, **kwargs) if resource_args is not None: __self__._internal_init(resource_name, opts, **resource_args.__dict__) else: __self__._internal_init(resource_name, *args, **kwargs) def _internal_init(__self__, resource_name: str, opts: Optional[pulumi.ResourceOptions] = None, config_id: Optional[pulumi.Input[str]] = None, description: Optional[pulumi.Input[str]] = None, organization: Optional[pulumi.Input[str]] = None, pubsub_topic: Optional[pulumi.Input[str]] = None, streaming_config: Optional[pulumi.Input[pulumi.InputType['NotificationConfigStreamingConfigArgs']]] = None, __props__=None): if opts is None: opts = pulumi.ResourceOptions() if not isinstance(opts, pulumi.ResourceOptions): raise TypeError('Expected resource options to be a ResourceOptions instance') if opts.version is None: opts.version = _utilities.get_version() if opts.id is None: if __props__ is not None: raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource') __props__ = NotificationConfigArgs.__new__(NotificationConfigArgs) if config_id is None and not opts.urn: raise TypeError("Missing required property 'config_id'") __props__.__dict__["config_id"] = config_id __props__.__dict__["description"] = description if organization is None and not opts.urn: raise TypeError("Missing required property 'organization'") __props__.__dict__["organization"] = organization if pubsub_topic is None and not opts.urn: raise TypeError("Missing required property 'pubsub_topic'") __props__.__dict__["pubsub_topic"] = pubsub_topic if streaming_config is None and not opts.urn: raise TypeError("Missing required property 'streaming_config'") __props__.__dict__["streaming_config"] = streaming_config __props__.__dict__["name"] = None __props__.__dict__["service_account"] = None super(NotificationConfig, __self__).__init__( 'gcp:securitycenter/notificationConfig:NotificationConfig', resource_name, __props__, opts)
[ 2, 19617, 28, 40477, 12, 23, 198, 2, 17202, 39410, 25, 428, 2393, 373, 7560, 416, 262, 21624, 12994, 24118, 687, 10290, 357, 27110, 5235, 8, 16984, 13, 17202, 198, 2, 17202, 2141, 407, 4370, 416, 1021, 4556, 345, 821, 1728, 345, 760...
2.405488
1,312
from abc import ABCMeta, abstractmethod import numpy as np
[ 6738, 450, 66, 1330, 9738, 48526, 11, 12531, 24396, 198, 11748, 299, 32152, 355, 45941, 628, 628 ]
3.647059
17
# # @lc app=leetcode id=290 lang=python3 # # [290] Word Pattern # # https://leetcode.com/problems/word-pattern/description/ # # algorithms # Easy (35.86%) # Likes: 825 # Dislikes: 113 # Total Accepted: 164K # Total Submissions: 455.9K # Testcase Example: '"abba"\n"dog cat cat dog"' # # Given a pattern and a string str, find if str follows the same pattern. # # Here follow means a full match, such that there is a bijection between a # letter in pattern and a non-empty word in str. # # Example 1: # # # Input: pattern = "abba", str = "dog cat cat dog" # Output: true # # Example 2: # # # Input:pattern = "abba", str = "dog cat cat fish" # Output: false # # Example 3: # # # Input: pattern = "aaaa", str = "dog cat cat dog" # Output: false # # Example 4: # # # Input: pattern = "abba", str = "dog dog dog dog" # Output: false # # Notes: # You may assume pattern contains only lowercase letters, and str contains # lowercase letters that may be separated by a single space. # # # @lc code=start from collections import defaultdict # @lc code=end
[ 2, 198, 2, 2488, 44601, 598, 28, 293, 316, 8189, 4686, 28, 24369, 42392, 28, 29412, 18, 198, 2, 198, 2, 685, 24369, 60, 9678, 23939, 198, 2, 198, 2, 3740, 1378, 293, 316, 8189, 13, 785, 14, 1676, 22143, 14, 4775, 12, 33279, 14, ...
2.833333
378
from torch import nn
[ 6738, 28034, 1330, 299, 77, 628, 198 ]
3.285714
7
import unittest from musket_core import coders import numpy as np import pandas as pd import os import math fl=__file__ fl=os.path.dirname(fl)
[ 11748, 555, 715, 395, 201, 198, 6738, 1928, 7126, 62, 7295, 1330, 14873, 364, 201, 198, 11748, 299, 32152, 355, 45941, 201, 198, 11748, 19798, 292, 355, 279, 67, 201, 198, 11748, 28686, 201, 198, 11748, 10688, 201, 198, 201, 198, 2704...
2.483871
62
#!/usr/bin/env python3 import os import sys BASE_DIR = os.path.dirname(os.path.abspath(__file__)) sys.path.append(BASE_DIR) import scripts.lib.setup_path_on_import if __name__ == "__main__": if 'posix' in os.name and os.geteuid() == 0: print("manage.py should not be run as root. Use `su zulip` to drop root.") sys.exit(1) if (os.access('/etc/zulip/zulip.conf', os.R_OK) and not os.access('/etc/zulip/zulip-secrets.conf', os.R_OK)): # The best way to detect running manage.py as another user in # production before importing anything that would require that # access is to check for access to /etc/zulip/zulip.conf (in # which case it's a production server, not a dev environment) # and lack of access for /etc/zulip/zulip-secrets.conf (which # should be only readable by root and zulip) print("Error accessing Zulip secrets; manage.py in production must be run as the zulip user.") sys.exit(1) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "zproject.settings") from django.conf import settings from django.core.management import execute_from_command_line from django.core.management.base import CommandError from scripts.lib.zulip_tools import log_management_command log_management_command(" ".join(sys.argv), settings.MANAGEMENT_LOG_PATH) os.environ.setdefault("PYTHONSTARTUP", os.path.join(BASE_DIR, "scripts/lib/pythonrc.py")) if "--no-traceback" not in sys.argv and len(sys.argv) > 1: sys.argv.append("--traceback") try: execute_from_command_line(sys.argv) except CommandError as e: print(e, file=sys.stderr) sys.exit(1)
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 18, 198, 11748, 28686, 198, 11748, 25064, 198, 198, 33, 11159, 62, 34720, 796, 28686, 13, 6978, 13, 15908, 3672, 7, 418, 13, 6978, 13, 397, 2777, 776, 7, 834, 7753, 834, 4008, 198, 17597,...
2.472464
690
import json, requests from bs4 import BeautifulSoup if __name__ == '__main__': """ This scripts fetches the contents of a webpage that contains nicely formatted data about the Z80 opcodes and outputs it to JSON. """ page = fetch() if page is not None: opcodes = parse_tables(page) with open('opcodes.json', 'w') as output: json.dump(opcodes, output, indent=2)
[ 11748, 33918, 11, 7007, 198, 6738, 275, 82, 19, 1330, 23762, 50, 10486, 628, 628, 198, 198, 361, 11593, 3672, 834, 6624, 705, 834, 12417, 834, 10354, 198, 220, 37227, 198, 220, 770, 14750, 11351, 2052, 262, 10154, 286, 257, 35699, 326...
3.022901
131
from ..dojo_test_case import DojoTestCase from dojo.models import Test from dojo.tools.intsights.parser import IntSightsParser
[ 6738, 11485, 4598, 7639, 62, 9288, 62, 7442, 1330, 2141, 7639, 14402, 20448, 198, 6738, 466, 7639, 13, 27530, 1330, 6208, 198, 6738, 466, 7639, 13, 31391, 13, 29503, 2337, 13, 48610, 1330, 2558, 50, 2337, 46677, 628 ]
3.368421
38
#!/usr/bin/env python # Copyright 2013-present Barefoot Networks, Inc. # Copyright 2018 VMware, 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, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Defines helper functions for a general testing framework. Used by multiple Python testing scripts in the backends folder.""" from __future__ import print_function import subprocess from subprocess import Popen from threading import Timer import sys import os TIMEOUT = 10 * 60 SUCCESS = 0 FAILURE = 1 SKIPPED = 2 # used occasionally to indicate that a test was not executed def is_err(p4filename): """ True if the filename represents a p4 program that should fail. """ return "_errors" in p4filename def report_err(file, *message): """ Write message to given file, report to stderr if verbose """ print("***", file=sys.stderr, *message) if (file and file != sys.stderr): err_file = open(file, "a+") print("***", file=err_file, *message) err_file.close() def report_output(file, verbose, *message): """ Write message to given file, report to stdout if verbose """ if (verbose): print(file=sys.stdout, *message) if (file and file != sys.stdout): out_file = open(file, "a+") print("", file=out_file, *message) out_file.close() def byte_to_hex(byteStr): """ Convert byte sequences to a hex string. """ return ''.join(["%02X " % ord(x) for x in byteStr]).strip() def hex_to_byte(hexStr): """ Convert hex strings to bytes. """ bytes = [] hexStr = ''.join(hexStr.split(" ")) for i in range(0, len(hexStr), 2): bytes.append(chr(int(hexStr[i:i + 2], 16))) return ''.join(bytes) def compare_pkt(outputs, expected, received): """ Compare two given byte sequences and check if they are the same. Report errors if this is not the case. """ received = ''.join(byte_to_hex(str(received)).split()).upper() expected = ''.join(expected.split()).upper() if len(received) < len(expected): report_err(outputs["stderr"], "Received packet too short", len(received), "vs", len(expected)) return FAILURE for i in range(0, len(expected)): if expected[i] == "*": continue if expected[i] != received[i]: report_err(outputs["stderr"], "Received packet ", received) report_err(outputs["stderr"], "Packet different at position", i, ": expected", expected[i], ", received", received[i]) report_err(outputs["stderr"], "Expected packet ", expected) return FAILURE return SUCCESS def open_process(verbose, args, outputs): """ Run the given arguments as a subprocess. Time out after TIMEOUT seconds and report failures or stdout. """ report_output(outputs["stdout"], verbose, "Writing", args) proc = None if outputs["stderr"] is not None: try: proc = Popen(args, stdout=subprocess.PIPE, shell=True, stdin=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) except OSError as e: report_err(outputs["stderr"], "Failed executing: ", e) if proc is None: # Never even started report_err(outputs["stderr"], "Process failed to start") return proc def check_root(): """ This function returns False if the user does not have root privileges. Caution: Only works on Unix systems """ return (os.getuid() == 0)
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 2, 15069, 2211, 12, 25579, 38234, 5898, 27862, 11, 3457, 13, 198, 2, 15069, 2864, 37754, 11, 3457, 13, 198, 2, 198, 2, 49962, 739, 262, 24843, 13789, 11, 10628, 362, 13, 15, 357, 1...
2.65873
1,512
cycle = True heap = Heap() while cycle: try: line = input() cmd = line.split(' ', 2) try: if len(cmd) == 1 and cmd[0] == '': continue if len(cmd) == 2 and cmd[0] == '' and cmd[1] == '': continue if cmd[0] == 'add': heap.add(int(cmd[1]), cmd[2]) elif cmd[0] == 'set': heap.set(int(cmd[1]), cmd[2]) elif cmd[0] == 'delete': heap.delete(int(cmd[1])) elif cmd[0] == 'search': heap.search(int(cmd[1])) elif cmd[0] == 'min': heap.min() elif cmd[0] == 'max': heap.max() elif cmd[0] == 'extract': heap.extract() elif cmd[0] == 'print': heap.print() else: raise(Exception) except Exception: print('error') continue except Exception: cycle = False
[ 198, 198, 13696, 796, 6407, 198, 258, 499, 796, 679, 499, 3419, 198, 198, 4514, 6772, 25, 198, 220, 220, 220, 1949, 25, 198, 220, 220, 220, 220, 220, 220, 220, 1627, 796, 5128, 3419, 198, 220, 220, 220, 220, 220, 220, 220, 23991, ...
1.656598
629
from __future__ import unicode_literals try: from unittest.mock import patch except ImportError: from mock import patch from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.test import TestCase from django.urls import reverse from rest_framework.test import APIRequestFactory, force_authenticate from django_comments_xtd import django_comments from django_comments_xtd.api.views import CommentCreate from django_comments_xtd.tests.models import Article, Diary request_factory = APIRequestFactory()
[ 6738, 11593, 37443, 834, 1330, 28000, 1098, 62, 17201, 874, 198, 198, 28311, 25, 198, 220, 220, 220, 422, 555, 715, 395, 13, 76, 735, 1330, 8529, 198, 16341, 17267, 12331, 25, 198, 220, 220, 220, 422, 15290, 1330, 8529, 198, 198, 67...
3.490909
165
''' @file momentum_kinematics_optimizer.py @package momentumopt @author Brahayam Ponton (brahayam.ponton@tuebingen.mpg.de) @license License BSD-3-Clause @copyright Copyright (c) 2019, New York University and Max Planck Gesellschaft. @date 2019-10-08 ''' import os import numpy as np from momentumopt.kinoptpy.qp import QpSolver from momentumopt.kinoptpy.inverse_kinematics import PointContactInverseKinematics from pinocchio import RobotWrapper import pinocchio as se3 from pinocchio.utils import zero from pymomentum import * from momentumopt.quadruped.quadruped_wrapper import QuadrupedWrapper from momentumopt.kinoptpy.min_jerk_traj import * from pymomentum import \ PlannerVectorParam_KinematicDefaultJointPositions, \ PlannerIntParam_NumTimesteps, \ PlannerDoubleParam_TimeStep
[ 7061, 6, 198, 31, 7753, 12858, 62, 5116, 368, 23372, 62, 40085, 7509, 13, 9078, 198, 31, 26495, 12858, 8738, 198, 31, 9800, 36415, 323, 321, 26345, 261, 357, 65, 11392, 323, 321, 13, 79, 756, 261, 31, 83, 518, 4623, 268, 13, 3149,...
2.934307
274
import logging from gullveig import bootstrap_default_logger # Configure default logging _configure_default_web_logger()
[ 11748, 18931, 198, 198, 6738, 43289, 303, 328, 1330, 6297, 26418, 62, 12286, 62, 6404, 1362, 628, 198, 2, 17056, 495, 4277, 18931, 628, 198, 62, 11250, 495, 62, 12286, 62, 12384, 62, 6404, 1362, 3419, 198 ]
3.405405
37
import json import urllib import os import jupyterhub from tornado.httpclient import HTTPRequest, AsyncHTTPClient from traitlets import Unicode from jupyterhub.auth import Authenticator from tornado import gen
[ 11748, 33918, 198, 11748, 2956, 297, 571, 198, 11748, 28686, 198, 11748, 474, 929, 88, 353, 40140, 198, 6738, 33718, 13, 4023, 16366, 1330, 14626, 18453, 11, 1081, 13361, 40717, 11792, 198, 6738, 1291, 2578, 912, 1330, 34371, 198, 6738, ...
3.719298
57
import torch import torch.nn as nn import numpy as np import matplotlib.pyplot as plt # NOT -> ParameterModule # NOT -> children_and_parameters # NOT -> flatten_model # NOT -> lr_range # NOT -> scheduling functions # NOT -> SmoothenValue # YES -> lr_find # NOT -> plot_lr_find # NOT TO BE MODIFIED # NOT TO BE MODIFIED # To be used to flatten_model def children_and_parameters(m:nn.Module): "Return the children of `m` and its direct parameters not registered in modules." children = list(m.children()) children_p = sum([[id(p) for p in c.parameters()] for c in m.children()],[]) for p in m.parameters(): if id(p) not in children_p: children.append(ParameterModule(p)) return children # NOT TO BE MODIFIED flatten_model = lambda m: sum(map(flatten_model,children_and_parameters(m)),[]) if len(list(m.children())) else [m] # NOT TO BE MODIFIED def lr_range(model, lr): """ Build differential learning rate from lr. It will give you the Arguments: model :- torch.nn.Module lr :- float or slice Returns: Depending upon lr """ if not isinstance(lr, slice): return lr num_layer = len([nn.Sequential(*flatten_model(model))]) if lr.start: mult = lr.stop / lr.start step = mult**(1/(num_layer-1)) res = np.array([lr.start*(step**i) for i in range(num_layer)]) else: res = [lr.stop/10.]*(num_layer-1) + [lr.stop] return np.array(res) # NOT TO BE MODIFIED # These are the functions that would give us the values of lr. Liks for linearly # increasing lr we would use annealing_linear. # You can add your own custom function, for producing lr. # By defualt annealing_exp is used for both lr and momentum def annealing_no(start, end, pct:float): "No annealing, always return `start`." return start def annealing_linear(start, end, pct:float): "Linearly anneal from `start` to `end` as pct goes from 0.0 to 1.0." return start + pct * (end-start) def annealing_exp(start, end, pct:float): "Exponentially anneal from `start` to `end` as pct goes from 0.0 to 1.0." return start * (end/start) ** pct def annealing_cos(start, end, pct:float): "Cosine anneal from `start` to `end` as pct goes from 0.0 to 1.0." cos_out = np.cos(np.pi * pct) + 1 return end + (start-end)/2 * cos_out # NOT TO BE MODIFIED # NOT TO BE MODIFIED # TO BE MODIFIED IN SOME CASES def lr_find(data_loader, model, loss_fn, opt, wd:int=0, start_lr:float=1e-7, end_lr:float=10, num_it:int=100, stop_div:bool=True, smooth_beta:float=0.98, use_gpu:bool=True, device=torch.device('cuda'), anneal_func=annealing_exp): """ The main function that you will call to plot learning_rate vs losses graph. It is the only function from lr_find.py that you will call. By default it will use GPU. It assumes your model is already on GPU if you use use_gpu. Arguments:- data_loader :- torch.utils.data.DataLoader model :- torch.nn.Module loss_fn :- torch.nn.LossFunction opt :- torch.optim.Optimizer wd :- weight decay (default=0). start_lr :- The learning rate from where to start in lr_find (default=1e-7) end_lr :- The learning rate at which to end lr_find (default=10) num_it :- Number of iterations for lr_find (default=100) stop_div :- If the loss diverges, then stop early (default=True) smooth_beta :- The beta value to smoothen the running avergae of the loss function (default=0.98) use_gpu :- True (train on GPU) else CPU anneal_func :- The step function you want to use (default exp) device :- Torch device to use for training model (default GPU) Returns: losses :- list of smoothened version of losses lrs :- list of all lrs that we test """ model.train() stop = False flag = False best_loss = 0. iteration = 0 losses = [] lrs = [] lrs.append(start_lr) start_lr = lr_range(model, start_lr) start_lr = np.array(start_lr) if isinstance(start_lr, (tuple, list)) else start_lr end_lr = lr_range(model, end_lr) end_lr = np.array(end_lr) if isinstance(end_lr, (tuple, list)) else end_lr sched = Stepper((start_lr, end_lr), num_it, anneal_func) smoothener = SmoothenValue(smooth_beta) epochs = int(np.ceil(num_it/len(data_loader))) # save model_dict model_state = model.state_dict() opt_state = opt.state_dict() # Set optimizer learning_rate = start_lr for group in opt.param_groups: group['lr'] = sched.start for i in range(epochs): for data in data_loader: opt.zero_grad() ################### TO BE MODIFIED ################### # Depending on your model, you will have to modify your # data pipeline and how you give inputs to your model. inputs, labels = data if use_gpu: inputs = inputs.to(device) labels = labels.to(device) outputs = model(inputs) loss = loss_fn(outputs, labels) ##################################################### if use_gpu: smoothener.add_value(loss.detach().cpu()) else: smoothener.add_value(loss.detach()) smooth_loss = smoothener.smooth losses.append(smooth_loss) loss.backward() ################### TO BE MODIFIED ################### # For AdamW. If you want to use Adam, comment these lines for group in opt.param_groups: for param in group['params']: param.data = param.data.add(-wd * group['lr'], param.data) ##################################################### opt.step() # Change lr new_lr = sched.step() lrs.append(new_lr) for group in opt.param_groups: group['lr'] = new_lr ################### TO BE MODIFIED ################### # You necessarily don't want to change it. But in cases # when you are maximizing the loss, then you will have # to change it. if iteration == 0 or smooth_loss < best_loss: best_loss = smooth_loss iteration += 1 if sched.is_done or (stop_div and (smooth_loss > 4*best_loss or torch.isnan(loss))): flag = True break ##################################################### if iteration%10 == 0: print(f'Iteration: {iteration}') if flag: break # Load state dict model.load_state_dict(model_state) opt.load_state_dict(opt_state) lrs.pop() print(f'LR Finder is complete.') return losses, lrs # NOT TO BE MODIFIED def plot_lr_find(losses, lrs, skip_start:int=10, skip_end:int=5, suggestion:bool=False, return_fig:bool=None): """ It will take the losses and lrs returned by lr_find as input. Arguments:- skip_start -> It will skip skip_start lrs from the start skip_end -> It will skip skip_end lrs from the end suggestion -> If you want to see the point where the gradient changes most return_fig -> True then get the fig in the return statement """ lrs = lrs[skip_start:-skip_end] if skip_end > 0 else lrs[skip_start:] losses = losses[skip_start:-skip_end] if skip_end > 0 else losses[skip_start:] losses = [x.item() for x in losses] fig, ax = plt.subplots(1, 1) ax.plot(lrs, losses) ax.set_ylabel("Loss") ax.set_xlabel("Learning Rate") ax.set_xscale('log') ax.xaxis.set_major_formatter(plt.FormatStrFormatter('%.0e')) if suggestion: try: mg = (np.gradient(np.array(losses))).argmin() except: print("Failed to compute the gradients, there might not be enough points.") return print(f"Min numerical gradient: {lrs[mg]:.2E}") ax.plot(lrs[mg], losses[mg], markersize=10, marker='o', color='red') if return_fig is not None: return fig
[ 11748, 28034, 198, 11748, 28034, 13, 20471, 355, 299, 77, 198, 11748, 299, 32152, 355, 45941, 198, 11748, 2603, 29487, 8019, 13, 9078, 29487, 355, 458, 83, 198, 198, 2, 5626, 4613, 25139, 2357, 26796, 198, 2, 5626, 4613, 1751, 62, 392...
2.349915
3,518
""" Test the lldb disassemble command on each call frame when stopped on C's ctor. """ from __future__ import print_function import os import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil
[ 37811, 198, 14402, 262, 32660, 9945, 595, 292, 15140, 3141, 319, 1123, 869, 5739, 618, 5025, 319, 327, 338, 269, 13165, 13, 198, 37811, 198, 198, 6738, 11593, 37443, 834, 1330, 3601, 62, 8818, 628, 198, 11748, 28686, 198, 11748, 640, ...
3.077778
90
''' All the reserved, individual words used in MAlice. ''' A = "a" ALICE = "Alice" AND = "and" ATE = "ate" BECAME = "became" BECAUSE = "because" BUT = "but" CLOSED = "closed" COMMA = "," CONTAINED = "contained" DOT = "." DRANK = "drank" EITHER = "either" ENOUGH = "enough" EVENTUALLY = "eventually" FOUND = "found" HAD = "had" HATTA = "hatta" LETTER = "letter" LOOKING_GLASS = "looking-glass" LPAR = "(" MAYBE = "maybe" NUMBER = "number" OF = "of" OPENED = "opened" OR = "or" PERHAPS = "perhaps" PIECE = "piece" QUESTION = "?" ROOM = "room" RPAR = ")" S = "'s" SAID = "said" SENTENCE = "sentence" SO = "so" SPIDER = "spider" SPOKE = "spoke" THE = "The" THEN = "then" TIMES = "times" TOO = "too" UNDERSCORE = "_" UNSURE = "unsure" WAS = "was" WHAT = "what" WHICH = "which" RESTRICTED = [ A, ALICE, AND, ATE, BECAME ,BECAUSE ,BUT ,CLOSED ,COMMA ,CONTAINED ,DOT ,DRANK ,EITHER ,ENOUGH ,EVENTUALLY ,FOUND ,HAD ,HATTA ,LETTER ,LOOKING_GLASS ,LPAR ,MAYBE ,NUMBER ,OF ,OPENED ,OR ,PERHAPS ,PIECE ,QUESTION ,ROOM ,RPAR ,S ,SAID, SENTENCE ,SO ,SPIDER ,SPOKE ,THE ,THEN ,TIMES ,TOO ,UNDERSCORE ,UNSURE ,WAS ,WHAT ,WHICH]
[ 7061, 6, 198, 220, 220, 1439, 262, 10395, 11, 1981, 2456, 973, 287, 337, 44484, 13, 198, 7061, 6, 198, 198, 32, 796, 366, 64, 1, 198, 1847, 8476, 796, 366, 44484, 1, 198, 6981, 796, 366, 392, 1, 198, 6158, 796, 366, 378, 1, 19...
2.158607
517
# !/usr/bin/env python3 # Author: C.K # Email: theck17@163.com # DateTime:2021-04-12 18:35:15 # Description: import os import sys if __name__ == "__main__": pass
[ 2, 5145, 14, 14629, 14, 8800, 14, 24330, 21015, 18, 198, 2, 6434, 25, 327, 13, 42, 198, 2, 9570, 25, 262, 694, 1558, 31, 24136, 13, 785, 198, 2, 7536, 7575, 25, 1238, 2481, 12, 3023, 12, 1065, 1248, 25, 2327, 25, 1314, 198, 2,...
2.297297
74
# This file is part of the pyMOR project (http://www.pymor.org). # Copyright 2013-2020 pyMOR developers and contributors. All rights reserved. # License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) from pymortests.base import runmodule if __name__ == "__main__": runmodule(filename=__file__)
[ 2, 770, 2393, 318, 636, 286, 262, 12972, 44, 1581, 1628, 357, 4023, 1378, 2503, 13, 9078, 4491, 13, 2398, 737, 198, 2, 15069, 2211, 12, 42334, 12972, 44, 1581, 6505, 290, 20420, 13, 1439, 2489, 10395, 13, 198, 2, 13789, 25, 347, 1...
3.066667
105
from ..utils import SyncClient, __version__ from .bucket import SyncStorageBucketAPI from .file_api import SyncBucketProxy __all__ = [ "SyncStorageClient", ]
[ 6738, 11485, 26791, 1330, 35908, 11792, 11, 11593, 9641, 834, 198, 6738, 764, 27041, 316, 1330, 35908, 31425, 33, 38811, 17614, 198, 6738, 764, 7753, 62, 15042, 1330, 35908, 33, 38811, 44148, 198, 198, 834, 439, 834, 796, 685, 198, 220,...
3.215686
51
# The MIT License # # Copyright 2014, 2015 Piotr Dabkowski # # 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, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, subject # to the following conditions: # # The above copyright notice and this permission notice shall be included in all copies or # substantial portions of the Software. # # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT # LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE __all__ = ['PyJsParser', 'Node', 'WrappingNode', 'node_to_dict', 'parse', 'translate_js', 'translate', 'syntax_tree_translate', 'DEFAULT_HEADER'] __author__ = 'Piotr Dabkowski' __version__ = '2.2.0' from pyjsparser import PyJsParser, Node, WrappingNode, node_to_dict from translator import translate_js, trasnlate, syntax_tree_translate, DEFAULT_HEADER def parse(javascript_code): """Returns syntax tree of javascript_code. Syntax tree has the same structure as syntax tree produced by esprima.js Same as PyJsParser().parse For your convenience :) """ p = PyJsParser() return p.parse(javascript_code)
[ 2, 383, 17168, 13789, 198, 2, 198, 2, 15069, 1946, 11, 1853, 350, 5151, 81, 360, 397, 26216, 198, 2, 198, 2, 2448, 3411, 318, 29376, 7520, 11, 1479, 286, 3877, 11, 284, 597, 1048, 16727, 198, 2, 257, 4866, 286, 428, 3788, 290, 3...
3.427734
512
#!/usr/bin/env python # -*- coding: UTF-8 -*- # Copyright (c) 2020, Sandflow Consulting LLC # # 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 following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Unit tests for the SCC PACs""" # pylint: disable=R0201,C0115,C0116 import unittest from ttconv.scc.codes.preambles_address_codes import SccPreambleAddressCode from ttconv.style_properties import TextDecorationType, NamedColors, FontStyleType if __name__ == '__main__': unittest.main()
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 2, 532, 9, 12, 19617, 25, 41002, 12, 23, 532, 9, 12, 198, 198, 2, 15069, 357, 66, 8, 12131, 11, 3837, 11125, 41005, 11419, 198, 2, 198, 2, 2297, 396, 3890, 290, 779, 287, 2723, ...
3.28937
508
# 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 cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- from msrest.serialization import Model
[ 2, 19617, 28, 40477, 12, 23, 198, 2, 16529, 35937, 198, 2, 15069, 357, 66, 8, 5413, 10501, 13, 1439, 2489, 10395, 13, 198, 2, 49962, 739, 262, 17168, 13789, 13, 4091, 13789, 13, 14116, 287, 262, 1628, 6808, 329, 198, 2, 5964, 1321...
5.354167
96
import torch def expanded_pairwise_distances(x, y): ''' Input: x is a bxNxd matrix y is an optional bxMxd matirx Output: dist is a bxNxM matrix where dist[i,j] is the square norm between x[i,:] and y[j,:] if y is not given then use 'y=x'. i.e. dist[i,j] = ||x[i,:]-y[j,:]||^2 ''' differences = x.unsqueeze(2) - y.unsqueeze(1) distances = torch.sum(differences * differences, -1) return distances def chamfer_distance(x, y): ''' input x and y are bxNxM matrix, b: batch, N:number of point, M: point dim (ex. 2 for 2D or 3 for 3D) output is a bx1 Matrix with the value of the chamfer distance for each sample of the batch ''' dist_vec = expanded_pairwise_distances(x, y) min_distances = torch.topk(dist_vec, k=1, dim=2, largest=False).values chamfer = torch.sum(min_distances, dim=1) / torch.tensor(x.shape[1]) return chamfer if __name__ == "__main__": x = torch.tensor([ [ [0., 0., 0.], [0., 1., 0.], [0., 1., 0.], ], [ [1., 1., 0.], [1., 2., 0.], [0., 1., 0.], ] ]) y = torch.tensor([ [ [0., 1., 0.], [0., 1., 0.], [0., 1., 0.], ], [ [1., 1., 0.], [1., 2., 0.], [0., 1., 0.], ] ]) chamfer = ChamferLoss() print('chamfer loss torch (cpu):', chamfer(x, y)) print('chamfer loss torch (cuda):', chamfer(x.cuda(), y.cuda())) # import sys # sys.path.append("../distance/chamfer/") # import dist_chamfer as cd # CD = cd.chamferDist() # dist1, dist2, _, _= CD(x, y) # print('orig', dist1)
[ 11748, 28034, 198, 198, 4299, 9902, 62, 24874, 3083, 62, 17080, 1817, 7, 87, 11, 331, 2599, 198, 220, 220, 220, 705, 7061, 198, 220, 220, 220, 23412, 25, 2124, 318, 257, 275, 87, 45, 24954, 17593, 198, 220, 220, 220, 220, 220, 220...
1.917582
910
from __future__ import absolute_import from __future__ import print_function from __future__ import division from __future__ import unicode_literals from django.http import HttpResponse, HttpResponseRedirect, JsonResponse, QueryDict #, HttpResponseForbidden, Http404, , JsonResponse from django.shortcuts import get_object_or_404, render, redirect from django.urls import reverse from django.contrib.admin.views.decorators import staff_member_required, user_passes_test from rules.contrib.views import permission_required, objectgetter from isisdata.models import * from isisdata.utils import strip_punctuation, normalize from isisdata import operations from isisdata.filters import * from isisdata import tasks as data_tasks from curation import p3_port_utils from curation.forms import * from curation.contrib.views import check_rules
[ 6738, 11593, 37443, 834, 1330, 4112, 62, 11748, 198, 6738, 11593, 37443, 834, 1330, 3601, 62, 8818, 198, 6738, 11593, 37443, 834, 1330, 7297, 198, 6738, 11593, 37443, 834, 1330, 28000, 1098, 62, 17201, 874, 198, 198, 6738, 42625, 14208, ...
3.527197
239
#!/usr/bin/env python3 # coding: utf8 # /*########################################################################## # # Copyright (c) 2015-2021 European Synchrotron Radiation Facility # # 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, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # ###########################################################################*/ """Run the tests of the project. This script expects a suite function in <project_package>.test, which returns a unittest.TestSuite. Test coverage dependencies: coverage, lxml. """ __authors__ = ["Jrme Kieffer", "Thomas Vincent"] __date__ = "30/09/2020" __license__ = "MIT" import distutils.util import logging import os import subprocess import sys import importlib # Capture all default warnings logging.captureWarnings(True) import warnings warnings.simplefilter('default') logger = logging.getLogger("run_tests") logger.setLevel(logging.WARNING) logger.info("Python %s %s", sys.version, tuple.__itemsize__ * 8) try: import numpy except Exception as error: logger.warning("Numpy missing: %s", error) else: logger.info("Numpy %s", numpy.version.version) try: import h5py except Exception as error: logger.warning("h5py missing: %s", error) else: logger.info("h5py %s", h5py.version.version) def get_project_name(root_dir): """Retrieve project name by running python setup.py --name in root_dir. :param str root_dir: Directory where to run the command. :return: The name of the project stored in root_dir """ logger.debug("Getting project name in %s", root_dir) p = subprocess.Popen([sys.executable, "setup.py", "--name"], shell=False, cwd=root_dir, stdout=subprocess.PIPE) name, _stderr_data = p.communicate() logger.debug("subprocess ended with rc= %s", p.returncode) return name.split()[-1].decode('ascii') def is_debug_python(): """Returns true if the Python interpreter is in debug mode.""" try: import sysconfig except ImportError: # pragma nocover # Python < 2.7 import distutils.sysconfig as sysconfig if sysconfig.get_config_var("Py_DEBUG"): return True return hasattr(sys, "gettotalrefcount") def build_project(name, root_dir): """Run python setup.py build for the project. Build directory can be modified by environment variables. :param str name: Name of the project. :param str root_dir: Root directory of the project :return: The path to the directory were build was performed """ platform = distutils.util.get_platform() architecture = "lib.%s-%i.%i" % (platform, sys.version_info[0], sys.version_info[1]) if is_debug_python(): architecture += "-pydebug" if os.environ.get("PYBUILD_NAME") == name: # we are in the debian packaging way home = os.environ.get("PYTHONPATH", "").split(os.pathsep)[-1] elif os.environ.get("BUILDPYTHONPATH"): home = os.path.abspath(os.environ.get("BUILDPYTHONPATH", "")) else: home = os.path.join(root_dir, "build", architecture) logger.warning("Building %s to %s", name, home) p = subprocess.Popen([sys.executable, "setup.py", "build"], shell=False, cwd=root_dir) logger.debug("subprocess ended with rc= %s", p.wait()) if os.path.isdir(home): return home alt_home = os.path.join(os.path.dirname(home), "lib") if os.path.isdir(alt_home): return alt_home def import_project_module(project_name, project_dir): """Import project module, from the system of from the project directory""" if "--installed" in sys.argv: try: module = importlib.import_module(project_name) except Exception: logger.error("Cannot run tests on installed version: %s not installed or raising error.", project_name) raise else: # Use built source build_dir = build_project(project_name, project_dir) if build_dir is None: logging.error("Built project is not available !!! investigate") sys.path.insert(0, build_dir) logger.warning("Patched sys.path, added: '%s'", build_dir) module = importlib.import_module(project_name) return module if __name__ == "__main__": # Needed for multiprocessing support on Windows import pytest PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) PROJECT_NAME = get_project_name(PROJECT_DIR) logger.info("Project name: %s", PROJECT_NAME) project_module = import_project_module(PROJECT_NAME, PROJECT_DIR) PROJECT_VERSION = getattr(project_module, 'version', '') PROJECT_PATH = project_module.__path__[0] args = [normalize_option(p) for p in sys.argv[1:] if p != "--installed"] # Run test on PROJECT_PATH if nothing is specified without_options = [a for a in args if not a.startswith("-")] if len(without_options) == 0: args += [PROJECT_PATH] argv = ["--rootdir", PROJECT_PATH] + args sys.exit(pytest.main(argv))
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 18, 198, 2, 19617, 25, 3384, 69, 23, 198, 2, 11900, 29113, 29113, 7804, 2235, 198, 2, 198, 2, 15069, 357, 66, 8, 1853, 12, 1238, 2481, 3427, 16065, 354, 10599, 1313, 47532, 29118, 198, ...
2.792435
2,168
# Copyright 2008-2015 Nokia Solutions and Networks # # 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, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os import re import sys import traceback from robot.errors import RobotError from .platform import JYTHON, RERAISED_EXCEPTIONS from .unic import unic EXCLUDE_ROBOT_TRACES = not os.getenv('ROBOT_INTERNAL_TRACES') if JYTHON: from java.io import StringWriter, PrintWriter from java.lang import Throwable, OutOfMemoryError else: Throwable = () def get_error_message(): """Returns error message of the last occurred exception. This method handles also exceptions containing unicode messages. Thus it MUST be used to get messages from all exceptions originating outside the framework. """ return ErrorDetails().message def get_error_details(exclude_robot_traces=EXCLUDE_ROBOT_TRACES): """Returns error message and details of the last occurred exception.""" details = ErrorDetails(exclude_robot_traces=exclude_robot_traces) return details.message, details.traceback def ErrorDetails(exc_info=None, exclude_robot_traces=EXCLUDE_ROBOT_TRACES): """This factory returns an object that wraps the last occurred exception It has attributes `message`, `traceback` and `error`, where `message` contains type and message of the original error, `traceback` contains the traceback/stack trace and `error` contains the original error instance. """ exc_type, exc_value, exc_traceback = exc_info or sys.exc_info() if exc_type in RERAISED_EXCEPTIONS: raise exc_value details = PythonErrorDetails \ if not isinstance(exc_value, Throwable) else JavaErrorDetails return details(exc_type, exc_value, exc_traceback, exclude_robot_traces)
[ 2, 220, 15069, 3648, 12, 4626, 26182, 23555, 290, 27862, 198, 2, 198, 2, 220, 49962, 739, 262, 24843, 13789, 11, 10628, 362, 13, 15, 357, 1169, 366, 34156, 15341, 198, 2, 220, 345, 743, 407, 779, 428, 2393, 2845, 287, 11846, 351, ...
3.242775
692
from dedupe.api import StaticDedupe, Dedupe from dedupe.api import StaticRecordLink, RecordLink from dedupe.api import StaticGazetteer, Gazetteer from dedupe.core import randomPairs, randomPairsMatch, frozendict from dedupe.convenience import consoleLabel, trainingDataDedupe, trainingDataLink, canonicalize
[ 6738, 4648, 48722, 13, 15042, 1330, 36125, 35, 15532, 431, 11, 360, 15532, 431, 198, 6738, 4648, 48722, 13, 15042, 1330, 36125, 23739, 11280, 11, 13266, 11280, 198, 6738, 4648, 48722, 13, 15042, 1330, 36125, 38, 1031, 5857, 263, 11, 387...
3.54023
87
import unittest from unittest import TestCase from misc import verify if __name__ == "__main__": unittest.main()
[ 11748, 555, 715, 395, 198, 6738, 555, 715, 395, 1330, 6208, 20448, 198, 198, 6738, 12747, 1330, 11767, 628, 198, 198, 361, 11593, 3672, 834, 6624, 366, 834, 12417, 834, 1298, 198, 220, 220, 220, 555, 715, 395, 13, 12417, 3419, 198 ]
2.880952
42
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 1999-2020 Alibaba Group Holding 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 required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import numpy as np from ... import opcodes as OperandDef from ..datasource import tensor as astensor from .core import TensorComplexFFTMixin, validate_fft, TensorStandardFFT def ifft(a, n=None, axis=-1, norm=None): """ Compute the one-dimensional inverse discrete Fourier Transform. This function computes the inverse of the one-dimensional *n*-point discrete Fourier transform computed by `fft`. In other words, ``ifft(fft(a)) == a`` to within numerical accuracy. For a general description of the algorithm and definitions, see `mt.fft`. The input should be ordered in the same way as is returned by `fft`, i.e., * ``a[0]`` should contain the zero frequency term, * ``a[1:n//2]`` should contain the positive-frequency terms, * ``a[n//2 + 1:]`` should contain the negative-frequency terms, in increasing order starting from the most negative frequency. For an even number of input points, ``A[n//2]`` represents the sum of the values at the positive and negative Nyquist frequencies, as the two are aliased together. See `numpy.fft` for details. Parameters ---------- a : array_like Input tensor, can be complex. n : int, optional Length of the transformed axis of the output. If `n` is smaller than the length of the input, the input is cropped. If it is larger, the input is padded with zeros. If `n` is not given, the length of the input along the axis specified by `axis` is used. See notes about padding issues. axis : int, optional Axis over which to compute the inverse DFT. If not given, the last axis is used. norm : {None, "ortho"}, optional Normalization mode (see `numpy.fft`). Default is None. Returns ------- out : complex Tensor The truncated or zero-padded input, transformed along the axis indicated by `axis`, or the last one if `axis` is not specified. Raises ------ IndexError If `axes` is larger than the last axis of `a`. See Also -------- mt.fft : An introduction, with definitions and general explanations. fft : The one-dimensional (forward) FFT, of which `ifft` is the inverse ifft2 : The two-dimensional inverse FFT. ifftn : The n-dimensional inverse FFT. Notes ----- If the input parameter `n` is larger than the size of the input, the input is padded by appending zeros at the end. Even though this is the common approach, it might lead to surprising results. If a different padding is desired, it must be performed before calling `ifft`. Examples -------- >>> import mars.tensor as mt >>> mt.fft.ifft([0, 4, 0, 0]).execute() array([ 1.+0.j, 0.+1.j, -1.+0.j, 0.-1.j]) Create and plot a band-limited signal with random phases: >>> import matplotlib.pyplot as plt >>> t = mt.arange(400) >>> n = mt.zeros((400,), dtype=complex) >>> n[40:60] = mt.exp(1j*mt.random.uniform(0, 2*mt.pi, (20,))) >>> s = mt.fft.ifft(n) >>> plt.plot(t.execute(), s.real.execute(), 'b-', t.execute(), s.imag.execute(), 'r--') ... >>> plt.legend(('real', 'imaginary')) ... >>> plt.show() """ a = astensor(a) validate_fft(a, axis, norm) op = TensorIFFT(n=n, axis=axis, norm=norm, dtype=np.dtype(np.complex_)) return op(a)
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 2, 15069, 7358, 12, 42334, 41992, 4912, 31703, 12052, 13, 198, 2, 198, 2, 49962, 739, 262, 24843, 13789, 11, 10628, 3...
2.86771
1,406
import numpy as np import math extraNumber = 4 * math.pi * pow(10,-7) avgEMF()
[ 11748, 299, 32152, 355, 45941, 201, 198, 11748, 10688, 201, 198, 201, 198, 26086, 15057, 796, 604, 1635, 10688, 13, 14415, 1635, 7182, 7, 940, 12095, 22, 8, 201, 198, 201, 198, 615, 70, 3620, 37, 3419, 201, 198 ]
2.230769
39
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Computes the spectrogram of a test signal using cupy and cuFFT. Author: Jan Schlter """ import sys import os import timeit import numpy as np import cupy as cp INPUT_ON_GPU = True OUTPUT_ON_GPU = True from testfile import make_test_signal def spectrogram(signal, sample_rate=22050, frame_len=1024, fps=70): """ Computes a magnitude spectrogram at a given sample rate (in Hz), frame length (in samples) and frame rate (in Hz), on CUDA using cupy. """ if not INPUT_ON_GPU: signal = cp.array(signal.astype(np.float32)) # already blown up to a list of frames win = cp.hanning(frame_len).astype(cp.float32) # apply window function #signal *= win # this doesn't work correctly for some reason. signal = signal * win # perform FFT spect = cp.fft.rfft(signal) # convert into magnitude spectrogram spect = cp.abs(spect) # return if OUTPUT_ON_GPU: cp.cuda.get_current_stream().synchronize() else: return spect.get() if __name__=="__main__": main()
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 198, 37811, 198, 7293, 1769, 262, 5444, 39529, 286, 257, 1332, 6737, 1262, 6508, 88, 290, 18912, 5777, 51, 13, 198, 1...
2.58156
423
test = { 'name': 'q2b3', 'points': 5, 'suites': [ { 'cases': [ { 'code': '>>> ' 'histories_2b[2].model.count_params()\n' '119260', 'hidden': False, 'locked': False}, { 'code': '>>> ' 'histories_2b[2].model.layers[1].activation.__name__\n' "'sigmoid'", 'hidden': False, 'locked': False}, { 'code': '>>> ' 'histories_2b[2].model.layers[1].units\n' '150', 'hidden': False, 'locked': False}, { 'code': '>>> ' "histories_2b[2].history['loss'][4] " '<= ' "histories_2b[1].history['loss'][4]\n" 'True', 'hidden': False, 'locked': False}], 'scored': True, 'setup': '', 'teardown': '', 'type': 'doctest'}]}
[ 9288, 796, 1391, 220, 220, 705, 3672, 10354, 705, 80, 17, 65, 18, 3256, 198, 220, 220, 220, 705, 13033, 10354, 642, 11, 198, 220, 220, 220, 705, 2385, 2737, 10354, 685, 220, 220, 1391, 220, 220, 705, 33964, 10354, 685, 220, 220, 1...
1.285829
1,242
from django.apps import AppConfig from django.contrib.admin.apps import AdminConfig from django.contrib.auth.apps import AuthConfig from django.contrib.contenttypes.apps import ContentTypesConfig from django.contrib.sessions.apps import SessionsConfig from django.db.models.signals import post_migrate from django_celery_results.apps import CeleryResultConfig from geotrek.common.utils.signals import check_srid_has_meter_unit, pm_callback
[ 6738, 42625, 14208, 13, 18211, 1330, 2034, 16934, 198, 6738, 42625, 14208, 13, 3642, 822, 13, 28482, 13, 18211, 1330, 32053, 16934, 198, 6738, 42625, 14208, 13, 3642, 822, 13, 18439, 13, 18211, 1330, 26828, 16934, 198, 6738, 42625, 14208,...
3.419847
131
""" To avoid any issues of memory hanging around between inputs, we run each input as a separate process. A little ugly but effective """ import gc import glob import json import os import random import time import numpy as np import torch from common import invoke_main, read_json, write_json, prepare_out_file, check_file_exists from validate_config import validate_trials_config from pt_trial_util import create_csv_writer from tqdm import tqdm import model_util def save_trial_log(dest_dir, sim_conf_filename, model_name, specific_params, is_baseline=False): """ Find the last DTR log produced in the trial (if any exist) and move it to the directory """ all_logs = glob.glob(os.path.join(os.getcwd(), '*.log')) if not all_logs: return # if we delete all logs in advance, there should be at most one log assert len(all_logs) == 1 most_recent = all_logs[0] # rename and move # (new name just appends info to the old one) batch_size = specific_params['batch_size'] budget = specific_params['memory_budget'] if budget < 0: budget = 'inf' new_name = '{}-{}-{}-{}'.format(model_name, batch_size, budget, os.path.basename(most_recent)) filename = prepare_out_file(dest_dir, new_name) os.rename(most_recent, filename) if is_baseline and sim_conf_filename is not None: extend_simrd_config(dest_dir, sim_conf_filename, model_name, specific_params, filename) def run_single_measurement(model_name, produce_model, run_model, teardown, inp, criterion, extra_params, use_dtr, use_profiling): """ This function initializes a model and performs a single measurement of the model on the given input. While it might seem most reasonable to initialize the model outside of the loop, DTR's logs have shown that certain constants in the model persist between loop iterations; performing these actions in a separate *function scope* turned out to be the only way to prevent having those constants hang around. Returns a dict of measurements """ torch.cuda.reset_max_memory_allocated() # resetting means the count should be reset to # only what's in scope, meaning only the input input_mem = torch.cuda.max_memory_allocated() model = produce_model(extra_params=extra_params) params = [] for m in model: if hasattr(m, 'parameters'): params.extend(m.parameters()) model_mem = torch.cuda.max_memory_allocated() optimizer = torch.optim.SGD(model[0].parameters(), 1e-3, momentum=0.9, weight_decay=1e-4) start = torch.cuda.Event(enable_timing=True) end = torch.cuda.Event(enable_timing=True) # start timing torch.cuda.synchronize() start_time = time.time() if use_dtr: torch.reset_profile() start.record() # with torch.autograd.profiler.profile(use_cuda=True) as prof: run_model(criterion, *model, *inp, optimizer=optimizer) end.record() start_sync = time.time() torch.cuda.synchronize() end_sync = time.time() end_time = time.time() # end timing if use_dtr: # operators-only time, tracked by DTR cuda_time = torch.compute_time() base_compute_time = -1 remat_compute_time = -1 search_time = -1 cost_time = -1 if use_profiling: base_compute_time = torch.base_compute_time() remat_compute_time = torch.remat_compute_time() search_time = torch.search_time() cost_time = torch.cost_time() torch.reset_profile() total_mem = torch.cuda.max_memory_allocated() teardown(*model) torch.cuda.reset_max_memory_allocated() del model if use_dtr: torch.toggle_log(False) del params batch_size = len(inp[0]) ips = batch_size / (end_time - start_time) result = { 'time': end_time - start_time, 'sync_time': end_sync - start_sync, 'gpu_time': start.elapsed_time(end), 'input_mem': input_mem, 'model_mem': model_mem, 'total_mem': total_mem, 'base_compute_time': base_compute_time, 'remat_compute_time': remat_compute_time, 'search_time': search_time, 'cost_time': cost_time, 'batch_size': batch_size, 'ips': ips } if use_dtr: result['cuda_time'] = cuda_time else: result['cuda_time'] = -1.0 return result if __name__ == '__main__': invoke_main(main, 'config_dir', 'experiment_mode', 'model_name', 'input_idx', 'params_file', 'out_file', 'trial_run', 'trial_run_outfile')
[ 37811, 198, 2514, 3368, 597, 2428, 286, 4088, 10938, 1088, 1022, 17311, 11, 198, 732, 1057, 1123, 5128, 355, 257, 4553, 1429, 13, 198, 198, 32, 1310, 13400, 475, 4050, 198, 37811, 198, 11748, 308, 66, 198, 11748, 15095, 198, 11748, 33...
2.483422
1,870
import sys, os from subprocess import call try: from downloadPdb import downloadPDB except ImportError: from .downloadPdb import downloadPDB pdbListFile="/home/rsanchez/Tesis/rriPredMethod/data/joanDimers/117_dimers_list.tsv" outPath="/home/rsanchez/Tesis/rriPredMethod/data/joanDimers/pdbFiles/rawPDBs" USE_BIO_UNIT=False ##def downloadPDB(pdbId, pdbOutPath, useBioUnit): #### descargar pdb: wget ftp://ftp.wwpdb.org/pub/pdb/data/biounit/coordinates/all/1i1q.pdb2.gz o ya descomprimido #### wget -qO- ftp://ftp.wwpdb.org/pub/pdb/data/biounit/coordinates/all/1i1q.pdb2.gz |zcat > 1i1q.pdb ## outName= os.path.join(pdbOutPath,pdbId+'.pdb') ## if not os.path.isfile(outName): ## if useBioUnit: ## cmd= 'wget -qO- ftp://ftp.wwpdb.org/pub/pdb/data/biounit/coordinates/all/%s.pdb1.gz |zcat > %s'%(pdbId.lower(), outName) ## else: ## cmd= 'wget -qO- http://www.pdb.org/pdb/files/%s.pdb | cat > %s'%(pdbId.upper(), outName) ## print(cmd) ## call(cmd, shell= True) if __name__=="__main__": if len(sys.argv)==3: pdbListFile= os.path.abspath(os.path.expanduser(sys.argv[1])) outPath= os.path.abspath(os.path.expanduser(sys.argv[2])) print( pdbListFile, outPath) downloadInFile(pdbListFile, outPath, USE_BIO_UNIT)
[ 11748, 25064, 11, 28686, 198, 6738, 850, 14681, 1330, 869, 198, 198, 28311, 25, 198, 220, 422, 4321, 47, 9945, 1330, 4321, 5760, 33, 198, 16341, 17267, 12331, 25, 198, 220, 422, 764, 15002, 47, 9945, 1330, 4321, 5760, 33, 198, 220, ...
2.136594
593
#!/usr/bin/env python import json import sys import xapian import support ### End of example code. if len(sys.argv) < 3: print("Usage: %s DBPATH QUERYTERM..." % sys.argv[0]) sys.exit(1) search(dbpath = sys.argv[1], querystring = " ".join(sys.argv[2:]))
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 198, 11748, 33918, 198, 11748, 25064, 198, 11748, 2124, 499, 666, 198, 11748, 1104, 198, 21017, 5268, 286, 1672, 2438, 13, 198, 198, 361, 18896, 7, 17597, 13, 853, 85, 8, 1279, 513, ...
2.444444
108
import re from rest_framework import serializers from .models import Collection, CollectionIcon
[ 11748, 302, 198, 6738, 1334, 62, 30604, 1330, 11389, 11341, 198, 198, 6738, 764, 27530, 1330, 12251, 11, 12251, 19578, 628, 198 ]
4.5
22
# Time: O(n*2^n) # Space: O(2^n) # Time: O(k^(n-k) * k!) # Space: O(n) # DFS solution with pruning.
[ 2, 3862, 25, 220, 440, 7, 77, 9, 17, 61, 77, 8, 198, 2, 4687, 25, 440, 7, 17, 61, 77, 8, 628, 198, 2, 3862, 25, 220, 440, 7, 74, 61, 7, 77, 12, 74, 8, 1635, 479, 8133, 198, 2, 4687, 25, 440, 7, 77, 8, 198, 2, 360, ...
1.810345
58
# 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.package import * # See also: AspellDictPackage
[ 2, 15069, 2211, 12, 1238, 1828, 13914, 45036, 3549, 2351, 4765, 11, 11419, 290, 584, 198, 2, 1338, 441, 4935, 34152, 13, 4091, 262, 1353, 12, 5715, 27975, 38162, 9947, 2393, 329, 3307, 13, 198, 2, 198, 2, 30628, 55, 12, 34156, 12, ...
3.350649
77
# # Copyright (C) 2001 greg Landrum # """ unit testing code for compound descriptors """ from __future__ import print_function import unittest import Parser from rdkit.six.moves import xrange if __name__ == '__main__': suite = TestSuite() unittest.TextTestRunner().run(suite)
[ 2, 198, 2, 220, 15069, 357, 34, 8, 5878, 220, 308, 2301, 6379, 6582, 198, 2, 198, 198, 37811, 4326, 4856, 2438, 329, 13061, 12145, 669, 198, 198, 37811, 198, 6738, 11593, 37443, 834, 1330, 3601, 62, 8818, 198, 11748, 555, 715, 395, ...
2.881188
101
from setuptools import setup, find_packages import pathlib here = pathlib.Path(__file__).parent.resolve() long_description = (here / "readme.md").read_text(encoding="utf-8") setup( name="data_dashboard", version="0.1.1", description="Dashboard to explore the data and to create baseline Machine Learning model.", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/maciek3000/data_dashboard", author="Maciej Dowgird", author_email="dowgird.maciej@gmail.com", classifiers=[ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: Education", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7", "Topic :: Scientific/Engineering :: Artificial Intelligence", "Topic :: Scientific/Engineering :: Visualization" ], package_dir={"data_dashboard": "data_dashboard"}, packages=find_packages(), python_requires=">=3.7", install_requires=[ "pandas>=1.2.3", "numpy>=1.19.5", "scipy>=1.6.1", "beautifulsoup4>=4.9.3", "scikit-learn>=0.24.1", "seaborn>=0.11.1", "bokeh>=2.3.0", "Jinja2>=2.11.3", "xgboost>=1.3.3", "lightgbm>=3.2.0" ], package_data={ "data_dashboard": ["static/*", "templates/*", "examples/*"] }, project_urls={ "Github": "https://github.com/maciek3000/data_dashboard", }, )
[ 6738, 900, 37623, 10141, 1330, 9058, 11, 1064, 62, 43789, 198, 11748, 3108, 8019, 628, 198, 1456, 796, 3108, 8019, 13, 15235, 7, 834, 7753, 834, 737, 8000, 13, 411, 6442, 3419, 198, 6511, 62, 11213, 796, 357, 1456, 1220, 366, 961, 1...
2.285922
689
# 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://aws.amazon.com/apache2.0/ # # or in the "license" file accompanying this file. This file is distributed # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either # express or implied. See the License for the specific language governing # permissions and limitations under the License. """Integration tests for Instance API. """ import datetime import pytest import time import logging from acktest.resources import random_suffix_name from acktest.k8s import resource as k8s from e2e import service_marker, CRD_GROUP, CRD_VERSION, load_ec2_resource from e2e.replacement_values import REPLACEMENT_VALUES from e2e.bootstrap_resources import get_bootstrap_resources RESOURCE_PLURAL = "instances" # highly available instance type for deterministic testing INSTANCE_TYPE = "m4.large" INSTANCE_AMI = "Amazon Linux 2 Kernel" INSTANCE_TAG_KEY = "owner" INSTANCE_TAG_VAL = "ack-controller" CREATE_WAIT_AFTER_SECONDS = 10 DELETE_WAIT_AFTER_SECONDS = 10 TIMEOUT_SECONDS = 300
[ 2, 15069, 6186, 13, 785, 3457, 13, 393, 663, 29116, 13, 1439, 6923, 33876, 13, 198, 2, 198, 2, 49962, 739, 262, 24843, 13789, 11, 10628, 362, 13, 15, 357, 1169, 366, 34156, 11074, 921, 743, 198, 2, 407, 779, 428, 2393, 2845, 287, ...
3.300532
376
from flask_wtf import FlaskForm from wtforms import Form, StringField, PasswordField, BooleanField, SubmitField, IntegerField, validators, FileField, \ MultipleFileField, SelectField, RadioField, HiddenField, DecimalField, TextAreaField from wtforms.fields.html5 import DateField from wtforms.validators import DataRequired # Structure of the Login form # Structure of the Register form # Structure of the Login form # Structure of the Subir Anuncio form
[ 6738, 42903, 62, 86, 27110, 1330, 46947, 8479, 198, 6738, 266, 83, 23914, 1330, 5178, 11, 10903, 15878, 11, 30275, 15878, 11, 41146, 15878, 11, 39900, 15878, 11, 34142, 15878, 11, 4938, 2024, 11, 9220, 15878, 11, 3467, 198, 220, 220, ...
3.758065
124
#coding: utf-8 import sys import os import asyncio import websockets import json import socket import xlrd #global vars phd_data = None pro_data = None #json port = 5678 if len(sys.argv) >=2: port = sys.argv[1] ws_server = websockets.serve(main_logic, '0.0.0.0', port) asyncio.get_event_loop().run_until_complete(ws_server) asyncio.get_event_loop().run_forever()
[ 2, 66, 7656, 25, 3384, 69, 12, 23, 198, 11748, 25064, 198, 11748, 28686, 198, 198, 11748, 30351, 952, 198, 11748, 2639, 11603, 198, 11748, 33918, 198, 11748, 17802, 198, 11748, 2124, 75, 4372, 198, 198, 2, 20541, 410, 945, 198, 746, ...
2.412903
155
# # Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. # Use of this file is governed by the BSD 3-clause license that # can be found in the LICENSE.txt file in the project root. #/ # A DFA walker that knows how to dump them to serialized strings.#/ from io import StringIO from antlr4 import DFA from antlr4.Utils import str_list from antlr4.dfa.DFAState import DFAState
[ 2, 198, 2, 15069, 357, 66, 8, 2321, 12, 5539, 383, 3537, 14990, 49, 4935, 13, 1439, 2489, 10395, 13, 198, 2, 5765, 286, 428, 2393, 318, 21825, 416, 262, 347, 10305, 513, 12, 565, 682, 5964, 326, 198, 2, 460, 307, 1043, 287, 262,...
3.198347
121
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """ Calibration Controller Performs calibration for hue, center of camera position, and servo offsets """ import os import cv2 import time import json import argparse import datetime import numpy as np import logging as log from env import MoabEnv from typing import Tuple from common import Vector2 from detector import hsv_detector from controllers import pid_controller from dataclasses import dataclass, astuple from hardware import plate_angles_to_servo_positions def ball_close_enough(x, y, radius, max_ball_dist=0.045, min_ball_dist=0.01): # reject balls which are too far from the center and too small return ( np.abs(x) < max_ball_dist and np.abs(y) < max_ball_dist and radius > min_ball_dist ) def calibrate_hue(camera_fn, detector_fn, is_menu_down_fn): hue_low = 0 hue_high = 360 hue_steps = 41 # Is 41 instead of 40 so that the steps are even img_frame, elapsed_time = camera_fn() hue_options = list(np.linspace(hue_low, hue_high, hue_steps)) detected_hues = [] for hue in hue_options: if is_menu_down_fn(): return CalibHue(early_quit=True) img_frame, elapsed_time = camera_fn() ball_detected, ((x, y), radius) = detector_fn(img_frame, hue=hue, debug=True) # If we found a ball roughly in the center that is large enough if ball_detected and ball_close_enough(x, y, radius): log.info( f"hue={hue:0.3f}, ball_detected={ball_detected}, " f"(x, y)={x:0.3f} {y:0.3f}, radius={radius:0.3f}" ) detected_hues.append(hue) if len(detected_hues) > 0: # https://en.wikipedia.org/wiki/Mean_of_circular_quantities detected_hues_rad = np.radians(detected_hues) sines, cosines = np.sin(detected_hues_rad), np.cos(detected_hues_rad) sin_mean, cos_mean = np.mean(sines), np.mean(cosines) avg_hue_rad = np.arctan2(sin_mean, cos_mean) avg_hue = np.degrees(avg_hue_rad) % 360 # Convert back to [0, 360] print(f"Hues are: {detected_hues}") print(f"Hue calibrated: {avg_hue:0.2f}") print(f"Avg hue: {avg_hue:0.2f}") return CalibHue(hue=int(avg_hue), success=True) else: log.warning(f"Hue calibration failed.") return CalibHue() def calibrate_pos(camera_fn, detector_fn, hue, is_menu_down_fn): for i in range(10): # Try and detect for 10 frames before giving up if is_menu_down_fn(): return CalibPos(early_quit=True) img_frame, elapsed_time = camera_fn() ball_detected, ((x, y), radius) = detector_fn(img_frame, hue=hue) # If we found a ball roughly in the center that is large enough if ball_detected and ball_close_enough(x, y, radius): x_offset = round(x, 3) y_offset = round(y, 3) log.info(f"Offset calibrated: [{x_offset:.3f}, {y_offset:.3f}]") return CalibPos(position=(x_offset, y_offset), success=True) log.warning(f"Offset calibration failed.") return CalibPos() def calibrate_servo_offsets(pid_fn, env, stationary_vel=0.005, time_limit=20): start_time = time.time() action = Vector2(0, 0) # Initial high vel_history (to use the vel_hist[-100:] later) vel_x_hist = [1.0 for _ in range(100)] vel_y_hist = [1.0 for _ in range(100)] # Run until the ball has stabilized or the time limit was reached while time.time() < start_time + time_limit: state = env.step(action) action, info = pid_fn(state) (x, y, vel_x, vel_y, sum_x, sum_y), ball_detected, buttons = state # Quit on menu down if buttons.menu_button: return CalibServos(early_quit=True) if ball_detected: vel_x_hist.append(vel_x) vel_y_hist.append(vel_y) prev_100_x = np.mean(np.abs(vel_x_hist[-100:])) prev_100_y = np.mean(np.abs(vel_y_hist[-100:])) print("Prev 100: ", (prev_100_x, prev_100_y)) # If the average velocity for the last 100 timesteps is under the limit if (prev_100_x < stationary_vel) and (prev_100_y < stationary_vel): # Calculate offsets by calculating servo positions at the # current stable position and subtracting the `default` zeroed # position of the servos. servos = np.array(plate_angles_to_servo_positions(*action)) servos_zeroed = np.array(plate_angles_to_servo_positions(0, 0)) servo_offsets = list(servos - servos_zeroed) return CalibServos(servos=servo_offsets, success=True) # If the plate could be stabilized in time_limit seconds, quit log.warning(f"Servo calibration failed.") return CalibServos() def write_calibration(calibration_dict, calibration_file="bot.json"): log.info("Writing calibration.") # write out stuff with open(calibration_file, "w+") as outfile: log.info(f"Creating calibration file {calibration_file}") json.dump(calibration_dict, outfile, indent=4, sort_keys=True) def read_calibration(calibration_file="bot.json"): log.info("Reading previous calibration.") if os.path.isfile(calibration_file): with open(calibration_file, "r") as f: calibration_dict = json.load(f) else: # Use defaults calibration_dict = { "ball_hue": 44, "plate_offsets": (0.0, 0.0), "servo_offsets": (0.0, 0.0, 0.0), } return calibration_dict def wait_for_joystick_or_menu(hardware, sleep_time=1 / 30): """Waits for either the joystick or the menu. Returns the buttons""" while True: buttons = hardware.get_buttons() if buttons.menu_button or buttons.joy_button: return buttons time.sleep(sleep_time) if __name__ == "__main__": # Parse command line args parser = argparse.ArgumentParser() parser.add_argument("-d", "--debug", action="store_true") parser.add_argument("-f", "--file", default="bot.json", type=str) args, _ = parser.parse_known_args() main(args.file, debug=args.debug)
[ 2, 15069, 357, 66, 8, 5413, 10501, 13, 198, 2, 49962, 739, 262, 17168, 13789, 13, 198, 198, 37811, 198, 9771, 571, 1358, 22741, 198, 198, 5990, 23914, 36537, 329, 37409, 11, 3641, 286, 4676, 2292, 11, 290, 1113, 78, 49005, 198, 3781...
2.310358
2,713
from datetime import datetime, timedelta from django.test import TestCase from django.test.utils import override_settings from marketing.tasks import ( delete_multiple_contacts_tasks, list_all_bounces_unsubscribes, run_all_campaigns, run_campaign, send_campaign_email_to_admin_contact, send_scheduled_campaigns, upload_csv_file, ) from marketing.tests import TestMarketingModel
[ 6738, 4818, 8079, 1330, 4818, 8079, 11, 28805, 12514, 198, 198, 6738, 42625, 14208, 13, 9288, 1330, 6208, 20448, 198, 6738, 42625, 14208, 13, 9288, 13, 26791, 1330, 20957, 62, 33692, 198, 198, 6738, 7124, 13, 83, 6791, 1330, 357, 198, ...
2.900709
141
from py2html.main import * page = web() page.create() # Header Parameters # text = header text # n = title level page.header(text='My Site', n=1) # Label Parameters # text = label text # color = label color page.label(text='', color='') page.compile()
[ 6738, 12972, 17, 6494, 13, 12417, 1330, 1635, 198, 198, 7700, 796, 3992, 3419, 198, 7700, 13, 17953, 3419, 198, 198, 2, 48900, 40117, 198, 2, 220, 220, 2420, 796, 13639, 2420, 198, 2, 220, 220, 299, 796, 3670, 1241, 198, 7700, 13, ...
2.797872
94
import unittest from JorGpi.pickup.pickup import SmartPickUp,Reference,CommandLineOptions
[ 11748, 555, 715, 395, 198, 198, 6738, 449, 273, 38, 14415, 13, 27729, 929, 13, 27729, 929, 1330, 10880, 31686, 4933, 11, 26687, 11, 21575, 13949, 29046, 198 ]
3.25
28
from django.contrib import admin from django.contrib.auth import get_user_model User = get_user_model() admin.site.register(User)
[ 6738, 42625, 14208, 13, 3642, 822, 1330, 13169, 198, 6738, 42625, 14208, 13, 3642, 822, 13, 18439, 1330, 651, 62, 7220, 62, 19849, 198, 198, 12982, 796, 651, 62, 7220, 62, 19849, 3419, 198, 28482, 13, 15654, 13, 30238, 7, 12982, 8, ...
3.046512
43
# Copyright 2021 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 from django.test import TestCase from django.conf import settings from django.test.client import Client from spotseeker_server.models import Spot import simplejson as json from decimal import * from django.test.utils import override_settings from mock import patch from spotseeker_server import models
[ 2, 15069, 33448, 33436, 12, 2043, 11, 2059, 286, 2669, 198, 2, 30628, 55, 12, 34156, 12, 33234, 7483, 25, 24843, 12, 17, 13, 15, 198, 198, 6738, 42625, 14208, 13, 9288, 1330, 6208, 20448, 198, 6738, 42625, 14208, 13, 10414, 1330, 64...
3.833333
102
# this python script makes a rest call to Juniper Northstar to get active LSPs # usage: python get_active_LSPs.py import json import requests from requests.auth import HTTPBasicAuth from pprint import pprint import yaml from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) my_variables_in_yaml=import_variables_from_file() authuser = my_variables_in_yaml['northstar']['username'] authpwd = my_variables_in_yaml['northstar']['password'] url_base = 'http://' + my_variables_in_yaml['northstar']['ip'] + ':8091/NorthStar/API/v2/tenant/' url = url_base + '1/topology/1/te-lsps' headers = { 'Accept': 'application/json' } headers = { 'Content-type': 'application/json' } # r = requests.get(url, headers=headers, auth=(authuser, authpwd)) get_token() headers = {'Authorization':get_token(), 'Accept' : 'application/json', 'Content-Type' : 'application/json'} r = requests.get(url, headers=headers, verify=False) # type(r.json()) # pprint(r.json()) # This gives the names of all the LSPs that are active for item in r.json(): if item['operationalStatus'] == 'Active': print "This LSP is active: " + item['name']
[ 2, 428, 21015, 4226, 1838, 257, 1334, 869, 284, 7653, 9346, 2258, 7364, 284, 651, 4075, 406, 4303, 82, 220, 198, 2, 8748, 25, 21015, 651, 62, 5275, 62, 43, 4303, 82, 13, 9078, 198, 198, 11748, 33918, 198, 11748, 7007, 198, 6738, 7...
2.897129
418
# Copyright 2018 Adrien Guinet <adrien@guinet.me> # # 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, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # RUN: "%python" "%s" # import pydffi import sys F = pydffi.FFI() CU = F.cdef(''' #include <stdint.h> typedef int32_t MyInt; typedef struct { int a; int b; } A; ''') assert(CU.types.MyInt == F.Int32Ty) assert(isinstance(CU.types.A, pydffi.StructType))
[ 2, 15069, 2864, 1215, 15355, 1962, 42504, 1279, 324, 15355, 31, 5162, 42504, 13, 1326, 29, 198, 2, 220, 198, 2, 49962, 739, 262, 24843, 13789, 11, 10628, 362, 13, 15, 357, 1169, 366, 34156, 15341, 198, 2, 345, 743, 407, 779, 428, ...
2.993031
287
# coding=utf-8 # Copyright 2021 The Google Research 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 or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Environment wrapper around the maze navigation environment. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import copy from . import simple_maze import cv2 import numpy as np
[ 2, 19617, 28, 40477, 12, 23, 198, 2, 15069, 33448, 383, 3012, 4992, 46665, 13, 198, 2, 198, 2, 49962, 739, 262, 24843, 13789, 11, 10628, 362, 13, 15, 357, 1169, 366, 34156, 15341, 198, 2, 345, 743, 407, 779, 428, 2393, 2845, 287, ...
3.873303
221
# Generated by Django 3.2.5 on 2021-07-11 23:51 from django.db import migrations, models import django.db.models.deletion
[ 2, 2980, 515, 416, 37770, 513, 13, 17, 13, 20, 319, 33448, 12, 2998, 12, 1157, 2242, 25, 4349, 198, 198, 6738, 42625, 14208, 13, 9945, 1330, 15720, 602, 11, 4981, 198, 11748, 42625, 14208, 13, 9945, 13, 27530, 13, 2934, 1616, 295, ...
2.818182
44
import logging import os from decimal import Decimal from time import sleep import requests from hexbytes import HexBytes from web3 import Web3 from web3 import contract from web3.contract import Contract from config.constants import BASE_CURRENCIES from config.constants import GAS_LIMITS from config.constants import MULTICHAIN_CONFIG from config.enums import Network from src.harvester import IHarvester from src.misc_utils import hours from src.misc_utils import seconds_to_blocks from src.tx_utils import get_effective_gas_price from src.tx_utils import get_gas_price_of_tx from src.tx_utils import get_priority_fee from src.web3_utils import confirm_transaction from src.utils import get_abi from src.discord_utils import get_hash_from_failed_tx_error from src.web3_utils import get_last_harvest_times from src.token_utils import get_token_price from src.discord_utils import send_error_to_discord from src.discord_utils import send_success_to_discord logging.basicConfig(level=logging.INFO) MAX_TIME_BETWEEN_HARVESTS = hours(120) HARVEST_THRESHOLD = 0.0005 # min ratio of want to total vault AUM required to harvest NUM_FLASHBOTS_BUNDLES = 6
[ 11748, 18931, 198, 11748, 28686, 198, 6738, 32465, 1330, 4280, 4402, 198, 6738, 640, 1330, 3993, 198, 198, 11748, 7007, 198, 6738, 17910, 33661, 1330, 22212, 45992, 198, 6738, 3992, 18, 1330, 5313, 18, 198, 6738, 3992, 18, 1330, 2775, 1...
3.175824
364
#!/usr/bin/env python # License: Apache-2.0 # Copyright (C) 2020 Mikhail f. Shiryaev
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 198, 2, 13789, 25, 24843, 12, 17, 13, 15, 198, 2, 15069, 357, 34, 8, 12131, 42040, 277, 13, 21972, 3972, 1990, 628 ]
2.71875
32
#!/usr/bin/env python3 import os import sys MAX = 8 fpath = sys.argv[1] name = sys.argv[2] with open(fpath, "rb") as fh: sys.stdout.write("char %s[] = {" % (name,) ) i = 0 while True: if i > 0: sys.stdout.write(", ") if i % MAX == 0: sys.stdout.write("\n\t") c = fh.read(1) if not c: sys.stdout.write("\n") break sys.stdout.write("0x%.2x" % (ord(c), )) i = i + 1 print("};") print("") print("unsigned int %s_sz = %s;" % (name, i)) print("")
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 18, 198, 198, 11748, 28686, 198, 11748, 25064, 198, 198, 22921, 796, 807, 198, 198, 69, 6978, 796, 25064, 13, 853, 85, 58, 16, 60, 198, 3672, 796, 25064, 13, 853, 85, 58, 17, 60, 198, ...
1.808777
319
import unittest from reactivex import operators as ops from reactivex.testing import ReactiveTest, TestScheduler on_next = ReactiveTest.on_next on_completed = ReactiveTest.on_completed on_error = ReactiveTest.on_error subscribe = ReactiveTest.subscribe subscribed = ReactiveTest.subscribed disposed = ReactiveTest.disposed created = ReactiveTest.created if __name__ == "__main__": unittest.main()
[ 11748, 555, 715, 395, 198, 198, 6738, 32242, 87, 1330, 12879, 355, 39628, 198, 6738, 32242, 87, 13, 33407, 1330, 797, 5275, 14402, 11, 6208, 50, 1740, 18173, 198, 198, 261, 62, 19545, 796, 797, 5275, 14402, 13, 261, 62, 19545, 198, ...
3.147287
129
if __name__ == "__main__": T = int(input()) for t in range(T): n = int(input()) red = input() blue = input() solve(n, red, blue)
[ 628, 198, 361, 11593, 3672, 834, 6624, 366, 834, 12417, 834, 1298, 198, 220, 220, 220, 309, 796, 493, 7, 15414, 28955, 198, 220, 220, 220, 329, 256, 287, 2837, 7, 51, 2599, 198, 220, 220, 220, 220, 220, 220, 220, 299, 796, 493, ...
1.965517
87
# Copyright 2014 Scopely, 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, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Start polling of SQS and metadata.""" import shudder.queue as queue import shudder.metadata as metadata from shudder.config import CONFIG import time import os import requests import signal import subprocess import sys if __name__ == '__main__': sqs_connection, sqs_queue = queue.create_queue() sns_connection, subscription_arn = queue.subscribe_sns(sqs_queue) uncatchable = ['SIG_DFL','SIGSTOP','SIGKILL'] for i in [x for x in dir(signal) if x.startswith("SIG")]: if not i in uncatchable: signum = getattr(signal,i) signal.signal(signum, receive_signal) while True: message = queue.poll_queue(sqs_connection, sqs_queue) if message or metadata.poll_instance_metadata(): queue.clean_up_sns(sns_connection, subscription_arn, sqs_queue) if 'endpoint' in CONFIG: requests.get(CONFIG["endpoint"]) if 'endpoints' in CONFIG: for endpoint in CONFIG["endpoints"]: requests.get(endpoint) if 'commands' in CONFIG: for command in CONFIG["commands"]: print 'Running command: %s' % command process = subprocess.Popen(command) while process.poll() is None: time.sleep(30) """Send a heart beat to aws""" queue.record_lifecycle_action_heartbeat(message) """Send a complete lifecycle action""" queue.complete_lifecycle_action(message) sys.exit(0) time.sleep(5)
[ 2, 15069, 1946, 41063, 306, 11, 3457, 13, 198, 2, 198, 2, 49962, 739, 262, 24843, 13789, 11, 10628, 362, 13, 15, 357, 1169, 366, 34156, 15341, 198, 2, 345, 743, 407, 779, 428, 2393, 2845, 287, 11846, 351, 262, 13789, 13, 198, 2, ...
2.44581
895
import autograd.numpy as np from pyCHAMP.wavefunction.wf_base import WF from pyCHAMP.optimizer.minimize import Minimize from pyCHAMP.sampler.metropolis import Metropolis from pyCHAMP.sampler.hamiltonian import Hamiltonian from pyCHAMP.solver.vmc import VMC if __name__ == "__main__": wf = Hydrogen(nelec=1, ndim=3) sampler = Metropolis(nwalkers=1000, nstep=1000, step_size=3, nelec=1, ndim=3, domain={'min': -5, 'max': 5}) sampler = Hamiltonian(nwalkers=1000, nstep=1000, step_size=3, nelec=1, ndim=3) optimizer = Minimize(method='bfgs', maxiter=25, tol=1E-4) # VMS solver vmc = VMC(wf=wf, sampler=sampler, optimizer=optimizer) # single point opt_param = [1.] pos, e, s = vmc.single_point(opt_param) print('Energy : ', e) print('Variance : ', s) vmc.plot_density(pos) # optimization init_param = [0.5] vmc.optimize(init_param) vmc.plot_history()
[ 11748, 1960, 519, 6335, 13, 77, 32152, 355, 45941, 198, 198, 6738, 12972, 3398, 23518, 13, 19204, 8818, 13, 86, 69, 62, 8692, 1330, 370, 37, 198, 6738, 12972, 3398, 23518, 13, 40085, 7509, 13, 1084, 48439, 1330, 1855, 48439, 198, 6738...
2.186937
444
from braintree.configuration import Configuration from braintree.resource import Resource
[ 6738, 865, 2913, 631, 13, 11250, 3924, 1330, 28373, 198, 6738, 865, 2913, 631, 13, 31092, 1330, 20857, 198 ]
4.736842
19
import pygame import pygame.gfxdraw from constants import Constants
[ 11748, 12972, 6057, 198, 11748, 12972, 6057, 13, 70, 21373, 19334, 198, 6738, 38491, 1330, 4757, 1187, 628, 198 ]
3.684211
19
from pyqtgraph.Qt import QtCore, QtGui import numpy as np from scipy.spatial import distance as dist import glob import re import os from PyQt5 import QtGui from PyQt5.QtCore import * from PyQt5.QtGui import * import sys import cv2 import pandas as pd from PyQt5.Qt import * import pyqtgraph as pg #from PyQt4.Qt import * #%% #============================================================================== # #============================================================================== #============================================================================== # Close button - not implemented (hidden) #============================================================================== #============================================================================== # def closeEvent(self, event): # # quit_msg = "Are you sure you want to exit the program?" # reply = QtGui.QMessageBox.question(self, 'Message', # quit_msg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) # # if reply == QtGui.QMessageBox.Yes: # #event.accept() # app.quit() # else: # event.ignore() # #============================================================================== #============================================================================== # #self.originalEggRotBBox = eggRotBBox.copy() # #self.originalEggBoxPoints = eggBoxPoints.copy() # #self.currROI_eggRotBBox = self.eggRotBBox[self.intDivVal,self.withinSeqVal] # #self.currROI_eggBoxPoints = self.eggBoxPoints[self.intDivVal,self.withinSeqVal] # # # Modified version of updateOpenCVEggROICurrEmbryo # # Remove previous # self.diag.imv.removeItem(self.roi) # # Get relevant video position and ROI. # self.getSeqValsAndCurrROI() # # Get rotated bounding box points # ySorted = self.originalEggBoxPoints[np.argsort(self.originalEggBoxPoints[:, 1]), :] # # Get bottom most, and top most sorted corner points # bottomMost = ySorted[:2, :] # topMost = ySorted[2:, :] # # Get bottom most # bottomMost = bottomMost[np.argsort(bottomMost[:, 1]), :] # (bl, br) = bottomMost # # Use bottom-left coordinate as anchor to calculate the Euclidean distance between the # # The point with the largest distance will be our bottom-right point # D = dist.cdist(bl[np.newaxis], topMost, "euclidean")[0] # (tl, tr) = topMost[np.argsort(D)[::-1], :] # # Make ROI - note non 0,or 90 degree angles, require different of the X size # # Rectangular ROI used to enable more easy handling of corner handles for tracking user chagnges. # if (self.originalEggRotBBox[4] == -90.0) | (self.originalEggRotBBox[4] == -0.0)| (self.originalEggRotBBox[4] == 0.0): # self.roi = pg.ROI([bottomMost[0][0], bottomMost[0][1]], [self.originalEggRotBBox[2], self.originalEggRotBBox[3]]) # # roi = pg.EllipseROI([bottomMost[0][0], bottomMost[0][1]], [eggRotBBox[vidTime][2], eggRotBBox[vidTime][3]]) # else: # # Random angle ROIs # self.roi = pg.ROI([bottomMost[0][0], bottomMost[0][1]], [-self.originalEggRotBBox[2], self.originalEggRotBBox[3]]) # self.roi.setAngle(self.originalEggRotBBox[4], update=True) # # roi = pg.EllipseROI([bottomMost[0][0], bottomMost[0][1]], [-eggRotBBox[vidTime][2], eggRotBBox[vidTime][3]]) # # Add handles # self.roi.addRotateHandle([1, 0],[0.5,0.5]) # self.roi.addRotateHandle([0, 1], [0.5,0.5]) # self.roi.addScaleHandle([1, 1], [0, 0]) # self.roi.addScaleHandle([0, 0], [1, 1]) # self.roi.setPen('y',width=3) # self.roi.removable # self.roi.invertible = 'True' # # Make var for dealing with modifications to roi # self.updatedEggROI=[] # ### Still to do... # self.diag.imv.addItem(self.roi) # self.roi.sigRegionChangeFinished.connect(self.updateROI) #============================================================================== #===============
[ 6738, 12972, 80, 25297, 1470, 13, 48, 83, 1330, 33734, 14055, 11, 33734, 8205, 72, 198, 11748, 299, 32152, 355, 45941, 198, 6738, 629, 541, 88, 13, 2777, 34961, 1330, 5253, 355, 1233, 198, 11748, 15095, 198, 11748, 302, 198, 11748, 28...
2.394438
1,762
frase = input('Digite uma frase: ').upper().strip().replace(' ', '') tamanho = int(len(frase)) inverso = '' #Opo mais simples: # inverso = frase[::-1] for contador in range(tamanho-1, -1, -1): inverso += frase[contador] print('O inverso de {} {}'.format(frase, inverso)) if frase == inverso: print('Temos um palndromo!') else: print('A frase digitada no um palndromo!')
[ 8310, 589, 796, 5128, 10786, 19511, 578, 334, 2611, 1216, 589, 25, 705, 737, 45828, 22446, 36311, 22446, 33491, 10786, 46083, 10148, 8, 198, 83, 10546, 8873, 796, 493, 7, 11925, 7, 8310, 589, 4008, 198, 259, 332, 568, 796, 10148, 198,...
2.374233
163
from unittest import TestCase from options.pricing.binomial_trees import BinomialTreePricer from options.option import OptionType, Option
[ 198, 6738, 555, 715, 395, 1330, 6208, 20448, 198, 198, 6738, 3689, 13, 1050, 6345, 13, 8800, 49070, 62, 83, 6037, 1330, 20828, 49070, 27660, 47, 1173, 263, 198, 6738, 3689, 13, 18076, 1330, 16018, 6030, 11, 16018, 628 ]
3.615385
39
import atexit import os import sys import platform import json import glob import datetime import time import threading import tkinter as tk from pynput import mouse from pathlib import Path from playsound import playsound from enum import Enum import copy #"THE BEER-WARE LICENSE" (Revision 42): #bleach86 wrote this file. As long as you retain this notice you can do whatever you want with this stuff. #If we meet some day, and you think this stuff is worth it, you can buy me a beer in return input_fil = Path("/Users/sharpieman20/MCtimer/MCtimer") / "input.txt" # continuously read from input file every 10ms # when you get a "reset timer" message, reset the timer # # class Category: # def __init__(): # self.actions = [] # self.attempts = [] # # convert actions to attempts # def read(): # def write(): # class Actions(Enum): # CREATE_WORLD = 0 # START = 1 # class Attempt: stage = 0 ind = 0 time_count = 0 rsg = [ ("World Created", True), ([ "Savannah", "Desert", "Plains", "Other" ], False), ([ "0-15", "15-30", "30-45", "45-60", "60-75", "75+" ], False), ([ "Iron", "Logs", "Feathers", "Wool", "Gravel" ], True), ("Enter Nether", True), ("Find Fortress", True), ("Find Spawner", True), ("Exit Spawner", True), ("Exit Nether", True), ("Tower Build Start", True), ("Tower Build Finished", True), ("Tower Leave", True), ("Enter Stronghold", True), ("Enter End", True), ("Finish", True) ] cur_stages = {} json_file = 'mct_config.json' with open(json_file) as json_file: data2 = json.load(json_file) if data2['borderless'] == 'true': data2['borderless'] else: data2['borderless'] = False running_path = Path.cwd() NUM_CHARS = 11 system_type = platform.system() if system_type == 'Linux': directory = os.path.expanduser(data2['linux_saves']) elif system_type == 'Darwin': directory = os.path.expanduser(data2['mac_saves']) elif system_type == 'Windows': directory = os.path.expanduser(data2['windows_saves']) amount2 = 0 last_amount = 0 window = tk.Tk() # bg = BindGlobal(widget=window) window.text = tk.StringVar() window.text2 = tk.StringVar() window.text3 = tk.StringVar() window.text4 = tk.StringVar() window.geometry("{}x{}".format(data2["width"], data2["height"])) window.configure(bg='black') rt = time.time() old_version = False did_change = False count = 0 ig = 0 base = 0 program_time = 0 metronome_armed = False metronome_running = False metronome_active = False metronome_beats = int(data2['metronome_beats']) listener = None metronome_time = 0 base_update = int(data2['base_update']) rta_update = int(data2['rta_update']) * base_update metronome_bpm = int(data2['metronome_bpm']) metronome_interval = 0 if data2['auto_start'] == 'true': click1 = 1 click2 = 1 else: click1 = 0 click2 = 0 cur_fil = None world_base_time = 0 # def update_split() ''' METRONOME CODE ''' ''' Metronome mouse listener ''' atexit.register(exit_handler) ''' Sound playing code ''' ''' Metronome functions ''' main()
[ 11748, 379, 37023, 198, 11748, 28686, 198, 11748, 25064, 198, 11748, 3859, 198, 11748, 33918, 198, 11748, 15095, 198, 11748, 4818, 8079, 198, 11748, 640, 198, 11748, 4704, 278, 198, 11748, 256, 74, 3849, 355, 256, 74, 198, 6738, 279, 20...
2.452075
1,325
""" Other useful structs """ from __future__ import absolute_import from collections import namedtuple """A topic and partition tuple Keyword Arguments: topic (str): A topic name partition (int): A partition id """ TopicPartition = namedtuple("TopicPartition", ["topic", "partition"]) """A Kafka broker metadata used by admin tools. Keyword Arguments: nodeID (int): The Kafka broker id. host (str): The Kafka broker hostname. port (int): The Kafka broker port. rack (str): The rack of the broker, which is used to in rack aware partition assignment for fault tolerance. Examples: `RACK1`, `us-east-1d`. Default: None """ BrokerMetadata = namedtuple("BrokerMetadata", ["nodeId", "host", "port", "rack"]) """A topic partition metadata describing the state in the MetadataResponse. Keyword Arguments: topic (str): The topic name of the partition this metadata relates to. partition (int): The id of the partition this metadata relates to. leader (int): The id of the broker that is the leader for the partition. replicas (List[int]): The ids of all brokers that contain replicas of the partition. isr (List[int]): The ids of all brokers that contain in-sync replicas of the partition. error (KafkaError): A KafkaError object associated with the request for this partition metadata. """ PartitionMetadata = namedtuple("PartitionMetadata", ["topic", "partition", "leader", "replicas", "isr", "error"]) """The Kafka offset commit API The Kafka offset commit API allows users to provide additional metadata (in the form of a string) when an offset is committed. This can be useful (for example) to store information about which node made the commit, what time the commit was made, etc. Keyword Arguments: offset (int): The offset to be committed metadata (str): Non-null metadata """ OffsetAndMetadata = namedtuple("OffsetAndMetadata", # TODO add leaderEpoch: OffsetAndMetadata(offset, leaderEpoch, metadata) ["offset", "metadata"]) """An offset and timestamp tuple Keyword Arguments: offset (int): An offset timestamp (int): The timestamp associated to the offset """ OffsetAndTimestamp = namedtuple("OffsetAndTimestamp", ["offset", "timestamp"]) MemberInformation = namedtuple("MemberInformation", ["member_id", "client_id", "client_host", "member_metadata", "member_assignment"]) GroupInformation = namedtuple("GroupInformation", ["error_code", "group", "state", "protocol_type", "protocol", "members", "authorized_operations"]) """Define retry policy for async producer Keyword Arguments: Limit (int): Number of retries. limit >= 0, 0 means no retries backoff_ms (int): Milliseconds to backoff. retry_on_timeouts: """ RetryOptions = namedtuple("RetryOptions", ["limit", "backoff_ms", "retry_on_timeouts"])
[ 37811, 3819, 4465, 2878, 82, 37227, 198, 6738, 11593, 37443, 834, 1330, 4112, 62, 11748, 198, 198, 6738, 17268, 1330, 3706, 83, 29291, 628, 198, 37811, 32, 7243, 290, 18398, 46545, 198, 198, 9218, 4775, 20559, 2886, 25, 198, 220, 220, ...
3.117146
939
import cv2 from trackers.tracker import create_blob, add_new_blobs, remove_duplicates import numpy as np from collections import OrderedDict from detectors.detector import get_bounding_boxes import uuid import os import contextlib from datetime import datetime import argparse from utils.detection_roi import get_roi_frame, draw_roi from counter import get_counting_line, is_passed_counting_line # parse CLI arguments parser = argparse.ArgumentParser() parser.add_argument('video', help='relative/absolute path to video or camera input of traffic scene') parser.add_argument('--iscam', action='store_true', help='specify if video capture is from a camera') parser.add_argument('--droi', help='specify a detection region of interest (ROI) \ i.e a set of vertices that represent the area (polygon) \ where you want detections to be made (format: 1,2|3,4|5,6|7,8|9,10 \ default: 0,0|frame_width,0|frame_width,frame_height|0,frame_height \ [i.e the whole video frame])') parser.add_argument('--showdroi', action='store_true', help='display/overlay the detection roi on the video') parser.add_argument('--mctf', type=int, help='maximum consecutive tracking failures \ i.e number of tracking failures before the tracker concludes \ the tracked object has left the frame') parser.add_argument('--di', type=int, help='detection interval i.e number of frames \ before detection is carried out again (in order to find new vehicles \ and update the trackers of old ones)') parser.add_argument('--detector', help='select a model/algorithm to use for vehicle detection \ (options: yolo, haarc, bgsub, ssd | default: yolo)') parser.add_argument('--tracker', help='select a model/algorithm to use for vehicle tracking \ (options: csrt, kcf, camshift | default: kcf)') parser.add_argument('--record', action='store_true', help='record video and vehicle count logs') parser.add_argument('--clposition', help='position of counting line (options: top, bottom, \ left, right | default: bottom)') parser.add_argument('--hideimage', action='store_true', help='hide resulting image') args = parser.parse_args() # capture traffic scene video video = int(args.video) if args.iscam else args.video cap = cv2.VideoCapture(video) _, frame = cap.read() # configs blobs = OrderedDict() blob_id = 1 frame_counter = 0 DETECTION_INTERVAL = 10 if args.di == None else args.di MAX_CONSECUTIVE_TRACKING_FAILURES = 3 if args.mctf == None else args.mctf detector = 'yolo' if args.detector == None else args.detector tracker = 'kcf' if args.tracker == None else args.tracker f_height, f_width, _ = frame.shape # init video object and log file to record counting if args.record: output_video = cv2.VideoWriter('./videos/output.avi', cv2.VideoWriter_fourcc('M','J','P','G'), 30, (f_width, f_height)) log_file_name = 'log.txt' with contextlib.suppress(FileNotFoundError): os.remove(log_file_name) log_file = open(log_file_name, 'a') log_file.write('vehicle_id, count, datetime\n') log_file.flush() # set counting line clposition = 'bottom' if args.clposition == None else args.clposition counting_line = get_counting_line(clposition, f_width, f_height) vehicle_count = 0 # create detection ROI droi = [(0, 0), (f_width, 0), (f_width, f_height), (0, f_height)] if args.droi: droi = [] points = args.droi.replace(' ', '').split('|') for point_str in points: point = tuple(map(int, point_str.split(','))) droi.append(point) # initialize trackers and create new blobs droi_frame = get_roi_frame(frame, droi) initial_bboxes = get_bounding_boxes(droi_frame, detector) for box in initial_bboxes: _blob = create_blob(box, frame, tracker) blobs[blob_id] = _blob blob_id += 1 while True: k = cv2.waitKey(1) if args.iscam or cap.get(cv2.CAP_PROP_POS_FRAMES) + 1 < cap.get(cv2.CAP_PROP_FRAME_COUNT): _, frame = cap.read() nframes = cap.get(cv2.CAP_PROP_POS_FRAMES) frame_count = cap.get(cv2.CAP_PROP_FRAME_COUNT) if nframes % 10 == 0 or nframes == 1: print("Processing {} of {} frames".format(nframes,frame_count)) for _id, blob in list(blobs.items()): # update trackers success, box = blob.tracker.update(frame) if success: blob.num_consecutive_tracking_failures = 0 blob.update(box) else: blob.num_consecutive_tracking_failures += 1 # delete untracked blobs if blob.num_consecutive_tracking_failures >= MAX_CONSECUTIVE_TRACKING_FAILURES: del blobs[_id] # count vehicles if is_passed_counting_line(blob.centroid, counting_line, clposition) and not blob.counted: blob.counted = True vehicle_count += 1 # log count data to a file (vehicle_id, count, datetime) if args.record: _row = '{0}, {1}, {2}\n'.format('v_' + str(_id), vehicle_count, datetime.now()) log_file.write(_row) log_file.flush() if frame_counter >= DETECTION_INTERVAL: # rerun detection droi_frame = get_roi_frame(frame, droi) boxes = get_bounding_boxes(droi_frame, detector) blobs, current_blob_id = add_new_blobs(boxes, blobs, frame, tracker, blob_id, counting_line, clposition) blob_id = current_blob_id blobs = remove_duplicates(blobs) frame_counter = 0 # draw and label blob bounding boxes for _id, blob in blobs.items(): (x, y, w, h) = [int(v) for v in blob.bounding_box] cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2) cv2.putText(frame, 'v_' + str(_id), (x, y - 2), cv2.FONT_HERSHEY_DUPLEX, 1, (0, 255, 0), 2, cv2.LINE_AA) # draw counting line cv2.line(frame, counting_line[0], counting_line[1], (0, 255, 0), 3) # display vehicle count cv2.putText(frame, 'Count: ' + str(vehicle_count), (20, 60), cv2.FONT_HERSHEY_DUPLEX, 2, (255, 0, 0), 2, cv2.LINE_AA) # show detection roi if args.showdroi: frame = draw_roi(frame, droi) # save frame in video output if args.record: output_video.write(frame) # visualize vehicle counting if not args.hideimage: resized_frame = cv2.resize(frame, (858, 480)) cv2.imshow('tracking', resized_frame) frame_counter += 1 # save frame if 's' key is pressed if k & 0xFF == ord('s'): cv2.imwrite(os.path.join('screenshots', 'ss_' + uuid.uuid4().hex + '.png'), frame) print('Screenshot taken.') else: print('End of video.') # end video loop if on the last frame break # end video loop if 'q' key is pressed if k & 0xFF == ord('q'): print('Video exited.') break # end capture, close window, close log file and video objects if any cap.release() if not args.hideimage: cv2.destroyAllWindows() if args.record: log_file.close() output_video.release()
[ 11748, 269, 85, 17, 198, 6738, 2610, 364, 13, 2213, 10735, 1330, 2251, 62, 2436, 672, 11, 751, 62, 3605, 62, 2436, 8158, 11, 4781, 62, 646, 489, 16856, 198, 11748, 299, 32152, 355, 45941, 198, 6738, 17268, 1330, 14230, 1068, 35, 713...
2.321553
3,169
from flask import request from resources.api_view import ApiView from exceptions.invalid_usage_exception import InvalidUsageException from models.user.user import User from models.user.authenticated_user import AuthenticatedUser
[ 6738, 42903, 1330, 2581, 198, 6738, 4133, 13, 15042, 62, 1177, 1330, 5949, 72, 7680, 198, 6738, 13269, 13, 259, 12102, 62, 26060, 62, 1069, 4516, 1330, 17665, 28350, 16922, 198, 6738, 4981, 13, 7220, 13, 7220, 1330, 11787, 198, 6738, ...
4.259259
54
# Copyright 2018 Contributors to Hyperledger Sawtooth # # 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, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ----------------------------------------------------------------------------- """ Propose Role Add Member Test """ # pylint: disable=invalid-name import time import requests import pytest from rbac.common.logs import get_logger from tests.rbac import helper from tests.rbac.api.assertions import assert_api_error from tests.rbac.api.assertions import assert_api_success from tests.rbac.api.assertions import assert_api_post_requires_auth LOGGER = get_logger(__name__)
[ 2, 15069, 2864, 25767, 669, 284, 15079, 992, 1362, 19882, 1462, 849, 198, 2, 198, 2, 49962, 739, 262, 24843, 13789, 11, 10628, 362, 13, 15, 357, 1169, 366, 34156, 15341, 198, 2, 345, 743, 407, 779, 428, 2393, 2845, 287, 11846, 351, ...
3.762238
286
import cv2 import os import numpy as np from PIL import Image if __name__ == '__main__': im_dir = '/media/hy/Seagate Expansion Drive/Results/merge_dir/' # video_dir = '/media/hy/Seagate Expansion Drive/Results/sandy.mp4' # fps = 15 # frame2video(im_dir, video_dir, fps)
[ 11748, 269, 85, 17, 198, 11748, 28686, 198, 11748, 299, 32152, 355, 45941, 198, 6738, 350, 4146, 1330, 7412, 628, 198, 198, 361, 11593, 3672, 834, 6624, 705, 834, 12417, 834, 10354, 198, 220, 220, 220, 545, 62, 15908, 796, 31051, 1143...
2.478992
119
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Dec 14 17:38:48 2020 @author: luke """ import sys from functools import partial import torch import torch.nn as nn import prettytable as pt from .basic_hook import MODULES_MAPPING def compute_average_compute_cost(self): """ A method that will be available after add_computing_methods() is called on a desired net object. Returns current mean flops/mac consumption per image. """ batches_count = self.__batch_counter__ flops_sum = 0 mac_sum = 0 params_sum = 0 for module in self.modules(): if is_supported_instance(module): flops_sum += module.__flops__ mac_sum += module.__mac__ params_sum = get_model_parameters_number(self) return flops_sum / batches_count, mac_sum / batches_count, params_sum def start_compute(self, **kwargs): """ A method that will be available after add_computing_methods() is called on a desired net object. Activates the computation of mean flops/mac consumption per image. Call it before you run the network. """ add_batch_counter_hook_function(self) seen_types = set() self.apply(partial(add_compute_hook_function, **kwargs)) def stop_compute(self): """ A method that will be available after add_computing_methods() is called on a desired net object. Stops computing the mean flops consumption per image. Call whenever you want to pause the computation. """ remove_batch_counter_hook_function(self) self.apply(remove_compute_hook_function) def reset_compute(self): """ A method that will be available after add_computing_methods() is called on a desired net object. Resets statistics computed so far. """ add_batch_counter_variables_or_reset(self) self.apply(add_compute_variable_or_reset)
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 18, 198, 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 37811, 198, 41972, 319, 2892, 4280, 1478, 1596, 25, 2548, 25, 2780, 12131, 198, 198, 31, 9800, 25, 300, 4649, 198...
2.819672
671
# SPDX-License-Identifier: MIT # Copyright (C) 2019-2020 Tobias Gruetzmacher # Copyright (C) 2019-2020 Daniel Ring from ..scraper import _ParserScraper from ..helpers import indirectStarter
[ 2, 30628, 55, 12, 34156, 12, 33234, 7483, 25, 17168, 198, 2, 15069, 357, 34, 8, 13130, 12, 42334, 46675, 25665, 23773, 76, 3493, 198, 2, 15069, 357, 34, 8, 13130, 12, 42334, 7806, 12569, 198, 6738, 11485, 1416, 38545, 1330, 4808, 46...
3.472727
55
""" Function are subprograms which are used to compute a value or perform a task. Type of Functions:- Built in Functions: print(), upper() User define functions Advantage of Functions 1. Write once and use it as many time as you need. This provides code reusability 2. Function facilitates ease of code maintenance 3. Divide Large task into many small task so it will help you to debug code 4. You can remove or add new feature to a function anytime. """ """ We can define a function using def keyword followed by function name with parentheses. This is also called as Creating a function, Writing a Function, Defining a FUnction. Syntax:- def function_name(): Local Variable block of statement return(variable or expression) def function_name(param1, param2, param3, .....) Local Variable Block of statement return (variable or expression) Note - Nooed to mainitain a proper indentation """ # creating a list if __name__ == '__main__': add() print() # another method if __name__ == '__main__': sum_list() print() if __name__ == '__main__': multiplylist() # Method 2: Unsing numpy.prid() ^ Install numpy package import numpy product_total() print() findingminmax(22, 26, 30) print() print("Another Method to find maximum") x = int(input("Enter your first Number: ")) y = int(input("Enter your second Number: ")) z = int(input("Enter your third Number: ")) print("Maximum number is ::>", findingmaximum(x, y, z)) """Python program to print the even numbers from a given list""" find_even() print() """ Pythhon program to find prime numbers in given list Function should return true if the number is prime; else false """ number =int(input("Enter the number you will like to check whether the number is prime or not: \n")) if isPrime(number): print(number, "is a Prime Number") else: print(number, "is not a Prime number") """ Another Method to find prime number """
[ 37811, 198, 22203, 389, 850, 23065, 82, 543, 389, 973, 284, 24061, 257, 1988, 393, 1620, 257, 4876, 13, 198, 198, 6030, 286, 40480, 21912, 198, 198, 39582, 287, 40480, 25, 198, 220, 220, 220, 220, 220, 220, 3601, 22784, 6727, 3419, ...
3.330508
590
# coding: utf-8 import click if __name__ == "__main__": main()
[ 2, 19617, 25, 3384, 69, 12, 23, 198, 11748, 3904, 628, 198, 198, 361, 11593, 3672, 834, 6624, 366, 834, 12417, 834, 1298, 198, 220, 220, 220, 1388, 3419, 198 ]
2.333333
30
from enum import Enum, auto from subprocess import CalledProcessError, run from pitop.common.command_runner import run_command from pitop.common.logger import PTLogger def send_notification( title: str, text: str, icon_name: str = "", timeout: int = 0, app_name: str = "", notification_id: int = -1, actions_manager: NotificationActionManager = None, urgency_level: NotificationUrgencyLevel = None, capture_notification_id: bool = True, ) -> str: # Check that `notify-send-ng` is available, as it's not a hard dependency of the package try: run(["dpkg-query", "-l", "notify-send-ng"], capture_output=True, check=True) except CalledProcessError: raise Exception("notify-send-ng not installed") cmd = "/usr/bin/notify-send " cmd += "--print-id " cmd += "--expire-time=" + str(timeout) + " " if icon_name: cmd += "--icon=" + icon_name + " " if notification_id >= 0: cmd += "--replace=" + str(notification_id) + " " if actions_manager is not None: for action in actions_manager.actions: cmd += ( '--action="' + action.call_to_action_text + ":" + action.command_str + '" ' ) if actions_manager.default_action is not None: cmd += ( "--default-action=" + actions_manager.default_action.command_str + " " ) if actions_manager.close_action is not None: cmd += "--close-action=" + actions_manager.close_action.command_str + " " if app_name: cmd += "--app-name=" + app_name + " " if urgency_level is not None: cmd += "--urgency=" + urgency_level.name + " " cmd += ' "' + title + '" ' cmd += '"' + text + '"' PTLogger.info("notify-send command: {}".format(cmd)) try: resp_stdout = run_command(cmd, 2000, capture_output=capture_notification_id) except Exception as e: PTLogger.warning("Failed to show message: {}".format(e)) raise return resp_stdout
[ 6738, 33829, 1330, 2039, 388, 11, 8295, 198, 6738, 850, 14681, 1330, 34099, 18709, 12331, 11, 1057, 198, 198, 6738, 6028, 404, 13, 11321, 13, 21812, 62, 16737, 1330, 1057, 62, 21812, 198, 6738, 6028, 404, 13, 11321, 13, 6404, 1362, 13...
2.3534
897
# xy to location # # Gismo is a plugin for GIS environmental analysis (GPL) started by Djordje Spasic. # # This file is part of Gismo. # # Copyright (c) 2019, Djordje Spasic <djordjedspasic@gmail.com> # Gismo 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. # # Gismo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. # # The GPL-3.0+ license <http://spdx.org/licenses/GPL-3.0+> """ Use this component to calculate latitude and longitude coordinates of the _point in Rhino scene. For example: you created some building shapes with Gismo "OSM Shapes" component, and now you would like to check what are the latitude and longtitude coordinates of particular part of the building. - Provided by Gismo 0.0.3 input: _point: A point for which we would like to calculate its latitude and longitude coordinates anchorLocation_: Represents latitude,longitude coordinates which correspond to anchorOrigin_ in Rhino scene. - If nothing added to this input, anchorLocation_ with both latitude and longitude set to "0" will be used as a default. anchorOrigin_: A point in Rhino scene which corresponds to anchorLocation_. - If nothing added to this input, anchorOrigin will be set to: 0,0,0. output: readMe!: ... location: Location (latitude, longitude coordinates) of the _point input. """ ghenv.Component.Name = "Gismo_XY To Location" ghenv.Component.NickName = "XYtoLocation" ghenv.Component.Message = "VER 0.0.3\nJAN_29_2019" ghenv.Component.IconDisplayMode = ghenv.Component.IconDisplayMode.application ghenv.Component.Category = "Gismo" ghenv.Component.SubCategory = "1 | Gismo" #compatibleGismoVersion = VER 0.0.3\nJAN_29_2019 try: ghenv.Component.AdditionalHelpFromDocStrings = "2" except: pass import scriptcontext as sc import Grasshopper import Rhino level = Grasshopper.Kernel.GH_RuntimeMessageLevel.Warning if sc.sticky.has_key("gismoGismo_released"): validVersionDate, printMsg = sc.sticky["gismo_check"].versionDate(ghenv.Component) if validVersionDate: gismo_preparation = sc.sticky["gismo_Preparation"]() gismo_gis = sc.sticky["gismo_GIS"]() location, validInputData, printMsg = main(_point, anchorLocation_, anchorOrigin_) if not validInputData: print printMsg ghenv.Component.AddRuntimeMessage(level, printMsg) else: print printMsg ghenv.Component.AddRuntimeMessage(level, printMsg) else: printMsg = "First please run the Gismo Gismo component." print printMsg ghenv.Component.AddRuntimeMessage(level, printMsg)
[ 2, 2124, 88, 284, 4067, 201, 198, 2, 201, 198, 2, 402, 44126, 318, 257, 13877, 329, 402, 1797, 6142, 3781, 357, 38, 6489, 8, 2067, 416, 19307, 585, 18015, 1338, 292, 291, 13, 201, 198, 2, 201, 198, 2, 770, 2393, 318, 636, 286, ...
2.794983
1,156
# pylint: disable-msg=C0103 """ SentinelAnomalyLookup: This package is developed for Azure Sentinel Anomaly lookup """ # __init__.py from .anomaly_lookup_view_helper import AnomalyLookupViewHelper from .anomaly_finder import AnomalyQueries, AnomalyFinder
[ 2, 279, 2645, 600, 25, 15560, 12, 19662, 28, 34, 486, 3070, 198, 37811, 198, 31837, 20538, 2025, 24335, 8567, 929, 25, 770, 5301, 318, 4166, 329, 22134, 26716, 1052, 24335, 35847, 198, 37811, 198, 198, 2, 11593, 15003, 834, 13, 9078, ...
3.2
80
import pygame from pygame.sprite import Sprite
[ 11748, 12972, 6057, 198, 6738, 12972, 6057, 13, 34975, 578, 1330, 33132, 628 ]
3.692308
13
from geo.calc import Calc from geo.calc import Distance from geo.geosp import Wt from geo.geosp import Gh from geo.files.csv_file import check
[ 6738, 40087, 13, 9948, 66, 1330, 2199, 66, 198, 6738, 40087, 13, 9948, 66, 1330, 34600, 198, 6738, 40087, 13, 469, 2117, 1330, 370, 83, 198, 6738, 40087, 13, 469, 2117, 1330, 11972, 198, 6738, 40087, 13, 16624, 13, 40664, 62, 7753, ...
3.227273
44
from pathlib import Path from nb_helpers.clean import clean_all, clean_one from tests import TEST_PATH TEST_PATH TEST_NB = Path("test_nb.py") def test_clean_one(): "clean just one nb" clean_one(TEST_NB) def test_clean_all(): "clean all test nbs" clean_all(path=TEST_PATH)
[ 6738, 3108, 8019, 1330, 10644, 198, 6738, 299, 65, 62, 16794, 364, 13, 27773, 1330, 3424, 62, 439, 11, 3424, 62, 505, 198, 6738, 5254, 1330, 43001, 62, 34219, 198, 198, 51, 6465, 62, 34219, 198, 51, 6465, 62, 32819, 796, 10644, 7203...
2.483051
118
import streamlit as st
[ 11748, 4269, 18250, 355, 336, 198 ]
3.833333
6
from __future__ import absolute_import from mock import patch from django.db import IntegrityError from sentry.mediators.sentry_apps import Creator from sentry.models import ( AuditLogEntry, AuditLogEntryEvent, ApiApplication, IntegrationFeature, SentryApp, SentryAppComponent, User, ) from sentry.testutils import TestCase
[ 6738, 11593, 37443, 834, 1330, 4112, 62, 11748, 198, 198, 6738, 15290, 1330, 8529, 198, 6738, 42625, 14208, 13, 9945, 1330, 39348, 12331, 198, 198, 6738, 1908, 563, 13, 2379, 2024, 13, 82, 13000, 62, 18211, 1330, 21038, 198, 6738, 1908,...
3.114035
114
# This file was automatically created by FeynRules 2.3.32 # Mathematica version: 11.3.0 for Mac OS X x86 (64-bit) (March 7, 2018) # Date: Sat 21 Apr 2018 20:48:39 from object_library import all_parameters, Parameter from function_library import complexconjugate, re, im, csc, sec, acsc, asec, cot # This is a default parameter object representing 0. ZERO = Parameter(name = 'ZERO', nature = 'internal', type = 'real', value = '0.0', texname = '0') # User-defined parameters. cabi = Parameter(name = 'cabi', nature = 'external', type = 'real', value = 0.227736, texname = '\\theta _c', lhablock = 'CKMBLOCK', lhacode = [ 1 ]) aEWM1 = Parameter(name = 'aEWM1', nature = 'external', type = 'real', value = 127.9, texname = '\\text{aEWM1}', lhablock = 'SMINPUTS', lhacode = [ 1 ]) Gf = Parameter(name = 'Gf', nature = 'external', type = 'real', value = 0.0000116637, texname = 'G_f', lhablock = 'SMINPUTS', lhacode = [ 2 ]) aS = Parameter(name = 'aS', nature = 'external', type = 'real', value = 0.1184, texname = '\\alpha _s', lhablock = 'SMINPUTS', lhacode = [ 3 ]) ymdo = Parameter(name = 'ymdo', nature = 'external', type = 'real', value = 0.00504, texname = '\\text{ymdo}', lhablock = 'YUKAWA', lhacode = [ 1 ]) ymup = Parameter(name = 'ymup', nature = 'external', type = 'real', value = 0.00255, texname = '\\text{ymup}', lhablock = 'YUKAWA', lhacode = [ 2 ]) yms = Parameter(name = 'yms', nature = 'external', type = 'real', value = 0.101, texname = '\\text{yms}', lhablock = 'YUKAWA', lhacode = [ 3 ]) ymc = Parameter(name = 'ymc', nature = 'external', type = 'real', value = 1.27, texname = '\\text{ymc}', lhablock = 'YUKAWA', lhacode = [ 4 ]) ymb = Parameter(name = 'ymb', nature = 'external', type = 'real', value = 4.7, texname = '\\text{ymb}', lhablock = 'YUKAWA', lhacode = [ 5 ]) ymt = Parameter(name = 'ymt', nature = 'external', type = 'real', value = 172, texname = '\\text{ymt}', lhablock = 'YUKAWA', lhacode = [ 6 ]) yme = Parameter(name = 'yme', nature = 'external', type = 'real', value = 0.000511, texname = '\\text{yme}', lhablock = 'YUKAWA', lhacode = [ 11 ]) ymm = Parameter(name = 'ymm', nature = 'external', type = 'real', value = 0.10566, texname = '\\text{ymm}', lhablock = 'YUKAWA', lhacode = [ 13 ]) ymtau = Parameter(name = 'ymtau', nature = 'external', type = 'real', value = 1.777, texname = '\\text{ymtau}', lhablock = 'YUKAWA', lhacode = [ 15 ]) kq = Parameter(name = 'kq', nature = 'external', type = 'real', value = 0.001, texname = 'k_q', lhablock = 'FRBlock', lhacode = [ 1 ]) lamf = Parameter(name = 'lamf', nature = 'external', type = 'real', value = 0.1, texname = 'l_{\\text{fi}}', lhablock = 'FRBlock', lhacode = [ 2 ]) yf1x1 = Parameter(name = 'yf1x1', nature = 'external', type = 'complex', value = 0, texname = '\\text{yf1x1}', lhablock = 'FRBlock6', lhacode = [ 1, 1 ]) yf1x2 = Parameter(name = 'yf1x2', nature = 'external', type = 'complex', value = 0, texname = '\\text{yf1x2}', lhablock = 'FRBlock6', lhacode = [ 1, 2 ]) yf1x3 = Parameter(name = 'yf1x3', nature = 'external', type = 'complex', value = 0, texname = '\\text{yf1x3}', lhablock = 'FRBlock6', lhacode = [ 1, 3 ]) yf2x1 = Parameter(name = 'yf2x1', nature = 'external', type = 'complex', value = 0, texname = '\\text{yf2x1}', lhablock = 'FRBlock6', lhacode = [ 2, 1 ]) yf2x2 = Parameter(name = 'yf2x2', nature = 'external', type = 'complex', value = 0, texname = '\\text{yf2x2}', lhablock = 'FRBlock6', lhacode = [ 2, 2 ]) yf2x3 = Parameter(name = 'yf2x3', nature = 'external', type = 'complex', value = 1.e-6, texname = '\\text{yf2x3}', lhablock = 'FRBlock6', lhacode = [ 2, 3 ]) yf3x1 = Parameter(name = 'yf3x1', nature = 'external', type = 'complex', value = 0, texname = '\\text{yf3x1}', lhablock = 'FRBlock6', lhacode = [ 3, 1 ]) yf3x2 = Parameter(name = 'yf3x2', nature = 'external', type = 'complex', value = 0, texname = '\\text{yf3x2}', lhablock = 'FRBlock6', lhacode = [ 3, 2 ]) yf3x3 = Parameter(name = 'yf3x3', nature = 'external', type = 'complex', value = 0, texname = '\\text{yf3x3}', lhablock = 'FRBlock6', lhacode = [ 3, 3 ]) MZ = Parameter(name = 'MZ', nature = 'external', type = 'real', value = 91.1876, texname = '\\text{MZ}', lhablock = 'MASS', lhacode = [ 23 ]) Me = Parameter(name = 'Me', nature = 'external', type = 'real', value = 0.000511, texname = '\\text{Me}', lhablock = 'MASS', lhacode = [ 11 ]) MMU = Parameter(name = 'MMU', nature = 'external', type = 'real', value = 0.10566, texname = '\\text{MMU}', lhablock = 'MASS', lhacode = [ 13 ]) MTA = Parameter(name = 'MTA', nature = 'external', type = 'real', value = 1.777, texname = '\\text{MTA}', lhablock = 'MASS', lhacode = [ 15 ]) MU = Parameter(name = 'MU', nature = 'external', type = 'real', value = 0.00255, texname = 'M', lhablock = 'MASS', lhacode = [ 2 ]) MC = Parameter(name = 'MC', nature = 'external', type = 'real', value = 1.27, texname = '\\text{MC}', lhablock = 'MASS', lhacode = [ 4 ]) MT = Parameter(name = 'MT', nature = 'external', type = 'real', value = 172, texname = '\\text{MT}', lhablock = 'MASS', lhacode = [ 6 ]) MD = Parameter(name = 'MD', nature = 'external', type = 'real', value = 0.00504, texname = '\\text{MD}', lhablock = 'MASS', lhacode = [ 1 ]) MS = Parameter(name = 'MS', nature = 'external', type = 'real', value = 0.101, texname = '\\text{MS}', lhablock = 'MASS', lhacode = [ 3 ]) MB = Parameter(name = 'MB', nature = 'external', type = 'real', value = 4.7, texname = '\\text{MB}', lhablock = 'MASS', lhacode = [ 5 ]) MH = Parameter(name = 'MH', nature = 'external', type = 'real', value = 125, texname = '\\text{MH}', lhablock = 'MASS', lhacode = [ 25 ]) MP = Parameter(name = 'MP', nature = 'external', type = 'real', value = 120, texname = '\\text{MP}', lhablock = 'MASS', lhacode = [ 9000005 ]) Mfi = Parameter(name = 'Mfi', nature = 'external', type = 'real', value = 10, texname = '\\text{Mfi}', lhablock = 'MASS', lhacode = [ 9000006 ]) WZ = Parameter(name = 'WZ', nature = 'external', type = 'real', value = 2.4952, texname = '\\text{WZ}', lhablock = 'DECAY', lhacode = [ 23 ]) WW = Parameter(name = 'WW', nature = 'external', type = 'real', value = 2.085, texname = '\\text{WW}', lhablock = 'DECAY', lhacode = [ 24 ]) WT = Parameter(name = 'WT', nature = 'external', type = 'real', value = 1.50833649, texname = '\\text{WT}', lhablock = 'DECAY', lhacode = [ 6 ]) WH = Parameter(name = 'WH', nature = 'external', type = 'real', value = 0.00589569, texname = '\\text{WH}', lhablock = 'DECAY', lhacode = [ 25 ]) WH1 = Parameter(name = 'WH1', nature = 'external', type = 'real', value = 0.00575308848, texname = '\\text{WH1}', lhablock = 'DECAY', lhacode = [ 9000005 ]) Wfi = Parameter(name = 'Wfi', nature = 'external', type = 'real', value = 6.03044e-9, texname = '\\text{Wfi}', lhablock = 'DECAY', lhacode = [ 9000006 ]) aEW = Parameter(name = 'aEW', nature = 'internal', type = 'real', value = '1/aEWM1', texname = '\\alpha _{\\text{EW}}') G = Parameter(name = 'G', nature = 'internal', type = 'real', value = '2*cmath.sqrt(aS)*cmath.sqrt(cmath.pi)', texname = 'G') CKM1x1 = Parameter(name = 'CKM1x1', nature = 'internal', type = 'complex', value = 'cmath.cos(cabi)', texname = '\\text{CKM1x1}') CKM1x2 = Parameter(name = 'CKM1x2', nature = 'internal', type = 'complex', value = 'cmath.sin(cabi)', texname = '\\text{CKM1x2}') CKM1x3 = Parameter(name = 'CKM1x3', nature = 'internal', type = 'complex', value = '0', texname = '\\text{CKM1x3}') CKM2x1 = Parameter(name = 'CKM2x1', nature = 'internal', type = 'complex', value = '-cmath.sin(cabi)', texname = '\\text{CKM2x1}') CKM2x2 = Parameter(name = 'CKM2x2', nature = 'internal', type = 'complex', value = 'cmath.cos(cabi)', texname = '\\text{CKM2x2}') CKM2x3 = Parameter(name = 'CKM2x3', nature = 'internal', type = 'complex', value = '0', texname = '\\text{CKM2x3}') CKM3x1 = Parameter(name = 'CKM3x1', nature = 'internal', type = 'complex', value = '0', texname = '\\text{CKM3x1}') CKM3x2 = Parameter(name = 'CKM3x2', nature = 'internal', type = 'complex', value = '0', texname = '\\text{CKM3x2}') CKM3x3 = Parameter(name = 'CKM3x3', nature = 'internal', type = 'complex', value = '1', texname = '\\text{CKM3x3}') MW = Parameter(name = 'MW', nature = 'internal', type = 'real', value = 'cmath.sqrt(MZ**2/2. + cmath.sqrt(MZ**4/4. - (aEW*cmath.pi*MZ**2)/(Gf*cmath.sqrt(2))))', texname = 'M_W') ee = Parameter(name = 'ee', nature = 'internal', type = 'real', value = '2*cmath.sqrt(aEW)*cmath.sqrt(cmath.pi)', texname = 'e') sw2 = Parameter(name = 'sw2', nature = 'internal', type = 'real', value = '1 - MW**2/MZ**2', texname = '\\text{sw2}') cw = Parameter(name = 'cw', nature = 'internal', type = 'real', value = 'cmath.sqrt(1 - sw2)', texname = 'c_w') sw = Parameter(name = 'sw', nature = 'internal', type = 'real', value = 'cmath.sqrt(sw2)', texname = 's_w') g1 = Parameter(name = 'g1', nature = 'internal', type = 'real', value = 'ee/cw', texname = 'g_1') gw = Parameter(name = 'gw', nature = 'internal', type = 'real', value = 'ee/sw', texname = 'g_w') vev = Parameter(name = 'vev', nature = 'internal', type = 'real', value = '(2*MW*sw)/ee', texname = '\\text{vev}') mfi = Parameter(name = 'mfi', nature = 'internal', type = 'real', value = 'cmath.sqrt(100 - (kq*vev**2)/2.)', texname = 'M_{\\text{fi}}') AH = Parameter(name = 'AH', nature = 'internal', type = 'real', value = '(47*ee**2*(1 - (2*MH**4)/(987.*MT**4) - (14*MH**2)/(705.*MT**2) + (213*MH**12)/(2.634632e7*MW**12) + (5*MH**10)/(119756.*MW**10) + (41*MH**8)/(180950.*MW**8) + (87*MH**6)/(65800.*MW**6) + (57*MH**4)/(6580.*MW**4) + (33*MH**2)/(470.*MW**2)))/(72.*cmath.pi**2*vev)', texname = 'A_H') GH = Parameter(name = 'GH', nature = 'internal', type = 'real', value = '-(G**2*(1 + (13*MH**6)/(16800.*MT**6) + MH**4/(168.*MT**4) + (7*MH**2)/(120.*MT**2)))/(12.*cmath.pi**2*vev)', texname = 'G_H') Gphi = Parameter(name = 'Gphi', nature = 'internal', type = 'real', value = '-(G**2*(1 + MH**6/(560.*MT**6) + MH**4/(90.*MT**4) + MH**2/(12.*MT**2)))/(8.*cmath.pi**2*vev)', texname = 'G_h') lam = Parameter(name = 'lam', nature = 'internal', type = 'real', value = 'MH**2/(2.*vev**2)', texname = '\\text{lam}') yb = Parameter(name = 'yb', nature = 'internal', type = 'real', value = '(ymb*cmath.sqrt(2))/vev', texname = '\\text{yb}') yc = Parameter(name = 'yc', nature = 'internal', type = 'real', value = '(ymc*cmath.sqrt(2))/vev', texname = '\\text{yc}') ydo = Parameter(name = 'ydo', nature = 'internal', type = 'real', value = '(ymdo*cmath.sqrt(2))/vev', texname = '\\text{ydo}') ye = Parameter(name = 'ye', nature = 'internal', type = 'real', value = '(yme*cmath.sqrt(2))/vev', texname = '\\text{ye}') ym = Parameter(name = 'ym', nature = 'internal', type = 'real', value = '(ymm*cmath.sqrt(2))/vev', texname = '\\text{ym}') ys = Parameter(name = 'ys', nature = 'internal', type = 'real', value = '(yms*cmath.sqrt(2))/vev', texname = '\\text{ys}') yt = Parameter(name = 'yt', nature = 'internal', type = 'real', value = '(ymt*cmath.sqrt(2))/vev', texname = '\\text{yt}') ytau = Parameter(name = 'ytau', nature = 'internal', type = 'real', value = '(ymtau*cmath.sqrt(2))/vev', texname = '\\text{ytau}') yup = Parameter(name = 'yup', nature = 'internal', type = 'real', value = '(ymup*cmath.sqrt(2))/vev', texname = '\\text{yup}') muH = Parameter(name = 'muH', nature = 'internal', type = 'real', value = 'cmath.sqrt(lam*vev**2)', texname = '\\mu')
[ 2, 770, 2393, 373, 6338, 2727, 416, 5452, 2047, 37766, 362, 13, 18, 13, 2624, 198, 2, 6550, 23380, 64, 2196, 25, 1367, 13, 18, 13, 15, 329, 4100, 7294, 1395, 2124, 4521, 357, 2414, 12, 2545, 8, 357, 16192, 767, 11, 2864, 8, 198,...
1.59673
11,191
import time musicLrc = """ [00:03.50] [00:19.10] [00:20.60] [00:26.60] [04:40.75][02:39.90][00:36.25] [04:49.00] [02:47.44][00:43.69] [02:54.83][00:51.24] [03:02.32][00:58.75] [03:08.15][01:04.30] [03:09.35][01:05.50] [03:16.90][01:13.13] [03:24.42][01:20.92] [03:31.85][01:28.44] [03:38.67][01:35.05] [04:09.96][03:39.87][01:36.25] [04:16.37][03:46.38][01:42.47] [04:24.82][03:54.83][01:51.18] [04:31.38][04:01.40][01:57.43] [04:39.55][04:09.00][02:07.85] """ lrcDict = {} musicLrcList = musicLrc.splitlines() #print(musicLrcList) for lrcLine in musicLrcList: #[04:40.75][02:39.90][00:36.25] #[04:40.75 [02:39.90 [00:36.25 #[00:20.60] lrcLineList = lrcLine.split("]") for index in range(len(lrcLineList) - 1): timeStr = lrcLineList[index][1:] #print(timeStr) #00:03.50 timeList = timeStr.split(":") timelrc = float(timeList[0]) * 60 + float(timeList[1]) #print(time) lrcDict[timelrc] = lrcLineList[-1] print(lrcDict) allTimeList = [] for t in lrcDict: allTimeList.append(t) allTimeList.sort() #print(allTimeList) ''' while 1: getTime = float(input("")) for n in range(len(allTimeList)): tempTime = allTimeList[n] if getTime < tempTime: break if n == 0: print("") else: print(lrcDict[allTimeList[n - 1]]) ''' getTime = 0 while 1: for n in range(len(allTimeList)): tempTime = allTimeList[n] if getTime < tempTime: break lrc = lrcDict.get(allTimeList[n - 1]) if lrc == None: pass else: print(lrc) time.sleep(1) getTime += 1
[ 11748, 640, 198, 198, 28965, 43, 6015, 796, 37227, 198, 58, 405, 25, 3070, 13, 1120, 60, 198, 58, 405, 25, 1129, 13, 940, 60, 220, 198, 58, 405, 25, 1238, 13, 1899, 60, 198, 58, 405, 25, 2075, 13, 1899, 60, 198, 58, 3023, 25, ...
1.805464
915
# coding=utf-8 from __future__ import absolute_import import datetime import logging import sys import flask import octoprint.plugin from octoprint.events import eventManager, Events from octoprint.server import user_permission from octoprint.util import RepeatedTimer from .bed_notifications import BedNotifications from .custom_notifications import CustomNotifications from .ifttt_notifications import IFTTTAlerts from .job_notifications import JobNotifications from .layer_notifications import LayerNotifications from .libs.sbc import SBCFactory, SBC, RPi from .mmu import MMUAssistance from .palette2 import Palette2Notifications from .paused_for_user import PausedForUser from .soc_temp_notifications import SocTempNotifications from .thermal_protection_notifications import ThermalProtectionNotifications from .tools_notifications import ToolsNotifications # Plugin that stores APNS tokens reported from iOS devices to know which iOS devices to alert # when print is done or other relevant events debug_soc_temp = False # If you want your plugin to be registered within OctoPrint under a different name than what you defined in setup.py # ("OctoPrint-PluginSkeleton"), you may define that here. Same goes for the other metadata derived from setup.py that # can be overwritten via __plugin_xyz__ control properties. See the documentation for that. __plugin_name__ = "OctoPod Plugin" __plugin_pythoncompat__ = ">=2.7,<4"
[ 2, 19617, 28, 40477, 12, 23, 198, 6738, 11593, 37443, 834, 1330, 4112, 62, 11748, 198, 198, 11748, 4818, 8079, 198, 11748, 18931, 198, 11748, 25064, 198, 198, 11748, 42903, 198, 11748, 19318, 404, 22272, 13, 33803, 198, 6738, 19318, 404...
3.793651
378
from cspatterns.datastructures import buffer
[ 6738, 269, 2777, 265, 759, 82, 13, 19608, 459, 1356, 942, 1330, 11876 ]
3.384615
13
# Generated by Django 2.1.7 on 2019-02-17 14:50 from django.db import migrations, models
[ 2, 2980, 515, 416, 37770, 362, 13, 16, 13, 22, 319, 13130, 12, 2999, 12, 1558, 1478, 25, 1120, 198, 198, 6738, 42625, 14208, 13, 9945, 1330, 15720, 602, 11, 4981, 628 ]
2.84375
32
from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import matplotlib.colors as colors from numpy import array from numpy import max map = Basemap(llcrnrlon=-0.5,llcrnrlat=39.8,urcrnrlon=4.,urcrnrlat=43., resolution='i', projection='tmerc', lat_0 = 39.5, lon_0 = 1) map.readshapefile('../sample_files/lightnings', 'lightnings') x = [] y = [] c = [] for info, lightning in zip(map.lightnings_info, map.lightnings): x.append(lightning[0]) y.append(lightning[1]) if float(info['amplitude']) < 0: c.append(-1 * float(info['amplitude'])) else: c.append(float(info['amplitude'])) plt.figure(0) map.drawcoastlines() map.readshapefile('../sample_files/comarques', 'comarques') map.hexbin(array(x), array(y)) map.colorbar(location='bottom') plt.figure(1) map.drawcoastlines() map.readshapefile('../sample_files/comarques', 'comarques') map.hexbin(array(x), array(y), gridsize=20, mincnt=1, cmap='summer', bins='log') map.colorbar(location='bottom', format='%.1f', label='log(# lightnings)') plt.figure(2) map.drawcoastlines() map.readshapefile('../sample_files/comarques', 'comarques') map.hexbin(array(x), array(y), gridsize=20, mincnt=1, cmap='summer', norm=colors.LogNorm()) cb = map.colorbar(location='bottom', format='%d', label='# lightnings') cb.set_ticks([1, 5, 10, 15, 20, 25, 30]) cb.set_ticklabels([1, 5, 10, 15, 20, 25, 30]) plt.figure(3) map.drawcoastlines() map.readshapefile('../sample_files/comarques', 'comarques') map.hexbin(array(x), array(y), C = array(c), reduce_C_function = max, gridsize=20, mincnt=1, cmap='YlOrBr', linewidths=0.5, edgecolors='k') map.colorbar(location='bottom', label='Mean amplitude (kA)') plt.show()
[ 6738, 285, 489, 62, 25981, 74, 896, 13, 12093, 368, 499, 1330, 6455, 368, 499, 198, 11748, 2603, 29487, 8019, 13, 9078, 29487, 355, 458, 83, 198, 11748, 2603, 29487, 8019, 13, 4033, 669, 355, 7577, 198, 6738, 299, 32152, 1330, 7177, ...
2.384932
730
from nonebot import on_keyword, on_command from nonebot.typing import T_State from nonebot.adapters.cqhttp import Message, Bot, Event # from nonebot.adapters.cqhttp.message import MessageSegment import requests from nonebot.permission import * from nonebot.rule import to_me from aiocqhttp.exceptions import Error as CQHttpError sheying = on_keyword({''})
[ 6738, 4844, 13645, 1330, 319, 62, 2539, 4775, 11, 319, 62, 21812, 201, 198, 6738, 4844, 13645, 13, 774, 13886, 1330, 309, 62, 9012, 201, 198, 6738, 4844, 13645, 13, 324, 12126, 13, 66, 80, 4023, 1330, 16000, 11, 18579, 11, 8558, 220...
2.976
125
import html from collections import namedtuple from pathlib import Path from typing import List, Dict import requests from bs4 import BeautifulSoup from lxml import etree from lxml.etree import XPath Emoji = namedtuple('Emoji', 'char name')
[ 11748, 27711, 198, 6738, 17268, 1330, 3706, 83, 29291, 198, 6738, 3108, 8019, 1330, 10644, 198, 6738, 19720, 1330, 7343, 11, 360, 713, 198, 198, 11748, 7007, 198, 6738, 275, 82, 19, 1330, 23762, 50, 10486, 198, 6738, 300, 19875, 1330, ...
3.388889
72