content
stringlengths
1
1.05M
input_ids
listlengths
1
883k
ratio_char_token
float64
1
22.9
token_count
int64
1
883k
import SparkHelper as sh sparkSession = sh.getSpark() sparkSession.sparkContext.setLogLevel("ERROR") # URL url = sh.getUrl('postgres','postgres','foobar_secret') q1 = "SELECT * FROM foo_left" q2 = "SELECT * FROM foo_right" df1 = sh.getQueryDataFrame(sparkSession, url, q1) df2 = sh.getQueryDataFrame(sparkSession, url, q2) # Do an outer join dfj = df1.join(df2, df1.name_left == df2.name_right, 'full_outer') dfj.show() # Now we have outer join where rows havent matched, but some have # so extract the misses. left_cols_only = [x for x in dfj.columns if 'left' in x] df1miss = dfj.select(left_cols_only).filter("name_right is null") right_cols_only = [x for x in dfj.columns if 'right' in x] df2miss = dfj.select(right_cols_only).filter("name_left is null") df1miss.show() df2miss.show() # We remove the misses from original frame (we only keep the good records dfj = dfj.filter('name_left is not null and name_right is not null') dfj.show() # Now 'normalise' name on both sides of the misses from pyspark.sql.functions import regexp_replace, col df1miss = df1miss.withColumn('name_left', regexp_replace( col('name_left'), '(_[0-9]*_|_[0-9]*$)','@CX@')) df2miss = df2miss.withColumn('name_right', regexp_replace( col('name_right'), '(_[0-9]*_|_[0-9]*$)','@CX@')) df1miss.show() df2miss.show() # Attempt join again on the misses subset, this time with additional columns # as the keys dfj2 = df1miss.join(df2miss, [df1miss.name_left == df2miss.name_right, df1miss.uid_left == df2miss.uid_right], 'full_outer') dfj2.show() # Take a union dfj3 = dfj.union(dfj2) dfj3.show() sparkSession.stop()
[ 11748, 17732, 47429, 355, 427, 201, 198, 201, 198, 2777, 668, 36044, 796, 427, 13, 1136, 4561, 668, 3419, 201, 198, 2777, 668, 36044, 13, 2777, 668, 21947, 13, 2617, 11187, 4971, 7203, 24908, 4943, 201, 198, 2, 10289, 201, 198, 6371, ...
2.49696
658
# Generated by the protocol buffer compiler. DO NOT EDIT! # source: modules/drivers/camera/proto/camera_conf.proto import sys _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database from google.protobuf import descriptor_pb2 # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() DESCRIPTOR = _descriptor.FileDescriptor( name='modules/drivers/camera/proto/camera_conf.proto', package='apollo.drivers.camera', syntax='proto2', serialized_pb=_b('\n.modules/drivers/camera/proto/camera_conf.proto\x12\x15\x61pollo.drivers.camera\"\xe3\x05\n\nCameraConf\x12\x10\n\x05index\x18\x01 \x02(\r:\x01\x30\x12\x18\n\x08position\x18\x02 \x01(\t:\x06\x63\x65ntre\x12\x14\n\ntopic_name\x18\x03 \x01(\t:\x00\x12!\n\x0cvideo_device\x18\x04 \x01(\t:\x0b/dev/video0\x12 \n\x0b\x63\x61mera_name\x18\x05 \x01(\t:\x0bhead_camera\x12\x19\n\x0f\x63\x61mera_info_url\x18\x06 \x01(\t:\x00\x12\x19\n\x0f\x63\x61mera_frame_id\x18\x07 \x01(\t:\x00\x12\x1c\n\x0e\x63\x61mera_timeout\x18\x08 \x01(\r:\x04\x31\x30\x30\x30\x12\x1c\n\rspin_interval\x18\t \x01(\x01:\x05\x30.005\x12\x17\n\tio_method\x18\n \x01(\t:\x04mmap\x12\x1b\n\x0cpixel_format\x18\x0b \x01(\t:\x05mjpeg\x12\x18\n\x0bimage_width\x18\x0c \x01(\r:\x03\x36\x34\x30\x12\x19\n\x0cimage_height\x18\r \x01(\r:\x03\x34\x38\x30\x12\x16\n\nframe_rate\x18\x0e \x01(\x04:\x02\x33\x30\x12\x16\n\nbrightness\x18\x0f \x01(\x05:\x02-1\x12\x14\n\x08\x63ontrast\x18\x10 \x01(\x05:\x02-1\x12\x16\n\nsaturation\x18\x11 \x01(\x05:\x02-1\x12\x15\n\tsharpness\x18\x12 \x01(\x05:\x02-1\x12\x10\n\x04gain\x18\x13 \x01(\x05:\x02-1\x12\x1a\n\x0c\x61utoexposure\x18\x14 \x01(\x08:\x04true\x12\x15\n\x08\x65xposure\x18\x15 \x01(\r:\x03\x31\x30\x30\x12\x18\n\tautofocus\x18\x16 \x01(\x08:\x05\x66\x61lse\x12\x11\n\x05\x66ocus\x18\x17 \x01(\x05:\x02-1\x12 \n\x12\x61uto_white_balance\x18\x18 \x01(\x08:\x04true\x12\x1b\n\rwhite_balance\x18\x19 \x01(\x05:\x04\x34\x30\x30\x30\x12\x1b\n\x10trigger_internal\x18\x1a \x01(\r:\x01\x30\x12\x17\n\x0btrigger_fps\x18\x1b \x01(\r:\x02\x33\x30\x12\x15\n\nerror_code\x18\x1c \x01(\r:\x01\x30') ) _CAMERACONF = _descriptor.Descriptor( name='CameraConf', full_name='apollo.drivers.camera.CameraConf', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='index', full_name='apollo.drivers.camera.CameraConf.index', index=0, number=1, type=13, cpp_type=3, label=2, has_default_value=True, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='position', full_name='apollo.drivers.camera.CameraConf.position', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("centre").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='topic_name', full_name='apollo.drivers.camera.CameraConf.topic_name', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='video_device', full_name='apollo.drivers.camera.CameraConf.video_device', index=3, number=4, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("/dev/video0").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='camera_name', full_name='apollo.drivers.camera.CameraConf.camera_name', index=4, number=5, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("head_camera").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='camera_info_url', full_name='apollo.drivers.camera.CameraConf.camera_info_url', index=5, number=6, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='camera_frame_id', full_name='apollo.drivers.camera.CameraConf.camera_frame_id', index=6, number=7, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='camera_timeout', full_name='apollo.drivers.camera.CameraConf.camera_timeout', index=7, number=8, type=13, cpp_type=3, label=1, has_default_value=True, default_value=1000, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='spin_interval', full_name='apollo.drivers.camera.CameraConf.spin_interval', index=8, number=9, type=1, cpp_type=5, label=1, has_default_value=True, default_value=float(0.005), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='io_method', full_name='apollo.drivers.camera.CameraConf.io_method', index=9, number=10, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("mmap").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='pixel_format', full_name='apollo.drivers.camera.CameraConf.pixel_format', index=10, number=11, type=9, cpp_type=9, label=1, has_default_value=True, default_value=_b("mjpeg").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='image_width', full_name='apollo.drivers.camera.CameraConf.image_width', index=11, number=12, type=13, cpp_type=3, label=1, has_default_value=True, default_value=640, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='image_height', full_name='apollo.drivers.camera.CameraConf.image_height', index=12, number=13, type=13, cpp_type=3, label=1, has_default_value=True, default_value=480, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='frame_rate', full_name='apollo.drivers.camera.CameraConf.frame_rate', index=13, number=14, type=4, cpp_type=4, label=1, has_default_value=True, default_value=30, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='brightness', full_name='apollo.drivers.camera.CameraConf.brightness', index=14, number=15, type=5, cpp_type=1, label=1, has_default_value=True, default_value=-1, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='contrast', full_name='apollo.drivers.camera.CameraConf.contrast', index=15, number=16, type=5, cpp_type=1, label=1, has_default_value=True, default_value=-1, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='saturation', full_name='apollo.drivers.camera.CameraConf.saturation', index=16, number=17, type=5, cpp_type=1, label=1, has_default_value=True, default_value=-1, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='sharpness', full_name='apollo.drivers.camera.CameraConf.sharpness', index=17, number=18, type=5, cpp_type=1, label=1, has_default_value=True, default_value=-1, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='gain', full_name='apollo.drivers.camera.CameraConf.gain', index=18, number=19, type=5, cpp_type=1, label=1, has_default_value=True, default_value=-1, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='autoexposure', full_name='apollo.drivers.camera.CameraConf.autoexposure', index=19, number=20, type=8, cpp_type=7, label=1, has_default_value=True, default_value=True, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='exposure', full_name='apollo.drivers.camera.CameraConf.exposure', index=20, number=21, type=13, cpp_type=3, label=1, has_default_value=True, default_value=100, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='autofocus', full_name='apollo.drivers.camera.CameraConf.autofocus', index=21, number=22, type=8, cpp_type=7, label=1, has_default_value=True, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='focus', full_name='apollo.drivers.camera.CameraConf.focus', index=22, number=23, type=5, cpp_type=1, label=1, has_default_value=True, default_value=-1, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='auto_white_balance', full_name='apollo.drivers.camera.CameraConf.auto_white_balance', index=23, number=24, type=8, cpp_type=7, label=1, has_default_value=True, default_value=True, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='white_balance', full_name='apollo.drivers.camera.CameraConf.white_balance', index=24, number=25, type=5, cpp_type=1, label=1, has_default_value=True, default_value=4000, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='trigger_internal', full_name='apollo.drivers.camera.CameraConf.trigger_internal', index=25, number=26, type=13, cpp_type=3, label=1, has_default_value=True, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='trigger_fps', full_name='apollo.drivers.camera.CameraConf.trigger_fps', index=26, number=27, type=13, cpp_type=3, label=1, has_default_value=True, default_value=30, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='error_code', full_name='apollo.drivers.camera.CameraConf.error_code', index=27, number=28, type=13, cpp_type=3, label=1, has_default_value=True, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto2', extension_ranges=[], oneofs=[ ], serialized_start=74, serialized_end=813, ) DESCRIPTOR.message_types_by_name['CameraConf'] = _CAMERACONF _sym_db.RegisterFileDescriptor(DESCRIPTOR) CameraConf = _reflection.GeneratedProtocolMessageType('CameraConf', (_message.Message,), dict( DESCRIPTOR = _CAMERACONF, __module__ = 'modules.drivers.camera.proto.camera_conf_pb2' # @@protoc_insertion_point(class_scope:apollo.drivers.camera.CameraConf) )) _sym_db.RegisterMessage(CameraConf) # @@protoc_insertion_point(module_scope)
[ 2, 2980, 515, 416, 262, 8435, 11876, 17050, 13, 220, 8410, 5626, 48483, 0, 198, 2, 2723, 25, 13103, 14, 36702, 14, 25695, 14, 1676, 1462, 14, 25695, 62, 10414, 13, 1676, 1462, 198, 198, 11748, 25064, 198, 62, 65, 28, 17597, 13, 96...
2.30878
5,729
# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2011, Martn Ral Villalba # # 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. # ############################################################################## LOG_LOCATION = '/tmp/python-ant.logtest.ant' import unittest from ant.core.log import *
[ 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 29113, 29113, 7804, 4242, 2235, 198, 2, 198, 2, 15069, 357, 66, 8, 2813, 11, 3981, 77, 371, 282, 9757, 282, 7012, 198, 2, 198, 2, 2448, 3411, 318, 29376, 7520, 11, ...
3.90085
353
########################################################################## # # Copyright (c) 2016, Image Engine Design Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above # copyright notice, this list of conditions and the following # disclaimer. # # * 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. # # * Neither the name of John Haddon nor the names of # any other contributors to this software may be used to endorse or # promote products derived from this software without specific prior # written permission. # # 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. # ########################################################################## import Gaffer import GafferScene import GafferSceneUI Gaffer.Metadata.registerNode( GafferScene.LightToCamera, "description", """ Converts lights into cameras. Spotlights are converted to a perspective camera with the field of view matching the cone angle, and distant lights are converted to an orthographic camera. """, plugs = { "filmFit" : filmFitMetadata(), "distantAperture" : [ "description", """ The orthographic aperture used when converting distant lights ( which are theoretically infinite in extent ) """, ], "clippingPlanes" : [ "description", """ Clipping planes for the created cameras. When creating a perspective camera, a near clip <= 0 is invalid, and will be replaced with 0.01. Also, certain lights only start casting light at some distance - if near clip is less than this, it will be increased. """, ], "filter" : [ "description", """ Specifies which lights to convert. """, ], } )
[ 29113, 29113, 7804, 2235, 198, 2, 198, 2, 220, 15069, 357, 66, 8, 1584, 11, 7412, 7117, 8495, 3457, 13, 1439, 2489, 10395, 13, 198, 2, 198, 2, 220, 2297, 396, 3890, 290, 779, 287, 2723, 290, 13934, 5107, 11, 351, 393, 1231, 198, ...
3.297521
847
#!/usr/bin/env python3 from time import sleep import logging import os import subprocess print("Nebra ECC Tool") preTestFail = 0 afterTestFail = 0 ECC_SUCCESSFUL_TOUCH_FILEPATH = "/var/data/gwmfr_ecc_provisioned" logging.basicConfig(level=os.environ.get("LOGLEVEL", "DEBUG")) while preTestFail < 10: preTest = subprocess.run(["/opt/gateway_mfr/bin/gateway_mfr", "ecc", "onboarding"], capture_output=True) preTestResult = str(preTest.stdout.decode('ascii')).rstrip() if "not responding to pings" not in preTestResult: break else: print("Can't load provisioning tool, retrying") preTestFail += 1 sleep(2) if "ecc_response_exec_error" in preTestResult: print("Provisioning") while afterTestFail < 5: subprocess.run(["/opt/gateway_mfr/bin/gateway_mfr", "ecc", "provision"]) print("Testing") afterTest = subprocess.run(["/opt/gateway_mfr/bin/gateway_mfr", "ecc", "onboarding"], capture_output=True).stdout afterTestResult = str(afterTest.decode('ascii')).rstrip() print(afterTestResult) if "ecc_response_exec_error" in afterTestResult: print("\033[91mProgramming FAILED\033[0m") print("Retrying provisioning") afterTestFail += 1 sleep(2) elif (len(afterTestResult) == 51 or len(afterTestResult) == 52): print("\033[92mProgramming Success!\033[0m") record_successful_provision() break else: print("\033[91mAn Unknown Error Occured\033[0m") print("Retrying provisioning") afterTestFail += 1 sleep(2) elif (len(preTestResult) == 50 or len(preTestResult) == 51 or len(preTestResult) == 52): print("\033[93mKey Already Programmed\033[0m") print(preTestResult) record_successful_provision() else: print("An Unknown Error Occured") print(preTestResult) # This next bit of mank is so we can run the gwmfr container for longer # by providing the OVERRIDE_GWMFR_EXIT environment variable for trouble # shooting purposes. if os.getenv('OVERRIDE_GWMFR_EXIT', None): while(True): print("GWMFR Utility Exit Overriden") sleep(300)
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 18, 198, 198, 6738, 640, 1330, 3993, 198, 11748, 18931, 198, 11748, 28686, 198, 11748, 850, 14681, 198, 198, 4798, 7203, 45, 37052, 412, 4093, 16984, 4943, 198, 198, 3866, 14402, 39044, 796, ...
2.362087
939
DOIT_CONFIG = {'default_tasks': ['use_cmd', 'use_python']}
[ 18227, 2043, 62, 10943, 16254, 796, 1391, 6, 12286, 62, 83, 6791, 10354, 37250, 1904, 62, 28758, 3256, 705, 1904, 62, 29412, 20520, 92, 628, 198 ]
2.346154
26
#!/usr/bin/env python3 """ Simple example/demo of the unlinkable DP-3T design This demo simulates some interactions between two phones, represented by the contact tracing modules, and then runs contact tracing. """ __copyright__ = """ Copyright 2020 EPFL 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. """ __license__ = "Apache 2.0" from datetime import timedelta from dp3t.protocols.unlinkable import ContactTracer, TracingDataBatch def report_broadcasted_ephids(name, app): """ Convenience function to report some broadcasted EphIDs """ reporting_time = app.start_of_today + timedelta(hours=10) ephid = app.get_ephid_for_time(reporting_time) print("At {}: {} broadcasts {}".format(reporting_time.time(), name, ephid.hex())) def report_day(time): """ Convenience function to report start of the day """ print("---- {} ----".format(time)) def process_single_day(alice, bob, interaction_time=None): """ Convenience function, process and report on a single day """ report_day(alice.today) report_broadcasted_ephids("Alice", alice) report_broadcasted_ephids("Bob", bob) if interaction_time: print("Alice and Bob interact:") ephid_bob = bob.get_ephid_for_time(interaction_time) alice.add_observation(ephid_bob, interaction_time) print(" Alice observes Bob's EphID {}".format(ephid_bob.hex())) ephid_alice = alice.get_ephid_for_time(interaction_time) bob.add_observation(ephid_alice, interaction_time) print(" Bob observes Alice's EphID {}".format(ephid_alice.hex())) else: print("Alice and Bob do not interact") # Advance to the next day alice.next_day() bob.next_day() print("") if __name__ == "__main__": main()
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 18, 198, 198, 37811, 17427, 1672, 14, 9536, 78, 286, 262, 555, 8726, 540, 27704, 12, 18, 51, 1486, 198, 198, 1212, 13605, 985, 15968, 617, 12213, 1022, 734, 9512, 11, 198, 33469, 416, 262...
2.823529
816
from django.urls import reverse from rest_framework import status from rest_framework.test import force_authenticate from rest_framework_simplejwt.state import User from core.views import DeactivateSelfAPIView, BecomeCommercialAPIView from tests.unittests.common import APIFactoryTestCase
[ 6738, 42625, 14208, 13, 6371, 82, 1330, 9575, 198, 6738, 1334, 62, 30604, 1330, 3722, 198, 6738, 1334, 62, 30604, 13, 9288, 1330, 2700, 62, 41299, 5344, 198, 6738, 1334, 62, 30604, 62, 36439, 73, 46569, 13, 5219, 1330, 11787, 198, 198...
3.88
75
"""Defines the unit tests for the :mod:`colour.colorimetry.spectrum` module.""" import colour import numpy as np import unittest import scipy from distutils.version import LooseVersion from colour.algebra import CubicSplineInterpolator from colour.colorimetry.spectrum import SPECTRAL_SHAPE_DEFAULT from colour.colorimetry.spectrum import ( SpectralShape, SpectralDistribution, MultiSpectralDistributions, reshape_sd, reshape_msds, sds_and_msds_to_sds, sds_and_msds_to_msds, ) from colour.hints import Dict, Tuple from colour.utilities import tstack __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" __license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" __all__ = [ "DATA_SAMPLE", "DATA_SAMPLE_NON_UNIFORM", "DATA_SAMPLE_INTERPOLATED", "DATA_SAMPLE_INTERPOLATED_NON_UNIFORM", "DATA_SAMPLE_NORMALISED", "DATA_STANDARD_OBSERVER_2_DEGREE_CIE1931", "DATA_CMFS", "DATA_SAMPLE_ABRIDGED", "DATA_MULTI_SAMPLE_ABRIDGED", "TestSpectralShape", "TestSpectralDistribution", "TestMultiSpectralDistributions", "TestReshapeSd", "TestSdsAndMdsToSds", "TestSdsAndMsdsToMsds", ] DATA_SAMPLE: Dict = { 340: 0.0000, 360: 0.0000, 380: 0.0000, 400: 0.0641, 420: 0.0645, 440: 0.0562, 460: 0.0537, 480: 0.0559, 500: 0.0651, 520: 0.0705, 540: 0.0772, 560: 0.0870, 580: 0.1128, 600: 0.1360, 620: 0.1511, 640: 0.1688, 660: 0.1996, 680: 0.2397, 700: 0.2852, 720: 0.0000, 740: 0.0000, 760: 0.0000, 780: 0.0000, 800: 0.0000, 820: 0.0000, } DATA_SAMPLE_NON_UNIFORM: Dict = { 391.898: 16.331740, 392.069: 16.333122, 405.606: 40.197224, 406.794: 39.923366, 406.891: 39.924098, 407.026: 39.925138, 416.286: 40.064293, 418.690: 40.009950, 426.700: 18.045809, 426.726: 18.045986, 432.556: 38.435883, 464.742: 29.534647, 465.025: 29.534647, 465.147: 29.534647, 466.586: 38.226470, 477.175: 7.487795, 493.205: 7.684766, 505.217: 7.684766, 513.294: 20.701285, 513.328: 20.704211, 514.349: 20.704211, 514.516: 20.709788, 515.109: 20.709788, 538.034: 7.684766, 564.807: 20.704211, 566.247: 20.709788, 569.592: 32.103387, 580.133: 37.548490, 581.198: 37.548490, 582.642: 40.197224, 588.977: 18.045986, 589.159: 18.045809, 600.113: 8.643020, 600.603: 8.647157, 600.718: 8.640394, 601.068: 8.640394, 601.322: 8.647157, 601.484: 8.643020, 657.805: 14.448826, 658.288: 14.448826, 658.761: 8.537097, 674.438: 38.22647, 678.390: 20.709788, 703.725: 38.435883, 711.318: 8.647157, 711.519: 8.640394, 711.563: 22.532398, 711.699: 8.647157, 711.990: 22.536906, 723.132: 16.33174, 723.642: 16.333122, 761.265: 41.342187, 786.089: 8.850659, 805.862: 8.850659, } DATA_SAMPLE_INTERPOLATED: Tuple = ( 0.000000000000000, 0.000230709627131, 0.000384144814593, 0.000507137093115, 0.000632114832536, 0.000778810112328, 0.000955965592105, 0.001163041382140, 0.001391921913876, 0.001628622810444, 0.001854997757177, 0.002050445372122, 0.002193616076555, 0.002264118965498, 0.002244228678230, 0.002120592268802, 0.001885936076555, 0.001540772596628, 0.001095107350478, 0.000570145756392, 0.000000000000000, -0.000581325882457, -0.001183945630981, -0.001820338942229, -0.002492278660287, -0.003192248184715, -0.003904858878589, -0.004608267476544, -0.005275593492823, -0.005876336629317, -0.006377794183612, -0.006746478457031, -0.006949534162679, -0.006956155833489, -0.006739005230263, -0.006275628749720, -0.005549874832536, -0.004553311371393, -0.003286643119019, -0.001761129096236, 0.000000000000000, 0.001979832128906, 0.004221516875000, 0.006762744980469, 0.009617760000000, 0.012780285644531, 0.016226453125000, 0.019917728496094, 0.023803840000000, 0.027825705410156, 0.031918359375000, 0.036013880761719, 0.040044320000000, 0.043944626425781, 0.047655575625000, 0.051126696777344, 0.054319200000000, 0.057208903691406, 0.059789161875000, 0.062073791542969, 0.064100000000000, 0.065908998066406, 0.067477265625000, 0.068776060136719, 0.069791040000000, 0.070520520019531, 0.070973726875000, 0.071169054589844, 0.071132320000000, 0.070895018222656, 0.070492578125000, 0.069962617792969, 0.069343200000000, 0.068671087675781, 0.067979999375000, 0.067298864746094, 0.066650080000000, 0.066047763378906, 0.065496010625000, 0.064987150449219, 0.064500000000000, 0.064007805449219, 0.063510900625000, 0.063016138378906, 0.062528640000000, 0.062051989746094, 0.061588429375000, 0.061139052675781, 0.060704000000000, 0.060282652792969, 0.059873828125000, 0.059475973222656, 0.059087360000000, 0.058706279589844, 0.058331236875000, 0.057961145019531, 0.057595520000000, 0.057234675136719, 0.056879915625000, 0.056533733066406, 0.056200000000000, 0.055883811757812, 0.055589516250000, 0.055320009023437, 0.055076960000000, 0.054860961914063, 0.054671678750000, 0.054507994179687, 0.054368160000000, 0.054249944570312, 0.054150781250000, 0.054067916835938, 0.053998560000000, 0.053940029726562, 0.053889903750000, 0.053846166992187, 0.053807360000000, 0.053772727382813, 0.053742366250000, 0.053717374648438, 0.053700000000000, 0.053692483144531, 0.053693175625000, 0.053700270058594, 0.053712960000000, 0.053731311035156, 0.053756131875000, 0.053788845449219, 0.053831360000000, 0.053885940175781, 0.053955078125000, 0.054041364589844, 0.054147360000000, 0.054275465566406, 0.054427794375000, 0.054606042480469, 0.054811360000000, 0.055044222207031, 0.055304300625000, 0.055590334121094, 0.055900000000000, 0.056231407851562, 0.056587597500000, 0.056971279335937, 0.057383360000000, 0.057823168945313, 0.058288685000000, 0.058776762929688, 0.059283360000000, 0.059803762539063, 0.060332812500000, 0.060865134023438, 0.061395360000000, 0.061918358632813, 0.062429460000000, 0.062924682617188, 0.063400960000000, 0.063856367226563, 0.064290347500000, 0.064703938710938, 0.065100000000000, 0.065481647265625, 0.065846786250000, 0.066192982265625, 0.066519040000000, 0.066824853515625, 0.067111256250000, 0.067379871015625, 0.067632960000000, 0.067873274765625, 0.068103906250000, 0.068328134765625, 0.068549280000000, 0.068770551015625, 0.068994896250000, 0.069224853515625, 0.069462400000000, 0.069708802265625, 0.069964466250000, 0.070228787265625, 0.070500000000000, 0.070776270703125, 0.071059446250000, 0.071351597578125, 0.071653920000000, 0.071966845703125, 0.072290156250000, 0.072623095078125, 0.072964480000000, 0.073312815703125, 0.073666406250000, 0.074023467578125, 0.074382240000000, 0.074741100703125, 0.075098676250000, 0.075453955078125, 0.075806400000000, 0.076156060703125, 0.076503686250000, 0.076850837578125, 0.077200000000000, 0.077552701992188, 0.077904262500000, 0.078250762070313, 0.078590880000000, 0.078925561523438, 0.079257685000000, 0.079591729101562, 0.079933440000000, 0.080289498554688, 0.080667187500000, 0.081074058632813, 0.081517600000000, 0.082004903085938, 0.082542330000000, 0.083135180664063, 0.083787360000000, 0.084501045117188, 0.085276352500000, 0.086111005195313, 0.087000000000000, 0.087938453242188, 0.088930890000000, 0.089981833007812, 0.091092960000000, 0.092263452148438, 0.093490342500000, 0.094768864414062, 0.096092800000000, 0.097454828554687, 0.098846875000000, 0.100260458320312, 0.101687040000000, 0.103118372460937, 0.104546847500000, 0.105965844726563, 0.107370080000000, 0.108755953867188, 0.110121900000000, 0.111468733632812, 0.112800000000000, 0.114120657988281, 0.115431176875000, 0.116730532871094, 0.118017600000000, 0.119291174316406, 0.120549998125000, 0.121792784199219, 0.123018240000000, 0.124225091894531, 0.125412109375000, 0.126578129277344, 0.127722080000000, 0.128843005722656, 0.129940090625000, 0.131012683105469, 0.132060320000000, 0.133082750800781, 0.134079961875000, 0.135052200683594, 0.136000000000000, 0.136923531484375, 0.137820920000000, 0.138690739765625, 0.139532640000000, 0.140347216796875, 0.141135885000000, 0.141900750078125, 0.142644480000000, 0.143370177109375, 0.144081250000000, 0.144781285390625, 0.145473920000000, 0.146162712421875, 0.146851015000000, 0.147541845703125, 0.148237760000000, 0.148940722734375, 0.149651980000000, 0.150371931015625, 0.151100000000000, 0.151834687363281, 0.152574745625000, 0.153319862089844, 0.154070560000000, 0.154828088378906, 0.155594311875000, 0.156371600605469, 0.157162720000000, 0.157970720644531, 0.158798828125000, 0.159650332871094, 0.160528480000000, 0.161436359160156, 0.162376794375000, 0.163352233886719, 0.164364640000000, 0.165415378925781, 0.166505110625000, 0.167633678652344, 0.168800000000000, 0.170002988242187, 0.171244585000000, 0.172526722382812, 0.173850400000000, 0.175215795898437, 0.176622377500000, 0.178069012539063, 0.179554080000000, 0.181075581054688, 0.182631250000000, 0.184218665195313, 0.185835360000000, 0.187478933710938, 0.189147162500000, 0.190838110351563, 0.192550240000000, 0.194282523867188, 0.196034555000000, 0.197806658007813, 0.199600000000000, 0.201405046894531, 0.203174116875000, 0.204868198964844, 0.206468000000000, 0.207971350097656, 0.209390608125000, 0.210750067167969, 0.212083360000000, 0.213430864550781, 0.214837109375000, 0.216348179121094, 0.218009120000000, 0.219861345253906, 0.221940040625000, 0.224271569824219, 0.226870880000000, 0.229738907207031, 0.232859981875000, 0.236199234277344, 0.239700000000000, 0.243337282929688, 0.247262056250000, 0.251598942851562, 0.256394240000000, 0.261625952148438, 0.267213823750000, 0.273029372070313, 0.278905920000000, 0.284648628867188, 0.290044531250000, 0.294872563789062, 0.298913600000000, 0.301960483085938, 0.303828058750000, 0.304363208007813, 0.303454880000000, 0.301044124804688, 0.297134126250000, 0.291800234726562, 0.285200000000000, 0.277470396855469, 0.268408756875000, 0.257826504003906, 0.245651040000000, 0.231911267089844, 0.216723110625000, 0.200275041738281, 0.182813600000000, 0.164628916074219, 0.146040234375000, 0.127381435722656, 0.108986560000000, 0.091175328808594, 0.074238668125000, 0.058424230957031, 0.043921920000000, 0.030849410292969, 0.019237671875000, 0.009016492441406, 0.000000000000000, -0.008014721386719, -0.014901410625000, -0.020510217441406, -0.024767360000000, -0.027665856933594, -0.029256259375000, -0.029637382988281, -0.028947040000000, -0.027352771230469, -0.025042578125000, -0.022215654785156, -0.019073120000000, -0.015808749277344, -0.012599706875000, -0.009597277832031, -0.006917600000000, -0.004632396074219, -0.002759705625000, -0.001254617128906, 0.000000000000000, 0.001146203203125, 0.002165737500000, 0.003010363984375, 0.003650560000000, 0.004073291015625, 0.004279782500000, 0.004283291796875, 0.004106880000000, 0.003781183828125, 0.003342187500000, 0.002828994609375, 0.002281600000000, 0.001738661640625, 0.001235272500000, 0.000800732421875, 0.000456320000000, 0.000213064453125, 0.000069517500000, 0.000009525234375, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, ) DATA_SAMPLE_INTERPOLATED_NON_UNIFORM: Tuple = ( 16.329808636577400, 16.722487609243078, 17.780769796558388, 19.388440919210822, 21.429286697887836, 23.787092853276910, 26.345645106065515, 28.988729176941121, 31.600130786591194, 34.063635655703216, 36.263029504964656, 38.082098055062993, 39.404627026685688, 40.114402140520198, 40.111247588026082, 39.925103635141149, 39.890167058876870, 39.799323872976096, 39.680556569501256, 39.561845869769570, 39.471172495098209, 39.436517166804364, 39.485860606205222, 39.647183534617994, 39.948466673359860, 40.374181475729280, 40.480943048717741, 39.587763146544347, 37.399010971904012, 34.259517350145224, 30.574008069142096, 26.747208916768866, 23.183845680899680, 20.288644149408725, 18.466330110170176, 18.131455040802454, 19.618408431271092, 22.601624593221480, 26.621530082560952, 31.218551455196845, 35.933115267036499, 40.312773209586069, 44.121677838324345, 47.374686358105983, 50.100647613008405, 52.328410447109043, 54.086823704485290, 55.404736229214613, 56.310996865374428, 56.834454457042114, 57.003957848295137, 56.848355883210893, 56.396497405866839, 55.677231260340363, 54.719406290708918, 53.551871341049903, 52.203475255440743, 50.703066877958868, 49.079495052681693, 47.361608623686649, 45.578256435051173, 43.758287330852653, 41.930550155168532, 40.123893752076235, 38.367166965653183, 36.689218639976801, 35.118897619124496, 33.685052747173714, 32.416532868201863, 31.342186826286373, 30.490863465504646, 29.891411629934137, 29.572680163652254, 29.538621481156376, 33.594913456316092, 41.048330705400552, 45.551744552213606, 47.142069193311166, 46.264235269850914, 43.363173422990592, 38.883814293887831, 33.271088523700378, 26.969926753585888, 20.425259624702068, 14.082017778206605, 8.385131855257200, 3.728429425651282, 0.156961054721180, -2.429909888236355, -4.133307786198728, -5.054357022143353, -5.294181979047651, -4.953907039889023, -4.134656587644884, -2.937555005292646, -1.463726675809728, 0.185704017826468, 1.909612692638526, 3.606874965649032, 5.176366453880572, 6.516962774355742, 7.527539544097118, 8.122379803803623, 8.331483144611147, 8.237444938631239, 7.923124732066758, 7.471382071120567, 6.965076501995521, 6.487067570894484, 6.120214824020312, 5.947377807575871, 6.051416067764015, 6.515189150787608, 7.421556602849507, 8.833103319101975, 10.654113909347958, 12.714472051171430, 14.843629856075644, 16.871039435563851, 18.626152901139314, 19.938422364305275, 20.637299936564997, 20.706835013628812, 20.713132276905259, 20.620587314150111, 20.396819412610807, 20.054405097058748, 19.605938071902443, 19.064012041550384, 18.441220710411045, 17.750157782892924, 17.003416963404511, 16.213591956354293, 15.393276466150766, 14.555064197202412, 13.711548853917725, 12.875324140705192, 12.058983761973309, 11.275121422130562, 10.536330825585436, 9.855205676746426, 9.244339680022023, 8.716326539820709, 8.283759960550988, 7.959233646621334, 7.755341302440248, 7.684676632416213, 7.756084346822568, 7.961801724157814, 8.289468950531905, 8.726726048591537, 9.261213040983417, 9.880569950354237, 10.572436799350699, 11.324453610619505, 12.124260406807357, 12.959497210560945, 13.817804044526978, 14.686820931352152, 15.554187893683173, 16.407544954166731, 17.234532135449530, 18.022789460178267, 18.759956950999651, 19.433674630560375, 20.031582521507140, 20.541320646486646, 20.950529028145592, 21.246847689130675, 21.417916652088600, 21.451375939666065, 21.334865574509770, 21.056025579266414, 20.604750276779001, 20.494345115463702, 22.221705466331883, 25.661450384670388, 29.775598875658655, 33.531925166546948, 36.383260993760757, 38.399428506854193, 39.690190939354423, 40.365311524788659, 40.534553496684069, 40.307680088567857, 39.794454533967205, 39.104640066409281, 38.347999919421312, 37.634297326530451, 37.374685121273394, 39.119690201154867, 40.253206513156250, 38.299118522290833, 34.130306343480264, 28.883500017392159, 23.695429584694160, 19.702825086053920, 18.042370406596557, 17.942146149526579, 17.437952042997388, 16.603615436175311, 15.527509997088327, 14.298009393764401, 13.003487294231499, 11.732317366517600, 10.572873278650665, 9.613528698658669, 8.942657294569587, 8.648632734411382, 8.638275005914387, 8.608461770725761, 8.468358277399256, 8.236485894689265, 7.918459394063972, 7.519893546991550, 7.046403124940173, 6.503602899378026, 5.897107641773280, 5.232532123594114, 4.515491116308703, 3.751599391385226, 2.946471720291860, 2.105722874496783, 1.234967625468170, 0.339820744674198, -0.574102996416954, -1.501188826337108, -2.435821973618090, -3.372387666791723, -4.305271134389827, -5.228857604944231, -6.137532306986749, -7.025680469049206, -7.887687319663434, -8.717938087361247, -9.510818000674471, -10.260712288134929, -10.962006178274445, -11.609084899624833, -12.196333680717927, -12.718137750085543, -13.168882336259514, -13.542952667771653, -13.834733973153785, -14.038611480937735, -14.148970419655322, -14.160196017838375, -14.066673504018716, -13.862788106728164, -13.542925054498539, -13.101469575861673, -12.532806899349385, -11.831322253493493, -10.991400866825831, -10.007427967878208, -8.873788785182459, -7.584868547270405, -6.135052482673858, -4.518725819924658, -2.730273787554616, -0.764081614095559, 1.385465471920696, 3.723982241962316, 6.257083467497486, 8.990383919994379, 11.929498370921175, 14.976162260830137, 5.084237255461949, -6.729230790271000, -14.622433089729542, -19.038838171389944, -20.421914563728482, -19.215130795221405, -15.861955394344996, -10.805856889575507, -4.490303809389212, 2.641235317737622, 10.145291963328749, 17.578397598907866, 24.497083695998736, 30.457881726125084, 35.017323160810655, 37.731939471579153, 38.169944675202451, 36.103648065327157, 31.478944095141092, 24.247257545409393, 14.377470469911161, 2.089605892978410, -12.208009328653077, -28.102486071018522, -45.180935210153116, -63.030467622092019, -81.238194182870473, -99.391225768523640, -117.076673255086732, -133.881647518594917, -149.393259435083451, -163.198619880587444, -174.884839731142108, -184.039029862782684, -190.248301151544382, -193.099764473462415, -192.180530704571822, -187.077710720907902, -177.378415398505837, -162.669755613400923, -142.538842241628146, -116.572786159222886, -84.358698242220214, -45.483689366655454, 0.465129591436323, 53.867241377821607, 111.906385750398641, 165.969680931356891, 206.832112792864763, 225.268667207090687, 212.054330046203120, 157.964087182370434, 53.772924487761195, 24.128558965593012, 155.948189345952358, 238.667542187567193, 279.823268952005947, 286.952021100836475, 267.590450095627091, 229.275207397946076, 179.542944469361430, 125.930312771441450, 75.973963765754249, 37.210548913868003, 17.176719677350921, 17.152394375030820, 19.379794324130732, 21.517434431022508, 23.565545988087592, 25.524360287707406, 27.394108622263396, 29.175022284136993, 30.867332565709628, 32.471270759362753, 33.987068157477793, 35.414956052436175, 36.755165736619354, 38.007928502408760, 39.173475642185821, 40.252038448331973, 41.243848213228674, 42.149136229257330, 42.968133788799399, 43.701072184236310, 44.348182707949491, 44.909696652320392, 45.385845309730442, 45.776859972561077, 46.082971933193733, 46.304412484009845, 46.441412917390849, 46.494204525718175, 46.463018601373285, 46.348086436737596, 46.149639324192542, 45.867908556119552, 45.503125424900077, 45.055521222915552, 44.525327242547419, 43.912774776177095, 43.218095116186007, 42.441519554955640, 41.583279384867382, 40.643991169034841, 39.627797988936805, 38.540734852902020, 37.388854826093969, 36.178210973676094, 34.914856360811882, 33.604844052664760, 32.254227114398248, 30.869058611175774, 29.455391608160820, 28.019279170516839, 26.566774363407301, 25.103930251995678, 23.636799901445418, 22.171436376920010, 20.713892743582907, 19.270222066597562, 17.846477411127466, 16.448711842336071, 15.082978425386836, 13.755330225443233, 12.471820307668732, 11.238501737226787, 10.061427579280879, 8.946650898994456, 7.900224761530997, 6.928202232053956, 6.036636375726809, 5.231580257713018, 4.519086943176044, 3.905209497279358, 3.396000985186418, 2.997514472060695, 2.715803023065654, 2.556919703364760, 2.526917578121476, 2.631849712499274, 2.877769171661610, 3.270729020771954, 3.816782324993773, 4.521982149490528, 5.392381559425689, 6.434033619962720, 7.652991396265083, ) DATA_SAMPLE_NORMALISED: Tuple = ( 0.000000000000000, 0.000000000000000, 0.000000000000000, 22.475455820476860, 22.615708274894811, 19.705469845722302, 18.828892005610097, 19.600280504908834, 22.826086956521742, 24.719495091164092, 27.068723702664798, 30.504908835904626, 39.551192145862551, 47.685834502103788, 52.980364656381497, 59.186535764375883, 69.985974754558200, 84.046283309957929, 100.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, 0.000000000000000, ) DATA_STANDARD_OBSERVER_2_DEGREE_CIE1931: Dict = { 380: (0.001368, 0.000039, 0.006450), 385: (0.002236, 0.000064, 0.010550), 390: (0.004243, 0.000120, 0.020050), 395: (0.007650, 0.000217, 0.036210), 400: (0.014310, 0.000396, 0.067850), 405: (0.023190, 0.000640, 0.110200), 410: (0.043510, 0.001210, 0.207400), 415: (0.077630, 0.002180, 0.371300), 420: (0.134380, 0.004000, 0.645600), 425: (0.214770, 0.007300, 1.039050), 430: (0.283900, 0.011600, 1.385600), 435: (0.328500, 0.016840, 1.622960), 440: (0.348280, 0.023000, 1.747060), 445: (0.348060, 0.029800, 1.782600), 450: (0.336200, 0.038000, 1.772110), 455: (0.318700, 0.048000, 1.744100), 460: (0.290800, 0.060000, 1.669200), 465: (0.251100, 0.073900, 1.528100), 470: (0.195360, 0.090980, 1.287640), 475: (0.142100, 0.112600, 1.041900), 480: (0.095640, 0.139020, 0.812950), 485: (0.057950, 0.169300, 0.616200), 490: (0.032010, 0.208020, 0.465180), 495: (0.014700, 0.258600, 0.353300), 500: (0.004900, 0.323000, 0.272000), 505: (0.002400, 0.407300, 0.212300), 510: (0.009300, 0.503000, 0.158200), 515: (0.029100, 0.608200, 0.111700), 520: (0.063270, 0.710000, 0.078250), 525: (0.109600, 0.793200, 0.057250), 530: (0.165500, 0.862000, 0.042160), 535: (0.225750, 0.914850, 0.029840), 540: (0.290400, 0.954000, 0.020300), 545: (0.359700, 0.980300, 0.013400), 550: (0.433450, 0.994950, 0.008750), 555: (0.512050, 1.000000, 0.005750), 560: (0.594500, 0.995000, 0.003900), 565: (0.678400, 0.978600, 0.002750), 570: (0.762100, 0.952000, 0.002100), 575: (0.842500, 0.915400, 0.001800), 580: (0.916300, 0.870000, 0.001650), 585: (0.978600, 0.816300, 0.001400), 590: (1.026300, 0.757000, 0.001100), 595: (1.056700, 0.694900, 0.001000), 600: (1.062200, 0.631000, 0.000800), 605: (1.045600, 0.566800, 0.000600), 610: (1.002600, 0.503000, 0.000340), 615: (0.938400, 0.441200, 0.000240), 620: (0.854450, 0.381000, 0.000190), 625: (0.751400, 0.321000, 0.000100), 630: (0.642400, 0.265000, 0.000050), 635: (0.541900, 0.217000, 0.000030), 640: (0.447900, 0.175000, 0.000020), 645: (0.360800, 0.138200, 0.000010), 650: (0.283500, 0.107000, 0.000000), 655: (0.218700, 0.081600, 0.000000), 660: (0.164900, 0.061000, 0.000000), 665: (0.121200, 0.044580, 0.000000), 670: (0.087400, 0.032000, 0.000000), 675: (0.063600, 0.023200, 0.000000), 680: (0.046770, 0.017000, 0.000000), 685: (0.032900, 0.011920, 0.000000), 690: (0.022700, 0.008210, 0.000000), 695: (0.015840, 0.005723, 0.000000), 700: (0.011359, 0.004102, 0.000000), 705: (0.008111, 0.002929, 0.000000), 710: (0.005790, 0.002091, 0.000000), 715: (0.004109, 0.001484, 0.000000), 720: (0.002899, 0.001047, 0.000000), 725: (0.002049, 0.000740, 0.000000), 730: (0.001440, 0.000520, 0.000000), 735: (0.001000, 0.000361, 0.000000), 740: (0.000690, 0.000249, 0.000000), 745: (0.000476, 0.000172, 0.000000), 750: (0.000332, 0.000120, 0.000000), 755: (0.000235, 0.000085, 0.000000), 760: (0.000166, 0.000060, 0.000000), 765: (0.000117, 0.000042, 0.000000), 770: (0.000083, 0.000030, 0.000000), 775: (0.000059, 0.000021, 0.000000), 780: (0.000042, 0.000015, 0.000000), } DATA_CMFS: Dict = { 380: np.array([0.001368, 3.90e-05, 0.006450]), 385: np.array([0.002236, 6.40e-05, 0.010550]), 390: np.array([0.004243, 0.000120, 0.020050]), 395: np.array([0.007650, 0.000217, 0.036210]), 400: np.array([0.014310, 0.000396, 0.067850]), 405: np.array([0.023190, 0.000640, 0.110200]), 410: np.array([0.043510, 0.001210, 0.207400]), 415: np.array([0.077630, 0.002180, 0.371300]), 420: np.array([0.134380, 0.004000, 0.645600]), 425: np.array([0.214770, 0.007300, 1.039050]), 430: np.array([0.283900, 0.011600, 1.385600]), 435: np.array([0.328500, 0.016840, 1.622960]), 440: np.array([0.348280, 0.023000, 1.747060]), 445: np.array([0.348060, 0.029800, 1.782600]), 450: np.array([0.336200, 0.038000, 1.772110]), 455: np.array([0.318700, 0.048000, 1.744100]), 460: np.array([0.290800, 0.060000, 1.669200]), 465: np.array([0.251100, 0.073900, 1.528100]), 470: np.array([0.195360, 0.090980, 1.287640]), 475: np.array([0.142100, 0.112600, 1.041900]), 480: np.array([0.095640, 0.139020, 0.812950]), 485: np.array([0.057950, 0.169300, 0.616200]), 490: np.array([0.032010, 0.208020, 0.465180]), 495: np.array([0.014700, 0.258600, 0.353300]), 500: np.array([0.004900, 0.323000, 0.272000]), 505: np.array([0.002400, 0.407300, 0.212300]), 510: np.array([0.009300, 0.503000, 0.158200]), 515: np.array([0.029100, 0.608200, 0.111700]), 520: np.array([0.063270, 0.710000, 0.078250]), 525: np.array([0.109600, 0.793200, 0.057250]), 530: np.array([0.165500, 0.862000, 0.042160]), 535: np.array([0.225750, 0.914850, 0.029840]), 540: np.array([0.290400, 0.954000, 0.020300]), 545: np.array([0.359700, 0.980300, 0.013400]), 550: np.array([0.433450, 0.994950, 0.008750]), 555: np.array([0.512050, 1.000000, 0.005750]), 560: np.array([0.594500, 0.995000, 0.003900]), 565: np.array([0.678400, 0.978600, 0.002750]), 570: np.array([0.762100, 0.952000, 0.002100]), 575: np.array([0.842500, 0.915400, 0.001800]), 580: np.array([0.916300, 0.870000, 0.001650]), 585: np.array([0.978600, 0.816300, 0.001400]), 590: np.array([1.026300, 0.757000, 0.001100]), 595: np.array([1.056700, 0.694900, 0.001000]), 600: np.array([1.062200, 0.631000, 0.000800]), 605: np.array([1.045600, 0.566800, 0.000600]), 610: np.array([1.002600, 0.503000, 0.000340]), 615: np.array([0.938400, 0.441200, 0.000240]), 620: np.array([0.854450, 0.381000, 0.000190]), 625: np.array([0.751400, 0.321000, 0.000100]), 630: np.array([0.642400, 0.265000, 5.00e-05]), 635: np.array([0.541900, 0.217000, 3.00e-05]), 640: np.array([0.447900, 0.175000, 2.00e-05]), 645: np.array([0.360800, 0.138200, 1.00e-05]), 650: np.array([0.283500, 0.107000, 0.000000]), 655: np.array([0.218700, 0.081600, 0.000000]), 660: np.array([0.164900, 0.061000, 0.000000]), 665: np.array([0.121200, 0.044580, 0.000000]), 670: np.array([0.087400, 0.032000, 0.000000]), 675: np.array([0.063600, 0.023200, 0.000000]), 680: np.array([0.046770, 0.017000, 0.000000]), 685: np.array([0.032900, 0.011920, 0.000000]), 690: np.array([0.022700, 0.008210, 0.000000]), 695: np.array([0.015840, 0.005723, 0.000000]), 700: np.array([0.011359, 0.004102, 0.000000]), 705: np.array([0.008111, 0.002929, 0.000000]), 710: np.array([0.005790, 0.002091, 0.000000]), 715: np.array([0.004109, 0.001484, 0.000000]), 720: np.array([0.002899, 0.001047, 0.000000]), 725: np.array([0.002049, 0.000740, 0.000000]), 730: np.array([0.001440, 0.000520, 0.000000]), 735: np.array([0.001000, 0.000361, 0.000000]), 740: np.array([0.000690, 0.000249, 0.000000]), 745: np.array([0.000476, 0.000172, 0.000000]), 750: np.array([0.000332, 0.000120, 0.000000]), 755: np.array([0.000235, 8.50e-05, 0.000000]), 760: np.array([0.000166, 6.00e-05, 0.000000]), 765: np.array([0.000117, 4.20e-05, 0.000000]), 770: np.array([8.30e-05, 3.00e-05, 0.000000]), 775: np.array([5.90e-05, 2.10e-05, 0.000000]), 780: np.array([4.20e-05, 1.50e-05, 0.000000]), } DATA_SAMPLE_ABRIDGED: Dict = { 500: 0.0651, 520: 0.0705, 540: 0.0772, 560: 0.0870, 580: 0.1128, 600: 0.1360, } DATA_MULTI_SAMPLE_ABRIDGED: Dict = { 500: (0.004900, 0.323000, 0.272000), 510: (0.009300, 0.503000, 0.158200), 520: (0.063270, 0.710000, 0.078250), 530: (0.165500, 0.862000, 0.042160), 540: (0.290400, 0.954000, 0.020300), 550: (0.433450, 0.994950, 0.008750), 560: (0.594500, 0.995000, 0.003900), } if __name__ == "__main__": unittest.main()
[ 37811, 7469, 1127, 262, 4326, 5254, 329, 262, 1058, 4666, 25, 63, 49903, 13, 8043, 320, 11973, 13, 4443, 6582, 63, 8265, 526, 15931, 198, 198, 11748, 9568, 198, 11748, 299, 32152, 355, 45941, 198, 11748, 555, 715, 395, 198, 11748, 629...
1.824613
18,023
# Comment import pandas as pd import re from google.cloud import storage from pathlib import Path def download_blob(bucket_name, source_blob_name, destination_file_name): """Downloads a blob from the bucket.""" # bucket_name = "your-bucket-name" # source_blob_name = "storage-object-name" # destination_file_name = "local/path/to/file" storage_client = storage.Client() bucket = storage_client.bucket(bucket_name) blob = bucket.blob(source_blob_name) blob.download_to_filename(destination_file_name) print(f"Blob {source_blob_name} downloaded to {destination_file_name}.") def upload_blob(bucket_name, source_file_name, destination_blob_name): """Uploads a file to the bucket.""" # bucket_name = "your-bucket-name" # source_file_name = "local/path/to/file" # destination_blob_name = "storage-object-name" storage_client = storage.Client() bucket = storage_client.bucket(bucket_name) blob = bucket.blob(destination_blob_name) blob.upload_from_filename(source_file_name) print(f"File {source_file_name} uploaded to {destination_blob_name}.") if __name__ == '__main__': main()
[ 2, 18957, 198, 11748, 19798, 292, 355, 279, 67, 198, 11748, 302, 198, 6738, 23645, 13, 17721, 1330, 6143, 198, 6738, 3108, 8019, 1330, 10644, 628, 628, 628, 628, 198, 4299, 4321, 62, 2436, 672, 7, 27041, 316, 62, 3672, 11, 2723, 62,...
2.700696
431
from dash import dcc, html import dash_bootstrap_components as dbc from dash.dependencies import Input, Output, State import numpy as np import pandas as pd import plotly.io as pio import plotly.graph_objects as go from plotly.subplots import make_subplots import yfinance as yf import math from sklearn.linear_model import LinearRegression from app import app np.seterr(divide='ignore') pd.options.display.float_format = '{:,.2f}'.format # FORMATA E CONFIGURA GRFICOS pio.templates["draft"] = go.layout.Template( layout=go.Layout( title_x = 0.0, title_pad = dict(l=10, t=10), margin = dict(l=50,t=50, b=50, r=50, pad=0, autoexpand=True), font = dict(family="Arial", size=10), autosize=True, ), layout_annotations=[ dict( name="draft watermark", text="KWT-Community", textangle=-30, opacity=0.03, font=dict(family="Arial", color="black", size=80), xref="paper", yref="paper", x=0.5, y=0.5, showarrow=False, ) ] ) pio.templates.default = "seaborn+draft" plotres:dict = dict(width=1920, height=1080) config1 = { "displaylogo": False, "toImageButtonOptions": plotres, "modeBarButtonsToAdd": [ "drawline", "drawopenpath", "drawclosedpath", "drawcircle", "drawrect", "eraseshape", "hoverClosestCartesian", "hoverCompareCartesian" ] } # INPUTS PARA DROPDOWN MENU tickers = pd.read_csv('db/tickers.csv', delimiter=';') # ativos da na bolsa brasileira tickers['label'] = tickers['value']+" - "+tickers['label'] tickers['value'] = tickers['value']+".SA" other = pd.read_csv('db/other.csv', delimiter=';') # outros ativos e ndices other['label'] = other['value']+" - "+other['label'] tickers=pd.concat([tickers,other]) tickers = tickers.to_dict('records') periods = pd.read_csv('db/periods.csv', delimiter=';').to_dict('records') # perodos de anlise intervals = pd.read_csv('db/intervals.csv', delimiter=';').to_dict('records') # intervalos entre dados do perodo def market_beta(X,Y,N): """ X = The independent variable which is the Market Y = The dependent variable which is the Stock N = The length of the Window It returns the alphas and the betas of the rolling regression """ # all the observations obs = len(X) # initiate the betas with null values betas = np.full(obs, np.nan) # initiate the alphas with null values alphas = np.full(obs, np.nan) for i in range((obs-N)): regressor = LinearRegression() regressor.fit(X.to_numpy()[i : i + N+1].reshape(-1,1), Y.to_numpy()[i : i + N+1]) betas[i+N] = regressor.coef_[0] alphas[i+N] = regressor.intercept_ return(alphas, betas) # LAYOUT layout = dbc.Container( children=[ dcc.Loading( #className="kwtload", id="load_o1", color='#0a0', style={'background-color':'rgba(0, 0, 0, 0.5)'}, parent_style={}, fullscreen=True, children=html.Span(id="correl_load_o1", children=["LOADING..."]), type="default", ), dbc.Row([ html.Div(className='kwtdrops', children=[ html.H5("ATIVO"), dcc.Dropdown( id="ticker", options=tickers, value='VALE3.SA', clearable=False, style={'width':'300px'} ), html.H5("BENCHMARK"), dcc.Dropdown( id="indexer", options=tickers, value='^BVSP', clearable=False, style={'width':'300px'} ), html.H5("PERODO"), dcc.Dropdown( id="periods", options=periods, value='1y', clearable=False, style={'width':'10rem'} ), html.H5("INTERVALO"), dcc.Dropdown( id="intervals", options=intervals, value='1d', clearable=False, style={'width':'10rem'} ), dbc.Button(className="kwtchartbtn",id='submitb', n_clicks=0, children='Atualizar') ]), ]), html.Br(), dbc.Row([ dcc.Graph(id="correl_graph", config=config1), dcc.Graph(id="correl_graph1", config=config1), dcc.Graph(id="correl_graph2", config=config1), dcc.Graph(id="correl_graph3", config=config1), ]), ], fluid=True) ####### CALLBACKS ####### ####### CALLBACK PAINEL MERCADO #
[ 6738, 14470, 1330, 288, 535, 11, 27711, 198, 11748, 14470, 62, 18769, 26418, 62, 5589, 3906, 355, 288, 15630, 198, 6738, 14470, 13, 45841, 3976, 1330, 23412, 11, 25235, 11, 1812, 198, 11748, 299, 32152, 355, 45941, 198, 11748, 19798, 29...
2.018688
2,301
import math from collections import namedtuple from . import geohash Box = namedtuple("Box", ["s", "w", "n", "e"])
[ 11748, 10688, 198, 6738, 17268, 1330, 3706, 83, 29291, 198, 198, 6738, 764, 1330, 4903, 1219, 1077, 198, 198, 14253, 796, 3706, 83, 29291, 7203, 14253, 1600, 14631, 82, 1600, 366, 86, 1600, 366, 77, 1600, 366, 68, 8973, 8, 628, 628, ...
2.795455
44
import torch import torch.nn as nn import torchvision from collections import namedtuple Config = namedtuple('Config', ['iSz', 'oSz', 'gSz']) default_config = Config(iSz=160, oSz=56, gSz=112) def updatePadding(net, nn_padding): typename = torch.typename(net) # print(typename) if typename.find('Sequential') >= 0 or typename.find('Bottleneck') >= 0: modules_keys = list(net._modules.keys()) for i in reversed(range(len(modules_keys))): subnet = net._modules[modules_keys[i]] out = updatePadding(subnet, nn_padding) if out != -1: p = out in_c, out_c, k, s, _, d, g, b = \ subnet.in_channels, subnet.out_channels, \ subnet.kernel_size[0], subnet.stride[0], \ subnet.padding[0], subnet.dilation[0], \ subnet.groups, subnet.bias, conv_temple = nn.Conv2d(in_c, out_c, k, stride=s, padding=0, dilation=d, groups=g, bias=b) conv_temple.weight = subnet.weight conv_temple.bias = subnet.bias if p > 1: net._modules[modules_keys[i]] = nn.Sequential(SymmetricPad2d(p), conv_temple) else: net._modules[modules_keys[i]] = nn.Sequential(nn_padding(p), conv_temple) else: if typename.find('torch.nn.modules.conv.Conv2d') >= 0: k_sz, p_sz = net.kernel_size[0], net.padding[0] if ((k_sz == 3) or (k_sz == 7)) and p_sz != 0: return p_sz return -1 if __name__ == '__main__': a = SymmetricPad2d(3) x = torch.tensor([[[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]]) out = a(x) print(out) import torch Config = namedtuple('Config', ['iSz', 'oSz', 'gSz']) config = Config(iSz=160, oSz=56, gSz=112) model = DeepMask(config).cuda() # training mode x = torch.rand(32, 3, config.iSz+32, config.iSz+32).cuda() pred_mask, pred_cls = model(x) print("Output (training mode)", pred_mask.shape, pred_cls.shape) # full image testing mode model.context = False # really important!! input_size = config.iSz + model.strides * 16 + (model.context * 32) x = torch.rand(8, 3, input_size, input_size).cuda() pred_mask, pred_cls = model(x) print("Output (testing mode)", pred_mask.shape, pred_cls.shape)
[ 11748, 28034, 198, 11748, 28034, 13, 20471, 355, 299, 77, 198, 11748, 28034, 10178, 198, 6738, 17268, 1330, 3706, 83, 29291, 198, 198, 16934, 796, 3706, 83, 29291, 10786, 16934, 3256, 37250, 72, 50, 89, 3256, 705, 34049, 89, 3256, 705, ...
1.965154
1,234
nums = [0,1] for i in range(45): if i % 15 == 0 or i == 44: phi = calcFi() print(phi) if i == 44: with open("outputs/phi.txt", "w") as f: f.write(str(phi)) else: calcFi()
[ 77, 5700, 796, 685, 15, 11, 16, 60, 198, 1640, 1312, 287, 2837, 7, 2231, 2599, 198, 220, 220, 220, 611, 1312, 4064, 1315, 6624, 657, 393, 1312, 6624, 5846, 25, 198, 220, 220, 220, 220, 220, 220, 220, 872, 72, 796, 42302, 10547, ...
1.707143
140
import os import glob import torch import numpy as np # from PIL import Image, UnidentifiedImageError from torch.utils.data import Dataset from torchvision.datasets import MNIST
[ 11748, 28686, 198, 11748, 15095, 198, 11748, 28034, 198, 11748, 299, 32152, 355, 45941, 198, 2, 422, 350, 4146, 1330, 7412, 11, 791, 19107, 5159, 12331, 198, 6738, 28034, 13, 26791, 13, 7890, 1330, 16092, 292, 316, 198, 6738, 28034, 101...
3.62
50
from django.shortcuts import render, HttpResponse from django.views.generic.list import ListView from django.views.generic.edit import UpdateView, DeleteView, CreateView from . models import OuverTimeRecord from django.contrib.auth.models import User from django.urls import reverse_lazy from django.views import View import json import csv # Import for reportlab import io from django.http import FileResponse from reportlab.pdfgen import canvas # Import for Xhtm2 from django.template.loader import get_template from xhtml2pdf import pisa #import Xlwt import xlwt # ReportLab def some_view(request): response = HttpResponse(content_type='application/pdf') response['Content-Disposition'] = 'attachment; filename="mypdf.pdf"' buffer = io.BytesIO() p = canvas.Canvas(buffer) p.drawString(200, 810, 'Relatorio de Horas ReportLab') times = OuverTimeRecord.objects.filter( employee=request.user.employee.company.id) y = 790 for time in times: p.drawString(10, y, time.reason) p.drawString(100, y, time.employee.name) p.drawString(200, y, str(time.hours)) p.drawString(300, y, str(time.used)) y -= 40 p.showPage() p.save() pdf = buffer.getvalue() buffer.close() response.write(pdf) return response # Xhtml2 def link_callback(uri, rel): """ Convert HTML URIs to absolute system paths so xhtml2pdf can access those resources """ result = finders.find(uri) if result: if not isinstance(result, (list, tuple)): result = [result] result = list(os.path.realpath(path) for path in result) path = result[0] else: sUrl = settings.STATIC_URL # Typically /static/ sRoot = settings.STATIC_ROOT # Typically /home/userX/project_static/ mUrl = settings.MEDIA_URL # Typically /media/ mRoot = settings.MEDIA_ROOT # Typically /home/userX/project_static/media/ if uri.startswith(mUrl): path = os.path.join(mRoot, uri.replace(mUrl, "")) elif uri.startswith(sUrl): path = os.path.join(sRoot, uri.replace(sUrl, "")) else: return uri # make sure that file exists if not os.path.isfile(path): raise Exception( 'media URI must start with %s or %s' % (sUrl, mUrl) ) return path # Excel
[ 6738, 42625, 14208, 13, 19509, 23779, 1330, 8543, 11, 367, 29281, 31077, 198, 6738, 42625, 14208, 13, 33571, 13, 41357, 13, 4868, 1330, 7343, 7680, 198, 6738, 42625, 14208, 13, 33571, 13, 41357, 13, 19312, 1330, 10133, 7680, 11, 23520, ...
2.455193
982
import unittest as ut import time if __name__ == '__main__': main() # test()
[ 11748, 555, 715, 395, 355, 3384, 198, 11748, 640, 628, 628, 628, 198, 361, 11593, 3672, 834, 6624, 705, 834, 12417, 834, 10354, 198, 220, 220, 220, 1388, 3419, 198, 220, 220, 220, 1303, 1332, 3419, 198 ]
2.459459
37
# coding=utf-8 # Copyright 2020 The Tensor2Robot 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. # Lint as python3 """Functions for converting env episode data to tfrecords of transitions.""" import collections import gin import numpy as np from PIL import Image import six from six.moves import range import tensorflow.compat.v1 as tf _bytes_feature = ( lambda v: tf.train.Feature(bytes_list=tf.train.BytesList(value=v))) _int64_feature = ( lambda v: tf.train.Feature(int64_list=tf.train.Int64List(value=v))) _float_feature = ( lambda v: tf.train.Feature(float_list=tf.train.FloatList(value=v))) _IMAGE_KEY_PREFIX = 'image'
[ 2, 19617, 28, 40477, 12, 23, 198, 2, 15069, 12131, 383, 309, 22854, 17, 14350, 313, 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, ...
3.234637
358
import numpy as np from ..discretization import StructuredGrid, UnstructuredGrid from ..utils import geometry try: import matplotlib.pyplot as plt import matplotlib.colors from matplotlib.collections import PathCollection, LineCollection from matplotlib.path import Path except (ImportError, ModuleNotFoundError): plt = None from . import plotutil import warnings warnings.simplefilter("always", PendingDeprecationWarning)
[ 11748, 299, 32152, 355, 45941, 198, 6738, 11485, 15410, 1186, 1634, 1330, 32112, 1522, 41339, 11, 791, 7249, 1522, 41339, 198, 6738, 11485, 26791, 1330, 22939, 198, 198, 28311, 25, 198, 220, 220, 220, 1330, 2603, 29487, 8019, 13, 9078, ...
3.401515
132
#!/usr/bin/env python3 import argparse from pathlib import Path import json import random import string from botocore.exceptions import ClientError module_info = { "name": "rds__explore_snapshots", "author": "Alexander Morgenstern alexander.morgenstern@rhinosecuritylabs.com", "category": "EXFIL", "one_liner": "Creates copies of running RDS databases to access protected information", "description": "Creates a snapshot of all database instances, restores new database instances from those snapshots, and then changes the master password to allow access to the copied database. After the database has been created, the connection information is given. After interactions with the database are complete, the temporary resources are deleted. If there is an unexpected crash during the module's execution, the subsequent run of the module will attempt to clean up any leftover temporary resources.", "services": ["RDS"], "prerequisite_modules": [], "external_dependencies": [], "arguments_to_autocomplete": ["--regions"], } parser = argparse.ArgumentParser(add_help=False, description=module_info["description"]) parser.add_argument( "--regions", required=False, default=None, help="One or more (comma separated) AWS regions in the format us-east-1. Defaults to all session regions.", ) TEMP_FILE = Path(__file__).parent / "temp.json" WAIT_CONFIG = {"Delay": 10} def main(args, pacu): """Main module function, called from Pacu""" args = parser.parse_args(args) if args.regions: regions = args.regions.split(",") else: regions = pacu.get_regions("rds") if not cleanup(pacu): if pacu.input(" Cleanup Failed. Continue? (y/n) ") != "y": return {"fail": "Failed to delete temporary data."} summary_data = {"instances": 0} for region in regions: pacu.print("Region: {}".format(region)) client = pacu.get_boto3_client("rds", region) pacu.print(" Getting RDS instances...") active_instances = get_all_region_instances(client, pacu.print) pacu.print(" Found {} RDS instance(s)".format(len(active_instances))) for instance in active_instances: prompt = " Target: {} (y/n)? ".format(instance["DBInstanceIdentifier"]) if pacu.input(prompt).lower() != "y": continue pacu.print(" Creating temporary snapshot...") temp_snapshot = create_snapshot_from_instance(client, instance, pacu.print) if not temp_snapshot: pacu.print(" Failed to create temporary snapshot") continue pacu.print(" Restoring temporary instance from snapshot...") temp_instance = restore_instance_from_snapshot( client, temp_snapshot, pacu.print ) if not temp_instance: pacu.print(" Failed to create temporary instance") delete_snapshot(client, temp_snapshot, pacu.print) continue process_instance(pacu, client, temp_instance) pacu.print(" Deleting temporary resources...") delete_instance(client, temp_instance, pacu.print) delete_snapshot(client, temp_snapshot, pacu.print) summary_data["instances"] += 1 if not cleanup(pacu): summary_data["fail"] = "Failed to delete temporary data." return summary_data
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 18, 198, 11748, 1822, 29572, 198, 6738, 3108, 8019, 1330, 10644, 198, 11748, 33918, 198, 11748, 4738, 198, 11748, 4731, 198, 198, 6738, 10214, 420, 382, 13, 1069, 11755, 1330, 20985, 12331, 1...
2.641985
1,310
""" Executes the automation part of 1DMin """ import statistics import autofile from autorun import run_script from mechroutines.trans._routines import _geom as geom from mechroutines.trans._routines import _gather as gather from mechroutines.trans.runner import lj as lj_runner from mechlib import filesys from mechlib import amech_io from mechlib.amech_io import printer as ioprinter def onedmin(spc_name, spc_dct, thy_dct, etrans_keyword_dct, run_prefix, save_prefix): """ Run the task """ bath_name = etrans_keyword_dct['bath'] tgt_dct, bath_dct = spc_dct[spc_name], spc_dct[bath_name] tgt_info = filesys.inf.get_spc_info(tgt_dct) bath_info = filesys.inf.get_spc_info(bath_dct) lj_info = filesys.inf.combine_spc_info(tgt_info, bath_info) # Build the modified thy objs inp_thy_info = filesys.inf.get_es_info( etrans_keyword_dct['inplvl'], thy_dct) run_thy_info = filesys.inf.get_es_info( etrans_keyword_dct['runlvl'], thy_dct) tgt_mod_thy_info = filesys.inf.modify_orb_restrict( tgt_info, inp_thy_info) bath_mod_thy_info = filesys.inf.modify_orb_restrict( bath_info, inp_thy_info) lj_mod_thy_info = filesys.inf.modify_orb_restrict( lj_info, run_thy_info) # Build the target conformer filesystem objects tgt_cnf_run_fs, tgt_cnf_save_fs = filesys.build_fs( run_prefix, save_prefix, 'CONFORMER', spc_locs=tgt_info, thy_locs=tgt_mod_thy_info[1:]) tgt_loc_info = filesys.mincnf.min_energy_conformer_locators( tgt_cnf_save_fs, tgt_mod_thy_info) tgt_min_cnf_locs, tgt_cnf_save_path = tgt_loc_info # Create run fs if that directory has been deleted to run the jobs tgt_cnf_run_fs[-1].create(tgt_min_cnf_locs) tgt_cnf_run_path = tgt_cnf_run_fs[-1].path(tgt_min_cnf_locs) # Get options from the dct or es options lst # tgt_cnf_run_fs[-1].create(tgt_min_cnf_locs) # tgt_cnf_run_path = filesys.build.cnf_paths_from_locs( # tgt_cnf_run_fs, [tgt_min_cnf_locs])[0] # Build the target energy transfer filesystem objects etrans_run_fs = autofile.fs.energy_transfer(tgt_cnf_run_path) etrans_save_fs = autofile.fs.energy_transfer(tgt_cnf_save_path) etrans_locs = bath_info + lj_mod_thy_info[1:4] # Build the bath conformer filesystem objects # _, bath_thy_save_path = filesys.build.spc_thy_fs_from_root( # save_prefix, bath_info, bath_mod_thy_info) # ioprinter.debug_message('bath path', bath_thy_save_path) # bath_cnf_save_fs = autofile.fs.conformer(bath_thy_save_path) # Calculate and save the Lennard-Jones parameters, if needed run_needed, nsamp_needed = _need_run( etrans_save_fs, etrans_locs, etrans_keyword_dct) if run_needed: _runlj(nsamp_needed, lj_info, lj_mod_thy_info, tgt_mod_thy_info, bath_mod_thy_info, tgt_cnf_save_fs, bath_cnf_save_fs, etrans_run_fs, etrans_locs, etrans_keyword_dct) _savelj(etrans_run_fs, etrans_save_fs, etrans_locs, etrans_keyword_dct) else: epath = etrans_save_fs[-1].file.lennard_jones_epsilon.path(etrans_locs) spath = etrans_save_fs[-1].file.lennard_jones_sigma.path(etrans_locs) ioprinter.info_message( '- Lennard-Jones epsilon found at path {}'.format(epath)) ioprinter.info_message( '- Lennard-Jones sigma found at path {}'.format(spath)) def _need_run(etrans_save_fs, etrans_locs, etrans_keyword_dct): """ Check if job needs to run """ nsamp = etrans_keyword_dct['nsamp'] overwrite = etrans_keyword_dct['overwrite'] ex1 = etrans_save_fs[-1].file.lennard_jones_epsilon.exists(etrans_locs) ex2 = etrans_save_fs[-1].file.lennard_jones_sigma.exists(etrans_locs) if not ex1 or not ex2: ioprinter.info_message( 'Either no Lennard-Jones epsilon or sigma found in', 'save filesys. Running OneDMin for params...') run = True nsamp_need = nsamp elif overwrite: ioprinter.info_message( 'User specified to overwrite parameters with new run...') run = True nsamp_need = nsamp else: inf_obj = etrans_save_fs[-1].file.info.read(etrans_locs) nsampd = inf_obj.nsamp if nsamp < nsampd: run = True nsamp_need = nsampd - nsamp else: run = False nsamp_need = 0 return run, nsamp_need def _runlj(nsamp_needed, lj_info, lj_mod_thy_info, tgt_mod_thy_info, bath_mod_thy_info, tgt_cnf_save_fs, bath_cnf_save_fs, etrans_run_fs, etrans_locs, etrans_keyword_dct): """ Run the Lennard-Jones parameters """ # Pull stuff from dct njobs = etrans_keyword_dct['njobs'] smin = etrans_keyword_dct['smin'] smax = etrans_keyword_dct['smax'] conf = etrans_keyword_dct['conf'] # Determine the number of samples per job nsamp_per_job = nsamp_needed // njobs # Set the path to the executable onedmin_exe_path = '/lcrc/project/CMRP/amech/OneDMin/build' # Obtain the geometry for the target and bath tgt_geo = geom.get_geometry( tgt_cnf_save_fs, tgt_mod_thy_info, conf=conf) bath_geo = geom.get_geometry( bath_cnf_save_fs, bath_mod_thy_info, conf=conf) # Set the path to the etrans lead fs etrans_run_path = etrans_run_fs[-1].path(etrans_locs) # Build the run directory onedmin_run_path = lj_runner.build_rundir(etrans_run_path) # Run an instancw of 1DMin for each processor for idx in range(njobs): # Build run directory onedmin_job_path = lj_runner.make_jobdir(onedmin_run_path, idx) # Write the input files xyz1_str, xyz2_str = lj_runner.write_xyz(tgt_geo, bath_geo) elstruct_inp_str, elstruct_sub_str = lj_runner.write_elstruct_inp( lj_info, lj_mod_thy_info) onedmin_str = lj_runner.write_input( nsamp_per_job, smin=smin, smax=smax, target_name='target.xyz', bath_name='bath.xyz') input_strs = ( xyz1_str, xyz2_str, elstruct_inp_str, elstruct_sub_str, onedmin_str) input_names = ( 'target.xyz', 'bath.xyz', 'qc.mol', 'ene.x', 'input.dat') inp = tuple(zip(input_strs, input_names)) amech_io.writer.write_files( inp, onedmin_job_path, exe_names=('ene.x')) # Write the batch submission script for each instance onedmin_sub_str = lj_runner.write_onedmin_sub( njobs, onedmin_run_path, onedmin_exe_path, exe_name='onedmin-dd-molpro.x') sub_inp = ((onedmin_sub_str, 'build.sh'),) amech_io.writer.write_files( sub_inp, onedmin_run_path, exe_names=('build.sh')) # Submit the all of the OneDMin jobs ioprinter.info_message('Running each OneDMin job...', newline=2) run_script(onedmin_sub_str, onedmin_run_path) def _savelj(etrans_run_fs, etrans_save_fs, etrans_locs, etrans_keyword_dct): """ Save the Lennard-Jones parameters """ # Read the dictionary ljpotential = etrans_keyword_dct['pot'] # Set the run path to read the files etrans_run_path = etrans_run_fs[-1].path(etrans_locs) # Read any epsilons and sigma currently in the filesystem ioprinter.info_message( 'Reading Lennard-Jones parameters and Geoms from filesystem...', newline=1) fs_geoms, fs_epsilons, fs_sigmas = gather.read_filesys( etrans_save_fs, etrans_locs) gather.print_lj_parms(fs_sigmas, fs_epsilons) # Read the lj from all the output files ioprinter.info_message( 'Reading Lennard-Jones parameters and Geoms from output...', newline=1) run_geoms, run_epsilons, run_sigmas = gather.read_output(etrans_run_path) gather.print_lj_parms(run_sigmas, run_epsilons) # Read the program and version for onedmin prog_version = gather.prog_version(etrans_run_path) # Add the lists from the two together geoms = fs_geoms + run_geoms sigmas = fs_sigmas + run_sigmas epsilons = fs_epsilons + run_epsilons # Average the sigma and epsilon values if geoms and sigmas and epsilons: assert len(geoms) == len(sigmas) == len(epsilons), ( 'Number of geoms, sigmas, and epsilons not the same' ) avg_sigma = statistics.mean(sigmas) avg_epsilon = statistics.mean(epsilons) nsampd = len(sigmas) ioprinter.info_message( 'Average Sigma to save [unit]:', avg_sigma, newline=1) ioprinter.info_message('Average Epsilont to save [unit]:', avg_epsilon) ioprinter.info_message('Number of values = ', nsampd) # Update the trajectory file traj = [] for geo, eps, sig in zip(geoms, epsilons, sigmas): comment = 'Epsilon: {} Sigma: {}'.format(eps, sig) traj.append((comment, geo)) # Write the info obj inf_obj = autofile.schema.info_objects.lennard_jones( nsampd, potential=ljpotential, program='OneDMin', version=prog_version) # Set up the electronic structure input file onedmin_inp_str = '<ONEDMIN INP>' els_inp_str = '<ELSTRUCT INP>' # Write the params to the save file system etrans_save_fs[-1].file.lj_input.write(onedmin_inp_str, etrans_locs) etrans_save_fs[-1].file.info.write(inf_obj, etrans_locs) etrans_save_fs[-1].file.molpro_inp_file.write(els_inp_str, etrans_locs) etrans_save_fs[-1].file.epsilon.write(avg_epsilon, etrans_locs) etrans_save_fs[-1].file.sigma.write(avg_sigma, etrans_locs) etrans_save_fs[1].file.trajectory.write(traj, etrans_locs)
[ 37811, 198, 23002, 1769, 262, 22771, 636, 286, 352, 35, 9452, 198, 37811, 198, 198, 11748, 7869, 198, 11748, 1960, 1659, 576, 198, 6738, 1960, 273, 403, 1330, 1057, 62, 12048, 198, 6738, 36571, 81, 448, 1127, 13, 7645, 13557, 81, 448,...
2.096678
4,696
from exceptions import BarryFileException, BarryConversionException, BarryExportException, BarryDFException import pandas as pd import requests from StringIO import StringIO def detect_file_extension(filename): """Extract and return the extension of a file given a filename. Args: filename (str): name of the file Returns: str: extension of the file Raises: BarryFileException: if extension not present in filename """ if filename is None: raise BarryFileException("Input file name cannot be None") split_filename = filename.split(".") if len(split_filename) > 1: return str(split_filename[-1]).lower() else: raise BarryFileException("Could not determine input file type from file extension") def xls_to_df(filename, skip_rows, skip_header, columns): """Converts a XLS file to Pandas dataframe. Args: filename (str): name of the file skip_rows (int): number of rows to skip from top skip_header (bool): whether to skip header columns (list or None): list of column names Returns: dataframe: a pandas dataframe Raises: BarryConversionException: if file cannot be converted to dataframe """ try: # Check if columns names has been passed if columns is not None and len(columns) > 0: skip_header = 0 # Check if header needs to be skipped if skip_header is True: skip_header = None else: skip_header = 0 return pd.read_excel(filename, skiprows=skip_rows, header=skip_header, names=columns) except Exception as e: raise BarryConversionException("Could not convert file %s to dataframe" % (filename)) def xlsx_to_df(filename, skip_rows, skip_header, columns): """Converts a XLSX file to Pandas dataframe. Args: filename (str): name of the file skip_rows (int): number of rows to skip from top skip_header (bool): whether to skip header columns (list or None): list of column names Returns: dataframe: a pandas dataframe Raises: BarryConversionException: if file cannot be converted to dataframe """ try: # Check if columns names has been passed if columns is not None and len(columns) > 0: skip_header = 0 # Check if header needs to be skipped if skip_header is True: skip_header = None else: skip_header = 0 return pd.read_excel(filename, skiprows=skip_rows, header=skip_header, names=columns) except Exception as e: raise BarryConversionException("Could not convert file %s to dataframe" % (filename)) def csv_to_df(filename, skip_rows, skip_header, columns): """Converts a CSV file to Pandas dataframe. Args: filename (str): name of the file skip_rows (int): number of rows to skip from top skip_header (bool): whether to skip header columns (list or None): list of column names Returns: dataframe: a pandas dataframe Raises: BarryConversionException: if file cannot be converted to dataframe """ try: # Check if columns names has been passed if columns is not None and len(columns) > 0: skip_header = 0 # Check if header needs to be skipped if skip_header is True: skip_header = None else: skip_header = 0 return pd.read_csv(filename, skiprows=skip_rows, header=skip_header, names=columns) except Exception as e: raise BarryConversionException("Could not convert file %s to dataframe" % (filename)) def url_to_df(url, skip_rows, skip_header, columns): """Converts a CSV from HTTP URL to Pandas dataframe. Args: url (str): http url of the csv skip_rows (int): number of rows to skip from top skip_header (bool): whether to skip header columns (list or None): list of column names Returns: dataframe: a pandas dataframe Raises: BarryConversionException: if file cannot be converted to dataframe """ try: # Check if columns names has been passed if columns is not None and len(columns) > 0: skip_header = 0 # Check if header needs to be skipped if skip_header is True: skip_header = None else: skip_header = 0 url_content = requests.get(url).content return pd.read_csv(StringIO(url_content), skiprows=skip_rows, header=skip_header, names=columns) except Exception as e: raise BarryConversionException("Could not convert file %s to dataframe" % (filename)) def df_to_xls(df, out_filename): """Writes a Pandas dataframe to a XLS file. Args: df (dataframe): dataframe to be written to file filename (str): name of the file Raises: BarryExportException: if file cannot be converted to dataframe """ try: df.to_excel(out_filename) except Exception as e: raise BarryExportException("Could not write dataframe to file %s" % (out_filename)) def df_to_xlsx(df, out_filename): """Writes a Pandas dataframe to a XLS file. Args: df (dataframe): dataframe to be written to file filename (str): name of the file Raises: BarryExportException: if file cannot be converted to dataframe """ try: df.to_excel(out_filename) except Exception as e: raise BarryExportException("Could not write dataframe to file %s" % (out_filename)) def df_to_json(df, out_filename): """Writes a Pandas dataframe to a JSON file. Args: df (dataframe): dataframe to be written to file filename (str): name of the file Raises: BarryExportException: if file cannot be converted to dataframe """ try: df.to_json(out_filename) except Exception as e: raise BarryExportException("Could not write dataframe to file %s" % (out_filename)) def df_to_csv(df, out_filename): """Writes a Pandas dataframe to a CSV file. Args: df (dataframe): dataframe to be written to file filename (str): name of the file Raises: BarryExportException: if file cannot be converted to dataframe """ try: df.to_csv(out_filename) except Exception as e: raise BarryExportException("Could not write dataframe to file %s" % (out_filename)) def sort_df(df, sort_column, ascending): """Sort a DataFrame with the column name passed in ascending/descending order. Args: df (dataframe): dataframe that needs to be sorted sort_column (str): column to be sorted on ascending (bool): sort order, ascending if True, descending if False Returns: dataframe: a pandas dataframe Raises: BarryDFException: if there is any error while sorting the dataframe """ try: return df.sort(columns=sort_column, ascending=ascending) except Exception as e: raise BarryDFException("Could not sort dataframe on columns %s" % (sort_column))
[ 6738, 13269, 1330, 14488, 8979, 16922, 11, 14488, 3103, 9641, 16922, 11, 14488, 43834, 16922, 11, 14488, 8068, 16922, 198, 11748, 19798, 292, 355, 279, 67, 198, 11748, 7007, 198, 6738, 10903, 9399, 1330, 10903, 9399, 628, 198, 4299, 4886,...
2.642384
2,718
from flask_script import Command from app import db
[ 6738, 42903, 62, 12048, 1330, 9455, 198, 198, 6738, 598, 1330, 20613, 628 ]
4.153846
13
a = [2, 4, 5, 7, 8, 9] sum = 0 for i in range(len(a) - 1): if a[i] % 2 == 0: sum = sum + a[i] print(sum)
[ 64, 796, 685, 17, 11, 604, 11, 642, 11, 767, 11, 807, 11, 860, 60, 198, 16345, 796, 657, 198, 1640, 1312, 287, 2837, 7, 11925, 7, 64, 8, 532, 352, 2599, 198, 220, 220, 220, 611, 257, 58, 72, 60, 4064, 362, 6624, 657, 25, 198...
1.710145
69
# -*- coding: utf-8 -*- """ Core client, used for all API requests. """ import os import platform from collections import namedtuple from plivo.base import ResponseObject from plivo.exceptions import (AuthenticationError, InvalidRequestError, PlivoRestError, PlivoServerError, ResourceNotFoundError, ValidationError) from plivo.resources import (Accounts, Addresses, Applications, Calls, Conferences, Endpoints, Identities, Messages, Numbers, Pricings, Recordings, Subaccounts) from plivo.resources.live_calls import LiveCalls from plivo.resources.queued_calls import QueuedCalls from plivo.utils import is_valid_mainaccount, is_valid_subaccount from plivo.version import __version__ from requests import Request, Session AuthenticationCredentials = namedtuple('AuthenticationCredentials', 'auth_id auth_token') PLIVO_API = 'https://api.plivo.com' PLIVO_API_BASE_URI = '/'.join([PLIVO_API, 'v1/Account']) def fetch_credentials(auth_id, auth_token): """Fetches the right credentials either from params or from environment""" if not (auth_id and auth_token): try: auth_id = os.environ['PLIVO_AUTH_ID'] auth_token = os.environ['PLIVO_AUTH_TOKEN'] except KeyError: raise AuthenticationError('The Plivo Python SDK ' 'could not find your auth credentials.') if not (is_valid_mainaccount(auth_id) or is_valid_subaccount(auth_id)): raise AuthenticationError('Invalid auth_id supplied: %s' % auth_id) return AuthenticationCredentials(auth_id=auth_id, auth_token=auth_token)
[ 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 37811, 198, 14055, 5456, 11, 973, 329, 477, 7824, 7007, 13, 198, 37811, 198, 198, 11748, 28686, 198, 11748, 3859, 198, 6738, 17268, 1330, 3706, 83, 29291, 198, 198, 6738...
2.446779
714
# Part 3 of UWCSE's Project 3 # # based on Lab Final from UCSC's Networking Class # which is based on of_tutorial by James McCauley from pox.core import core import pox.openflow.libopenflow_01 as of from pox.lib.addresses import IPAddr, IPAddr6, EthAddr log = core.getLogger() #statically allocate a routing table for hosts #MACs used in only in part 4 IPS = { "h10" : ("10.0.1.10", '00:00:00:00:00:01'), "h20" : ("10.0.2.20", '00:00:00:00:00:02'), "h30" : ("10.0.3.30", '00:00:00:00:00:03'), "serv1" : ("10.0.4.10", '00:00:00:00:00:04'), "hnotrust" : ("172.16.10.100", '00:00:00:00:00:05'), } def launch (): """ Starts the component """ core.openflow.addListenerByName("ConnectionUp", start_switch)
[ 2, 2142, 513, 286, 471, 27353, 5188, 338, 4935, 513, 198, 2, 198, 2, 1912, 319, 3498, 8125, 422, 14417, 6173, 338, 7311, 278, 5016, 198, 2, 543, 318, 1912, 319, 286, 62, 83, 44917, 416, 3700, 5108, 559, 1636, 198, 198, 6738, 745, ...
2.359477
306
#students exams data entries for terminal report card print("Westside Educational Complex--End Of second Terminal Report--Class-KKJA--Name:Theodora Obaa Yaa Gyarbeng") while True: student_score = float(input ("Enter the student score:")) if student_score >= 1.0 and student_score <= 39.9: print("student_score is F9", "fail") elif student_score >= 40 and student_score <= 49.9: print("student_score is E8", "pass" ) elif student_score >= 50 and student_score <= 59.9: print("student_score is D7", "credit") elif student_score >= 60 and student_score <= 69.9: print("student_score is C4", "good") elif student_score >= 70 and student_score <= 79.9: print("student_score is B2", "very_good") elif student_score >= 80 and student_score <= 100: print("student_score is A1", "excellent") else: print("student_score is invalid entry") student = []
[ 2, 19149, 658, 26420, 1366, 12784, 329, 12094, 989, 2657, 198, 4798, 7203, 15045, 1589, 30038, 19157, 438, 12915, 3226, 1218, 24523, 6358, 438, 9487, 12, 16601, 37048, 438, 5376, 25, 464, 375, 5799, 1835, 7252, 575, 7252, 18488, 38039, ...
2.655556
360
n = int(input()) l = [] c = 0 for i in range(0,n): p = input() print('c -> ', c) if p in l: c += 1 l.append(p) print("Falta(m) {} pomekon(s).".format(151 - (n-c)))
[ 77, 796, 493, 7, 15414, 28955, 198, 75, 796, 17635, 198, 66, 796, 657, 198, 198, 1640, 1312, 287, 2837, 7, 15, 11, 77, 2599, 198, 220, 220, 220, 279, 796, 5128, 3419, 198, 220, 220, 220, 220, 628, 220, 220, 220, 3601, 10786, 66,...
1.794643
112
from django import template from django.conf import settings from django.utils.safestring import mark_safe register = template.Library() #@register.filter #def format_difference(value): # number = int(value) # if number > 0: # return mark_safe('<span style="color: green">+' + str(number) + '</span>') # elif number < 0: # return mark_safe('<span style="color: red">' + str(number) + '</span>') # else: # return mark_safe(str(number))
[ 6738, 42625, 14208, 1330, 11055, 198, 6738, 42625, 14208, 13, 10414, 1330, 6460, 198, 6738, 42625, 14208, 13, 26791, 13, 49585, 395, 1806, 1330, 1317, 62, 21230, 198, 198, 30238, 796, 11055, 13, 23377, 3419, 628, 198, 2, 31, 30238, 13, ...
2.631285
179
# Given a series of input numbers, count the number of times # the values increase from one to the next. import pandas as pd # Part 1 sample = pd.read_csv(".\Day1\sample.txt", header=None, squeeze=True) input = pd.read_csv(".\Day1\input.txt", header=None, squeeze=True) #print(type(input)) ans = input.diff(1).apply(lambda x: x > 0).sum() #print(ans) # Part 2 #print(sample) rolling = input.rolling(window=3,min_periods=3,center=True) print(rolling.sum().dropna().diff(1).apply(lambda x: x > 0).sum())
[ 2, 11259, 257, 2168, 286, 5128, 3146, 11, 954, 262, 1271, 286, 1661, 198, 2, 262, 3815, 2620, 422, 530, 284, 262, 1306, 13, 198, 11748, 19798, 292, 355, 279, 67, 628, 198, 2, 2142, 352, 198, 39873, 796, 279, 67, 13, 961, 62, 406...
2.755435
184
import kivy from kivy.app import App from kivy.uix.boxlayout import BoxLayout kivy.require('1.9.0') glApp = GUITestApp() glApp.run()
[ 11748, 479, 452, 88, 198, 6738, 479, 452, 88, 13, 1324, 1330, 2034, 198, 6738, 479, 452, 88, 13, 84, 844, 13, 3524, 39786, 1330, 8315, 32517, 198, 74, 452, 88, 13, 46115, 10786, 16, 13, 24, 13, 15, 11537, 198, 198, 4743, 4677, 7...
2.350877
57
################################################################################ # Copyright (c) 2021 ContinualAI. # # Copyrights licensed under the MIT License. # # See the accompanying LICENSE file for terms. # # # # Date: 19-01-2021 # # Author(s): Vincenzo Lomonaco, Lorenzo Pellegrini # # E-mail: contact@continualai.org # # Website: www.continualai.org # ################################################################################ import GPUtil from threading import Thread import time import warnings from typing import Optional, TYPE_CHECKING, List from avalanche.evaluation import Metric, PluginMetric from avalanche.evaluation.metric_results import MetricValue, MetricResult from avalanche.evaluation.metric_utils import get_metric_name, \ phase_and_task, stream_type if TYPE_CHECKING: from avalanche.training import BaseStrategy def gpu_usage_metrics(gpu_id, every=0.5, minibatch=False, epoch=False, experience=False, stream=False) -> List[PluginMetric]: """ Helper method that can be used to obtain the desired set of plugin metrics. :param gpu_id: GPU device ID. :param every: seconds after which update the maximum GPU usage :param minibatch: If True, will return a metric able to log the minibatch max GPU usage. :param epoch: If True, will return a metric able to log the epoch max GPU usage. :param experience: If True, will return a metric able to log the experience max GPU usage. :param stream: If True, will return a metric able to log the evaluation max stream GPU usage. :return: A list of plugin metrics. """ metrics = [] if minibatch: metrics.append(MinibatchMaxGPU(gpu_id, every)) if epoch: metrics.append(EpochMaxGPU(gpu_id, every)) if experience: metrics.append(ExperienceMaxGPU(gpu_id, every)) if stream: metrics.append(StreamMaxGPU(gpu_id, every)) return metrics __all__ = [ 'MaxGPU', 'MinibatchMaxGPU', 'EpochMaxGPU', 'ExperienceMaxGPU', 'StreamMaxGPU', 'gpu_usage_metrics' ]
[ 29113, 29113, 14468, 198, 2, 15069, 357, 66, 8, 33448, 6389, 723, 20185, 13, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 2...
2.312616
1,078
# # @lc app=leetcode id=971 lang=python3 # # [971] Flip Binary Tree To Match Preorder Traversal # # @lc code=start # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right from collections import deque
[ 2, 198, 2, 2488, 44601, 598, 28, 293, 316, 8189, 4686, 28, 24, 4869, 42392, 28, 29412, 18, 198, 2, 198, 2, 685, 24, 4869, 60, 29583, 45755, 12200, 1675, 13225, 3771, 2875, 4759, 690, 282, 198, 2, 198, 198, 2, 2488, 44601, 2438, ...
2.453237
139
import base64 import datetime import io import json import os import requests from collections import namedtuple from urllib.parse import urlparse import faust import numpy as np import keras_preprocessing.image as keras_img from avro import schema from confluent_kafka import avro from confluent_kafka.avro import AvroProducer from confluent_kafka.avro.cached_schema_registry_client import CachedSchemaRegistryClient from confluent_kafka.schema_registry import SchemaRegistryClient from confluent_kafka.schema_registry.avro import AvroSerializer from biovolume import calc_biovolume from blob import Blob, BlobConfig config_path = os.environ.get('IFCB_STREAM_APP_CONFIG', 'config.json') with open(config_path) as config_file: config = json.load(config_file) Stats = namedtuple( 'Stats', ['time', 'ifcb_id', 'roi', 'name', 'classifier', 'prob', 'classification_time', 'biovolume', 'carbon', 'hab'] ) ClassifierStats = namedtuple( 'ClassifierStats', ['sample_name', 'prob', 'classifier', 'classification_time'] ) schema_config = { 'url': config['schema.registry.url'], 'ssl.ca.location': None } # need to use CachedSchemaRegistryClient to get schema # - need to copy config because it is consumed when used in CachedSchemaRegistryClient schema_config_copy = schema_config.copy() cached_schema_client = CachedSchemaRegistryClient(schema_config) key_schema = str(cached_schema_client.get_latest_schema('ifcb-stats-key')[1]) value_schema = str(cached_schema_client.get_latest_schema('ifcb-stats-value')[1]) key_schema = avro.loads(key_schema) value_schema = avro.loads(value_schema) producer = AvroProducer({ 'bootstrap.servers': config['bootstrap.servers'], 'schema.registry.url': config['schema.registry.url'] }, default_key_schema=key_schema, default_value_schema=value_schema ) app = faust.App( config['app_name'], broker=config['broker'], topic_partitions=config['topic_partitions'], store='rocksdb://', consumer_auto_offset_reset='earliest', version=1 ) image_topic = app.topic(config['image_topic']) stats_topic = app.topic(config['stats_topic']) classifier_stats_table = app.Table('ifcb-classifier-stats', default=ClassifierStats) diatoms = config['diatoms'] class_names = config['class_names'] hab_species = config['hab_species'] def publish_stats(feature_key, image, classifier_stats, blob_config=BlobConfig()): """Calculate biovolume, carbon, hab, and publish to Kafka""" # calculate biovolume # - scale biovolume for 3d (from ifcb-analysis) blob = Blob(image, blob_config) biovolume = calc_biovolume(blob) mu = 1/3.4 biovolume = biovolume * mu ** 3 carbon = calc_carbon(classifier_stats[0], biovolume) hab = classifier_stats[0] in hab_species time, ifcb_id, roi = feature_key.split('_') roi = int(roi) timestamp = int(datetime.datetime.strptime(time[1:], '%Y%m%dT%H%M%S').timestamp()) stats = Stats( timestamp, ifcb_id, roi, classifier_stats[0], classifier_stats[2], classifier_stats[1], classifier_stats[3], biovolume, carbon, hab ) # send to topic with Avro schema producer.poll(0) producer.produce( topic=config['stats_topic'], key={ 'pid': f"{time}_{ifcb_id}", 'roi': int(roi) }, value=stats._asdict() ) producer.flush() def get_classifier(url): """Given TF style url, return name and version""" parse_results = urlparse(url) _, version, _, name_raw = parse_results.path.split('/') name = name_raw.split(':')[0] return (name, version) def calc_carbon(english_name, scaled_biovolume, diatom_list=diatoms): """Given volume in u3/cell return carbon in pg C/cell. $log_10(C) = log(a) + b \cdot log_10(V)$ """ if english_name in diatom_list: carbon = 10**(-0.665 + 0.939*np.log10(scaled_biovolume)) else: carbon = 10**(-0.993 + 0.881*np.log10(scaled_biovolume)) return carbon if __name__ == '__main__': app.main()
[ 11748, 2779, 2414, 198, 11748, 4818, 8079, 198, 11748, 33245, 198, 11748, 33918, 198, 11748, 28686, 198, 11748, 7007, 198, 6738, 17268, 1330, 3706, 83, 29291, 198, 6738, 2956, 297, 571, 13, 29572, 1330, 19016, 29572, 198, 198, 11748, 2468...
2.464178
1,661
import discord from discord.ext import commands from discord.utils import get
[ 11748, 36446, 198, 6738, 36446, 13, 2302, 1330, 9729, 198, 6738, 36446, 13, 26791, 1330, 651 ]
4.8125
16
from .cli import entrypoint if __name__ == "__main__": # pragma: no cover entrypoint.main()
[ 6738, 764, 44506, 1330, 5726, 4122, 198, 198, 361, 11593, 3672, 834, 6624, 366, 834, 12417, 834, 1298, 220, 1303, 23864, 2611, 25, 645, 3002, 198, 220, 220, 220, 5726, 4122, 13, 12417, 3419, 198 ]
2.8
35
from flask import jsonify from ..app import app
[ 6738, 42903, 1330, 33918, 1958, 198, 198, 6738, 11485, 1324, 1330, 598, 628 ]
3.846154
13
inst_25 = [(35,0,15),(29,0,20),(9,0,11),(9,13,35),(3,0,19),(37,0,8),(11,0,30),(19,0,25),(13,0,25),(39,0,18)] inst_bait = [(10,0,10), (14,0,11), (33,0,26),(4,2,18),(4,20,30),(39,117,137),(12,5,21),(28,0,14),(32,5,14),(32,15,44),(36,0,9),(40,0,14),(2,1,15),(2,17,35),(5,160,168),(11,158,164),(13,116,131)] inst_30 = [] inst_25late = [(32,160,190),(38,61,76),(39,446,466),(40,153,153+37),(39,269,329),(40,262,287),(38,7,42)] inst_25late_extended = [(39,269,369),(40,153,190),(38,7,50),(38,61,105),(32,160,199),(39,446,486),(35,70,119),(38,106,130),(36,204,233),(30,57,94),(29,221,241),(40,262,312),(29,160,184),(30,0,24)] inst_25_100P = [(38,131,131+80)] # treatments = {'25*' : inst_25late,'25' : inst_25,'baits' : inst_bait, '30' : inst_30} treatments = {'25_100' : inst_25_100P, '25*' : inst_25late,'25' : inst_25,'baits' : inst_bait, '30' : inst_30} plate_number = {(9,0,11) : 296, (9,13,35) : 296, (3,0,19) : 340, (37,0,8) : 269,(11,0,30) : 314, (19,0,25) : 344, (13,0,25) : 298, (39,0,18) : 297, (35,0,15) : 351,(10,0,10) : 395,(14,0,11) : 399, (33,0,26) : 420, (4,2,18) : 423, (4,20,30) : 423,(8,0,17): 434 ,(8,20,30) : 434,(39,117,137) : 433, (12,5,21) : 436, (28,0,14): 405,(32,5,45):409,(36,0,9) : 419,(40,0,14) : 425,(2,1,15):435,(2,17,35):435,(5,160,168):382,(11,158,164) : 416,(13,116,131) : 424, (29,0,20) : 373,(32,15,44):409, (32,5,14) : 409, (40,153,153+37) : 69,(39,269,329) : 94, (40,262,287) : 102,(38,7,42) : 59, (32,160,190) : 152,(38,61,76) : 137,(39,446,466) : 26, (38,131,131+80):721} comments = {395 : 'ignore', 399 : 'left', 405 : 'left', 409 : 'right', 416 : 'middle', 419 : 'middle', 420 : 'left', 423: 'right', 424 : 'left', 425 : 'middle', 433 : 'right', 435 : 'middle', 436 : 'left'}
[ 8625, 62, 1495, 796, 47527, 2327, 11, 15, 11, 1314, 828, 7, 1959, 11, 15, 11, 1238, 828, 7, 24, 11, 15, 11, 1157, 828, 7, 24, 11, 1485, 11, 2327, 828, 7, 18, 11, 15, 11, 1129, 828, 7, 2718, 11, 15, 11, 23, 828, 7, 1157, ...
1.822598
947
__version__ = '5.2.158 f.LUM'
[ 834, 9641, 834, 796, 705, 20, 13, 17, 13, 21273, 277, 13, 43, 5883, 6, 198 ]
1.875
16
import numpy as np import pickle expert_file = 'maze_expert.npy' imitation_agent_file = 'maze_agent.npy' with open(imitation_agent_file, 'rb') as handle: agent_data = pickle.load(handle) with open(expert_file, 'rb') as handle: expert_data = pickle.load(handle) print("OK")
[ 11748, 299, 32152, 355, 45941, 198, 11748, 2298, 293, 198, 1069, 11766, 62, 7753, 796, 705, 76, 6201, 62, 1069, 11766, 13, 77, 9078, 6, 198, 320, 3780, 62, 25781, 62, 7753, 796, 705, 76, 6201, 62, 25781, 13, 77, 9078, 6, 198, 4480...
2.568807
109
import unittest from celestial import Celestial from strings import CelestialStrings from datetime import datetime import pytest import math
[ 11748, 555, 715, 395, 198, 198, 6738, 33258, 1330, 37231, 198, 6738, 13042, 1330, 37231, 13290, 654, 198, 6738, 4818, 8079, 1330, 4818, 8079, 198, 11748, 12972, 9288, 198, 11748, 10688, 628 ]
4.46875
32
import copy import json import logging from . import utils # ------------------------------------------------------------------------------------------------- # ------------------------------------------------------------------------------------------------- # ------------------------------------------------------------------------------------------------- # ------------------------------------------------------------------------------------------------- # ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
[ 198, 11748, 4866, 198, 11748, 33918, 198, 11748, 18931, 198, 6738, 764, 1330, 3384, 4487, 628, 198, 2, 16529, 3880, 12, 628, 198, 2, 16529, 3880, 12, 628, 198, 2, 16529, 3880, 12, 628, 198, 2, 16529, 3880, 12, 628, 198, 2, 16529, ...
12.923077
52
from osmo import Osmo import random import time osmo = Osmo(PositiveCalculator()) osmo.generate()
[ 6738, 267, 5796, 78, 1330, 440, 5796, 78, 198, 11748, 4738, 198, 11748, 640, 628, 198, 198, 418, 5908, 796, 440, 5796, 78, 7, 21604, 1800, 9771, 3129, 1352, 28955, 198, 418, 5908, 13, 8612, 378, 3419, 198 ]
2.657895
38
#!/usr/bin/env python # Author: Omid Mashayekhi <omidm@stanford.edu> import sys import os import subprocess import config sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')) import ec2 temp_file_name = '_temp_file_'
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 198, 2, 6434, 25, 440, 13602, 30870, 323, 988, 5303, 1279, 296, 312, 76, 31, 14192, 3841, 13, 15532, 29, 198, 198, 11748, 25064, 198, 11748, 28686, 198, 11748, 850, 14681, 198, 198, ...
2.422018
109
frase = input().split() for palavra in frase: print(palavra[2], end='')
[ 8310, 589, 796, 5128, 22446, 35312, 3419, 198, 1640, 6340, 615, 430, 287, 1216, 589, 25, 198, 220, 220, 220, 3601, 7, 18596, 615, 430, 58, 17, 4357, 886, 28, 7061, 8 ]
2.34375
32
#To run the code, write #from ishashad import ishashad #then ishashad(number)
[ 2, 2514, 1057, 262, 2438, 11, 3551, 198, 198, 2, 6738, 318, 17831, 324, 1330, 318, 17831, 324, 198, 2, 8524, 318, 17831, 324, 7, 17618, 8 ]
2.888889
27
""" This module tests utils """ from unittest.mock import patch, MagicMock from superset_patchup.utils import get_complex_env_var, is_safe_url, is_valid_provider from superset_patchup.oauth import CustomSecurityManager
[ 37811, 198, 1212, 8265, 5254, 3384, 4487, 198, 37811, 198, 6738, 555, 715, 395, 13, 76, 735, 1330, 8529, 11, 6139, 44, 735, 198, 198, 6738, 22754, 316, 62, 17147, 929, 13, 26791, 1330, 651, 62, 41887, 62, 24330, 62, 7785, 11, 318, ...
3.202899
69
import random import torch import numpy as np from torch.autograd import gradcheck, gradgradcheck import xitorch as xt from xitorch.integrate import quad, solve_ivp, mcquad, SQuad from xitorch._tests.utils import device_dtype_float_test ################################## quadrature ################################## ################################## ivp ################################## class IVPNNModule(torch.nn.Module): # dydt: -a * y * t - b * y - c * y class IVPModule(xt.EditableModule): # dydt: -a * y * t - b * y - c * y ################################## mcquad ################################## class MCQuadLogProbNNModule(torch.nn.Module): class MCQuadFcnModule(xt.EditableModule): def get_true_output(w, a): # return a*a*w*w return 1.0 / torch.sqrt(1 + w * w / (a * a)) ################################## SQuad ################################## if __name__ == "__main__": # with torch.autograd.detect_anomaly(): test_mcquad()
[ 11748, 4738, 201, 198, 11748, 28034, 201, 198, 11748, 299, 32152, 355, 45941, 201, 198, 6738, 28034, 13, 2306, 519, 6335, 1330, 3915, 9122, 11, 3915, 9744, 9122, 201, 198, 11748, 2124, 2072, 354, 355, 220, 742, 201, 198, 6738, 2124, 2...
2.953216
342
from hub.dataload.nde import NDEFileSystemDumper
[ 6738, 12575, 13, 67, 10254, 1170, 13, 358, 68, 1330, 399, 7206, 8979, 11964, 35, 15829, 628 ]
2.941176
17
# -*- coding: utf-8 -*- """ File Name faiss_utils Description : faiss Author : mick.yi date 2019/1/4 """ import faiss import numpy as np def update_multi(index, vectors, ids): """ :param index: :param vectors: :param ids: :return: ValueError: array is not C-contiguous """ idx = np.argsort(ids) # index.remove_ids(ids[idx]) index.add_with_ids(vectors[idx], ids[idx])
[ 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 201, 198, 37811, 201, 198, 220, 220, 9220, 6530, 220, 220, 220, 220, 24685, 747, 62, 26791, 201, 198, 220, 220, 12489, 1058, 220, 220, 24685, 747, 201, 198, 220, 220, 6434,...
1.966942
242
import requests from custom.api.utils import EndpointMixin
[ 11748, 7007, 198, 6738, 2183, 13, 15042, 13, 26791, 1330, 5268, 4122, 35608, 259, 628, 198 ]
3.8125
16
# Generated by Django 2.2.5 on 2019-10-28 21:54 from django.db import migrations, models
[ 2, 2980, 515, 416, 37770, 362, 13, 17, 13, 20, 319, 13130, 12, 940, 12, 2078, 2310, 25, 4051, 198, 198, 6738, 42625, 14208, 13, 9945, 1330, 15720, 602, 11, 4981, 628 ]
2.84375
32
# Copyright 2015 Hewlett-Packard Development Company, L.P. # # Author: Endre Karlson <endre.karlson@hp.com> # # 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 uuid from tempest_lib import exceptions from functionaltests.common import datagen from functionaltests.api.v2.base import DesignateV2Test from functionaltests.api.v2.clients.pool_client import PoolClient
[ 2, 15069, 1853, 30446, 15503, 12, 11869, 446, 7712, 5834, 11, 406, 13, 47, 13, 198, 2, 198, 2, 6434, 25, 5268, 260, 15415, 1559, 1279, 437, 260, 13, 74, 7063, 1559, 31, 24831, 13, 785, 29, 198, 2, 198, 2, 49962, 739, 262, 24843,...
3.569672
244
from __future__ import (absolute_import, division, print_function, unicode_literals) import numpy as np import tensorflow as tf from fewshot.models.kmeans_utils import compute_logits from fewshot.models.model import Model from fewshot.models.refine_model import RefineModel from fewshot.models.basic_model_VAT import BasicModelVAT from fewshot.models.model_factory import RegisterModel from fewshot.models.nnlib import (concat, weight_variable) from fewshot.utils import logger from fewshot.utils.debug import debug_identity from fewshot.models.SSL_utils import * l2_norm = lambda t: tf.sqrt(tf.reduce_sum(tf.pow(t, 2))) log = logger.get()
[ 6738, 11593, 37443, 834, 1330, 357, 48546, 62, 11748, 11, 7297, 11, 3601, 62, 8818, 11, 198, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 28000, 1098, 62, 17201...
2.960352
227
""" @Author : xiaotao @Email : 18773993654@163.com @Lost modifid : 2020/4/24 10:02 @Filename : __init__.py.py @Description : @Software : PyCharm """
[ 37811, 198, 31, 13838, 197, 197, 197, 197, 25, 2124, 544, 4265, 78, 198, 31, 15333, 197, 197, 197, 197, 25, 1248, 3324, 28771, 2623, 4051, 31, 24136, 13, 785, 198, 31, 31042, 953, 361, 312, 197, 197, 25, 12131, 14, 19, 14, 1731, ...
1.942529
87
import numpy as np import re as re from molsysmt._private_tools.lists_and_tuples import is_list_or_tuple
[ 11748, 299, 32152, 355, 45941, 198, 11748, 302, 355, 302, 198, 6738, 285, 10220, 893, 16762, 13557, 19734, 62, 31391, 13, 20713, 62, 392, 62, 28047, 2374, 1330, 318, 62, 4868, 62, 273, 62, 83, 29291, 628 ]
2.864865
37
#!/usr/bin/env python3 import argparse import subprocess as sp import select import sys import time import yaml if __name__ == '__main__': """ We can daemonize our connections to our remote machines, list the FL processes on remote machines, or kill FL processes on remote machines. We can either pass a specfic run's metadata file, or we can use a 'global' metadata file to list all processes on a list of machines. """ parser = argparse.ArgumentParser() parser.add_argument('action', choices=['daemonize', 'list', 'kill']) parser.add_argument('--config') # read metadata config for the specified run args = parser.parse_args() if (args.config): with open(args.config) as config_file: config = yaml.load(config_file.read(), Loader=yaml.Loader) if 'timestamp' in config: machines = [config['agg_machine']] + config['party_machines'] usernames = [config['agg_username']] + config['party_usernames'] run_id = config['timestamp'] if 'timestamp' in config else '' else: machines = config['machines'] usernames = config['usernames'] run_id = '' localp = sp.Popen('mkdir -p {}/.ssh'.format(config['local_staging_dir']).split()) exit_code = localp.wait() # decide what to run based on input if args.action == 'daemonize': daemonize_cmd = 'ssh '\ '-o "ControlMaster=auto" '\ '-o "ControlPath={}/.ssh/master-%r@%h:%p" '\ '-o "ControlPersist=yes" '\ '-Nn {}@{}' cmds = [daemonize_cmd.format(config['local_staging_dir'], u, m) for m, u in zip(machines,usernames)] elif args.action == 'list': if 'timestamp' in config: list_cmd = \ 'ssh -o "ControlMaster=no" -o "ControlPath={}/.ssh/master-%r@%h:%p" {}@{} '\ '"set -o pipefail; '\ 'pgrep -u {} -f \\"bash.*run_agg\.py.*{}|bash.*run_party\.py.*{}\\" '\ '| xargs --no-run-if-empty -I@ pgrep -P @ -f \\"run\\" -a"' cmds = [list_cmd.format(config['local_staging_dir'], u, m, u, run_id, run_id, u, run_id, run_id) for m, u in zip(machines, usernames)] else: list_cmd = \ 'ssh -o "ControlMaster=no" -o "ControlPath={}/.ssh/master-%r@%h:%p" {}@{} ' \ '"set -o pipefail; '\ 'pgrep -f \\"bash.*run_agg\.py|bash.*run_party\.py\\" '\ '| tee >(xargs --no-run-if-empty -I@ pgrep -P @) '\ '| xargs --no-run-if-empty ps -o user:8,pid,ppid,cmd p"' cmds = [list_cmd.format(config['local_staging_dir'], u, m) for m, u in zip(machines, usernames)] elif args.action == 'kill': if 'timestamp' in config: kill_cmd = \ 'ssh -o "ControlMaster=no" -o "ControlPath={}/.ssh/master-%r@%h:%p" {}@{} '\ '"set -o pipefail; '\ 'pgrep -u {} -f \\"bash.*run_agg\.py.*{}|run_party\.py.*{}\\" '\ '| tee >(xargs --no-run-if-empty pgrep -P) | tee >(xargs --no-run-if-empty kill)"' cmds = [kill_cmd.format(config['local_staging_dir'], u, m, u, run_id, run_id, u, run_id, run_id) for m, u in zip(machines, usernames)] else: kill_cmd = \ 'ssh -o "ControlMaster=no" -o "ControlPath={}/.ssh/master-%r@%h:%p" {}@{} '\ '"set -o pipefail; '\ 'pgrep -u {} -f \\"run_agg\.py|run_party\.py\\" '\ '&& pkill -u {} -f \\"run_agg\.py|run_party\.py\\""' cmds = [kill_cmd.format(config['local_staging_dir'], u, m, u, u) for m, u in zip(machines, usernames)] else: print('Action not handled. Exiting.') exit(1) # start all processes procs = [sp.Popen(c, stdout=sp.PIPE, stderr=sp.PIPE, shell=True, universal_newlines=True) for c in cmds] stdout = ['' for _ in machines] stderr = ['' for _ in machines] loops = 0 # wait for output and finally exit when processes end, obtaining all output polls = list(p.poll() for p in procs) while any(r == None for r in polls): ret = select.select([p.stdout.fileno() for p,r in zip(procs,polls) if r == None], [], []) for fd in ret[0]: for i,p in enumerate(procs): if p.stdout.fileno() == fd: stdout[i] += '\t{}'.format(p.stdout.readline()) polls = tuple(p.poll() for p in procs) loops += 1 for i,p in enumerate(procs): for line in p.stdout: stdout[i] += '\t{}'.format(line) for line in p.stderr: stderr[i] += '\t{}'.format(line) if not stdout[i].strip(): stderr[i] += '\tNo processes found.\n' # print output if args.action != 'daemonize': for i,m in enumerate(machines): print("{}:".format(m)) if stdout[i].strip(): print(stdout[i]) if stderr[i].strip(): print(stderr[i])
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 18, 198, 198, 11748, 1822, 29572, 198, 11748, 850, 14681, 355, 599, 198, 11748, 2922, 198, 11748, 25064, 198, 11748, 640, 198, 11748, 331, 43695, 628, 198, 361, 11593, 3672, 834, 6624, 705, ...
2.027049
2,477
from .device import SampleDevice from .codeobject import SampleDeviceCodeObject __all__ = ['SampleDevice', 'SampleDeviceCodeObject']
[ 6738, 764, 25202, 1330, 27565, 24728, 198, 6738, 764, 8189, 15252, 1330, 27565, 24728, 10669, 10267, 198, 198, 834, 439, 834, 796, 37250, 36674, 24728, 3256, 705, 36674, 24728, 10669, 10267, 20520, 198 ]
4.060606
33
from beaker import Beaker
[ 6738, 307, 3110, 1330, 1355, 3110, 628 ]
3.857143
7
# coding: utf-8 # In[2]: import firebase_admin from firebase_admin import credentials from firebase_admin import db # Fetch the service account key JSON file contents cred = credentials.Certificate('/Users/Solomon/Desktop/cau-hashkeyword-serviceAccountKey.json') # Initialize the app with a service account, granting admin privileges firebase_admin.initialize_app(cred, { 'databaseURL': 'https://cau-hashkeyword.firebaseio.com' }) ref = db.reference('server/saving-data/crawling') # In[3]: from bs4 import BeautifulSoup from urllib.request import urlopen from selenium import webdriver import re # In[3]: options = webdriver.ChromeOptions() options.add_argument('headless') options.add_argument('window-size=1920x1080') options.add_argument('disable-gpu') # In[10]: cau_title_list = [] cau_date_list = [] cau_url_list = [] driver = webdriver.Chrome("/usr/local/bin/chromedriver", chrome_options=options) driver.get("https://www.cau.ac.kr/cms/FR_CON/index.do?MENU_ID=100") driver.implicitly_wait(3) cau_base_url = "https://www.cau.ac.kr/cms/FR_CON/BoardView.do?MENU_ID=100&CONTENTS_NO=1&SITE_NO=2&P_TAB_NO=&TAB_NO=&BOARD_SEQ=4&BOARD_CATEGORY_NO=&BBS_SEQ=" # BBS_SEQ=19642 (id=board_19642) board_list = driver.find_element_by_id("tbody").find_elements_by_tag_name("li") board_list.reverse() # count = 0 for item in board_list: # if count < 10: pass # # else: cau_title_list.append(item.find_element_by_class_name("txtL").find_element_by_tag_name('a').text) cau_date_list.append(item.find_element_by_class_name("txtInfo").find_element_by_class_name("date").text) cau_url_list.append(cau_base_url + item.get_attribute("id").replace("board_","")) # count += 1 driver.close() # list , insert(0,data) O(n) # class collections.deque([iterable[, maxlen]]) dequeue() O(1) # High Performance . # list reverse , append (, reverse O(n)) # In[11]: lib_title_list = [] lib_date_list = [] lib_url_list = [] driver = webdriver.Chrome("/usr/local/bin/chromedriver", chrome_options=options) driver.get("https://library.cau.ac.kr/#/bbs/notice?offset=0&max=20") driver.implicitly_wait(3) try: # tbody[0] . , . board_list = driver.find_elements_by_tag_name("tbody")[1].find_elements_by_class_name("ikc-item") board_list.reverse() for item in board_list: # tbody ikc-item , IndexError: list index out of range ( ) lib_title_list.append(item.find_elements_by_tag_name("td")[2].find_element_by_tag_name('a').text) # lib_date_list.append(item.find_elements_by_tag_name("td")[3].find_elements_by_tag_name("span")[1].text) except IndexError: print("IndexError") pass lib_base_url = "https://library.cau.ac.kr/#/bbs/notice/" # id lib_sub_url = "?offset=0&max=20" # url id .. driver.close() # In[14]: # dorm_title_list = [] dorm_date_list = [] dorm_url_list = [] dormnotice_url = "https://dormitory.cau.ac.kr/bbs/bbs_list.php?bbsID=notice" dormnotice_page = urlopen(dormnotice_url) dormnotice_soup = BeautifulSoup(dormnotice_page, "lxml") dormnotice_list = dormnotice_soup.find(id='content').find('div').find_all('tr',{'bgcolor':'#fffcdb'}) dormnotice_list.reverse() if dormnotice_list == []: print("No data") else : for item in dormnotice_list: dorm_title_list.append(item.find('span',class_='bbsTitle').get_text()) dorm_url_list.append(item.find('a')['href']) dorm_date_list.append("20" + item.find_all('td',class_='t_c')[3].get_text()) #try-except ? # In[13]: ict_title_list = [] ict_date_list = [] ict_url_list = [] ictnotice_url = "http://ict.cau.ac.kr/20150610/sub05/sub05_01_list.php" ictnotice_page = urlopen(ictnotice_url) ictnotice_soup = BeautifulSoup(ictnotice_page, "lxml") ict_base_url = "http://ict.cau.ac.kr/20150610/sub05/sub05_01_list.php?cmd=view&cpage=1&idx=" # id ict_sub_url = "&search_gbn=1&search_keyword=" ictnotice_list = ictnotice_soup.find('tbody').find_all('tr') ictnotice_list.reverse() if ictnotice_list == []: print("No data") else: for item in ictnotice_list: ict_title_list.append(item.find('td',class_='cont').find('a').get_text()) ict_url_list.append(ict_base_url + item.find('td',class_='cont').find('a')['href'][-7:-3] + ict_sub_url) ict_date_list.append(item.find_all('td')[2].get_text()) # In[10]: # ? ( ) cse_title_list = [] cse_date_list = [] cse_url_list = [] csenotice_url = "http://cse.cau.ac.kr/20141201/sub05/sub0501.php" csenotice_page = urlopen(csenotice_url) csenotice_soup = BeautifulSoup(csenotice_page, "lxml") csenotice_list = csenotice_soup.find('table',class_='nlist').find_all('tr') csenotice_list.reverse() if csenotice_list == []: print("No data") else: for item in csenotice_list: if item.find('td').get_text() != '': cse_title_list.append(re.sub('[\n\t\xa0]','',item.find('a').get_text())) # sub cse_url_list.append(csenotice_url + item.find_all('td')[2].find('a')['href']) cse_date_list.append(item.find_all('td')[4].get_text()) # In[15]: # Firebase import json from collections import OrderedDict crawling_data = OrderedDict() crawling_data['caunotice'] = {'title':cau_title_list, 'date':cau_date_list, 'url':cau_url_list} crawling_data['library'] = {'title':lib_title_list, 'date':lib_date_list, 'url':"https://library.cau.ac.kr/#/bbs/notice?offset=0&max=20"} crawling_data['dorm'] = {'title':dorm_title_list, 'date':dorm_date_list, 'url':dorm_url_list} crawling_data['ict'] = {'title':ict_title_list, 'date':ict_date_list, 'url':ict_url_list} crawling_data['cse'] = {'title':cse_title_list, 'date':cse_date_list, 'url':cse_url_list} crawling_json = json.dumps(crawling_data, ensure_ascii=False, indent="\t") webpage_ref = ref.child('webpages') webpage_ref.set(json.loads(crawling_json))
[ 198, 2, 19617, 25, 3384, 69, 12, 23, 198, 198, 2, 554, 58, 17, 5974, 628, 198, 11748, 2046, 8692, 62, 28482, 198, 6738, 2046, 8692, 62, 28482, 1330, 18031, 198, 6738, 2046, 8692, 62, 28482, 1330, 20613, 198, 198, 2, 376, 7569, 262...
2.343952
2,480
#coding: utf-8 from aip import AipSpeech from config import DefaultConfig as opt
[ 2, 66, 7656, 25, 3384, 69, 12, 23, 220, 198, 6738, 257, 541, 1330, 317, 541, 5248, 3055, 198, 6738, 4566, 1330, 15161, 16934, 355, 2172, 628 ]
3.074074
27
import unittest import os import pathlib import h5py from desc.input_reader import InputReader from desc.equilibrium_io import hdf5Writer, hdf5Reader from desc.configuration import Configuration, Equilibrium #from desc.input_output import read_input #class TestIO(unittest.TestCase): # """tests for input/output functions""" # # def test_min_input(self): # dirname = os.path.dirname(__file__) # filename = os.path.join(dirname, 'MIN_INPUT') # inputs = read_input(filename) # # self.assertEqual(len(inputs), 26)
[ 11748, 555, 715, 395, 198, 11748, 28686, 198, 11748, 3108, 8019, 198, 11748, 289, 20, 9078, 198, 6738, 1715, 13, 15414, 62, 46862, 1330, 23412, 33634, 198, 6738, 1715, 13, 4853, 24741, 62, 952, 1330, 289, 7568, 20, 34379, 11, 289, 756...
2.721393
201
from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as EC import pytest # Declare Fixtures # -------------------------------------------------------------------- # End to End testing with Selenium # --------------------------------------------------------------------
[ 6738, 384, 11925, 1505, 1330, 3992, 26230, 198, 6738, 384, 11925, 1505, 13, 12384, 26230, 13, 11321, 13, 13083, 1330, 26363, 198, 6738, 384, 11925, 1505, 13, 12384, 26230, 13, 11284, 1330, 2938, 62, 17561, 1756, 355, 13182, 198, 11748, ...
5.202899
69
#makes a toast with the given string ID from sys import argv if ( argv[0] == "makeToast.py" ): print make_toast(argv[1])
[ 2, 49123, 257, 27805, 351, 262, 1813, 4731, 4522, 198, 198, 6738, 25064, 1330, 1822, 85, 198, 198, 361, 357, 1822, 85, 58, 15, 60, 6624, 366, 15883, 2514, 459, 13, 9078, 1, 15179, 198, 197, 4798, 787, 62, 1462, 459, 7, 853, 85, ...
2.604167
48
# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-01-22 23:08 from __future__ import unicode_literals from django.db import migrations
[ 2, 532, 9, 12, 19617, 25, 3384, 69, 12, 23, 532, 9, 12, 198, 2, 2980, 515, 416, 37770, 352, 13, 1157, 13, 21, 319, 2864, 12, 486, 12, 1828, 2242, 25, 2919, 198, 6738, 11593, 37443, 834, 1330, 28000, 1098, 62, 17201, 874, 198, ...
2.690909
55
from unittest import skip import unittest2 from nose.plugins.attrib import attr from nose.tools import assert_equals
[ 6738, 555, 715, 395, 1330, 14267, 198, 198, 11748, 555, 715, 395, 17, 198, 6738, 9686, 13, 37390, 13, 1078, 822, 1330, 708, 81, 198, 6738, 9686, 13, 31391, 1330, 6818, 62, 4853, 874, 628 ]
3.4
35
# Copyright 2020-2021 Canonical 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. # # For further info, check https://github.com/canonical/charmcraft """Charmcraft manifest.yaml related functionality.""" import datetime import logging import pathlib from typing import Optional, List import yaml from charmcraft import __version__, config, linters logger = logging.getLogger(__name__) def create_manifest( basedir: pathlib.Path, started_at: datetime.datetime, bases_config: Optional[config.BasesConfiguration], linting_results: List[linters.CheckResult], ): """Create manifest.yaml in basedir for given base configuration. For packing bundles, `bases` will be skipped when bases_config is None. Charms should always include a valid bases_config. :param basedir: Directory to create Charm in. :param started_at: Build start time. :param bases_config: Relevant bases configuration, if any. :returns: Path to created manifest.yaml. """ content = { "charmcraft-version": __version__, "charmcraft-started-at": started_at.isoformat() + "Z", } # Annotate bases only if bases_config is not None. if bases_config is not None: bases = [ { "name": r.name, "channel": r.channel, "architectures": r.architectures, } for r in bases_config.run_on ] content["bases"] = bases # include the linters results (only for attributes) attributes_info = [ {"name": result.name, "result": result.result} for result in linting_results if result.check_type == linters.CheckType.attribute ] content["analysis"] = {"attributes": attributes_info} filepath = basedir / "manifest.yaml" filepath.write_text(yaml.dump(content)) return filepath
[ 2, 15069, 12131, 12, 1238, 2481, 19507, 605, 12052, 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, ...
2.866343
823
#ecoding:utf-8 import DatasetLoader import RICNNModel import tensorflow as tf import sys import numpy as np import regularization as re import os import trainLoader os.environ["CUDA_VISIBLE_DEVICES"] = "1" TRAIN_FILENAME = '/media/liuqi/Files/dataset/test_mnist_ricnn_raw_100.h5' TEST_FILENAME = '/media/liuqi/Files/dataset/test_mnist_ricnn_raw.h5' TRAIN_LABELS = '/media/liuqi/Files/dataset/rotate_100_simple.h5' TEST_LABELS = '/home/liuqi/Desktop/mnist_rotation_new/mnist_all_rotation_normalized_float_test.amat' LOADED_SIZE = 28 DESIRED_SIZE = 227 # model constants NUMBER_OF_CLASSES = 10 NUMBER_OF_FILTERS = 40 NUMBER_OF_FC_FEATURES = 5120 NUMBER_OF_TRANSFORMATIONS = 8 # optimization constants BATCH_SIZE = 64 TEST_CHUNK_SIZE = 100 ADAM_LEARNING_RATE = 1e-5 PRINTING_INTERVAL = 10 # set seeds np.random.seed(100) tf.set_random_seed(100) x = tf.placeholder(tf.float32, shape=[None, DESIRED_SIZE, DESIRED_SIZE, 1, NUMBER_OF_TRANSFORMATIONS]) y_gt = tf.placeholder(tf.float32, shape=[None, NUMBER_OF_CLASSES]) keep_prob = tf.placeholder(tf.float32) logits, raw_feature, regularization_loss = RICNNModel.define_model(x, keep_prob, NUMBER_OF_CLASSES, NUMBER_OF_FILTERS, NUMBER_OF_FC_FEATURES) with tf.name_scope('loss'): with tf.name_scope('re_loss'): re_loss = re.regu_constraint(raw_feature, logits) with tf.name_scope('sotfmax_loss'): sotfmax_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=y_gt)) with tf.name_scope('total_loss'): total_loss = sotfmax_loss train_step = tf.train.AdamOptimizer(ADAM_LEARNING_RATE).minimize(total_loss) correct_prediction = tf.equal(tf.argmax(logits, 1), tf.argmax(y_gt, 1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) session = tf.Session() session.run(tf.initialize_all_variables()) train_data_loader = trainLoader.DataLoader(TRAIN_FILENAME, TRAIN_LABELS, NUMBER_OF_CLASSES, NUMBER_OF_TRANSFORMATIONS, LOADED_SIZE, DESIRED_SIZE) test_data_loader = DatasetLoader.DataLoader(TEST_FILENAME, TEST_LABELS, NUMBER_OF_CLASSES, NUMBER_OF_TRANSFORMATIONS, LOADED_SIZE, DESIRED_SIZE) test_size = test_data_loader.all()[1].shape[0] assert test_size % TEST_CHUNK_SIZE == 0 number_of_test_chunks = test_size / TEST_CHUNK_SIZE while (True): batch = train_data_loader.next_batch(BATCH_SIZE) # next_batch from the loader txt_name = "accary_ricnn.txt" txt_file = file(txt_name, "a+") if (train_data_loader.is_new_epoch()): train_accuracy = session.run(accuracy, feed_dict={x : batch[0], y_gt : batch[1], keep_prob : 1.0}) print_loss = session.run(re_loss,feed_dict={x : batch[0], y_gt : batch[1], keep_prob : 1.0}) print_loss_1 = session.run(sotfmax_loss, feed_dict={x: batch[0], y_gt: batch[1], keep_prob: 1.0}) print(print_loss) print(print_loss_1) train_context = "epochs:" + str(train_data_loader.get_completed_epochs()) + '\n' txt_file.write(train_context) loss_context = "softmax_loss:" + str(print_loss_1) + '\n' txt_file.write(loss_context) txt_file.close() print("completed_epochs %d, training accuracy %g" % (train_data_loader.get_completed_epochs(), train_accuracy)) sys.stdout.flush() if (train_data_loader.get_completed_epochs() % PRINTING_INTERVAL == 0): sum = 0.0 xt_name = "accary_ricnn.txt" txt_file = file(txt_name, "a+") for chunk_index in xrange(number_of_test_chunks): chunk = test_data_loader.next_batch(TEST_CHUNK_SIZE) sum += session.run(accuracy, feed_dict={x : chunk[0], y_gt : chunk[1], keep_prob : 1.0}) test_accuracy = sum / number_of_test_chunks new_context = "testing accuracy: " + str(test_accuracy) + '\n' txt_file.write(new_context) txt_file.close() print("testing accuracy %g" % test_accuracy) sys.stdout.flush() session.run(train_step, feed_dict={x : batch[0], y_gt : batch[1], keep_prob : 0.5})
[ 2, 721, 7656, 25, 40477, 12, 23, 198, 11748, 16092, 292, 316, 17401, 198, 11748, 371, 2149, 6144, 17633, 198, 11748, 11192, 273, 11125, 355, 48700, 198, 11748, 25064, 198, 11748, 299, 32152, 355, 45941, 198, 11748, 3218, 1634, 355, 302,...
1.803655
2,791
#!/usr/bin/env python """Extract radial, sulcal, and gyral orientations from gyral coordinate NIFTI file"""
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 37811, 11627, 974, 44503, 11, 33154, 9948, 11, 290, 21486, 1373, 11367, 602, 422, 21486, 1373, 20435, 399, 5064, 25621, 2393, 37811, 628 ]
3.40625
32
import binascii from pyshark.packet.common import Pickleable, SlotsPickleable
[ 11748, 9874, 292, 979, 72, 198, 198, 6738, 279, 893, 71, 668, 13, 8002, 316, 13, 11321, 1330, 12346, 293, 540, 11, 3454, 1747, 31686, 293, 540, 628 ]
2.857143
28
import pyautogui import time import datetime
[ 11748, 12972, 2306, 519, 9019, 198, 11748, 640, 198, 11748, 4818, 8079, 198 ]
3.461538
13
# https://www.geeksforgeeks.org/write-a-program-to-reverse-an-array-or-string/ # Time: O(n) # Space: 1 arr = [1,2,3] result = reverseByMiddles(arr) print(result) print(reverseByMiddles(arr = [1,2,3,4]))
[ 2, 3740, 1378, 2503, 13, 469, 2573, 30293, 2573, 13, 2398, 14, 13564, 12, 64, 12, 23065, 12, 1462, 12, 50188, 12, 272, 12, 18747, 12, 273, 12, 8841, 14, 198, 2, 3862, 25, 440, 7, 77, 8, 198, 2, 4687, 25, 352, 198, 198, 3258, ...
2.263736
91
from service import Service from unittest import TestCase from mock import patch import sys
[ 6738, 2139, 1330, 4809, 198, 6738, 555, 715, 395, 1330, 6208, 20448, 198, 6738, 15290, 1330, 8529, 198, 11748, 25064, 198, 197, 197 ]
4.086957
23
"""Use TIMESTAMP column for latest submission Revision ID: eff79a07a88d Revises: 83e6b2a46191 Create Date: 2017-01-08 22:20:43.814375 """ # revision identifiers, used by Alembic. revision = 'eff79a07a88d' down_revision = '83e6b2a46191' from alembic import op # lgtm[py/unused-import] import sqlalchemy as sa # lgtm[py/unused-import] import libweasyl from libweasyl.legacy import UNIXTIME_OFFSET
[ 37811, 11041, 31742, 6465, 23518, 5721, 329, 3452, 14498, 198, 198, 18009, 1166, 4522, 25, 914, 3720, 64, 2998, 64, 3459, 67, 198, 18009, 2696, 25, 9698, 68, 21, 65, 17, 64, 3510, 26492, 198, 16447, 7536, 25, 2177, 12, 486, 12, 2919...
2.484663
163
import pandas as pd import numpy as np import os # Function, divided all data into groups by time period, like [1AM-3AM; 3AM-5Am ...] def binning(column, points, labels=None, month=0, stop=0): ''' Notes: The Row Data from MBTA webiste The Time format is from 3:00 to 27:00, means 3:00 AM today to next day 3:00 AM And in the csv file, it use int to replace date format, like 300 means 3:00 AM; 1500 means 3:00 PM :param column: use which column to divide, here we use TIME_PERIOD column :param points: the break points we use to divide :param labels: the labels for result groups that have been divided :param month: used to record error :param stop: used to record error ''' # Get max time and min time from data minval = column.min() maxval = column.max() # Handle break points and labels errors and print while maxval <= points[len(points)-1]: print ('Month: ' + str(month) + ' Stop: ' + stop) del points[len(points)-1] del labels[len(points)-1] while minval >= points[0]: print ('Month: ' + str(month) + ' Stop: ' + stop) del points[0] del labels[0] # The full break points includes min, max time break_points = [minval] + points + [maxval] # If user doesn't provide labels, using int number to replace, here I have provided labels, so it doesn't work if not labels: labels = range(len(points)+1) # cut() function to divide data into groups and return them columnbin = pd.cut(column, bins=break_points, labels=labels, include_lowest=True) return columnbin # Function, make directory. if exist, do nothing # Using Pandas read every months' row data, from January to July, there only 7 months provide by MBTA this year until now for month in range(1,8): csvfile = pd.read_csv('/Users/Eddy/Desktop/Python_MBTA/MBTA_Raw_Entry_Data/2018_0' + str(month) + '.csv') # Format file to prepare data analysis df = pd.DataFrame(csvfile) # Divide data into different part group by stop id grouped = df.groupby('GTFS_STOP_ID', as_index=False) # For every stop's data, using binning() function to divide into different time period for stop, group in grouped: # Define break points points = [500, 700, 900, 1100, 1300, 1500, 1700, 1900, 2100, 2300, 2500] # Define labels labels = ['3AM-5AM', '5AM-7AM', '7AM-9AM', '9AM-11AM', '11AM-1PM', '1PM-3PM', '3PM-5PM', '5PM-7PM', '7PM-9PM', '9PM-11PM', '11PM-1AM', '1AM-3AM'] # Create new column [TIME_PERIOD_Bin] for the result returned by binning() function group['TIME_PERIOD_Bin'] = binning(group['TIME_PERIOD'], points, labels, month, stop) # Format all the data again df_station = pd.DataFrame(group) # Until now, all data have been grouped by stop_id, and then grouped by time period that we create group_time = df_station.groupby('TIME_PERIOD_Bin') # Make directory to store new csv files mkdir('/Users/Eddy/Desktop/Python_MBTA/Step1/' + str(month)) # Calculate the sum of entry people number for every stops and every periods data1 = pd.DataFrame(group_time['STATION_ENTRIES'].agg(np.sum)) # Write into the csv files data1.to_csv('/Users/Eddy/Desktop/Python_MBTA/Step1/' + str(month) + "/" + stop + '.csv')
[ 11748, 19798, 292, 355, 279, 67, 198, 11748, 299, 32152, 355, 45941, 198, 11748, 28686, 198, 198, 2, 15553, 11, 9086, 477, 1366, 656, 2628, 416, 640, 2278, 11, 588, 685, 16, 2390, 12, 18, 2390, 26, 513, 2390, 12, 20, 5840, 2644, 6...
2.643357
1,287
from utils import default_args from datetime import timedelta from airflow import DAG from airflow_kubernetes_job_operator import ( KubernetesJobOperator, JobRunnerDeletePolicy, KubernetesLegacyJobOperator, ) dag = DAG( "kub-job-op-test-jinja", default_args=default_args, description="Test base job operator", schedule_interval=None, catchup=False, user_defined_macros={ "test_macro": lambda a: f"my {a}", "default_image": "ubuntu", }, ) namespace = None envs = { "TIC_COUNT": 3, "PASS_ARG": "a test", "JINJA_ENV": "{{ ds }}", } default_delete_policy = JobRunnerDeletePolicy.Never KubernetesJobOperator( task_id="test-job-success", namespace=namespace, image="{{default_image}}", body_filepath="./templates/test_job.success.jinja.yaml", envs=envs, dag=dag, delete_policy=default_delete_policy, jinja_job_args={"test": "lama"}, ) # bash_script = """ # #/usr/bin/env bash # echo "Legacy start for taskid {{ti.task_id}} {{job.test}}" # cur_count=0 # while true; do # cur_count=$((cur_count + 1)) # if [ "$cur_count" -ge "$TIC_COUNT" ]; then # break # fi # date # sleep 1 # done # echo "Complete" # """ # KubernetesLegacyJobOperator( # task_id="legacy-test-job-success", # image="{{default_image}}", # cmds=["bash", "-c", bash_script], # dag=dag, # is_delete_operator_pod=True, # env_vars=envs, # delete_policy=default_delete_policy, # ) if __name__ == "__main__": dag.clear(reset_dag_runs=True) dag.run()
[ 6738, 3384, 4487, 1330, 4277, 62, 22046, 198, 6738, 4818, 8079, 1330, 28805, 12514, 198, 6738, 45771, 1330, 360, 4760, 198, 6738, 45771, 62, 74, 18478, 3262, 274, 62, 21858, 62, 46616, 1330, 357, 198, 220, 220, 220, 12554, 527, 3262, ...
2.255014
698
import json import jsonpath import paramiko from spacecapsule.history import store_experiment, rollback_command from subprocess import Popen, PIPE from spacecapsule.k8s import prepare_api, copy_tar_file_to_namespaced_pod, executor_command_inside_namespaced_pod from spacecapsule.template import chaosblade_prepare_script, resource_path, chaosblade_inject, chaosblade_prepare, \ chaosblade_jvm_delay, chaosblade_prepare_script_vm
[ 11748, 33918, 198, 198, 11748, 33918, 6978, 198, 11748, 5772, 12125, 198, 198, 6738, 2272, 27979, 2261, 13, 23569, 1330, 3650, 62, 23100, 3681, 11, 4836, 1891, 62, 21812, 198, 6738, 850, 14681, 1330, 8099, 268, 11, 350, 4061, 36, 198, ...
3.217391
138
"""POD-NN modeling for 1D, unsteady Burger Equation.""" #%% Imports import sys import os import pickle import numpy as np sys.path.append(os.path.join("..", "..")) from poduqnn.podnnmodel import PodnnModel from poduqnn.mesh import read_multi_space_sol_input_mesh from poduqnn.handling import clean_dir, split_dataset from hyperparams import HP as hp resdir = "cache" clean_dir(resdir) # Getting data from the files # fake_x = np.zeros(hp["n_s"] + hp["n_s_tst"]) # test_size = hp["n_s_tst"] / (hp["n_s"] + hp["n_s_tst"]) # train_tst_idx = split_dataset(fake_x, fake_x, test_size, idx_only=True) train_tst_idx = ([129, 13, 161, 10, 3, 4, 68, 19, 108, 63, 62, 147, 117, 113, 165, 80, 124, 33, 41, 37, 79, 184, 154, 83, 102, 190, 195, 148, 46, 114, 16, 155, 121, 104, 120, 58, 53, 78, 160, 193, 126, 115, 95, 127, 166, 131, 49, 100, 84, 35, 12, 27, 118, 167, 66, 56, 106, 175, 143, 97, 87, 1, 183, 111, 36, 158, 153, 199, 17, 31, 177, 194, 182, 59, 187, 130, 163, 92, 48, 96, 82, 6, 123, 98, 192, 43, 26, 181, 170, 134, 72, 50, 24, 174, 122, 103, 71, 138, 110, 7, 65, 51, 28, 173, 172, 34, 90, 119, 185, 15, 186, 101, 85, 60, 75, 39, 38, 5, 141, 89, 57, 144, 64, 67, 171, 157, 94, 70, 142, 54, 74, 146, 191, 112, 107, 189, 30, 32, 133, 169, 151, 23, 21, 99, 2, 22, 116, 91, 145, 178, 137, 135, 40, 73, 47, 52, 25, 93, 128, 88, 109, 44, 29, 198, 159, 125, 11, 45, 197, 149, 69, 188, 164, 0, 18, 176, 9, 168, 77, 132], [76, 42, 179, 61, 105, 136, 86, 196, 8, 14, 139, 20, 150, 152, 180, 162, 140, 81, 55, 156]) with open(os.path.join("cache", "train_tst_idx.pkl"), "wb") as f: pickle.dump(train_tst_idx, f) datadir = "data" mu_path = os.path.join(datadir, "INPUT_MONTE_CARLO.dat") # x_mesh, connectivity, X_v, U = \ # read_multi_space_sol_input_mesh(hp["n_s"], 1, 1, train_tst_idx[0], # hp["mesh_idx"], datadir, mu_path, # hp["mu_idx"]) # np.save(os.path.join("cache", "x_mesh.npy"), x_mesh) # np.save(os.path.join("cache", "connectivity.npy"), connectivity) # np.save(os.path.join("cache", "X_v.npy"), X_v) # np.save(os.path.join("cache", "U.npy"), U) x_mesh = np.load(os.path.join("cache", "x_mesh.npy")) connectivity = np.load(os.path.join("cache", "connectivity.npy")) X_v = np.load(os.path.join("cache", "X_v.npy")) U = np.load(os.path.join("cache", "U.npy")) # x_mesh = np.load(os.path.join("cache", "x_mesh.npy")) # connectivity = np.load(os.path.join("cache", "connectivity.npy")) # X_v = np.load(os.path.join("cache", "X_v.npy")) # U = np.load(os.path.join("cache", "U.npy")) #%% Init the model model = PodnnModel(resdir, hp["n_v"], x_mesh, hp["n_t"]) #%% Generate the dataset from the mesh and params X_v_train, v_train, \ X_v_val, v_val, \ U_val = model.convert_multigpu_data(U, X_v, hp["train_val"], hp["eps"]) model.initVNNs(hp["n_M"], hp["h_layers"], hp["lr"], hp["lambda"], hp["adv_eps"], hp["soft_0"], hp["norm"])
[ 37811, 47, 3727, 12, 6144, 21128, 329, 352, 35, 11, 15014, 1329, 88, 28983, 7889, 341, 526, 15931, 198, 2, 16626, 1846, 3742, 198, 11748, 25064, 198, 11748, 28686, 198, 11748, 2298, 293, 198, 11748, 299, 32152, 355, 45941, 198, 198, 1...
2.143791
1,377
coordinates_01EE00 = ((121, 126), (121, 132), (121, 134), (121, 135), (121, 137), (121, 138), (121, 139), (121, 140), (121, 141), (122, 114), (122, 115), (122, 116), (122, 117), (122, 119), (122, 125), (122, 127), (122, 128), (122, 142), (123, 110), (123, 111), (123, 112), (123, 113), (123, 120), (123, 124), (123, 126), (123, 130), (123, 132), (123, 133), (123, 134), (123, 135), (123, 136), (123, 137), (123, 138), (123, 139), (123, 140), (123, 141), (123, 144), (124, 107), (124, 109), (124, 114), (124, 115), (124, 116), (124, 117), (124, 118), (124, 120), (124, 124), (124, 125), (124, 126), (124, 127), (124, 128), (124, 129), (124, 131), (124, 132), (124, 133), (124, 134), (124, 135), (124, 136), (124, 137), (124, 138), (124, 139), (124, 140), (124, 141), (124, 142), (124, 146), (125, 105), (125, 110), (125, 111), (125, 112), (125, 113), (125, 114), (125, 115), (125, 116), (125, 117), (125, 118), (125, 119), (125, 120), (125, 122), (125, 124), (125, 125), (125, 126), (125, 127), (125, 128), (125, 129), (125, 130), (125, 131), (125, 132), (125, 133), (125, 134), (125, 135), (125, 136), (125, 137), (125, 138), (125, 139), (125, 140), (125, 141), (125, 142), (125, 143), (125, 144), (125, 148), (126, 103), (126, 107), (126, 108), (126, 109), (126, 110), (126, 111), (126, 112), (126, 113), (126, 114), (126, 115), (126, 116), (126, 117), (126, 118), (126, 119), (126, 120), (126, 124), (126, 125), (126, 126), (126, 127), (126, 128), (126, 129), (126, 130), (126, 131), (126, 132), (126, 133), (126, 134), (126, 135), (126, 136), (126, 137), (126, 138), (126, 139), (126, 140), (126, 141), (126, 142), (126, 143), (126, 144), (126, 145), (126, 146), (126, 149), (127, 102), (127, 105), (127, 106), (127, 107), (127, 108), (127, 109), (127, 110), (127, 111), (127, 112), (127, 113), (127, 114), (127, 115), (127, 116), (127, 117), (127, 118), (127, 119), (127, 120), (127, 121), (127, 122), (127, 123), (127, 124), (127, 125), (127, 126), (127, 127), (127, 128), (127, 129), (127, 130), (127, 131), (127, 132), (127, 133), (127, 134), (127, 135), (127, 136), (127, 137), (127, 138), (127, 139), (127, 140), (127, 141), (127, 142), (127, 143), (127, 144), (127, 145), (127, 146), (127, 147), (127, 148), (127, 150), (128, 103), (128, 105), (128, 106), (128, 107), (128, 108), (128, 109), (128, 110), (128, 111), (128, 112), (128, 113), (128, 114), (128, 115), (128, 116), (128, 117), (128, 118), (128, 119), (128, 120), (128, 121), (128, 122), (128, 123), (128, 124), (128, 125), (128, 126), (128, 127), (128, 128), (128, 129), (128, 130), (128, 131), (128, 132), (128, 133), (128, 134), (128, 135), (128, 136), (128, 137), (128, 138), (128, 139), (128, 140), (128, 141), (128, 142), (128, 143), (128, 144), (128, 145), (128, 146), (128, 147), (128, 149), (129, 103), (129, 105), (129, 106), (129, 107), (129, 108), (129, 109), (129, 110), (129, 111), (129, 112), (129, 113), (129, 114), (129, 115), (129, 116), (129, 117), (129, 118), (129, 119), (129, 120), (129, 121), (129, 122), (129, 123), (129, 124), (129, 125), (129, 126), (129, 127), (129, 128), (129, 129), (129, 130), (129, 131), (129, 132), (129, 133), (129, 134), (129, 135), (129, 136), (129, 137), (129, 138), (129, 139), (129, 140), (129, 141), (129, 142), (129, 143), (129, 144), (129, 145), (129, 146), (129, 147), (129, 149), (130, 104), (130, 107), (130, 108), (130, 109), (130, 110), (130, 111), (130, 112), (130, 113), (130, 114), (130, 115), (130, 116), (130, 117), (130, 118), (130, 119), (130, 120), (130, 121), (130, 122), (130, 123), (130, 124), (130, 125), (130, 126), (130, 127), (130, 128), (130, 129), (130, 130), (130, 131), (130, 132), (130, 133), (130, 134), (130, 135), (130, 136), (130, 137), (130, 138), (130, 139), (130, 140), (130, 141), (130, 142), (130, 143), (130, 144), (130, 145), (130, 146), (130, 148), (131, 104), (131, 106), (131, 107), (131, 108), (131, 109), (131, 110), (131, 111), (131, 112), (131, 113), (131, 114), (131, 115), (131, 116), (131, 117), (131, 118), (131, 119), (131, 120), (131, 121), (131, 122), (131, 123), (131, 124), (131, 125), (131, 126), (131, 127), (131, 128), (131, 129), (131, 130), (131, 131), (131, 132), (131, 133), (131, 134), (131, 135), (131, 136), (131, 137), (131, 138), (131, 139), (131, 140), (131, 141), (131, 142), (131, 143), (131, 144), (131, 145), (131, 147), (132, 108), (132, 109), (132, 110), (132, 111), (132, 112), (132, 113), (132, 114), (132, 115), (132, 116), (132, 117), (132, 118), (132, 119), (132, 120), (132, 121), (132, 122), (132, 123), (132, 124), (132, 125), (132, 126), (132, 127), (132, 128), (132, 129), (132, 130), (132, 131), (132, 132), (132, 133), (132, 134), (132, 135), (132, 136), (132, 137), (132, 138), (132, 139), (132, 140), (132, 141), (132, 142), (132, 143), (132, 144), (132, 146), (133, 108), (133, 110), (133, 111), (133, 112), (133, 113), (133, 114), (133, 115), (133, 116), (133, 117), (133, 118), (133, 119), (133, 120), (133, 121), (133, 122), (133, 123), (133, 124), (133, 125), (133, 126), (133, 127), (133, 128), (133, 129), (133, 130), (133, 131), (133, 132), (133, 133), (133, 134), (133, 135), (133, 136), (133, 137), (133, 138), (133, 139), (133, 140), (133, 141), (133, 142), (133, 143), (133, 144), (133, 146), (134, 107), (134, 108), (134, 109), (134, 110), (134, 111), (134, 112), (134, 113), (134, 114), (134, 115), (134, 116), (134, 117), (134, 118), (134, 119), (134, 120), (134, 121), (134, 122), (134, 123), (134, 124), (134, 125), (134, 126), (134, 127), (134, 128), (134, 129), (134, 130), (134, 131), (134, 132), (134, 133), (134, 134), (134, 135), (134, 136), (134, 137), (134, 138), (134, 139), (134, 140), (134, 141), (134, 142), (134, 143), (134, 145), (135, 106), (135, 108), (135, 109), (135, 110), (135, 111), (135, 112), (135, 113), (135, 114), (135, 115), (135, 116), (135, 117), (135, 118), (135, 119), (135, 120), (135, 121), (135, 122), (135, 123), (135, 124), (135, 125), (135, 126), (135, 127), (135, 128), (135, 129), (135, 130), (135, 131), (135, 132), (135, 133), (135, 134), (135, 135), (135, 136), (135, 137), (135, 138), (135, 139), (135, 140), (135, 141), (135, 142), (135, 143), (135, 145), (136, 105), (136, 107), (136, 110), (136, 111), (136, 112), (136, 113), (136, 114), (136, 115), (136, 116), (136, 117), (136, 118), (136, 119), (136, 120), (136, 121), (136, 122), (136, 123), (136, 124), (136, 125), (136, 126), (136, 127), (136, 128), (136, 129), (136, 130), (136, 131), (136, 132), (136, 133), (136, 134), (136, 135), (136, 136), (136, 137), (136, 138), (136, 139), (136, 140), (136, 141), (136, 142), (136, 144), (137, 105), (137, 109), (137, 110), (137, 111), (137, 112), (137, 113), (137, 114), (137, 115), (137, 116), (137, 117), (137, 118), (137, 119), (137, 120), (137, 121), (137, 122), (137, 123), (137, 124), (137, 125), (137, 126), (137, 127), (137, 128), (137, 129), (137, 130), (137, 131), (137, 132), (137, 133), (137, 134), (137, 135), (137, 136), (137, 137), (137, 138), (137, 139), (137, 140), (137, 141), (137, 142), (137, 144), (138, 105), (138, 107), (138, 110), (138, 112), (138, 113), (138, 114), (138, 115), (138, 116), (138, 117), (138, 118), (138, 119), (138, 120), (138, 121), (138, 122), (138, 123), (138, 124), (138, 125), (138, 126), (138, 127), (138, 128), (138, 129), (138, 130), (138, 131), (138, 132), (138, 133), (138, 134), (138, 135), (138, 136), (138, 137), (138, 138), (138, 139), (138, 140), (138, 141), (138, 143), (139, 106), (139, 110), (139, 112), (139, 113), (139, 114), (139, 115), (139, 116), (139, 117), (139, 118), (139, 119), (139, 120), (139, 121), (139, 122), (139, 123), (139, 124), (139, 125), (139, 126), (139, 127), (139, 128), (139, 129), (139, 130), (139, 131), (139, 132), (139, 133), (139, 134), (139, 135), (139, 136), (139, 137), (139, 138), (139, 139), (139, 140), (139, 142), (140, 110), (140, 112), (140, 113), (140, 114), (140, 115), (140, 116), (140, 117), (140, 118), (140, 119), (140, 120), (140, 121), (140, 122), (140, 123), (140, 124), (140, 125), (140, 126), (140, 127), (140, 128), (140, 129), (140, 130), (140, 131), (140, 132), (140, 133), (140, 134), (140, 135), (140, 138), (140, 139), (140, 141), (141, 110), (141, 115), (141, 116), (141, 117), (141, 118), (141, 119), (141, 120), (141, 121), (141, 122), (141, 123), (141, 124), (141, 125), (141, 126), (141, 127), (141, 128), (141, 129), (141, 130), (141, 131), (141, 132), (141, 133), (141, 134), (141, 136), (141, 137), (141, 138), (141, 139), (141, 141), (142, 110), (142, 112), (142, 113), (142, 114), (142, 115), (142, 116), (142, 117), (142, 118), (142, 119), (142, 120), (142, 121), (142, 122), (142, 123), (142, 124), (142, 125), (142, 126), (142, 127), (142, 128), (142, 129), (142, 130), (142, 131), (142, 132), (142, 133), (142, 135), (142, 138), (142, 141), (143, 115), (143, 117), (143, 118), (143, 119), (143, 120), (143, 121), (143, 122), (143, 123), (143, 124), (143, 125), (143, 126), (143, 127), (143, 128), (143, 129), (143, 130), (143, 131), (143, 132), (143, 134), (143, 138), (143, 140), (144, 115), (144, 117), (144, 118), (144, 119), (144, 120), (144, 121), (144, 122), (144, 123), (144, 124), (144, 125), (144, 126), (144, 127), (144, 128), (144, 129), (144, 130), (144, 131), (144, 138), (145, 115), (145, 117), (145, 118), (145, 119), (145, 120), (145, 121), (145, 122), (145, 123), (145, 124), (145, 125), (145, 126), (145, 127), (145, 128), (145, 129), (145, 133), (145, 138), (145, 139), (146, 116), (146, 119), (146, 120), (146, 121), (146, 122), (146, 123), (146, 124), (146, 125), (146, 126), (146, 127), (146, 128), (146, 138), (147, 117), (147, 119), (147, 120), (147, 121), (147, 122), (147, 123), (147, 124), (147, 125), (147, 126), (147, 127), (147, 129), (148, 119), (148, 121), (148, 122), (148, 123), (148, 124), (148, 125), (148, 126), (148, 128), (149, 119), (149, 121), (149, 122), (149, 123), (149, 128), (150, 118), (150, 120), (150, 121), (150, 125), (150, 126), (150, 129), (151, 118), (151, 123), (151, 127), (151, 128), (151, 130), (151, 132), (152, 120), (152, 121), (152, 128), (152, 133), ) coordinates_00EE00 = ((98, 135), (99, 121), (99, 122), (99, 135), (99, 136), (100, 120), (100, 122), (100, 135), (101, 114), (101, 120), (101, 123), (101, 129), (101, 135), (101, 137), (102, 114), (102, 119), (102, 121), (102, 123), (102, 128), (102, 130), (102, 136), (103, 114), (103, 119), (103, 121), (103, 122), (103, 123), (103, 125), (103, 126), (103, 130), (104, 112), (104, 115), (104, 118), (104, 120), (104, 123), (104, 128), (104, 130), (105, 111), (105, 114), (105, 116), (105, 117), (105, 119), (105, 120), (105, 121), (105, 122), (105, 123), (105, 124), (105, 125), (105, 126), (105, 127), (105, 128), (105, 129), (105, 130), (105, 132), (106, 111), (106, 113), (106, 114), (106, 115), (106, 118), (106, 120), (106, 123), (106, 125), (106, 126), (106, 127), (106, 128), (106, 129), (106, 130), (106, 134), (107, 111), (107, 113), (107, 114), (107, 115), (107, 116), (107, 117), (107, 118), (107, 120), (107, 123), (107, 124), (107, 125), (107, 126), (107, 127), (107, 128), (107, 129), (107, 130), (107, 131), (107, 132), (107, 134), (108, 111), (108, 113), (108, 114), (108, 115), (108, 116), (108, 117), (108, 118), (108, 119), (108, 120), (108, 123), (108, 126), (108, 127), (108, 128), (108, 129), (108, 130), (108, 131), (108, 132), (108, 133), (108, 135), (109, 111), (109, 115), (109, 116), (109, 117), (109, 118), (109, 119), (109, 120), (109, 121), (109, 123), (109, 124), (109, 125), (109, 128), (109, 129), (109, 130), (109, 131), (109, 132), (109, 133), (109, 134), (109, 136), (110, 110), (110, 112), (110, 113), (110, 114), (110, 117), (110, 118), (110, 119), (110, 120), (110, 121), (110, 123), (110, 126), (110, 127), (110, 128), (110, 129), (110, 130), (110, 131), (110, 132), (110, 133), (110, 134), (110, 135), (110, 138), (111, 109), (111, 111), (111, 115), (111, 117), (111, 118), (111, 119), (111, 120), (111, 122), (111, 128), (111, 130), (111, 131), (111, 132), (111, 133), (111, 134), (111, 135), (111, 136), (111, 140), (112, 107), (112, 111), (112, 117), (112, 119), (112, 120), (112, 121), (112, 123), (112, 128), (112, 130), (112, 131), (112, 132), (112, 133), (112, 134), (112, 135), (112, 136), (112, 137), (112, 138), (113, 105), (113, 109), (113, 110), (113, 111), (113, 113), (113, 118), (113, 120), (113, 121), (113, 122), (113, 123), (113, 124), (113, 125), (113, 126), (113, 127), (113, 130), (113, 131), (113, 132), (113, 133), (113, 134), (113, 135), (113, 136), (113, 137), (113, 138), (113, 139), (113, 141), (114, 105), (114, 107), (114, 108), (114, 109), (114, 110), (114, 111), (114, 114), (114, 118), (114, 119), (114, 120), (114, 121), (114, 122), (114, 123), (114, 128), (114, 129), (114, 131), (114, 132), (114, 133), (114, 134), (114, 135), (114, 136), (114, 137), (114, 138), (114, 139), (114, 141), (115, 105), (115, 107), (115, 108), (115, 109), (115, 110), (115, 111), (115, 112), (115, 113), (115, 116), (115, 117), (115, 118), (115, 119), (115, 120), (115, 121), (115, 122), (115, 123), (115, 124), (115, 127), (115, 130), (115, 132), (115, 133), (115, 134), (115, 135), (115, 136), (115, 137), (115, 138), (115, 139), (115, 141), (116, 105), (116, 126), (116, 131), (116, 133), (116, 134), (116, 135), (116, 136), (116, 137), (116, 138), (116, 139), (116, 141), (117, 106), (117, 108), (117, 109), (117, 110), (117, 111), (117, 112), (117, 113), (117, 114), (117, 115), (117, 116), (117, 117), (117, 118), (117, 119), (117, 120), (117, 121), (117, 122), (117, 124), (117, 131), (117, 140), (118, 132), (118, 134), (118, 135), (118, 136), (118, 138), (118, 140), (119, 132), (119, 135), (119, 139), (119, 140), ) coordinates_E0E1E1 = ((126, 127), (126, 134), (127, 118), (127, 126), (127, 134), (128, 118), (128, 125), (128, 128), (129, 119), (129, 128), (129, 129), (130, 123), (130, 128), (130, 130), (131, 122), (131, 128), (131, 129), (132, 122), (132, 128), (134, 122), (136, 121), (137, 121), ) coordinates_E1E1E1 = ((111, 125), (112, 114), )
[ 37652, 17540, 62, 486, 6500, 405, 796, 14808, 19244, 11, 19710, 828, 220, 220, 198, 7, 19244, 11, 21761, 828, 357, 19244, 11, 22352, 828, 357, 19244, 11, 17501, 828, 357, 19244, 11, 21643, 828, 357, 19244, 11, 21503, 828, 357, 19244, ...
2.380555
5,873
cars = 100 space_in_a_car = 4.0 drivers = 30 passengers = 90 cars_not_driven = cars -drivers cars_driven = drivers carpool_carpacity = cars_driven * space_in_a_car average_passengers_per_car = passengers / cars_driven print("There are", cars, "cars available") print("There are only", drivers, "drivers available") print("There will be", cars_not_driven, "empty cars today") print("We can transport", carpool_carpacity, "people today") print("We have", passengers, "to carpool today") print("We need to put about", average_passengers_per_car, "people in each car")
[ 37993, 796, 1802, 198, 13200, 62, 259, 62, 64, 62, 7718, 796, 604, 13, 15, 198, 36702, 796, 1542, 198, 6603, 9302, 796, 4101, 198, 37993, 62, 1662, 62, 15808, 796, 5006, 532, 36702, 198, 37993, 62, 15808, 796, 6643, 198, 66, 5117, ...
3.228571
175
import json import logging import os import click import numpy as np from keras import backend as K from keras.models import load_model as keras_load from sklearn.base import clone as sklearn_clone from sklearn.externals import joblib from faculty_xval.utilities import keras_clone_and_compile LOGGER = logging.getLogger(__name__) logging.basicConfig(format="%(asctime)s %(message)s", level=logging.INFO) def load_model(path, model_type): """ Load the model using the method appropriate for its type ("keras" or other). Parameters ---------- path: String File path to look for the model. model_type: String String specifying the type of model to be loaded. Anything other than "keras" will be loaded using joblib. """ if model_type == "keras": # Load Keras model. LOGGER.info("Loading Keras model") model = keras_load(path) LOGGER.info("Model loading complete") else: # Load model of other type. LOGGER.info("Loading model with joblib") model = joblib.load(path) LOGGER.info("Model loading complete") return model def clone_model(model, model_type): """ Clone the model using the method appropriate for its type ("keras", "sklearn" or other). Reset the state of the model so that each train/test split is independent. Parameters ---------- model: Scikit-Learn/Keras Model Model to be cloned. model_type: String String specifying the type of model to be cloned. Recognised options are "keras" and "sklearn". Any other option results in the function returning the input model, thus doing nothing. Returns ------- cloned: Scikit-Learn/Keras Model The cloned model with reset state. """ if model_type == "keras": cloned = keras_clone_and_compile(model) elif model_type == "sklearn": cloned = sklearn_clone(model) else: cloned = model LOGGER.warning( "Model type not recognised. " + "Cannot reset the state of the model automatically" ) return cloned def validate( model, features, targets, i_train, i_test, fit_kwargs=None, predict_kwargs=None ): """ Fit the model on specific training data, and predict on specific test data. Parameters ---------- model: sklearn/keras Model Model to cross-validate. features: list of np.array Features for training/testing. For multi-input models, the list contains multiple Numpy arrays. targets: list of np.array Targets for training/testing. For multi-output models, the list contains multiple Numpy arrays. i_train: np.array np.array of indices corresponding to the rows used for training i_test: np.array np.array of indices corresponding to the rows used for testing fit_kwargs: dict, optional, default = None Dictionary of any additional kwargs to be used by the model during fitting. predict_kwargs: dict, optional, default = None Dictionary of any additional kwargs to be used by the model during prediction. Returns -------- predictions: np.array Model predictions. """ if fit_kwargs is None: fit_kwargs = {} if predict_kwargs is None: predict_kwargs = {} LOGGER.info("Training the model") features_train = [x[i_train] for x in features] targets_train = [y[i_train] for y in targets] if len(features_train) == 1: features_train = features_train[0].copy() if len(targets_train) == 1: targets_train = targets_train[0].copy() model.fit(features_train, targets_train, **fit_kwargs) LOGGER.info("Generating model predictions") features_test = [x[i_test] for x in features] if len(features_test) == 1: features_test = features_test[0].copy() predictions = model.predict(features_test, **predict_kwargs) return np.array(predictions) if __name__ == "__main__": main()
[ 11748, 33918, 198, 11748, 18931, 198, 11748, 28686, 198, 198, 11748, 3904, 198, 11748, 299, 32152, 355, 45941, 198, 198, 6738, 41927, 292, 1330, 30203, 355, 509, 198, 6738, 41927, 292, 13, 27530, 1330, 3440, 62, 19849, 355, 41927, 292, ...
2.586634
1,616
from bs4 import BeautifulSoup import requests import math import time start_url='https://www.macys.com' domain='https://www.macys.com' ''' get soup ''' '''find all anchor tags''' '''print all 'title' attributes''' '''iterate through all pages for each soup object''' '''filehandlers for output.txt and urlHandler.txt''' '''generates soup object for each url''' '''main function''' if __name__=='__main__': start_time=time.time() items=[] tags=findAllATags(url=start_url) '''executing getItems for tags[12:] because first 11 have no relevant information''' for i in tags[12:]: getItems(i.attrs['href']) print(time.time()-start_time)
[ 6738, 275, 82, 19, 1330, 23762, 50, 10486, 201, 198, 11748, 7007, 201, 198, 11748, 10688, 201, 198, 11748, 640, 201, 198, 201, 198, 201, 198, 9688, 62, 6371, 11639, 5450, 1378, 2503, 13, 20285, 893, 13, 785, 6, 201, 198, 27830, 1163...
2.537906
277
from django.conf.urls import url from contactnetwork import views # from django.views.generic import TemplateView urlpatterns = [ url(r'^clusteringdata$', views.ClusteringData, name='clusteringdata'), url(r'^clustering$', views.Clustering, name='clustering'), url(r'^structure_clustering$', views.Clustering, name='clustering'), url(r'^distances', views.ShowDistances, name='distances'), url(r'^distancedatagroups', views.DistanceDataGroups, name='distancedatagroups'), url(r'^distancedata', views.DistanceData, name='distancedata'), url(r'^interactions[/]?$', views.Interactions, name='interactions'), url(r'^comparative_analysis[/]?$', views.Interactions, name='interactions'), url(r'^interactiondata', views.InteractionData, name='interactiondata'), url(r'^browser[/]?$', views.InteractionBrowser, name='interactionsbrowser'), url(r'^browserdata', views.InteractionBrowserData, name='interactionsbrowserdata'), url(r'^state_contacts[/]?$', views.StateContacts, name='statecontacts'), url(r'^pdbtreedata', views.PdbTreeData, name='pdbtreedata'), url(r'^pdbtabledata', views.PdbTableData, name='pdbtabledata'), url(r'^pdb/(?P<pdbname>\w+)$', views.ServePDB, name='serve_pdb'), ]
[ 6738, 42625, 14208, 13, 10414, 13, 6371, 82, 1330, 19016, 198, 198, 6738, 2800, 27349, 1330, 5009, 198, 2, 422, 42625, 14208, 13, 33571, 13, 41357, 1330, 37350, 7680, 198, 198, 6371, 33279, 82, 796, 685, 198, 220, 220, 220, 19016, 7, ...
2.684665
463
course = "Python Programming" print(course.upper()) print(course.lower()) print(course.title()) course = " Python Programming" print(course) print(course.strip()) print(course.find("Pro")) print(course.find("pro")) print(course.replace("P", "-")) print("Programming" in course) print("Programming" not in course)
[ 17319, 796, 366, 37906, 30297, 1, 198, 4798, 7, 17319, 13, 45828, 28955, 198, 4798, 7, 17319, 13, 21037, 28955, 198, 4798, 7, 17319, 13, 7839, 28955, 198, 198, 17319, 796, 366, 220, 220, 220, 11361, 30297, 1, 198, 4798, 7, 17319, 8,...
3.106796
103
import re from data_transformer.views import stringIsInteger
[ 11748, 302, 198, 6738, 1366, 62, 7645, 16354, 13, 33571, 1330, 4731, 3792, 46541, 628, 628, 628, 628 ]
3.777778
18
from pydantic import BaseModel, Field, EmailStr
[ 6738, 279, 5173, 5109, 1330, 7308, 17633, 11, 7663, 11, 9570, 13290, 628, 198 ]
3.571429
14
__version__ = '1.0.2' __author__ = 'Christian Musa <christianmusa@gmail.com>' __url__ = 'https://github.com/crash7/griffin-powermate' __all__ = [] from griffin_powermate import *
[ 834, 9641, 834, 796, 705, 16, 13, 15, 13, 17, 6, 198, 834, 9800, 834, 220, 796, 705, 20298, 2629, 64, 1279, 43533, 666, 14664, 64, 31, 14816, 13, 785, 29, 6, 198, 834, 6371, 834, 220, 220, 220, 220, 796, 705, 5450, 1378, 12567, ...
2.410256
78
import unittest from parameterized import parameterized import os from integration_tests.dataproc_test_case import DataprocTestCase METADATA = 'flink-start-yarn-session=false' if __name__ == '__main__': unittest.main()
[ 11748, 555, 715, 395, 198, 198, 6738, 11507, 1143, 1330, 11507, 1143, 198, 11748, 28686, 198, 6738, 11812, 62, 41989, 13, 19608, 499, 12204, 62, 9288, 62, 7442, 1330, 16092, 499, 12204, 14402, 20448, 198, 198, 47123, 2885, 13563, 796, 7...
2.961039
77
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * 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. # * Neither the name of NVIDIA CORPORATION nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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. import test_plan import settings # Convenience globals kmd = Module.runScript devices = Module.deviceTargets ces = ["Core Engine Scheduler"] nn = ["Neural Network"] convd = ["CONV HW - Direct"] convi = ["CONV HW - Image"] convw = ["CONV HW - Winograd"] convp = ["CONV HW - Pipeline"] sdpx1 = ["SDP X1 HW"] sdpx2 = ["SDP X2 HW"] sdpy = ["SDP Y HW"] sdpf = ["SDP HW - Full"] cdp = ["CDP HW"] pdp = ["PDP HW"] Module.register_tests = registerTests
[ 2, 15069, 357, 66, 8, 2864, 11, 15127, 23929, 44680, 6234, 13, 1439, 2489, 10395, 13, 198, 2, 198, 2, 2297, 396, 3890, 290, 779, 287, 2723, 290, 13934, 5107, 11, 351, 393, 1231, 198, 2, 17613, 11, 389, 10431, 2810, 326, 262, 1708,...
3.302829
601
import numpy as np from typing import List, Tuple from .base import _DataSet
[ 11748, 299, 32152, 355, 45941, 198, 6738, 19720, 1330, 7343, 11, 309, 29291, 198, 198, 6738, 764, 8692, 1330, 4808, 6601, 7248, 628 ]
3.434783
23
#!/usr/bin/env python # vim:ts=4:sts=4:sw=4:et # # Author: Hari Sekhon # Date: 2018-09-09 23:06:06 +0100 (Sun, 09 Sep 2018) # # https://github.com/harisekhon/devops-python-tools # # License: see accompanying Hari Sekhon LICENSE file # # If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback # to help improve or steer this or other code I publish # pylint: disable=line-too-long # # https://www.linkedin.com/in/harisekhon # """ Strip ANSI Escape Codes from Text String input Works as a standard unix filter program, reading from file arguments or standard input and printing to standard output """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import os import sys libdir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'pylib')) sys.path.append(libdir) try: # pylint: disable=wrong-import-position from harisekhon.utils import die, ERRORS, log_option, strip_ansi_escape_codes from harisekhon import CLI except ImportError as _: print('module import failed: %s' % _, file=sys.stderr) print("Did you remember to build the project by running 'make'?", file=sys.stderr) print("Alternatively perhaps you tried to copy this program out without it's adjacent libraries?", file=sys.stderr) sys.exit(4) __author__ = 'Hari Sekhon' __version__ = '0.2' # pylint: disable=too-few-public-methods if __name__ == '__main__': StripAnsiEscapeCodes().main()
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 2, 220, 43907, 25, 912, 28, 19, 25, 6448, 28, 19, 25, 2032, 28, 19, 25, 316, 198, 2, 198, 2, 220, 6434, 25, 2113, 72, 37558, 24130, 198, 2, 220, 7536, 25, 2864, 12, 2931, 12, ...
2.961832
524
from vk_bot.core.modules.basicplug import BasicPlug import time
[ 6738, 410, 74, 62, 13645, 13, 7295, 13, 18170, 13, 35487, 16875, 1330, 14392, 23257, 198, 11748, 640, 198 ]
3.368421
19
## Copyright 2021, Oracle and/or its affiliates. ## Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. #!/usr/bin/env python from setuptools import setup setup(name='wind-marketplace-library', version="1.0.0", description='Robot Framework test library for OCI Marketplace', long_description='Robot Framework test library for OCI Marketplace', classifiers=[ 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 3.6', 'Framework :: WIND Robot Framework', ], author='arun.poonia@oracle.com', author_email='arun.poonia@oracle.com', packages=['MarketplaceLibrary'], license = "UPL-1.0", install_requires=[ ], extras_require={ 'dev': [ ] }, platforms='any', include_package_data=True, zip_safe=False)
[ 2235, 15069, 220, 33448, 11, 18650, 290, 14, 273, 663, 29116, 13, 220, 198, 2235, 49962, 739, 262, 14499, 2448, 33532, 13789, 410, 352, 13, 15, 355, 3402, 379, 3740, 1378, 793, 13, 273, 6008, 13, 785, 14, 677, 4541, 14, 84, 489, 1...
2.541333
375
__version__="0.3"
[ 834, 9641, 834, 2625, 15, 13, 18, 1 ]
2.125
8
from django.http import JsonResponse from django.shortcuts import reverse from django.urls import NoReverseMatch from django.views import View from rest_framework import __version__ as drf_version from rest_framework.exceptions import ValidationError from rest_framework.permissions import AllowAny from rest_framework.response import Response from rest_framework.viewsets import ViewSet from oilandrope import __version__
[ 6738, 42625, 14208, 13, 4023, 1330, 449, 1559, 31077, 198, 6738, 42625, 14208, 13, 19509, 23779, 1330, 9575, 198, 6738, 42625, 14208, 13, 6371, 82, 1330, 1400, 49, 964, 325, 23850, 198, 6738, 42625, 14208, 13, 33571, 1330, 3582, 198, 67...
3.944444
108
from verta import Client import pickle import mlflow import mlflow.sklearn from mlflow.tracking import MlflowClient import os # Function Calls ("MajorII","CovidPredictor","Version 1","model.pkl","pickle","pytorch") downloadArtifact("MajorII","CovidPredictor","Version 1","pickle") logModel("pytorch","CovidPredictor") #serveModel("CovidPredictor")
[ 6738, 9421, 64, 1330, 20985, 198, 11748, 2298, 293, 198, 11748, 285, 1652, 9319, 198, 11748, 285, 1652, 9319, 13, 8135, 35720, 198, 6738, 285, 1652, 9319, 13, 36280, 1330, 337, 1652, 9319, 11792, 198, 11748, 28686, 198, 198, 2, 15553, ...
2.966102
118
#!/usr/bin/env python #***************************************************************************** # dump_db.py # # Dump inventory database in XML format # # (c) 2006 Andres Heinloo, GFZ Potsdam # (c) 2007 Mathias Hoffmann, GFZ Potsdam # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2, or (at your option) any later # version. For more information, see http://www.gnu.org/ #***************************************************************************** import sys from seiscomp import logs from seiscomp.db.seiscomp3 import sc3wrap from seiscomp.db.seiscomp3.inventory import Inventory as SC3Inventory from seiscomp.db.seiscomp3.routing import Routing as SC3Routing from seiscomp3 import Core, Client, DataModel, Logging VERSION = "1.2 (2012.313)" if __name__ == "__main__": logs.debug = Logging.debug logs.info = Logging.info logs.notice = Logging.notice logs.warning = Logging.warning logs.error = Logging.error app = DumpDB(len(sys.argv), sys.argv) sys.exit(app())
[ 2, 48443, 14629, 14, 8800, 14, 24330, 21015, 198, 2, 17174, 17174, 4557, 35625, 220, 198, 2, 10285, 62, 9945, 13, 9078, 198, 2, 198, 2, 360, 931, 13184, 6831, 287, 23735, 5794, 198, 2, 198, 2, 357, 66, 8, 4793, 843, 411, 26431, ...
3.293103
348
import logging from typing import Optional from y import magic from y.datatypes import UsdPrice from y.typing import AnyAddressType, Block logger = logging.getLogger(__name__)
[ 198, 11748, 18931, 198, 6738, 19720, 1330, 32233, 198, 198, 6738, 331, 1330, 5536, 198, 6738, 331, 13, 19608, 265, 9497, 1330, 4021, 67, 18124, 198, 6738, 331, 13, 774, 13886, 1330, 4377, 20231, 6030, 11, 9726, 198, 198, 6404, 1362, 7...
3.377358
53
from zerver.lib.actions import do_add_realm_playground from zerver.lib.test_classes import ZulipTestCase from zerver.models import RealmPlayground, get_realm
[ 6738, 1976, 18497, 13, 8019, 13, 4658, 1330, 466, 62, 2860, 62, 5305, 76, 62, 1759, 2833, 198, 6738, 1976, 18497, 13, 8019, 13, 9288, 62, 37724, 1330, 1168, 377, 541, 14402, 20448, 198, 6738, 1976, 18497, 13, 27530, 1330, 23651, 11002...
3.244898
49
# # This is Seisflows # # See LICENCE file # # ############################################################################### # Import system modules import os # Import Numpy import numpy as np # Local imports from seisflows.tools import unix from seisflows.tools.math import dot from seisflows.tools.tools import loadtxt, savetxt, loadnpy, savenpy # Utility functions def fletcher_reeves(g_new, g_old, precond=lambda x: x): num = dot(precond(g_new), g_new) den = dot(g_old, g_old) beta = num/den return beta def pollak_ribere(g_new, g_old, precond=lambda x: x): num = dot(precond(g_new), g_new-g_old) den = dot(g_old, g_old) beta = num/den return beta def check_conjugacy(g_new, g_old): return abs(dot(g_new, g_old) / dot(g_new, g_new)) def check_descent(p_new, g_new): return dot(p_new, g_new) / dot(g_new, g_new)
[ 2, 198, 2, 770, 318, 1001, 271, 44041, 198, 2, 198, 2, 4091, 38559, 18310, 2393, 198, 2, 198, 2, 198, 29113, 29113, 7804, 4242, 21017, 198, 198, 2, 17267, 1080, 13103, 198, 11748, 28686, 198, 198, 2, 17267, 399, 32152, 198, 11748, ...
2.52907
344