text
stringlengths
2
999k
import json, base64, requests from jinja2 import Environment, FileSystemLoader from pathlib import Path import webbrowser import tweepy import sys class Twitter: def __init__(self, auth, Bearer_Token=None): self.auth = auth self.Bearer_Token = Bearer_Token if self.auth is None: raise ValueError("API Authorisation keys needed.") if (self.auth.get("API_key", None) == None) or (self.auth.get("API_secret_key", None) == None): raise ValueError("'API_key' and 'API_scret_key' not specified") Path().absolute().joinpath("data").mkdir(parents=True, exist_ok=True) def GET_BearerToken(self): credentials = self.auth["API_key"] + ":" + self.auth["API_secret_key"] b64_creds = base64.b64encode(credentials.encode()).decode() headers = { "Authorization" : "Basic " + b64_creds, "Content-Type" : "application/x-www-form-urlencoded", "charset" : "UTF-8" } payload = { "grant_type" : "client_credentials" } r = requests.post( "https://api.twitter.com/oauth2/token", headers=headers, data=payload ) self.Bearer_Token = r.json() later_use = input("Save Bearer Token for later use? [y/n] : ") if (later_use.lower() == "y"): with open("Bearer_Token.json", "w", encoding="UTF-8") as bt_file: json.dump(self.Bearer_Token, bt_file) print("Saved to Bearer_Token.json") return self.Bearer_Token def GET_Favourites(self, screen_name, count, Bearer_Token=None): if Bearer_Token == None: print("Bearer Token not specified.\n Using from Class Instance.") Bearer_Token = self.Bearer_Token if Bearer_Token == None: raise ValueError("Class instance not initialized Bearer_Token") headers = { "Authorization" : Bearer_Token["token_type"] + " " + Bearer_Token["access_token"] } payload = { "screen_name" : screen_name, "count" : count, "tweet_mode" : "extended" } r = requests.get( "https://api.twitter.com/1.1/favorites/list.json", headers=headers, params=payload ) favs = r.json() with open("data/favs.json", "w", encoding='UTF-8') as favs_file: json.dump(favs, favs_file, indent=4, ensure_ascii=False) print("{} Favourite Tweets Captured".format(len(favs))) return favs def GET_MediaTweets(self, favs=None): if favs == None : with open("data/favs.json", "r", encoding="UTF-8") as fav_file: favs = json.load(fav_file) media_tweets = [] for tweet in favs: extended_entity = tweet.get("extended_entities", None) if extended_entity != None: media_tweet = {} media_tweet["created_at"] = tweet["created_at"] media_tweet["media"] = tweet["extended_entities"]["media"] media_tweets.append(media_tweet) with open("data/media_tweets.json", "w", encoding="UTF-8") as media_tweets_file: json.dump(media_tweets, media_tweets_file, indent=4, ensure_ascii=False) print("{} Tweets with Media".format(len(media_tweets))) return media_tweets def GET_Media(self, media_tweets=None): if media_tweets == None: with open("data/media_tweets.json", "r", encoding="UTF-8") as media_tweets_file: media_tweets = json.load(media_tweets_file) custom_media_list = [] for tweet in media_tweets: media_ele_list = tweet["media"] for media_ele in media_ele_list: custom_media_ele = {} custom_media_ele["created_at"] = tweet["created_at"] custom_media_ele["type"] = media_ele["type"] custom_media_ele["id"] = media_ele["id_str"] if custom_media_ele["type"] == "video" or custom_media_ele["type"] == "animated_gif": variants = {} for video_variants in media_ele["video_info"]["variants"]: if video_variants["content_type"] == "video/mp4": variants[video_variants["bitrate"]] = video_variants["url"] max_bitrate = max(variants.keys()) custom_media_ele["url"] = variants[max_bitrate] else: custom_media_ele["url"] = media_ele["media_url"] custom_media_list.append(custom_media_ele) with open("data/media.json", "w", encoding="UTF-8") as media_file: json.dump(custom_media_list, media_file, indent=4, ensure_ascii=False) print("{} Media".format(len(custom_media_list))) return custom_media_list def visualize(self, media=None): if media == None: with open("data/media.json", "r", encoding="UTF-8") as media_file: media_list = json.load(media_file) else: media_list = media file_loader = FileSystemLoader('Templates') env = Environment(loader=file_loader) template = env.get_template('media.html') output = template.render(media_list=media_list) with open("./data/media.html", "w") as index_file: index_file.write(output) webbrowser.open("data\\media.html") with open("auth.json", "r") as auth_file: auth = json.load(auth_file) twpy = Twitter(auth) twpy.visualize( twpy.GET_Media( twpy.GET_MediaTweets( twpy.GET_Favourites( "Twitter", 200, twpy.GET_BearerToken() ) ) ) )
""" Provide the functionality to group entities. For more details about this component, please refer to the documentation at https://home-assistant.io/components/group/ """ import asyncio import logging import voluptuous as vol from homeassistant import core as ha from homeassistant.const import ( ATTR_ENTITY_ID, CONF_ICON, CONF_NAME, STATE_CLOSED, STATE_HOME, STATE_NOT_HOME, STATE_OFF, STATE_ON, STATE_OPEN, STATE_LOCKED, STATE_UNLOCKED, STATE_OK, STATE_PROBLEM, STATE_UNKNOWN, ATTR_ASSUMED_STATE, SERVICE_RELOAD) from homeassistant.core import callback from homeassistant.loader import bind_hass from homeassistant.helpers.entity import Entity, async_generate_entity_id from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.event import async_track_state_change import homeassistant.helpers.config_validation as cv from homeassistant.util.async_ import run_coroutine_threadsafe DOMAIN = 'group' ENTITY_ID_FORMAT = DOMAIN + '.{}' CONF_ENTITIES = 'entities' CONF_VIEW = 'view' CONF_CONTROL = 'control' ATTR_ADD_ENTITIES = 'add_entities' ATTR_AUTO = 'auto' ATTR_CONTROL = 'control' ATTR_ENTITIES = 'entities' ATTR_ICON = 'icon' ATTR_NAME = 'name' ATTR_OBJECT_ID = 'object_id' ATTR_ORDER = 'order' ATTR_VIEW = 'view' ATTR_VISIBLE = 'visible' SERVICE_SET_VISIBILITY = 'set_visibility' SERVICE_SET = 'set' SERVICE_REMOVE = 'remove' CONTROL_TYPES = vol.In(['hidden', None]) SET_VISIBILITY_SERVICE_SCHEMA = vol.Schema({ vol.Optional(ATTR_ENTITY_ID): cv.entity_ids, vol.Required(ATTR_VISIBLE): cv.boolean }) RELOAD_SERVICE_SCHEMA = vol.Schema({}) SET_SERVICE_SCHEMA = vol.Schema({ vol.Required(ATTR_OBJECT_ID): cv.slug, vol.Optional(ATTR_NAME): cv.string, vol.Optional(ATTR_VIEW): cv.boolean, vol.Optional(ATTR_ICON): cv.string, vol.Optional(ATTR_CONTROL): CONTROL_TYPES, vol.Optional(ATTR_VISIBLE): cv.boolean, vol.Exclusive(ATTR_ENTITIES, 'entities'): cv.entity_ids, vol.Exclusive(ATTR_ADD_ENTITIES, 'entities'): cv.entity_ids, }) REMOVE_SERVICE_SCHEMA = vol.Schema({ vol.Required(ATTR_OBJECT_ID): cv.slug, }) _LOGGER = logging.getLogger(__name__) def _conf_preprocess(value): """Preprocess alternative configuration formats.""" if not isinstance(value, dict): value = {CONF_ENTITIES: value} return value GROUP_SCHEMA = vol.Schema({ vol.Optional(CONF_ENTITIES): vol.Any(cv.entity_ids, None), CONF_VIEW: cv.boolean, CONF_NAME: cv.string, CONF_ICON: cv.icon, CONF_CONTROL: CONTROL_TYPES, }) CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema({cv.match_all: vol.All(_conf_preprocess, GROUP_SCHEMA)}) }, extra=vol.ALLOW_EXTRA) # List of ON/OFF state tuples for groupable states _GROUP_TYPES = [(STATE_ON, STATE_OFF), (STATE_HOME, STATE_NOT_HOME), (STATE_OPEN, STATE_CLOSED), (STATE_LOCKED, STATE_UNLOCKED), (STATE_PROBLEM, STATE_OK)] def _get_group_on_off(state): """Determine the group on/off states based on a state.""" for states in _GROUP_TYPES: if state in states: return states return None, None @bind_hass def is_on(hass, entity_id): """Test if the group state is in its ON-state.""" state = hass.states.get(entity_id) if state: group_on, _ = _get_group_on_off(state.state) # If we found a group_type, compare to ON-state return group_on is not None and state.state == group_on return False @bind_hass def reload(hass): """Reload the automation from config.""" hass.add_job(async_reload, hass) @callback @bind_hass def async_reload(hass): """Reload the automation from config.""" hass.async_add_job(hass.services.async_call(DOMAIN, SERVICE_RELOAD)) @bind_hass def set_visibility(hass, entity_id=None, visible=True): """Hide or shows a group.""" data = {ATTR_ENTITY_ID: entity_id, ATTR_VISIBLE: visible} hass.services.call(DOMAIN, SERVICE_SET_VISIBILITY, data) @bind_hass def set_group(hass, object_id, name=None, entity_ids=None, visible=None, icon=None, view=None, control=None, add=None): """Create/Update a group.""" hass.add_job( async_set_group, hass, object_id, name, entity_ids, visible, icon, view, control, add) @callback @bind_hass def async_set_group(hass, object_id, name=None, entity_ids=None, visible=None, icon=None, view=None, control=None, add=None): """Create/Update a group.""" data = { key: value for key, value in [ (ATTR_OBJECT_ID, object_id), (ATTR_NAME, name), (ATTR_ENTITIES, entity_ids), (ATTR_VISIBLE, visible), (ATTR_ICON, icon), (ATTR_VIEW, view), (ATTR_CONTROL, control), (ATTR_ADD_ENTITIES, add), ] if value is not None } hass.async_add_job(hass.services.async_call(DOMAIN, SERVICE_SET, data)) @bind_hass def remove(hass, name): """Remove a user group.""" hass.add_job(async_remove, hass, name) @callback @bind_hass def async_remove(hass, object_id): """Remove a user group.""" data = {ATTR_OBJECT_ID: object_id} hass.async_add_job(hass.services.async_call(DOMAIN, SERVICE_REMOVE, data)) @bind_hass def expand_entity_ids(hass, entity_ids): """Return entity_ids with group entity ids replaced by their members. Async friendly. """ found_ids = [] for entity_id in entity_ids: if not isinstance(entity_id, str): continue entity_id = entity_id.lower() try: # If entity_id points at a group, expand it domain, _ = ha.split_entity_id(entity_id) if domain == DOMAIN: child_entities = get_entity_ids(hass, entity_id) if entity_id in child_entities: child_entities = list(child_entities) child_entities.remove(entity_id) found_ids.extend( ent_id for ent_id in expand_entity_ids(hass, child_entities) if ent_id not in found_ids) else: if entity_id not in found_ids: found_ids.append(entity_id) except AttributeError: # Raised by split_entity_id if entity_id is not a string pass return found_ids @bind_hass def get_entity_ids(hass, entity_id, domain_filter=None): """Get members of this group. Async friendly. """ group = hass.states.get(entity_id) if not group or ATTR_ENTITY_ID not in group.attributes: return [] entity_ids = group.attributes[ATTR_ENTITY_ID] if not domain_filter: return entity_ids domain_filter = domain_filter.lower() + '.' return [ent_id for ent_id in entity_ids if ent_id.startswith(domain_filter)] async def async_setup(hass, config): """Set up all groups found defined in the configuration.""" component = hass.data.get(DOMAIN) if component is None: component = hass.data[DOMAIN] = EntityComponent(_LOGGER, DOMAIN, hass) await _async_process_config(hass, config, component) async def reload_service_handler(service): """Remove all user-defined groups and load new ones from config.""" auto = list(filter(lambda e: not e.user_defined, component.entities)) conf = await component.async_prepare_reload() if conf is None: return await _async_process_config(hass, conf, component) await component.async_add_entities(auto) hass.services.async_register( DOMAIN, SERVICE_RELOAD, reload_service_handler, schema=RELOAD_SERVICE_SCHEMA) async def groups_service_handler(service): """Handle dynamic group service functions.""" object_id = service.data[ATTR_OBJECT_ID] entity_id = ENTITY_ID_FORMAT.format(object_id) group = component.get_entity(entity_id) # new group if service.service == SERVICE_SET and group is None: entity_ids = service.data.get(ATTR_ENTITIES) or \ service.data.get(ATTR_ADD_ENTITIES) or None extra_arg = {attr: service.data[attr] for attr in ( ATTR_VISIBLE, ATTR_ICON, ATTR_VIEW, ATTR_CONTROL ) if service.data.get(attr) is not None} await Group.async_create_group( hass, service.data.get(ATTR_NAME, object_id), object_id=object_id, entity_ids=entity_ids, user_defined=False, **extra_arg ) return if group is None: _LOGGER.warning("%s:Group '%s' doesn't exist!", service.service, object_id) return # update group if service.service == SERVICE_SET: need_update = False if ATTR_ADD_ENTITIES in service.data: delta = service.data[ATTR_ADD_ENTITIES] entity_ids = set(group.tracking) | set(delta) await group.async_update_tracked_entity_ids(entity_ids) if ATTR_ENTITIES in service.data: entity_ids = service.data[ATTR_ENTITIES] await group.async_update_tracked_entity_ids(entity_ids) if ATTR_NAME in service.data: group.name = service.data[ATTR_NAME] need_update = True if ATTR_VISIBLE in service.data: group.visible = service.data[ATTR_VISIBLE] need_update = True if ATTR_ICON in service.data: group.icon = service.data[ATTR_ICON] need_update = True if ATTR_CONTROL in service.data: group.control = service.data[ATTR_CONTROL] need_update = True if ATTR_VIEW in service.data: group.view = service.data[ATTR_VIEW] need_update = True if need_update: await group.async_update_ha_state() return # remove group if service.service == SERVICE_REMOVE: await component.async_remove_entity(entity_id) hass.services.async_register( DOMAIN, SERVICE_SET, groups_service_handler, schema=SET_SERVICE_SCHEMA) hass.services.async_register( DOMAIN, SERVICE_REMOVE, groups_service_handler, schema=REMOVE_SERVICE_SCHEMA) async def visibility_service_handler(service): """Change visibility of a group.""" visible = service.data.get(ATTR_VISIBLE) tasks = [] for group in component.async_extract_from_service(service, expand_group=False): group.visible = visible tasks.append(group.async_update_ha_state()) if tasks: await asyncio.wait(tasks, loop=hass.loop) hass.services.async_register( DOMAIN, SERVICE_SET_VISIBILITY, visibility_service_handler, schema=SET_VISIBILITY_SERVICE_SCHEMA) return True async def _async_process_config(hass, config, component): """Process group configuration.""" for object_id, conf in config.get(DOMAIN, {}).items(): name = conf.get(CONF_NAME, object_id) entity_ids = conf.get(CONF_ENTITIES) or [] icon = conf.get(CONF_ICON) view = conf.get(CONF_VIEW) control = conf.get(CONF_CONTROL) # Don't create tasks and await them all. The order is important as # groups get a number based on creation order. await Group.async_create_group( hass, name, entity_ids, icon=icon, view=view, control=control, object_id=object_id) class Group(Entity): """Track a group of entity ids.""" def __init__(self, hass, name, order=None, visible=True, icon=None, view=False, control=None, user_defined=True, entity_ids=None): """Initialize a group. This Object has factory function for creation. """ self.hass = hass self._name = name self._state = STATE_UNKNOWN self._icon = icon self.view = view if entity_ids: self.tracking = tuple(ent_id.lower() for ent_id in entity_ids) else: self.tracking = tuple() self.group_on = None self.group_off = None self.visible = visible self.control = control self.user_defined = user_defined self._order = order self._assumed_state = False self._async_unsub_state_changed = None @staticmethod def create_group(hass, name, entity_ids=None, user_defined=True, visible=True, icon=None, view=False, control=None, object_id=None): """Initialize a group.""" return run_coroutine_threadsafe( Group.async_create_group( hass, name, entity_ids, user_defined, visible, icon, view, control, object_id), hass.loop).result() @staticmethod async def async_create_group(hass, name, entity_ids=None, user_defined=True, visible=True, icon=None, view=False, control=None, object_id=None): """Initialize a group. This method must be run in the event loop. """ group = Group( hass, name, order=len(hass.states.async_entity_ids(DOMAIN)), visible=visible, icon=icon, view=view, control=control, user_defined=user_defined, entity_ids=entity_ids ) group.entity_id = async_generate_entity_id( ENTITY_ID_FORMAT, object_id or name, hass=hass) # If called before the platform async_setup is called (test cases) component = hass.data.get(DOMAIN) if component is None: component = hass.data[DOMAIN] = \ EntityComponent(_LOGGER, DOMAIN, hass) await component.async_add_entities([group], True) return group @property def should_poll(self): """No need to poll because groups will update themselves.""" return False @property def name(self): """Return the name of the group.""" return self._name @name.setter def name(self, value): """Set Group name.""" self._name = value @property def state(self): """Return the state of the group.""" return self._state @property def icon(self): """Return the icon of the group.""" return self._icon @icon.setter def icon(self, value): """Set Icon for group.""" self._icon = value @property def hidden(self): """If group should be hidden or not.""" if self.visible and not self.view: return False return True @property def state_attributes(self): """Return the state attributes for the group.""" data = { ATTR_ENTITY_ID: self.tracking, ATTR_ORDER: self._order, } if not self.user_defined: data[ATTR_AUTO] = True if self.view: data[ATTR_VIEW] = True if self.control: data[ATTR_CONTROL] = self.control return data @property def assumed_state(self): """Test if any member has an assumed state.""" return self._assumed_state def update_tracked_entity_ids(self, entity_ids): """Update the member entity IDs.""" run_coroutine_threadsafe( self.async_update_tracked_entity_ids(entity_ids), self.hass.loop ).result() async def async_update_tracked_entity_ids(self, entity_ids): """Update the member entity IDs. This method must be run in the event loop. """ await self.async_stop() self.tracking = tuple(ent_id.lower() for ent_id in entity_ids) self.group_on, self.group_off = None, None await self.async_update_ha_state(True) self.async_start() @callback def async_start(self): """Start tracking members. This method must be run in the event loop. """ if self._async_unsub_state_changed is None: self._async_unsub_state_changed = async_track_state_change( self.hass, self.tracking, self._async_state_changed_listener ) async def async_stop(self): """Unregister the group from Home Assistant. This method must be run in the event loop. """ if self._async_unsub_state_changed: self._async_unsub_state_changed() self._async_unsub_state_changed = None async def async_update(self): """Query all members and determine current group state.""" self._state = STATE_UNKNOWN self._async_update_group_state() async def async_added_to_hass(self): """Callback when added to HASS.""" if self.tracking: self.async_start() async def async_will_remove_from_hass(self): """Callback when removed from HASS.""" if self._async_unsub_state_changed: self._async_unsub_state_changed() self._async_unsub_state_changed = None async def _async_state_changed_listener(self, entity_id, old_state, new_state): """Respond to a member state changing. This method must be run in the event loop. """ # removed if self._async_unsub_state_changed is None: return self._async_update_group_state(new_state) await self.async_update_ha_state() @property def _tracking_states(self): """Return the states that the group is tracking.""" states = [] for entity_id in self.tracking: state = self.hass.states.get(entity_id) if state is not None: states.append(state) return states @callback def _async_update_group_state(self, tr_state=None): """Update group state. Optionally you can provide the only state changed since last update allowing this method to take shortcuts. This method must be run in the event loop. """ # To store current states of group entities. Might not be needed. states = None gr_state = self._state gr_on = self.group_on gr_off = self.group_off # We have not determined type of group yet if gr_on is None: if tr_state is None: states = self._tracking_states for state in states: gr_on, gr_off = \ _get_group_on_off(state.state) if gr_on is not None: break else: gr_on, gr_off = _get_group_on_off(tr_state.state) if gr_on is not None: self.group_on, self.group_off = gr_on, gr_off # We cannot determine state of the group if gr_on is None: return if tr_state is None or ((gr_state == gr_on and tr_state.state == gr_off) or tr_state.state not in (gr_on, gr_off)): if states is None: states = self._tracking_states if any(state.state == gr_on for state in states): self._state = gr_on else: self._state = gr_off elif tr_state.state in (gr_on, gr_off): self._state = tr_state.state if tr_state is None or self._assumed_state and \ not tr_state.attributes.get(ATTR_ASSUMED_STATE): if states is None: states = self._tracking_states self._assumed_state = any( state.attributes.get(ATTR_ASSUMED_STATE) for state in states) elif tr_state.attributes.get(ATTR_ASSUMED_STATE): self._assumed_state = True
# Copyright 2013, Big Switch Networks, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import logging from django.core.urlresolvers import reverse from django.template import defaultfilters as filters from django.utils.translation import pgettext_lazy from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy from horizon import exceptions from horizon import tables from openstack_dashboard import api from openstack_dashboard import policy LOG = logging.getLogger(__name__) class AddRuleLink(tables.LinkAction): name = "addrule" verbose_name = _("Add Rule") url = "horizon:project:firewalls:addrule" classes = ("ajax-modal",) icon = "plus" policy_rules = (("network", "create_firewall_rule"),) class AddPolicyLink(tables.LinkAction): name = "addpolicy" verbose_name = _("Add Policy") url = "horizon:project:firewalls:addpolicy" classes = ("ajax-modal", "btn-addpolicy",) icon = "plus" policy_rules = (("network", "create_firewall_policy"),) class AddFirewallLink(tables.LinkAction): name = "addfirewall" verbose_name = _("Create Firewall") url = "horizon:project:firewalls:addfirewall" classes = ("ajax-modal",) icon = "plus" policy_rules = (("network", "create_firewall"),) class DeleteRuleLink(policy.PolicyTargetMixin, tables.DeleteAction): name = "deleterule" policy_rules = (("network", "delete_firewall_rule"),) @staticmethod def action_present(count): return ungettext_lazy( u"Delete Rule", u"Delete Rules", count ) @staticmethod def action_past(count): return ungettext_lazy( u"Scheduled deletion of Rule", u"Scheduled deletion of Rules", count ) def allowed(self, request, datum=None): if datum and datum.policy: return False return True def delete(self, request, obj_id): try: api.fwaas.rule_delete(request, obj_id) except Exception as e: exceptions.handle(request, _('Unable to delete rule. %s') % e) class DeletePolicyLink(policy.PolicyTargetMixin, tables.DeleteAction): name = "deletepolicy" policy_rules = (("network", "delete_firewall_policy"),) @staticmethod def action_present(count): return ungettext_lazy( u"Delete Policy", u"Delete Policies", count ) @staticmethod def action_past(count): return ungettext_lazy( u"Scheduled deletion of Policy", u"Scheduled deletion of Policies", count ) def delete(self, request, obj_id): try: api.fwaas.policy_delete(request, obj_id) except Exception as e: exceptions.handle(request, _('Unable to delete policy. %s') % e) class DeleteFirewallLink(policy.PolicyTargetMixin, tables.DeleteAction): name = "deletefirewall" policy_rules = (("network", "delete_firewall"),) @staticmethod def action_present(count): return ungettext_lazy( u"Delete Firewall", u"Delete Firewalls", count ) @staticmethod def action_past(count): return ungettext_lazy( u"Scheduled deletion of Firewall", u"Scheduled deletion of Firewalls", count ) def delete(self, request, obj_id): try: api.fwaas.firewall_delete(request, obj_id) except Exception as e: exceptions.handle(request, _('Unable to delete firewall. %s') % e) class UpdateRuleLink(policy.PolicyTargetMixin, tables.LinkAction): name = "updaterule" verbose_name = _("Edit Rule") classes = ("ajax-modal", "btn-update",) policy_rules = (("network", "update_firewall_rule"),) def get_link_url(self, rule): base_url = reverse("horizon:project:firewalls:updaterule", kwargs={'rule_id': rule.id}) return base_url class UpdatePolicyLink(policy.PolicyTargetMixin, tables.LinkAction): name = "updatepolicy" verbose_name = _("Edit Policy") classes = ("ajax-modal", "btn-update",) policy_rules = (("network", "update_firewall_policy"),) def get_link_url(self, policy): base_url = reverse("horizon:project:firewalls:updatepolicy", kwargs={'policy_id': policy.id}) return base_url class UpdateFirewallLink(policy.PolicyTargetMixin, tables.LinkAction): name = "updatefirewall" verbose_name = _("Edit Firewall") classes = ("ajax-modal", "btn-update",) policy_rules = (("network", "update_firewall"),) def get_link_url(self, firewall): base_url = reverse("horizon:project:firewalls:updatefirewall", kwargs={'firewall_id': firewall.id}) return base_url def allowed(self, request, firewall): if firewall.status in ("PENDING_CREATE", "PENDING_UPDATE", "PENDING_DELETE"): return False return True class InsertRuleToPolicyLink(policy.PolicyTargetMixin, tables.LinkAction): name = "insertrule" verbose_name = _("Insert Rule") classes = ("ajax-modal", "btn-update",) policy_rules = (("network", "get_firewall_policy"), ("network", "insert_rule"),) def get_link_url(self, policy): base_url = reverse("horizon:project:firewalls:insertrule", kwargs={'policy_id': policy.id}) return base_url class RemoveRuleFromPolicyLink(policy.PolicyTargetMixin, tables.LinkAction): name = "removerule" verbose_name = _("Remove Rule") classes = ("ajax-modal", "btn-danger",) policy_rules = (("network", "get_firewall_policy"), ("network", "remove_rule"),) def get_link_url(self, policy): base_url = reverse("horizon:project:firewalls:removerule", kwargs={'policy_id': policy.id}) return base_url def allowed(self, request, policy): if len(policy.rules) > 0: return True return False class AddRouterToFirewallLink(policy.PolicyTargetMixin, tables.LinkAction): name = "addrouter" verbose_name = _("Add Router") classes = ("ajax-modal", "btn-update",) policy_rules = (("network", "get_firewall"), ("network", "add_router"),) def get_link_url(self, firewall): base_url = reverse("horizon:project:firewalls:addrouter", kwargs={'firewall_id': firewall.id}) return base_url def allowed(self, request, firewall): if not api.neutron.is_extension_supported(request, 'fwaasrouterinsertion'): return False tenant_id = firewall['tenant_id'] available_routers = api.fwaas.firewall_unassociated_routers_list( request, tenant_id) return bool(available_routers) class RemoveRouterFromFirewallLink(policy.PolicyTargetMixin, tables.LinkAction): name = "removerouter" verbose_name = _("Remove Router") classes = ("ajax-modal", "btn-update",) policy_rules = (("network", "get_firewall"), ("network", "remove_router"),) def get_link_url(self, firewall): base_url = reverse("horizon:project:firewalls:removerouter", kwargs={'firewall_id': firewall.id}) return base_url def allowed(self, request, firewall): if not api.neutron.is_extension_supported(request, 'fwaasrouterinsertion'): return False return bool(firewall['router_ids']) def get_rules_name(datum): return ', '.join([rule.name or rule.id[:13] for rule in datum.rules]) def get_routers_name(firewall): if firewall.routers: return ', '.join(router.name_or_id for router in firewall.routers) def get_policy_name(datum): if datum.policy: return datum.policy.name or datum.policy.id def get_policy_link(datum): if datum.policy: return reverse('horizon:project:firewalls:policydetails', kwargs={'policy_id': datum.policy.id}) class RulesTable(tables.DataTable): ACTION_DISPLAY_CHOICES = ( ("Allow", pgettext_lazy("Action Name of a Firewall Rule", u"ALLOW")), ("Deny", pgettext_lazy("Action Name of a Firewall Rule", u"DENY")), ) name = tables.Column("name_or_id", verbose_name=_("Name"), link="horizon:project:firewalls:ruledetails") description = tables.Column('description', verbose_name=_('Description')) protocol = tables.Column("protocol", filters=(lambda v: filters.default(v, _("ANY")), filters.upper,), verbose_name=_("Protocol")) source_ip_address = tables.Column("source_ip_address", verbose_name=_("Source IP")) source_port = tables.Column("source_port", verbose_name=_("Source Port")) destination_ip_address = tables.Column("destination_ip_address", verbose_name=_("Destination IP")) destination_port = tables.Column("destination_port", verbose_name=_("Destination Port")) action = tables.Column("action", display_choices=ACTION_DISPLAY_CHOICES, verbose_name=_("Action")) shared = tables.Column("shared", verbose_name=_("Shared"), filters=(filters.yesno, filters.capfirst)) enabled = tables.Column("enabled", verbose_name=_("Enabled"), filters=(filters.yesno, filters.capfirst)) firewall_policy_id = tables.Column(get_policy_name, link=get_policy_link, verbose_name=_("In Policy")) class Meta(object): name = "rulestable" verbose_name = _("Rules") table_actions = (AddRuleLink, DeleteRuleLink) row_actions = (UpdateRuleLink, DeleteRuleLink) class PoliciesTable(tables.DataTable): name = tables.Column("name_or_id", verbose_name=_("Name"), link="horizon:project:firewalls:policydetails") description = tables.Column('description', verbose_name=_('Description')) firewall_rules = tables.Column(get_rules_name, verbose_name=_("Rules")) shared = tables.Column("shared", verbose_name=_("Shared"), filters=(filters.yesno, filters.capfirst)) audited = tables.Column("audited", verbose_name=_("Audited"), filters=(filters.yesno, filters.capfirst)) class Meta(object): name = "policiestable" verbose_name = _("Policies") table_actions = (AddPolicyLink, DeletePolicyLink) row_actions = (UpdatePolicyLink, InsertRuleToPolicyLink, RemoveRuleFromPolicyLink, DeletePolicyLink) class FirewallsTable(tables.DataTable): STATUS_DISPLAY_CHOICES = ( ("Active", pgettext_lazy("Current status of a Firewall", u"Active")), ("Down", pgettext_lazy("Current status of a Firewall", u"Down")), ("Error", pgettext_lazy("Current status of a Firewall", u"Error")), ("Created", pgettext_lazy("Current status of a Firewall", u"Created")), ("Pending_Create", pgettext_lazy("Current status of a Firewall", u"Pending Create")), ("Pending_Update", pgettext_lazy("Current status of a Firewall", u"Pending Update")), ("Pending_Delete", pgettext_lazy("Current status of a Firewall", u"Pending Delete")), ("Inactive", pgettext_lazy("Current status of a Firewall", u"Inactive")), ) ADMIN_STATE_DISPLAY_CHOICES = ( ("UP", pgettext_lazy("Admin state of a Firewall", u"UP")), ("DOWN", pgettext_lazy("Admin state of a Firewall", u"DOWN")), ) name = tables.Column("name_or_id", verbose_name=_("Name"), link="horizon:project:firewalls:firewalldetails") description = tables.Column('description', verbose_name=_('Description')) firewall_policy_id = tables.Column(get_policy_name, link=get_policy_link, verbose_name=_("Policy")) router_ids = tables.Column(get_routers_name, verbose_name=_("Associated Routers")) status = tables.Column("status", verbose_name=_("Status"), display_choices=STATUS_DISPLAY_CHOICES) admin_state = tables.Column("admin_state", verbose_name=_("Admin State"), display_choices=ADMIN_STATE_DISPLAY_CHOICES) class Meta(object): name = "firewallstable" verbose_name = _("Firewalls") table_actions = (AddFirewallLink, DeleteFirewallLink) row_actions = (UpdateFirewallLink, DeleteFirewallLink, AddRouterToFirewallLink, RemoveRouterFromFirewallLink) def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs): super(FirewallsTable, self).__init__( request, data=data, needs_form_wrapper=needs_form_wrapper, **kwargs) try: if not api.neutron.is_extension_supported(request, 'fwaasrouterinsertion'): del self.columns['router_ids'] except Exception as e: msg = _('Failed to verify extension support %(reason)s') % { 'reason': e} LOG.error(msg) exceptions.handle(request, msg)
from zipline.pipeline import Pipeline from zipline.api import attach_pipeline, pipeline_output from zipline.pipeline.data.equity_pricing import USEquityPricing from zipline.pipeline.data import morningstar from zipline.pipeline.factors import SimpleMovingAverage, AverageDollarVolume from zipline.pipeline.filters.morningstar import IsPrimaryShare import numpy as np # needed for NaN handling import math # ceil and floor are useful for rounding from itertools import cycle def initialize(context): # set_commission(commission.PerShare(cost=0.01, min_trade_cost=1.50)) set_slippage( slippage.VolumeShareSlippage( volume_limit=.20, price_impact=0.0)) # set_slippage(slippage.FixedSlippage(spread=0.00)) set_commission(commission.PerTrade(cost=0.00)) # set_slippage(slippage.FixedSlippage(spread=0.00)) set_long_only() context.MaxCandidates = 100 context.MaxBuyOrdersAtOnce = 30 context.MyLeastPrice = 3.00 context.MyMostPrice = 25.00 context.MyFireSalePrice = context.MyLeastPrice context.MyFireSaleAge = 6 # over simplistic tracking of position age context.age = {} print(len(context.portfolio.positions)) # Rebalance EveryThisManyMinutes = 10 TradingDayHours = 6.5 TradingDayMinutes = int(TradingDayHours * 60) for minutez in xrange( 1, TradingDayMinutes, EveryThisManyMinutes ): schedule_function( my_rebalance, date_rules.every_day(), time_rules.market_open( minutes=minutez)) # Prevent excessive logging of canceled orders at market close. schedule_function( cancel_open_orders, date_rules.every_day(), time_rules.market_close( hours=0, minutes=1)) # Record variables at the end of each day. schedule_function( my_record_vars, date_rules.every_day(), time_rules.market_close()) # Create our pipeline and attach it to our algorithm. my_pipe = make_pipeline(context) attach_pipeline(my_pipe, 'my_pipeline') def make_pipeline(context): """ Create our pipeline. """ # Filter for primary share equities. IsPrimaryShare is a built-in filter. primary_share = IsPrimaryShare() # Equities listed as common stock (as opposed to, say, preferred stock). # 'ST00000001' indicates common stock. common_stock = morningstar.share_class_reference.security_type.latest.eq( 'ST00000001') # Non-depositary receipts. Recall that the ~ operator inverts filters, # turning Trues into Falses and vice versa not_depositary = ~morningstar.share_class_reference.is_depositary_receipt.latest # Equities not trading over-the-counter. not_otc = ~morningstar.share_class_reference.exchange_id.latest.startswith( 'OTC') # Not when-issued equities. not_wi = ~morningstar.share_class_reference.symbol.latest.endswith('.WI') # Equities without LP in their name, .matches does a match using a regular # expression not_lp_name = ~morningstar.company_reference.standard_name.latest.matches( '.* L[. ]?P.?$') # Equities with a null value in the limited_partnership Morningstar # fundamental field. not_lp_balance_sheet = morningstar.balance_sheet.limited_partnership.latest.isnull() # Equities whose most recent Morningstar market cap is not null have # fundamental data and therefore are not ETFs. have_market_cap = morningstar.valuation.market_cap.latest.notnull() # At least a certain price price = USEquityPricing.close.latest AtLeastPrice = (price >= context.MyLeastPrice) AtMostPrice = (price <= context.MyMostPrice) # Filter for stocks that pass all of our previous filters. tradeable_stocks = ( primary_share & common_stock & not_depositary & not_otc & not_wi & not_lp_name & not_lp_balance_sheet & have_market_cap & AtLeastPrice & AtMostPrice ) LowVar = 6 HighVar = 40 log.info( ''' Algorithm initialized variables: context.MaxCandidates %s LowVar %s HighVar %s''' % (context.MaxCandidates, LowVar, HighVar)) # High dollar volume filter. base_universe = AverageDollarVolume( window_length=20, mask=tradeable_stocks ).percentile_between(LowVar, HighVar) # Short close price average. ShortAvg = SimpleMovingAverage( inputs=[USEquityPricing.close], window_length=3, mask=base_universe ) # Long close price average. LongAvg = SimpleMovingAverage( inputs=[USEquityPricing.close], window_length=45, mask=base_universe ) percent_difference = (ShortAvg - LongAvg) / LongAvg # Filter to select securities to long. stocks_worst = percent_difference.bottom(context.MaxCandidates) securities_to_trade = (stocks_worst) return Pipeline( columns={ 'stocks_worst': stocks_worst }, screen=(securities_to_trade), ) def my_compute_weights(context): """ Compute ordering weights. """ # Compute even target weights for our long positions and short positions. stocks_worst_weight = 1.00 / len(context.stocks_worst) return stocks_worst_weight def before_trading_start(context, data): # Gets our pipeline output every day. context.output = pipeline_output('my_pipeline') context.stocks_worst = context.output[ context.output['stocks_worst']].index.tolist() context.stocks_worst_weight = my_compute_weights(context) context.MyCandidate = cycle(context.stocks_worst) context.LowestPrice = context.MyLeastPrice # reset beginning of day print(len(context.portfolio.positions)) for stock in context.portfolio.positions: CurrPrice = float(data.current([stock], 'price')) if CurrPrice < context.LowestPrice: context.LowestPrice = CurrPrice if stock in context.age: context.age[stock] += 1 else: context.age[stock] = 1 for stock in context.age: if stock not in context.portfolio.positions: context.age[stock] = 0 message = 'stock.symbol: {symbol} : age: {age}' log.info(message.format(symbol=stock.symbol, age=context.age[stock])) pass def my_rebalance(context, data): BuyFactor = .99 SellFactor = 1.01 cash = context.portfolio.cash cancel_open_buy_orders(context, data) # Order sell at profit target in hope that somebody actually buys it for stock in context.portfolio.positions: if not get_open_orders(stock): StockShares = context.portfolio.positions[stock].amount CurrPrice = float(data.current([stock], 'price')) CostBasis = float(context.portfolio.positions[stock].cost_basis) SellPrice = float( make_div_by_05( CostBasis * SellFactor, buy=False)) if np.isnan(SellPrice): pass # probably best to wait until nan goes away elif (stock in context.age and context.age[stock] == 1): pass elif ( stock in context.age and context.MyFireSaleAge <= context.age[stock] and ( context.MyFireSalePrice > CurrPrice or CostBasis > CurrPrice ) ): if (stock in context.age and context.age[stock] < 2): pass elif stock not in context.age: context.age[stock] = 1 else: SellPrice = float( make_div_by_05(.95 * CurrPrice, buy=False)) order(stock, -StockShares, style=LimitOrder(SellPrice) ) else: if (stock in context.age and context.age[stock] < 2): pass elif stock not in context.age: context.age[stock] = 1 else: order(stock, -StockShares, style=LimitOrder(SellPrice) ) WeightThisBuyOrder = float(1.00 / context.MaxBuyOrdersAtOnce) for ThisBuyOrder in range(context.MaxBuyOrdersAtOnce): stock = context.MyCandidate.next() PH = data.history([stock], 'price', 20, '1d') PH_Avg = float(PH.mean()) CurrPrice = float(data.current([stock], 'price')) if np.isnan(CurrPrice): pass # probably best to wait until nan goes away else: if CurrPrice > float(1.25 * PH_Avg): BuyPrice = float(CurrPrice) else: BuyPrice = float(CurrPrice * BuyFactor) BuyPrice = float(make_div_by_05(BuyPrice, buy=True)) StockShares = int(WeightThisBuyOrder * cash / BuyPrice) order(stock, StockShares, style=LimitOrder(BuyPrice) ) # if cents not divisible by .05, round down if buy, round up if sell def make_div_by_05(s, buy=False): s *= 20.00 s = math.floor(s) if buy else math.ceil(s) s /= 20.00 return s def my_record_vars(context, data): """ Record variables at the end of each day. """ # Record our variables. record(leverage=context.account.leverage) record(positions=len(context.portfolio.positions)) if 0 < len(context.age): MaxAge = context.age[max( context.age.keys(), key=(lambda k: context.age[k]))] print(MaxAge) record(MaxAge=MaxAge) record(LowestPrice=context.LowestPrice) def log_open_order(StockToLog): oo = get_open_orders() if len(oo) == 0: return for stock, orders in oo.iteritems(): if stock == StockToLog: for o in orders: message = 'Found open order for {amount} shares in {stock}' log.info(message.format(amount=o.amount, stock=stock)) def log_open_orders(): oo = get_open_orders() if len(oo) == 0: return for stock, orders in oo.iteritems(): for o in orders: message = 'Found open order for {amount} shares in {stock}' log.info(message.format(amount=o.amount, stock=stock)) def cancel_open_buy_orders(context, data): oo = get_open_orders() if len(oo) == 0: return for stock, orders in oo.iteritems(): for o in orders: # message = 'Canceling order of {amount} shares in {stock}' # log.info(message.format(amount=o.amount, stock=stock)) if 0 < o.amount: # it is a buy order cancel_order(o) def cancel_open_orders(context, data): oo = get_open_orders() if len(oo) == 0: return for stock, orders in oo.iteritems(): for o in orders: # message = 'Canceling order of {amount} shares in {stock}' # log.info(message.format(amount=o.amount, stock=stock)) cancel_order(o) # This is the every minute stuff def handle_data(context, data): pass
FPS = 10 SCREEN_SIZE = (1200, 800) CARDFIELD_COORDS = [(230, 120), (700, 520)] BANK_COORDS = [(970, 160), (70, 350)] BACKGROUND = (140, 122, 230) WHITE = (255, 255, 255) GREY = (128, 128, 128) GREEN = (0, 128, 0) YELLOW = (180, 180, 0) BLACK = (0, 0, 0) COLORS = { "1": [(53, 59, 72), (47, 54, 64),], "2": [(245, 246, 250), (220, 221, 225)], "3": [(232, 65, 24), (194, 54, 22)], "4": [(76, 209, 55), (68, 189, 50)], "5": [(72, 126, 176), (64, 115, 158)] }
from time import sleep import pytest from ...utils import assert_finished, assert_send, receive_json class TestPeripheralSPI: def test_start(self, obniz): obniz.spi0.start( {"clk": 0, "frequency": 1000000, "miso": 2, "mode": "master", "mosi": 1} ) assert_send(obniz, [{"io0": {"output_type": "push-pull5v"}}]) assert_send(obniz, [{"io1": {"output_type": "push-pull5v"}}]) assert_send(obniz, [{"io2": {"output_type": "push-pull5v"}}]) assert_send(obniz, [{"io0": {"pull_type": "float"}}]) assert_send(obniz, [{"io1": {"pull_type": "float"}}]) assert_send(obniz, [{"io2": {"pull_type": "float"}}]) assert_send( obniz, [ { "spi0": { "clk": 0, "clock": 1000000, "miso": 2, "mode": "master", "mosi": 1, } } ], ) assert_finished(obniz) def test_start_with_gnd(self, obniz): obniz.spi0.start( { "clk": 0, "frequency": 1000000, "miso": 2, "mode": "master", "mosi": 1, "gnd": 7, } ) assert_send(obniz, [{"io0": {"output_type": "push-pull5v"}}]) assert_send(obniz, [{"io1": {"output_type": "push-pull5v"}}]) assert_send(obniz, [{"io2": {"output_type": "push-pull5v"}}]) assert_send(obniz, [{"io0": {"pull_type": "float"}}]) assert_send(obniz, [{"io1": {"pull_type": "float"}}]) assert_send(obniz, [{"io2": {"pull_type": "float"}}]) assert_send(obniz, [{"io7": False}]) # assert_send(obniz, [ # { # display: { # pin_assign: { # '7': { # module_name: 'spi0', # pin_name: 'gnd', # }, # }, # }, # }, # ]) assert_send( obniz, [ { "spi0": { "clk": 0, "clock": 1000000, "miso": 2, "mode": "master", "mosi": 1, } } ], ) assert_finished(obniz) def test_write(self, obniz): obniz.spi0.start({"clk": 0, "frequency": 1000000, "miso": 2, "mode": "master"}) assert_send(obniz, [{"io0": {"output_type": "push-pull5v"}}]) assert_send(obniz, [{"io2": {"output_type": "push-pull5v"}}]) assert_send(obniz, [{"io0": {"pull_type": "float"}}]) assert_send(obniz, [{"io2": {"pull_type": "float"}}]) assert_send( obniz, [{"spi0": {"clk": 0, "clock": 1000000, "miso": 2, "mode": "master"}}] ) def callback(value): assert value == [0x61, 0xF2] assert_finished(obniz) obniz.spi0.write_wait([0x12, 0x98]) assert_send(obniz, [{"spi0": {"data": [0x12, 0x98], "read": True}}]) sleep(0.01) receive_json(obniz, [{"spi0": {"data": [0x61, 0xF2]}}]) def test_write_over_32_to_lt_1_0_3(self, obniz): firmver_ver = obniz.firmware_ver obniz.firmware_ver = "1.0.2" obniz.spi0.start({"clk": 0, "frequency": 1000000, "miso": 2, "mode": "master"}) assert_send(obniz, [{"io0": {"output_type": "push-pull5v"}}]) assert_send(obniz, [{"io2": {"output_type": "push-pull5v"}}]) assert_send(obniz, [{"io0": {"pull_type": "float"}}]) assert_send(obniz, [{"io2": {"pull_type": "float"}}]) assert_send( obniz, [{"spi0": {"clk": 0, "clock": 1000000, "miso": 2, "mode": "master"}}] ) data = [] for i in range(0, 33): data.append(i) def callback(value): pass with pytest.raises( Exception, match="with your obniz 1.0.2. spi max length=32byte but yours 33. " + "Please update obniz firmware", ): obniz.spi0.write_wait(data) assert_finished(obniz) obniz.firmware_ver = firmver_ver def test_write_over_32_to_gte_1_0_3(self, obniz): firmver_ver = obniz.firmware_ver obniz.firmware_ver = "1.0.3" obniz.spi0.start({"clk": 0, "frequency": 1000000, "miso": 2, "mode": "master"}) assert_send(obniz, [{"io0": {"output_type": "push-pull5v"}}]) assert_send(obniz, [{"io2": {"output_type": "push-pull5v"}}]) assert_send(obniz, [{"io0": {"pull_type": "float"}}]) assert_send(obniz, [{"io2": {"pull_type": "float"}}]) assert_send( obniz, [{"spi0": {"clk": 0, "clock": 1000000, "miso": 2, "mode": "master"}}] ) data = [] for i in range(0, 33): data.append(i) def callback(value): assert value == data assert_finished(obniz) obniz.spi0.write_wait(data) assert_send(obniz, [{"spi0": {"data": data, "read": True}}]) sleep(0.01) receive_json(obniz, [{"spi0": {"data": data}}]) obniz.firmware_ver = firmver_ver # it.skip('SPI send 2byte and receive 3byte', function() { # obniz.spi0.start({ # "clk": 0, # "frequency": 1000000, # "miso": 2, # "mode": 'master', # "mosi": 1, # }) # assert_send(obniz, [{ "io0": { "output_type": 'push-pull5v' } }]) # assert_send(obniz, [{ "io1": { "output_type": 'push-pull5v' } }]) # assert_send(obniz, [{ "io2": { "output_type": 'push-pull5v' } }]) # assert_send(obniz, [{ "io0": { "pull_type": 'float' } }]) # assert_send(obniz, [{ "io1": { "pull_type": 'float' } }]) # assert_send(obniz, [{ "io2": { "pull_type": 'float' } }]) # assert_send(obniz, [ # { "spi0": { "clk": 0, "clock": 1000000, "miso": 2, "mode": 'master', "mosi": 1 } }, # ]) # r = obniz.spi0.write_wait([0x12, 0x98]).then( # function(value) { # expect(value).to.be.deep.equal([0x61, 0xf2]) # assert_finished(obniz) # }.bind(self) # ) # assert_send(obniz, [{ "spi0": { "data": [0x12, 0x98], "read": True } }]) # setTimeout( # function() { # receive_json(obniz, [ # { "spi0": { "data": [0x61, 0xf2, 0x34] } }, # ]) # }.bind(self), # 10 # ) # return r # }) def test_end(self, obniz): obniz.spi0.start( {"clk": 0, "frequency": 1000000, "miso": 2, "mode": "master", "mosi": 1} ) assert_send(obniz, [{"io0": {"output_type": "push-pull5v"}}]) assert_send(obniz, [{"io1": {"output_type": "push-pull5v"}}]) assert_send(obniz, [{"io2": {"output_type": "push-pull5v"}}]) assert_send(obniz, [{"io0": {"pull_type": "float"}}]) assert_send(obniz, [{"io1": {"pull_type": "float"}}]) assert_send(obniz, [{"io2": {"pull_type": "float"}}]) assert_send( obniz, [ { "spi0": { "clk": 0, "clock": 1000000, "miso": 2, "mode": "master", "mosi": 1, } } ], ) assert_finished(obniz) obniz.spi0.end() assert_send(obniz, [{"spi0": None}]) assert_finished(obniz)
# -*- coding: utf-8 -*- ''' Auther: cytopia License: MIT Transformer for kubernetes-incubator/metrics-server from json into Prometheus readable format. ''' import os import json import re import time import requests import subprocess from flask import Flask from flask import Response ''' Globals that specify at which url metrics for nodes and pods can be found ''' PROXY = 'http://127.0.0.1:8080' URL_NODES = PROXY + '/apis/metrics.k8s.io/v1beta1/nodes' URL_PODS = PROXY + '/apis/metrics.k8s.io/v1beta1/pods' def shell_exec(command): ''' Execute raw shell command and return exit code and output Args: command (str): Command to execute Returns: tuple (int, str, str): Returns exit code, stdout and stderr ''' # Get absolute path of bash bash = os.popen('command -v bash').read().rstrip('\r\n') # Execute cpt = subprocess.Popen( command, executable=bash, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) # Get stdout, stderr and return code stdout, stderr = cpt.communicate() return_code = 0 #cpt.returncode return return_code, stdout, stderr def json2dict(data): ''' Safely convert a potential JSON string into a dict Args: data (str): Valid or invalid JSON string. Returns: dict: Returns dict of string or empty dict in case of invalid JSON input. ''' json_object = dict() try: json_object = json.loads(data) except ValueError: pass return json_object def val2base(string): ''' Transforms an arbitrary string value into a prometheus valid base (int|float) type by best guess: https://prometheus.io/docs/instrumenting/exposition_formats/#comments-help-text-and-type-information https://golang.org/pkg/strconv/#ParseFloat https://golang.org/pkg/strconv/#ParseInt Currently able to handle values of: 15Ki 15Mi 15Gi 1m0s 5m Args: string (str): metrics-server metrics value Returns: int|float|string: transformed value or initial value if no transformation regex was found. ''' # Transform KiloByte into Bytes val = re.search('^([0-9]+)Ki$', string, re.IGNORECASE) if val and val.group(1): return int(val.group(1)) * 1024 # Transform Megabytes into Bytes val = re.search('^([0-9]+)Mi$', string, re.IGNORECASE) if val and val.group(1): return int(val.group(1)) * (1024*1024) # Transform Gigabytes into Bytes val = re.search('^([0-9]+)Gi$', string, re.IGNORECASE) if val and val.group(1): return int(val.group(1)) * (1024*1024*1024) # Transform Terrabytes into Bytes val = re.search('^([0-9]+)Ti$', string, re.IGNORECASE) if val and val.group(1): return int(val.group(1)) * (1024*1024*1024*1024) # Transform hours, minutes and seconds into seconds val = re.search('^(([0-9]+)\s*h\s*)?(([0-9]+)\s*m\s*)?(([0-9]+)\s*s\s*)?$', string, re.IGNORECASE) if val and (val.group(2) or val.group(4) or val.group(6)): return ( (int(val.group(2) or 0) * 60 * 60) + (int(val.group(4) or 0) * 60) + (int(val.group(6) or 0)) ) # Otherwise return value as it came in return string def trans_node_metrics(string): ''' Transforms metrics-server node metrics (in the form of a JSON string) into Prometheus readable metrics format (text-based). https://prometheus.io/docs/instrumenting/exposition_formats/ https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form Args: string (str): Valid or invalid JSON string. Returns: str: Returns newline separated node metrics ready for Prometheus to pull. ''' data = json2dict(string) cpu = [] mem = [] cpu.append('# HELP kube_metrics_server_node_cpu The CPU time of a node in seconds.') cpu.append('# TYPE kube_metrics_server_node_cpu gauge') mem.append('# HELP kube_metrics_server_node_mem The memory of a node in Bytes.') mem.append('# TYPE kube_metrics_server_node_mem gauge') tpl = 'kube_metrics_server_node_{}{{node="{}"}} {}' for node in data.get('items', []): lbl = { 'node': node.get('metadata', []).get('name', '') } val = { 'cpu': node.get('usage', []).get('cpu', ''), 'mem': node.get('usage', []).get('memory', '') } cpu.append(tpl.format('cpu', lbl['node'], val2base(val['cpu']))) mem.append(tpl.format('mem', lbl['node'], val2base(val['mem']))) return '\n'.join(cpu + mem) def trans_pod_metrics(string): ''' Transforms metrics-server pod metrics (in the form of a JSON string) into Prometheus readable metrics format (text-based). https://prometheus.io/docs/instrumenting/exposition_formats/ https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form Args: string (str): Valid or invalid JSON string. Returns: str: Returns newline separated node metrics ready for Prometheus to pull. ''' data = json2dict(string) more = get_pod_metrics_from_cli() cpu = [] mem = [] cpu.append('# HELP kube_metrics_server_pod_cpu The CPU time of a pod in seconds.') cpu.append('# TYPE kube_metrics_server_pod_cpu gauge') mem.append('# HELP kube_metrics_server_pod_mem The memory of a pod in Bytes.') mem.append('# TYPE kube_metrics_server_pod_mem gauge') tpl = 'kube_metrics_server_pod_{}{{node="{}",pod="{}",ip="{}",container="{}",namespace="{}"}} {}' for pod in data.get('items', []): lbl = { 'pod': pod.get('metadata', []).get('name', ''), 'ns': pod.get('metadata', []).get('namespace', '') } # Loop over defined container in each pod for container in pod.get('containers', []): lbl['cont'] = container.get('name', '') val = { 'cpu': container.get('usage', []).get('cpu', ''), 'mem': container.get('usage', []).get('memory', '') } cpu.append(tpl.format( 'cpu', more[lbl['pod']]['node'], lbl['pod'], more[lbl['pod']]['ip'], lbl['cont'], lbl['ns'], val2base(val['cpu']) )) mem.append(tpl.format( 'mem', more[lbl['pod']]['node'], lbl['pod'], more[lbl['pod']]['ip'], lbl['cont'], lbl['ns'], val2base(val['mem']) )) return '\n'.join(cpu + mem) def get_pod_metrics_from_cli(): ''' Get pod metrics via CLI (allows to have node for enriching the data) Returns data: Dictionary of additional pod metrics ''' data = dict() command = 'kubectl get pods -o wide --no-headers --all-namespaces' ret, out, err = shell_exec(command) # 1:NS | 2:Name | 3:Ready | 4:Status | 5:Restarts | 6:Age | 7:IP | 8:Node | 9: NOMINATED NODE reg = re.compile(r"^([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ \n]+)[^\n]*$") for line in out.splitlines(): line = line.decode("utf-8") line = reg.match(line) data[line.group(2)] = { 'ns': line.group(1), 'name': line.group(2), 'ready': line.group(3), 'status': line.group(4), 'restarts': line.group(5), 'age': line.group(6), 'ip': line.group(7), 'node': line.group(8) } return data application = Flask(__name__) # pylint: disable=invalid-name @application.route("/metrics") def metrics(): ''' This function is the /metrics http entrypoint and will itself do two callbacks to the running kubectl proxy in order to gather node and pod metrics from specified kubernetes api urls. Current output is JSON and we must therefore transform both results into Prometheus readable format: https://prometheus.io/docs/instrumenting/exposition_formats/ https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form ''' # Get info from K8s API req = { 'nodes': requests.get(URL_NODES), 'pods': requests.get(URL_PODS) } # Object to JSON text json = { 'nodes': req['nodes'].text, 'pods': req['pods'].text } # Convert to Prometheus format prom = { 'nodes': trans_node_metrics(json['nodes']), 'pods': trans_pod_metrics(json['pods']) } get_pod_metrics_from_cli() # Return response return Response(prom['nodes'] + '\n' + prom['pods'], status=200, mimetype='text/plain') @application.route("/healthz") def healthz(): ''' This function is the /healthz http entrypoint and will itself do two callbacks in order to determine the health of node and pod metric endpoints. Returns: Response: Flask Response object that will handle returning http header and body. If one of the pages (nodes or pods metrics by metrics-server) fails, it will report an overall failure and respond with 503 (service unavailable). If both a good, it will respond with 200. ''' req = { 'nodes': requests.get(URL_NODES), 'pods': requests.get(URL_PODS) } health = 'ok' status = 200 if req['nodes'].status_code != 200: health = 'failed' status = 503 if req['pods'].status_code != 200: health = 'failed' status = 503 return Response(health, status=status, mimetype='text/plain') @application.route("/") def index(): ''' This function is the / http entrypoint and will simply provide a link to the metrics and health page. This is done, because all metrics endpoints I have encountered so far also do it exactly this way. Returns: Response: Flask Response object that will handle returning http header and body. Returns default Prometheus endpoint index page (http 200) with links to /healthz and /metrics. ''' return ''' <html> <head><title>metrics-server-prom</title></head> <body> <h1>metrics-server-prom</h1> <ul> <li><a href='/metrics'>metrics</a></li> <li><a href='/healthz'>healthz</a></li> </ul> </body> </html> ''' if __name__ == "__main__": application.run(host='0.0.0.0')
from flask import Flask, request from hbase_manager import HBaseRecord import json from flask_cors import CORS app = Flask(__name__) CORS(app) @app.route('/') @app.route('/test') @app.route('/hello') def hello(): return 'Hello World!' @app.route('/get_places', methods=['GET', 'POST']) def get_places(): if request.method == 'GET': data = request.args else: if request.headers.get('Content-Type') == 'application/json': data = json.loads(request.data.decode()) else: data = request.form eid = data.get('eid') start_time = data.get('start_time') end_time = data.get('end_time') if not eid or not start_time or not end_time: return '参数格式错误', 400 records = app.config.get('hbase').get_places(eid, start_time, end_time) if not records: return '[]', 200, {'Content-Type': 'application/json'} result = [] for record in records: eid, timestamp, place_id = record[0].split('##') result.append({ 'eid': eid, 'timestamp': timestamp, 'place_id': place_id, 'place_name': record[1], 'longitude': record[2], 'latitude': record[3] }) return json.dumps(result), 200, {'Content-Type': 'application/json'} if __name__ == '__main__': app.config['hbase'] = HBaseRecord('http://cc-keybrl-node0:2048') app.run(host='0.0.0.0', port=8080, debug=False)
import aio_pika
# ------------------------------------------------------------------------------------------ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. # ------------------------------------------------------------------------------------------ from typing import List, Optional import pytest import torch from InnerEye.ML.common import ModelExecutionMode from InnerEye.ML.config import SegmentationModelBase, equally_weighted_classes from InnerEye.ML.models.architectures.base_model import BaseSegmentationModel from Tests.ML.configs.DummyModel import DummyModel def test_validate_inference_stride_size() -> None: SegmentationModelBase.validate_inference_stride_size(inference_stride_size=(5, 3, 1), output_size=(5, 3, 1)) SegmentationModelBase.validate_inference_stride_size(inference_stride_size=(5, 3, 1), output_size=None) with pytest.raises(ValueError): SegmentationModelBase.validate_inference_stride_size(inference_stride_size=(5, 3, 1), output_size=(3, 3, 3)) SegmentationModelBase.validate_inference_stride_size(inference_stride_size=(5, 3, 0), output_size=None) def test_inference_stride_size_setter() -> None: """Tests setter function raises an error when stride size is larger than output patch size""" test_output_size = (7, 3, 5) test_stride_size = (3, 3, 3) test_fail_stride_size = (1, 1, 9) model = IdentityModel() model_config = SegmentationModelBase(test_crop_size=test_output_size, should_validate=False) model_config.inference_stride_size = test_stride_size assert model_config.inference_stride_size == test_stride_size model_config.set_derived_model_properties(model) assert model_config.inference_stride_size == test_stride_size model_config.inference_stride_size = None model_config.set_derived_model_properties(model) assert model_config.inference_stride_size == test_output_size with pytest.raises(ValueError): model_config.inference_stride_size = test_fail_stride_size def test_crop_size() -> None: """Checks if test crop size is equal to train crop size if it's not specified at init time""" model_config = DummyModel() assert model_config.test_crop_size == model_config.crop_size def test_set_model_config_attributes() -> None: """Tests setter function for model config attributes""" train_output_size = (3, 5, 3) test_output_size = (7, 7, 7) model = IdentityModel() model_config = SegmentationModelBase(crop_size=train_output_size, test_crop_size=test_output_size, should_validate=False) model_config.set_derived_model_properties(model) assert model_config.inference_stride_size == test_output_size # noinspection PyArgumentList def test_get_output_size() -> None: """Tests config properties related to output tensor size""" train_output_size = (5, 5, 5) test_output_size = (7, 7, 7) model_config = SegmentationModelBase(crop_size=train_output_size, test_crop_size=test_output_size, should_validate=False) assert model_config.get_output_size(execution_mode=ModelExecutionMode.TRAIN) is None assert model_config.get_output_size(execution_mode=ModelExecutionMode.TEST) is None model = IdentityModel() model_config.set_derived_model_properties(model) assert model_config.get_output_size(execution_mode=ModelExecutionMode.TRAIN) == train_output_size assert model_config.get_output_size(execution_mode=ModelExecutionMode.TEST) == test_output_size class IdentityModel(BaseSegmentationModel): def __init__(self) -> None: super().__init__(input_channels=1, name='IdentityModel') def forward(self, x: torch.Tensor) -> torch.Tensor: # type: ignore # returns the input as it is return x def get_all_child_layers(self) -> List[torch.nn.Module]: return list() @pytest.mark.parametrize(["num_fg_classes", "background_weight", "expected"], [ (1, 0.2, [0.2, 0.8]), (1, None, [0.5] * 2), (9, None, [0.1] * 10), (3, None, [1 / 4] * 4), (3, 0.4, [0.4, 0.2, 0.2, 0.2]), ]) def test_equally_weighted_classes(num_fg_classes: int, background_weight: Optional[float], expected: List[float]) -> None: classes = [""] * num_fg_classes actual = equally_weighted_classes(classes, background_weight) assert isinstance(actual, list) assert len(actual) == num_fg_classes + 1 assert sum(actual) == pytest.approx(1.0) assert actual == pytest.approx(expected) @pytest.mark.parametrize(["num_fg_clases", "background_weight"], [ (0, 0.5), (1, 1.0), (1, -0.1) ]) def test_equally_weighted_classes_fails(num_fg_clases: int, background_weight: Optional[float]) -> None: classes = [""] * num_fg_clases with pytest.raises(ValueError): equally_weighted_classes(classes, background_weight)
from django.contrib import admin from .models import Board,TodoList @admin.register(Board) class BoardAdmin(admin.ModelAdmin): search_fields = ['title'] list_display = ('title',) @admin.register(TodoList) class TodoAdmin(admin.ModelAdmin): search_fields = ['title','created'] list_display = ('title','done') list_filter = ('done','user')
#################################################### ## 0. Useful stuff about Python #################################################### # Pyhton Enhancement Proposals, or PEPs, are useful conventions which guide # the user in writing readable and pretty code, as well as many other # details about Python. PEP-8 is the Style Guide (https://www.python.org/dev/peps/pep-0008/) # According to PEP-8, line length should be limited to 79 characters # No brackets are used for code blocks. Instead, indentation is used # The general consensus is to use 4 spaces, but it is not necessary # What is necessary is to NOT mix tabs and spaces. Python will complain # NOTE: You can still press the "Tab" key, but make sure your IDE is set # up so that it will type 4 spaces per press. # snake_case is the norm, as opposed to camelCase as is standard in other # languages # Single line comments start with a hash symbol. """ Multiline strings can be written using three "s, and are often used as documentation (docstrings). """ type(a_variable) # Used to find out the type of a variable help(an_object) # Used to print documentation about a class or function (the # ones written in the triple double-quotes) dir(an_object) # Used to find all the variable and function names of # an object or module # Special Python variables will be surrounded by double underscores. # A particularly useful one is __name__, which lets the module know # if it is the one being executed as the main program, in which case that # module's __name__ = "__main__", otherwise it will be its own filename. # https://www.geeksforgeeks.org/__name__-special-variable-python/ # EVERYTHING in Python is an object # Python has a print function. We'll look at functions later, for now: print("I'm Python. Nice to meet you!") # => I'm Python. Nice to meet you! # By default the print function also prints out a newline at the end. # Use the optional argument end to change the end string. print("Hello, World", end="!") # => Hello, World! # Simple way to get user input data from console input_string_var = input("Enter some data: ") # Returns the data as a string # Note: In earlier versions of Python, input() method was named as raw_input() #################################################### ## 1. Primitive Datatypes and Operators #################################################### # Math is what you would expect 1 + 1 # => 2 8 - 1 # => 7 10 * 2 # => 20 35 / 5 # => 7.0 # Integer division rounds down for both positive and negative numbers. 5 // 3 # => 1 -5 // 3 # => -2 5.0 // 3.0 # => 1.0 # works on floats too -5.0 // 3.0 # => -2.0 # The result of division is always a float 10.0 / 3 # => 3.3333333333333335 # Modulo operation 7 % 3 # => 1 # Exponentiation (x**y, x to the yth power) 2**3 # => 8 # Enforce precedence with parentheses 1 + 3 * 2 # => 7 (1 + 3) * 2 # => 8 # Round numbers manually with round() round(5.5) # => 6 round(5.758, 2) # => 5.76 # Work in other bases (binary, octal and hexadecimal) 0b10 # => 2 0o10 # => 8 0x10 # => 16 # Scientific notation is also accepted 2.99e8 1.65e-30 # Using underscores, you can make large numbers more legible 10000000 == 10_000_000 # => True # Boolean values are primitives (Note: the capitalization) True # => True False # => False # negate with not not True # => False not False # => True # Boolean Operators # Note "and" and "or" are case-sensitive True and False # => False False or True # => True # True and False are actually 1 and 0 but with different keywords True + True # => 2 True * 8 # => 8 False - 5 # => -5 # Comparison operators look at the numerical value of True and False 0 == False # => True 1 == True # => True 2 == True # => False -5 != False # => True # Using boolean logical operators on ints casts them to booleans for evaluation, but their non-cast value is returned # Don't mix up with bool(ints) and bitwise and/or (&,|) bool(0) # => False bool(0.0) # => False bool(4) # => True bool(-6) # => True 0 and 2 # => 0 -5 or 0 # => -5 # Equality is == 1 == 1 # => True 2 == 1 # => False # Inequality is != 1 != 1 # => False 2 != 1 # => True # More comparisons 1 < 10 # => True 1 > 10 # => False 2 <= 2 # => True 2 >= 2 # => True # Seeing whether a value is in a range 1 < 2 and 2 < 3 # => True 2 < 3 and 3 < 2 # => False # Chaining makes this look nicer 1 < 2 < 3 # => True 2 < 3 < 2 # => False # (is vs. ==) is checks if two variables refer to the same object, but == checks # if the objects pointed to have the same values. a = [1, 2, 3, 4] # Point a at a new list, [1, 2, 3, 4] b = a # Point b at what a is pointing to b is a # => True, a and b refer to the same object b == a # => True, a's and b's objects are equal b = [1, 2, 3, 4] # Point b at a new list, [1, 2, 3, 4] b is a # => False, a and b do not refer to the same object b == a # => True, a's and b's objects are equal # Strings are created with " or '. There is no 'char' type unlike in other languages "This is a string." 'This is also a string.' # Strings can be added too! But try not to do this. "Hello " + "world!" # => "Hello world!" # String literals (but not variables) can be concatenated without using '+' "Hello " "world!" # => "Hello world!" # A string can be treated like a list of characters "Hello world!"[0] # => 'H' # You can find the length of a string len("This is a string") # => 16 # You can split strings based on a delimiter, by default, space "This string".split() # You can also format using f-strings or formatted string literals (in Python 3.6+) name = "Reiko" f"She said her name is {name}." # => "She said her name is Reiko" # You can basically put any Python statement inside the braces and it will be output in the string. f"{name} is {len(name)} characters long." # => "Reiko is 5 characters long." number = 250_000_000 f"{number:,}" # => 100,000,000 # And raw strings too path = r"C:\Users\Documents" # => Prints it as is # Bytes are a thing, usually used when working with raw binary data data = b"some binaty data" # Python allows encoding and decoding of said data into strings and viceversa string_1 = "Hey, thís is ä string with Ùnicode charactêrs" bytes_1 = string_1.encode("utf-8") # => b'Hey, th\xc3\xads is \xc3\xa4 string with \xc3\x99nicode charact\xc3\xaars' bytes_1.decode("utf-8") # => Hey, thís is ä string with Ùnicode charactêrs # 'None' is an object too None # => None # Don't use the equality "==" symbol to compare objects to None # Use "is" instead. This checks for equality of object identity. "etc" is None # => False None is None # => True # None, 0, and empty strings/lists/dicts/tuples all evaluate to False. # All other values are True bool(0) # => False bool("") # => False bool("False") # => True bool([]) # => False bool({}) # => False bool(()) # => False # Casting is available through constructors int(-2.5) # => -2 int("340") float(2) float("2467") str(450) # And you can even get infinity float("inf") float("-inf") #################################################### ## 2. Variables and Collections #################################################### # There are no declarations, only assignments. A new object is created # on every assignment, but x = 300, x = 5, x = 300 will have created 2 # separate int objects. Technically, variables in Python are actually # references to objects some_var = 5 some_var # => 5 # Accessing a previously unassigned variable is an exception. # See Control Flow to learn more about exception handling. some_unknown_var # Raises a NameError # if can be used as an expression # Equivalent of C's '?:' ternary operator "yahoo!" if 3 > 2 else 2 # => "yahoo!" # Un-pythonic alternative, usually best to avoid it (value_if_false, value_if_true)[test] # Lists store sequences li = [] # You can start with a prefilled list other_li = [4, 5, 6] # Add stuff to the end of a list with extend li.extend("a", "b") # li is now ["a", "b"] li = [] # Add 1 element to the end with append li.append(1) # li is now [1] li.append(2) # li is now [1, 2] li.append(4) # li is now [1, 2, 4] li.append(3) # li is now [1, 2, 4, 3] li.append((5, 6)) # li is now [1, 2, 4, 3, (5, 6)] # Remove from the end with pop li.pop() # => (5,6) and li is now [1, 2, 4, 3] li.pop() # => 3 and li is now [1, 2, 4] # Let's put it back li.append(3) # li is now [1, 2, 4, 3] again. # Access a list like you would any array li[0] # => 1 # Look at the last element li[-1] # => 3 # Looking out of bounds is an IndexError li[4] # Raises an IndexError # Slicing # You can look at ranges with slice syntax. # The start index is included, the end index is not # (It's a closed/open range for you mathy types.) li[1:3] # Return list from index 1 to 3 => [2, 4] li[2:] # Return list starting from index 2 => [4, 3] li[:3] # Return list from beginning until index 3 => [1, 2, 4] li[::2] # Return list selecting every second entry => [1, 4] li[::-1] # Return list in reverse order => [3, 4, 2, 1] # Use any combination of these to make advanced slices # li[start:end:step] # Make a one-layer-deep shallow copy using slices li2 = li[:] # => li2 = [1, 2, 4, 3] but (li2 is li) will result in false. # Other ways to copy lists are: li2 = list(li) # This tends to be the best option, since it will work almost # always regardless of li's type li2 = li.copy() # Only works if li is a list # CAREFUL: if a list contains mutable objects, modifying them in li2 would # still change them in li, even though they are different lists. For example: li1 = [[1,2], [3,4]] li2 = li1[:] # list(li1) or li1.copy() would also work li2 is li1 # False li2 == li1 # True li2[0] is li1[0] # True # Remove arbitrary elements by index from a list with "del" del li[2] # li is now [1, 2, 3] # Remove first occurrence of a value li.remove(2) # li is now [1, 3] li.remove(2) # Raises a ValueError as 2 is not in the list # Insert an element at a specific index li.insert(1, 2) # li is now [1, 2, 3] again # Get the index of the first item found matching the argument li.index(2) # => 1 li.index(4) # Raises a ValueError as 4 is not in the list # You can add lists # Note: values for li and for other_li are not modified. li + other_li # => [1, 2, 3, 4, 5, 6] # Concatenate lists with "extend()" li.extend(other_li) # Now li is [1, 2, 3, 4, 5, 6] # Check for existence in a list with "in" 1 in li # => True # Examine the length with "len()" len(li) # => 6 # Reverse and sort lists li.reverse() # [6, 5, 4, 3, 2, 1] li.sort() # [1, 2, 3, 4, 5, 6] # reversed and sorted are used to not modify the original list, but return # a new one print(sorted(li)) # returns new list print(reversed(li)) # returns new iterator, not list # Generally, you want to use sorted() since it can work with immutable objects # and won't mess up the original # Choose a random element of any collection import random random.choice(iterable) # Tuples are like lists but are immutable. tup = (1, 2, 3) tup[0] # => 1 tup[0] = 3 # Raises a TypeError # Note that a tuple of length one has to have a comma after the last element but # tuples of other lengths, even zero, do not. type((1)) # => <class 'int'> type((1,)) # => <class 'tuple'> type(()) # => <class 'tuple'> # You can do most of the list operations on tuples too len(tup) # => 3 tup + (4, 5, 6) # => (1, 2, 3, 4, 5, 6) tup[:2] # => (1, 2) 2 in tup # => True # You can unpack tuples (or lists) into variables a, b, c = (1, 2, 3) # a is now 1, b is now 2 and c is now 3 # You can also do extended unpacking a, *b, c = (1, 2, 3, 4) # a is now 1, b is now [2, 3] and c is now 4 # Tuples are created by default if you leave out the parentheses d, e, f = 4, 5, 6 # tuple 4, 5, 6 is unpacked into variables d, e and f # respectively such that d = 4, e = 5 and f = 6 # Now look how easy it is to swap two values e, d = d, e # d is now 5 and e is now 4 # Dictionaries store mappings from keys to values empty_dict = {} # Here is a prefilled dictionary filled_dict = {"one": 1, "two": 2, "three": 3} # Note keys for dictionaries have to be immutable types. This is to ensure that # the key can be converted to a constant hash value for quick look-ups. # Immutable types include ints, floats, strings, tuples. invalid_dict = {[1,2,3]: "123"} # => Raises a TypeError: unhashable type: 'list' valid_dict = {(1,2,3):[1,2,3]} # Values can be of any type, however. # Look up values with [] filled_dict["one"] # => 1 # Get all keys as an iterable with "keys()". We need to wrap the call in list() # to turn it into a list. We'll talk about those later. Note - for Python # versions <3.7, dictionary key ordering is not guaranteed. Your results might # not match the example below exactly. However, as of Python 3.7, dictionary # items maintain the order at which they are inserted into the dictionary. list(filled_dict.keys()) # => ["three", "two", "one"] in Python <3.7 list(filled_dict.keys()) # => ["one", "two", "three"] in Python 3.7+ # Get all values as an iterable with "values()". Once again we need to wrap it # in list() to get it out of the iterable. Note - Same as above regarding key # ordering. list(filled_dict.values()) # => [3, 2, 1] in Python <3.7 list(filled_dict.values()) # => [1, 2, 3] in Python 3.7+ # Check for existence of keys in a dictionary with "in" "one" in filled_dict # => True 1 in filled_dict # => False # Looking up a non-existing key is a KeyError filled_dict["four"] # KeyError # Use "get()" method to avoid the KeyError filled_dict.get("one") # => 1 filled_dict.get("four") # => None # The get method supports a default argument when the value is missing filled_dict.get("one", 4) # => 1 filled_dict.get("four", 4) # => 4 # "setdefault()" inserts into a dictionary only if the given key isn't present filled_dict.setdefault("five", 5) # filled_dict["five"] is set to 5 filled_dict.setdefault("five", 6) # filled_dict["five"] is still 5 # Adding to a dictionary (updates value if key already existed) filled_dict.update({"four":4}) # => {"one": 1, "two": 2, "three": 3, "four": 4} filled_dict["four"] = 4 # another way to add to dict # Remove keys from a dictionary with del del filled_dict["one"] # Removes the key "one" from filled dict # From Python 3.5 you can also use the additional unpacking options {'a': 1, **{'b': 2}} # => {'a': 1, 'b': 2} {'a': 1, **{'a': 2}} # => {'a': 2} # Sets store ... well sets empty_set = set() # Initialize a set with a bunch of values. Yeah, it looks a bit like a dict. Sorry. some_set = {1, 1, 2, 2, 3, 4} # some_set is now {1, 2, 3, 4} # Similar to keys of a dictionary, elements of a set have to be immutable. invalid_set = {[1], 1} # => Raises a TypeError: unhashable type: 'list' valid_set = {(1,), 1} # Add one more item to the set filled_set = some_set filled_set.add(5) # filled_set is now {1, 2, 3, 4, 5} # Sets do not have duplicate elements filled_set.add(5) # it remains as before {1, 2, 3, 4, 5} # Remove one or more items with remove or discard filled_set.remove(6) # Raises KeyError since there's no 6 filled_set.discard(6) # Is silent # NOTE: Set operations can also be performed with functions, not shown here # Do set intersection with & other_set = {3, 4, 5, 6} filled_set & other_set # => {3, 4, 5} # Do set union with | filled_set | other_set # => {1, 2, 3, 4, 5, 6} # Do set difference with - {1, 2, 3, 4} - {2, 3, 5} # => {1, 4} # Do set symmetric difference with ^ {1, 2, 3, 4} ^ {2, 3, 5} # => {1, 4, 5} # Check if set on the left is a superset of set on the right {1, 2} >= {1, 2, 3} # => False # Check if set on the left is a subset of set on the right {1, 2} <= {1, 2, 3} # => True # Check for existence in a set with in 2 in filled_set # => True 10 in filled_set # => False # Make a one layer deep copy filled_set = some_set.copy() # filled_set is {1, 2, 3, 4, 5} filled_set is some_set # => False #################################################### ## 3. Control Flow and Iterables #################################################### # Let's just make a variable some_var = 5 # Here is an if statement. Indentation is significant in Python! # Convention is to use four spaces, not tabs. # This prints "some_var is smaller than 10" if some_var > 10: print("some_var is totally bigger than 10.") elif some_var < 10: # This elif clause is optional. print("some_var is smaller than 10.") else: # This is optional too. print("some_var is indeed 10.") """ For loops iterate over lists prints: dog is a mammal cat is a mammal mouse is a mammal """ for animal in ["dog", "cat", "mouse"]: # You can use format() to interpolate formatted strings print("{} is a mammal".format(animal)) """ "range(number)" returns an iterable of numbers from zero to the given number prints: 0 1 2 3 """ for i in range(4): print(i) """ "range(lower, upper)" returns an iterable of numbers from the lower number to the upper number prints: 4 5 6 7 """ for i in range(4, 8): print(i) """ "range(lower, upper, step)" returns an iterable of numbers from the lower number to the upper number, while incrementing by step. If step is not indicated, the default value is 1. prints: 4 6 """ for i in range(4, 8, 2): print(i) """ To loop over a list, and retrieve both the index and the value of each item in the list prints: 0 dog 1 cat 2 mouse """ animals = ["dog", "cat", "mouse"] for i, value in enumerate(animals): print(i, value) """ To loop over a dictionary, you can use the for ... in ... with the dictionary itself, which iterates over the keys, as well as .items() for key value tuples or .values() to only get the values: """ sample_dictionary = {1: "one", 2: "two"} for key in sample_dictionary: print(key) for key, value in sample_dictionary.items(): print(key, value) """ While loops go until a condition is no longer met. prints: 0 1 2 3 """ x = 0 while x < 4: print(x) x += 1 # Shorthand for x = x + 1 # Exception Handling """ Common errors are: IndexError: Index out of range ValueError: Object is of the right type, but contains an inappropriate value, eg. int("asdasd") KeyError: Look-up in a mapping fails. No such key is present TypeError: The type is not the expected. Usually not checked for; if your code works for more types than expected, it is seen as good in Python. If it fails, the exception will be raised anyways """ # EAFP (Easier to Ask for Forgiveness than Permission) is deeply ingrained in # Python. Do not check for specific error codes, but rather for exceptions, # and avoid preemptive checks, as that would be "asking for permission" # Handle exceptions with a try/except block try: # Use "raise" to raise an error raise IndexError("This is an index error") except IndexError as e: pass # Pass is just a no-op. Usually you would do recovery here. except (TypeError, NameError): pass # Multiple exceptions can be handled together, if required. else: # Optional clause to the try/except block. Must follow all except blocks print("All good!") # Runs only if the code in try raises no exceptions finally: # Execute under all circumstances print("We can clean up resources here") # Instead of try/finally to cleanup resources you can use a with statement with open("myfile.txt") as f: for line in f: print(line) # Writing to a file contents = {"aa": 12, "bb": 21} with open("myfile1.txt", "w+") as file: file.write(str(contents)) # writes a string to a file with open("myfile2.txt", "w+") as file: file.write(json.dumps(contents)) # writes an object to a file # Reading from a file with open('myfile1.txt', "r+") as file: contents = file.read() # reads a string from a file print(contents) # print: {"aa": 12, "bb": 21} with open('myfile2.txt', "r+") as file: contents = json.load(file) # reads a json object from a file print(contents) # print: {"aa": 12, "bb": 21} # Python offers a fundamental abstraction called the Iterable. # An iterable is an object that can be treated as a sequence. # The object returned by the range function, is an iterable. filled_dict = {"one": 1, "two": 2, "three": 3} our_iterable = filled_dict.keys() print(our_iterable) # => dict_keys(['one', 'two', 'three']). This is an object that implements our Iterable interface. # We can loop over it. for i in our_iterable: print(i) # Prints one, two, three # However we cannot address elements by index. our_iterable[1] # Raises a TypeError # An iterable is an object that knows how to create an iterator. our_iterator = iter(our_iterable) # Our iterator is an object that can remember the state as we traverse through it. # We get the next object with "next()". next(our_iterator) # => "one" # It maintains state as we iterate. next(our_iterator) # => "two" next(our_iterator) # => "three" # After the iterator has returned all of its data, it raises a StopIteration exception next(our_iterator) # Raises StopIteration # We can also loop over it, in fact, "for" does this implicitly! our_iterator = iter(our_iterable) for i in our_iterator: print(i) # Prints one, two, three # You can grab all the elements of an iterable or iterator by calling list() on it. list(our_iterable) # => Returns ["one", "two", "three"] list(our_iterator) # => Returns [] because state is saved #################################################### ## 4. Functions #################################################### # Use "def" to create new functions def add(x, y): print("x is {} and y is {}".format(x, y)) return x + y # Return values with a return statement # A function can be stopped prematurely with return, in which case None will # be returned instead def premature_stop_square(x): if(type(x) != "int"): return return x*x # Calling functions with parameters add(5, 6) # => prints out "x is 5 and y is 6" and returns 11 # Another way to call functions is with keyword arguments add(y=6, x=5) # Keyword arguments can arrive in any order. # Function Scope x = 5 def set_x(num): # Local var x not the same as global variable x x = num # => 43 print(x) # => 43 def set_global_x(num): global x print(x) # => 5 x = num # global var x is now set to 6 print(x) # => 6 set_x(43) set_global_x(6) # Arguments can also have default values, making them optional. These default # expressions are only evaluated once, meaning a = 5 and b= 5 will occur only # the first time the function is called. Any other time they won't happen def operation_with_defaults(a=5, b=4): print(a+b) operation_with_defaults(2) # => 6 # Always use immutable objects, such as ints or strings, for default values # or None, if you want to use mutable ones, such as Lists, for the reason # mentioned above def add_to_list(list=[]): # Do not do this list.append("a") print(list) add_to_list() # [a] add_to_list() # [a, a] add_to_list() # [a, a, a] def add_to_list_correct(list=None): # Do this instead if list is None: list = [] list.append("a") print(list) # You can define functions that take an indefinite number of # positional arguments def varargs(*args): return args varargs(1, 2, 3) # => (1, 2, 3) # You can define functions that take an indefinite number of # keyword arguments, as well def keyword_args(**kwargs): return kwargs # Let's call it to see what happens keyword_args(big="foot", loch="ness") # => {"big": "foot", "loch": "ness"} # You can do both at once, if you like def all_the_args(*args, **kwargs): print(args) print(kwargs) """ all_the_args(1, 2, a=3, b=4) prints: (1, 2) {"a": 3, "b": 4} """ # When calling functions, you can do the opposite of args/kwargs! # Use * to expand tuples and use ** to expand kwargs. args = (1, 2, 3, 4) kwargs = {"a": 3, "b": 4} all_the_args(*args) # equivalent to all_the_args(1, 2, 3, 4) all_the_args(**kwargs) # equivalent to all_the_args(a=3, b=4) all_the_args(*args, **kwargs) # equivalent to all_the_args(1, 2, 3, 4, a=3, b=4) # Returning multiple values (with tuple assignments) def swap(x, y): return y, x # Return multiple values as a tuple without the parenthesis. # (Note: parenthesis have been excluded but can be included) x = 1 y = 2 x, y = swap(x, y) # => x = 2, y = 1 # (x, y) = swap(x,y) # Again parenthesis have been excluded but can be included. # Python has first class functions def create_adder(x): def adder(y): return x + y return adder add_10 = create_adder(10) add_10(3) # => 13 # There are also anonymous functions (lambda x: x > 2)(3) # => True (lambda x, y: x ** 2 + y ** 2)(2, 1) # => 5 # There are built-in higher order functions list(map(add_10, [1, 2, 3])) # => [11, 12, 13] list(map(max, [1, 2, 3], [4, 2, 1])) # => [4, 2, 3] list(filter(lambda x: x > 5, [3, 4, 5, 6, 7])) # => [6, 7] # We can use list comprehensions for nice maps and filters # List comprehension stores the output as a list which can itself be a nested list [add_10(i) for i in [1, 2, 3]] # => [11, 12, 13] [x for x in [3, 4, 5, 6, 7] if x > 5] # => [6, 7] # You can construct set and dict comprehensions as well. {x for x in 'abcddeef' if x not in 'abc'} # => {'d', 'e', 'f'} {x: x**2 for x in range(5)} # => {0: 0, 1: 1, 2: 4, 3: 9, 4: 16} {value: key for key, value in some_dict} # This would "reverse" some_dict, # but keys could be overwritten since values are not unique within a dict #################################################### ## 5. Modules and Virtual Environments #################################################### # You can import modules import math print(math.sqrt(16)) # => 4.0 # You can get specific functions from a module from math import ceil, floor print(ceil(3.7)) # => 4.0 print(floor(3.7)) # => 3.0 # You can import all functions from a module. # Warning: this is not recommended from math import * # You can shorten module names import math as m math.sqrt(16) == m.sqrt(16) # => True # And even import specific functions with aliases from math import sqrt as alias_for_sqrt # Python modules are just ordinary Python files. You # can write your own, and import them. The name of the # module is the same as the name of the file. # You can find out which functions and attributes # are defined in a module. import math dir(math) # If you have a Python script named math.py in the same # folder as your current script, the file math.py will # be loaded instead of the built-in Python module. # This happens because the local folder has priority # over Python's built-in libraries. # NOTE: Virtual environments are incredibly useful and highly recommended # to keep your projects' dependencies unrelated to each other, thus avoiding # potential conflicts. To set them up, use the 'venv' tool included in Python # or virtualenv installed through pip. We'll use venv. # On Windows (either PowerShell or cmd work): # Ensure pip is up-to-date (comes with Python >=3.4): python -m pip install --upgrade pip # Then move to the desired folder and create the virtual env. cd path/to/your/directory python -m venv <MyEnv> # And activate the environment <MyEnv>\Scripts\activate.bat # on cmd <MyEnv>\Scripts\Activate.ps1 # on PowerShell # NOTE: you might get an error on PS. Fix it by running # Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser # This should now put you inside the virtual environment # Again, ensure pip is up to date and start installing modules! python -m pip install -U pip # 'python -m easy_install pip' if it doesn't work pip install modulename # And exit the virtual environment when done deactivate #################################################### ## 5.1 Pandas #################################################### # Pandas is a module made for data analysis and manipulation. It offers # data structures and operations for manipulating numerical tables and time series. # https://pandas.pydata.org/ # Pandas works with DataFrames, comprised of rows and columns # and Series, successions of values (equivalent to 1 column) # Commonly imported with import pandas as pd # Changing and resetting options pd.options.display.max_rows = 30 pd.reset_option("max_rows") my_series = pd.Series([1,2,3]) # DFs can be created from dictionaries my_df = pd.DataFrame({ "Column1": ["Row1", "Row2", "Row3", "Row4"], "Column2": my_series }) #Row4 will have NA/NaN value since my_series only has 3 values # Read from/Write to csv df = pd.read_csv("/somedirectory/csv") df.to_csv("name of the csv file.csv") # Read from/Write to Excel df2 = pd.read_excel("/somedirectory/excel") df2.to_xlsx("name of the excel file.xlsx") # Adding new columns my_df['Column3'] = [some_value, some_other_value] # Simple way to write a new column derived from others my_df["Column7"] = [int(row[1]["Column1"] and row[1]["Column2"]) for row in my_df.iterrows()] # describe() is useful to get a quick glance at the data # it will provide several metrics (count, mean, std, min, max...) df.describe() # Change the indexes for the rows with index() df.index = ["ROW1", "ROW2"] df.head() # First 5 rows of data df.head(n) # First n rows of data # hist() can be used to get a histogram of a specific column or Series df.hist('Column1') # scatter() can be used to get a scatter diagram of 2 given columns or Series df.plot.scatter('Column1', 'Column2') # Locating data in a DataFrame # https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html # Use single or double brackets to obtain Series or DataFrames df['Column3'] # Column as a Series df[['Column3']] # Column as a DataFrame df[["Column1", "Column4"]] # New Dataframe out of specific columns df['Column2'][1] # 2nd element of Column2 df[0:2] # DataFrame from the first 2 columns of df # Remember that 0:2 will have 2 columns. It is a closed-open range # In mathematical terms: [0,2) = [0,1] sliced_df = df[0:3, 1:10] # Grabs the first 3 columns, 2nd to 10th rows # loc is used to locate data with row indexes and column headers df.loc[0, "Column1"] # => Row1, with only Column1's value df.loc[0, "NotAColumn"] # => KeyError df.loc[0] # => Row1 entirely # iloc does the same but using only integers df.iloc[0, 0] # => Row1 df.iloc[0, 4000] # IndexError df.iloc[:, 0:4] # All rows, only the first 3 columns # Unique finds each individual value df["Column2"].unique() # => 1,2,3 #Filtering by value can also be done df["Column2"] >= 2 # => 2, 3 df1 = df[df["Column2"] >= 2] df1 = df[df.column2.isin([1, 4])] # Multiple explicit values for one column df1 = df[(df["Column2"] == 1) & (df["Column3"] == "some string")] # Multiple-column filtering # Operating with values # Operations can be done to columns/Series, so they are applied to each value df["Column2"] * 5 # => [5, 10, 15] # Drop specific columns df_1 = df.copy() df_1 = df_1.drop(df_1.columns[-9:-5], axis=1) # apply() is a strong tool which accepts lambda functions df["Column2"].apply(lambda val: val > 2) # => [3] #################################################### ## 5.2 NumPy #################################################### # NumPy is a module adding support for large, multi-dimensional arrays # and matrices, along with a large collection of high-level mathematical # functions to operate on these arrays. import numpy as np array = np.array([0,1,2,3,4]) # creating a 1-dimensional ndarray, the basic NumPy array. It works # as a usual array would, and can only take one data type a[3] # => 3 array.size # => 5 array.dim # => 1 array.shape # => (5,) gives the size of the array for each dimension, in a tuple # (rows, columns) array.dtype # => dtype('int64') type(array) # => numpy.ndarray # NumPy can perform vector operations much faster than normal Python can u = np.array([1,0]) v = np.array([0,1]) y = np.array([1,2]) # Addition and subtraction z = u + v # =>z is now the ndarray [1,1] z = u - v # => [1,-1] # Scalar multiplication, addition and subtraction z = 2 * y # => [2,4] z = u + 1 #=> [2,1] # Hadamard product (matrices of same dimensions) z = v*y # => [0,2] # Dot product (a measure of how similar 2 vectors are) z = np.dot(u, v) # => 1*0 + 0*1 = 0 z = np.dot(u, y) # => 1*1 + 0*2 = 1 # Universal functions are functions that work on ndarrays array.mean() # => 2 array.max() b = np.array([0, np.pi/2, np.pi]) np.sin(b) # [0,1,0] # linspace can be used to create an evenly-distributed array # given a starting and finishing point and number of elements np.linspace(0, 5, num=6) # => [0,1,2,3,4,5] np.linspace(-2, 2, num=9) # => [-2, -1.5, -1, -0.5. 0, 0.5, 1, 1.5, 2] # Arrays can be 2-Dimensional as well array = np.array([[11, 12, 13], [21, 22, 23], [31, 32, 33]]) array.ndim # => 2 array.shape # (3,3) where the first number is the number of lists (rows), # the second the number of elements in each list (columns) array.size # => 9 (3x3) b = np.array([[1, 0, 1], [0, 1, 1]]) b.shape # => (2,3) b.size # => 6 # And as with 1-D arrays, they can be operated upon, just like matrices # The only particular operation is matrix multiplication x = np.array([[0, 1, 1], [1, 0, 1]]) y = np.array([[1, 1], [1, 1], [-1, 1]]) # since x's rows must equal y's columns mult = np.dot(x, y) # => [[0,0], [0,2]] #################################################### ## 5.3 Keras #################################################### #################################################### ## 6. Classes #################################################### # We use the "class" statement to create a class class Human: # A class attribute. It is shared by all instances of this class species = "H. sapiens" # Basic initializer, this is called when this class is instantiated. # Note that the double leading and trailing underscores denote objects # or attributes that are used by Python but that live in user-controlled # namespaces. Methods(or objects or attributes) like: __init__, __str__, # __repr__ etc. are called special methods (or sometimes called dunder methods) # You should not invent such names on your own. # __init__() is an initializer, NOT a constructor as in other languages. # The object already exists, __init__ only gives values to attributes def __init__(self, name): self.name = name # Assign the argument to the instance's name attribute # Initialize property self._age = 0 # An instance method. All methods take "self" as the first argument def say(self, msg): print("{name}: {message}".format(name=self.name, message=msg)) # Another instance method def sing(self): return 'yo... yo... microphone check... one two... one two...' # A class method is shared among all instances # They are called with the calling class as the first argument @classmethod def get_species(cls): return cls.species # A static method can be called without a class or instance reference @staticmethod def grunt(): return "*grunt*" # A property is just like a getter. # It turns the method age() into an read-only attribute of the same name. # There's no need to write trivial getters and setters in Python, though. @property def age(self): return self._age # This allows the property to be set @age.setter def age(self, age): self._age = age # This allows the property to be deleted @age.deleter def age(self): del self._age # When a Python interpreter reads a source file it executes all its code. # This __name__ check makes sure this code block is only executed when this # module is the main program. if __name__ == '__main__': # Instantiate a class, creating an object of said class i = Human(name="Ian") i.say("hi") # "Ian: hi" Human.say(i, "hi") # Completely equivalent j = Human("Joel") j.say("hello") # "Joel: hello" # Call our class method i.say(i.get_species()) # "Ian: H. sapiens" # Change the shared attribute Human.species = "H. neanderthalensis" i.say(i.get_species()) # => "Ian: H. neanderthalensis" j.say(j.get_species()) # => "Joel: H. neanderthalensis" # Call the static method print(Human.grunt()) # => "*grunt*" # Cannot call static method with instance of object because i.grunt() will automatically put "self" (the object i) as an argument print(i.grunt()) # => TypeError: grunt() takes 0 positional arguments but 1 was given # Update the property for this instance i.age = 42 # Get the property i.say(i.age) # => "Ian: 42" j.say(j.age) # => "Joel: 0" # Delete the property del i.age # i.age # => this would raise an AttributeError # Objects can be compared by value and by identity # Value comparison can be done programmatically, # whereas identity comparison is carried out by the language itself r = [1, 2, 3] s = r print(r is s) # => True s = [1, 2, 3] print(r is s) # => False, they have different identities print(r == s) # => True, they have the same value #################################################### ## 6.1 Inheritance #################################################### # Inheritance allows new child classes to be defined that inherit methods and # variables from their parent class. # Using the Human class defined above as the base or parent class, we can # define a child class, Superhero, which inherits the class variables like # "species", "name", and "age", as well as methods, like "sing" and "grunt" # from the Human class, but can also have its own unique properties. # To take advantage of modularization by file you could place the classes above in their own files, # say, human.py # To import functions from other files use the following format # from "filename-without-extension" import "function-or-class" from human import Human # Specify the parent class(es) as parameters to the class definition class Superhero(Human): # If the child class should inherit all of the parent's definitions without # any modifications, you can just use the "pass" keyword (and nothing else) # but in this case it is commented out to allow for a unique child class: # pass # Child classes can override their parents' attributes species = 'Superhuman' # Children automatically inherit their parent class's constructor including # its arguments, but can also define additional arguments or definitions # and override its methods such as the class constructor. # This constructor inherits the "name" argument from the "Human" class and # adds the "superpower" and "movie" arguments: def __init__(self, name, movie=False, superpowers=["super strength", "bulletproofing"]): # add additional class attributes: self.fictional = True self.movie = movie # be aware of mutable default values, since defaults are shared self.superpowers = superpowers # The "super" function lets you access the parent class's methods # that are overridden by the child, in this case, the __init__ method. # This calls the parent class constructor: super().__init__(name) # override the sing method def sing(self): return 'Dun, dun, DUN!' # add an additional instance method def boast(self): for power in self.superpowers: print("I wield the power of {pow}!".format(pow=power)) if __name__ == '__main__': sup = Superhero(name="Tick") # Instance type checks if isinstance(sup, Human): print('I am human') if type(sup) is Superhero: print('I am a superhero') # Get the Method Resolution search Order used by both getattr() and super() # This attribute is dynamic and can be updated print(Superhero.__mro__) # => (<class '__main__.Superhero'>, # => <class 'human.Human'>, <class 'object'>) # Calls parent method but uses its own class attribute print(sup.get_species()) # => Superhuman # Calls overridden method print(sup.sing()) # => Dun, dun, DUN! # Calls method from Human sup.say('Spoon') # => Tick: Spoon # Call method that exists only in Superhero sup.boast() # => I wield the power of super strength! # => I wield the power of bulletproofing! # Inherited class attribute sup.age = 31 print(sup.age) # => 31 # Attribute that only exists within Superhero print('Am I Oscar eligible? ' + str(sup.movie)) #################################################### ## 6.2 Multiple Inheritance #################################################### # Another class definition # bat.py class Bat: species = 'Baty' def __init__(self, can_fly=True): self.fly = can_fly # This class also has a say method def say(self, msg): msg = '... ... ...' return msg # And its own method as well def sonar(self): return '))) ... (((' if __name__ == '__main__': b = Bat() print(b.say('hello')) print(b.fly) # And yet another class definition that inherits from Superhero and Bat # superhero.py from superhero import Superhero from bat import Bat # Define Batman as a child that inherits from both Superhero and Bat class Batman(Superhero, Bat): def __init__(self, *args, **kwargs): # Typically to inherit attributes you have to call super: # super(Batman, self).__init__(*args, **kwargs) # However we are dealing with multiple inheritance here, and super() # only works with the next base class in the MRO list. # So instead we explicitly call __init__ for all ancestors. # The use of *args and **kwargs allows for a clean way to pass arguments, # with each parent "peeling a layer of the onion". Superhero.__init__(self, 'anonymous', movie=True, superpowers=['Wealthy'], *args, **kwargs) Bat.__init__(self, *args, can_fly=False, **kwargs) # override the value for the name attribute self.name = 'Sad Affleck' def sing(self): return 'nan nan nan nan nan batman!' if __name__ == '__main__': sup = Batman() # Get the Method Resolution search Order used by both getattr() and super(). # This attribute is dynamic and can be updated print(Batman.__mro__) # => (<class '__main__.Batman'>, # => <class 'superhero.Superhero'>, # => <class 'human.Human'>, # => <class 'bat.Bat'>, <class 'object'>) # Calls parent method but uses its own class attribute print(sup.get_species()) # => Superhuman # Calls overridden method print(sup.sing()) # => nan nan nan nan nan batman! # Calls method from Human, because inheritance order matters sup.say('I agree') # => Sad Affleck: I agree # Call method that exists only in 2nd ancestor print(sup.sonar()) # => ))) ... ((( # Inherited class attribute sup.age = 100 print(sup.age) # => 100 # Inherited attribute from 2nd ancestor whose default value was overridden. print('Can I fly? ' + str(sup.fly)) # => Can I fly? False #################################################### ## 7. File Management #################################################### # Files in Python can be read or written to, as well as updated, supporting # either binary or encoded text files. By default, files are open to read text # The best syntax is the following: with open("filename", "mode", "encoding") as f: # Operate with the file, it'll be closed once done f.read() # But you can also use the old way f = open("filename", "mode", "encoding") # Remember to close files once done if you chose this f.close() """ Modes can be: r - Read (default) w - Write. Overwrites if already exists, creates if not a - Append. Creates if non-existant x - Exclusive creation. If the file already exists, it fails + - Update (read & write) t - Text mode (default) b - Binary mode (using bytes objects) These 2 blocks can actually be combined, e.g. "r+b", "a", "xb", "+" """ with open("filename", "mode", "encoding") as f: # Files can be read with read() or written to with write() f.read(5) # Reads 5 characters, and moves the reader pointer f.readline() # A more elegant way to read entire lines individually f.readlines() # Returns a list with every line in the file f.write("This is a string") # Writes with the specified encoding f.writelines(["This is a\n", "list of strings"]) # Writes without newlines # unless added in by hand # To relocate the pointer to a specific position, use seek() f.seek(0) # Returns to first character #################################################### ## 8. Advanced #################################################### # Generators help you make lazy code. Generators must have at least 1 "yield" # and can have return statements too. They create single-use generator objects # which are equal to iterators def double_numbers(iterable): for i in iterable: yield i + i # Generators are memory-efficient because they only load the data needed to # process the next value in the iterable. This allows them to perform # operations on otherwise prohibitively large value ranges. This is called # "lazy" loading # NOTE: `range` replaces `xrange` in Python 3. for i in double_numbers(range(1, 900000000)): # `range` is a generator. print(i) if i >= 30: break # Just as you can create a list comprehension, you can create generator # comprehensions as well using parentheses. values = (-x for x in [1, 2, 3, 4, 5]) for x in values: print(x) # prints -1 -2 -3 -4 -5 to console/terminal # You can also cast a generator comprehension directly to a list. values = (-x for x in [1, 2, 3, 4, 5]) gen_to_list = list(values) print(gen_to_list) # => [-1, -2, -3, -4, -5] # The zip() function takes 0 or more iterables, aggregates them in a tuple, # element by element (first element from all iterables, then second, # etc), and returns an iterator of said tuples number_list = [1, 2, 3] str_list = ['one', 'two', 'three', 'four'] # 'four' will never have a pair, since number_list only goes up to 3 print(list(zip())) # => [] zip_result = zip(number_list, str_list) print(set(zip_result)) # => {(2, 'two'), (1, 'one'), (3, 'three')} (order is random) print(list(zip_result)) # => [(1, 'one'), (2, 'two'), (3, 'three')] # zip can also be used to unzip collections into tuples numbers, names = zip(list(zip_result)) numbers # => (1, 2, 3) names # => ('one', 'two', 'three') # Cartesian product using itertools: import itertools somelists = [[1, 2, 3],['a', 'b'],[4, 5]] list(itertools.product(*somelists)) # Decorators # In this example `beg` wraps `say`. If say_please is True then it # will change the returned message. from functools import wraps def beg(target_function): @wraps(target_function) def wrapper(*args, **kwargs): msg, say_please = target_function(*args, **kwargs) if say_please: return "{} {}".format(msg, "Please! I am poor :(") return msg return wrapper @beg def say(say_please=False): return "Can you buy me a beer?", say_please print(say()) # Can you buy me a beer? print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :( #################################################### ## 9. Testing #################################################### # Automated tests are a fantastic way to ensure code works even after changes # are pushed, and to keep things running without spending hours manually # checking for errors in menial tasks # Python includes the module unittest not only for Unit Tests, but many others import unittest # Define a class which inherits from the type of test you want class Some_Testing_Class(unittest.TestCase): # You can perform set ups and tear downs per test method def setUp(self): # Create objects, open files... pass # And define the tests inside the class, always prefixing with "test_" def test_something(self): # Perform the test itself with the included tools, such as assertions self.assertEqual(some_function(), 4) # Fails if the function doesn't # return 4. Other types are asertTrue, asertRaises... pass def tearDown(self): # Delete objects, close files... pass if __name__ == "__main__": unittest.main() # And all tests included in the class will be run when the file containing # this class is run #################################################### ## 10. APIs #################################################### # APIs allow different programs or code written in other languages # to communicate with yours through sets of methods, or interfaces. # REST APIs (REpresentational State Transfer) work over internet # protocols, usually HTTP with JSON messages, though it may vary.
from django.urls import path from DBCalls.views import CollectionView, ExhibitView, ModuleView, QuestionView urlpatterns = [ path('Questions/<str:qID>', QuestionView.as_view(), name='questionview'), path('Questions/', QuestionView.as_view(), name='questionview'), path('Modules/<str:mID>', ModuleView.as_view(), name='moduleview'), path('Modules/', ModuleView.as_view(), name='moduleview'), path('Exhibits/<str:eID>', ExhibitView.as_view(), name='exhibitview'), path('Exhibits/', ExhibitView.as_view(), name='exhibitview'), path('<str:cID>/', CollectionView.as_view(), name='collectionview'), path('', CollectionView.as_view(), name='collectionview') ]
from ..utils import Object class CancelUploadFile(Object): """ Stops the uploading of a file. Supported only for files uploaded by using uploadFile. For other files the behavior is undefined Attributes: ID (:obj:`str`): ``CancelUploadFile`` Args: file_id (:obj:`int`): Identifier of the file to stop uploading Returns: Ok Raises: :class:`telegram.Error` """ ID = "cancelUploadFile" def __init__(self, file_id, extra=None, **kwargs): self.extra = extra self.file_id = file_id # int @staticmethod def read(q: dict, *args) -> "CancelUploadFile": file_id = q.get('file_id') return CancelUploadFile(file_id)
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack import * class Cblas(Package): """The BLAS (Basic Linear Algebra Subprograms) are routines that provide standard building blocks for performing basic vector and matrix operations.""" homepage = "http://www.netlib.org/blas/_cblas/" # tarball has no version, but on the date below, this MD5 was correct. version('2015-06-06', sha256='0f6354fd67fabd909baf57ced2ef84e962db58fae126e4f41b21dd4fec60a2a3', url='http://www.netlib.org/blas/blast-forum/cblas.tgz') depends_on('blas') parallel = False def patch(self): mf = FileFilter('Makefile.in') mf.filter('^BLLIB =.*', 'BLLIB = {0}'.format( ' '.join(self.spec['blas'].libs.libraries))) mf.filter('^CC =.*', 'CC = cc') mf.filter('^FC =.*', 'FC = fc') def install(self, spec, prefix): make('all') mkdirp(prefix.lib) mkdirp(prefix.include) # Rename the generated lib file to libcblas.a install('lib/cblas_LINUX.a', prefix.lib.join('libcblas.a')) install('include/cblas.h', prefix.include) install('include/cblas_f77.h', prefix.include)
import requests from allauth.socialaccount.helpers import render_authentication_error from allauth.socialaccount.models import SocialLogin, SocialAccount from allauth.socialaccount.providers.base import ProviderException from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter from allauth.socialaccount.providers.orcid.provider import OrcidProvider from allauth.socialaccount.providers.orcid.views import OrcidOAuth2Adapter from allauth.socialaccount.providers.oauth2.client import ( OAuth2Error, OAuth2Client ) from allauth.socialaccount.providers.oauth2.views import ( AuthError, OAuth2LoginView, OAuth2CallbackView, PermissionDenied, RequestException ) from allauth.utils import ( get_request_param, ) from allauth.account.signals import user_signed_up, user_logged_in from allauth.account import app_settings from rest_auth.registration.views import SocialLoginView from rest_framework.decorators import api_view, permission_classes from rest_framework.permissions import AllowAny, IsAuthenticated from rest_framework.response import Response from django.dispatch import receiver from mailchimp_marketing import Client from oauth.serializers import SocialLoginSerializer from oauth.adapters import GoogleOAuth2AdapterIdToken from oauth.helpers import complete_social_login from oauth.exceptions import LoginError from oauth.utils import get_orcid_names from researchhub.settings import ( GOOGLE_REDIRECT_URL, GOOGLE_YOLO_REDIRECT_URL, keys, MAILCHIMP_SERVER, MAILCHIMP_LIST_ID, RECAPTCHA_SECRET_KEY, RECAPTCHA_VERIFY_URL ) from user.models import Author from user.utils import merge_author_profiles from utils import sentry from utils.http import http_request, RequestMethods from utils.throttles import captcha_unlock from utils.siftscience import events_api @api_view([RequestMethods.POST]) @permission_classes([AllowAny]) def captcha_verify(request): verify_request = requests.post( RECAPTCHA_VERIFY_URL, { 'secret': RECAPTCHA_SECRET_KEY, 'response': request.data.get('response') } ) status = verify_request.status_code req_json = verify_request.json() data = {'success': req_json.get('success')} if req_json.get("error-codes"): data['errors'] = req_json.get('error-codes') if data['success']: # turn off throttling captcha_unlock(request) return Response(data, status=status) class GoogleLogin(SocialLoginView): adapter_class = GoogleOAuth2Adapter callback_url = GOOGLE_REDIRECT_URL client_class = OAuth2Client serializer_class = SocialLoginSerializer class GoogleYoloLogin(SocialLoginView): adapter_class = GoogleOAuth2AdapterIdToken callback_url = GOOGLE_YOLO_REDIRECT_URL client_class = OAuth2Client serializer_class = SocialLoginSerializer class CallbackView(OAuth2CallbackView): """ This class is copied from allauth/socialaccount/providers/oauth2/views.py but uses a custom method for `complete_social_login` """ permission_classes = (AllowAny,) def dispatch(self, request, *args, **kwargs): if 'error' in request.GET or 'code' not in request.GET: # Distinguish cancel from error auth_error = request.GET.get('error', None) if auth_error == self.adapter.login_cancelled_error: error = AuthError.CANCELLED else: error = AuthError.UNKNOWN return render_authentication_error( request, self.adapter.provider_id, error=error) app = self.adapter.get_provider().get_app(self.request) client = self.get_client(request, app) try: try: access_token = client.get_access_token(request.GET['code']) except Exception: access_token = client.get_access_token( request.GET['credential'] ) token = self.adapter.parse_token(access_token) token.app = app login = self.adapter.complete_login(request, app, token, response=access_token) login.token = token if self.adapter.provider_id != OrcidProvider.id: if self.adapter.supports_state: login.state = SocialLogin \ .verify_and_unstash_state( request, get_request_param(request, 'state')) else: login.state = SocialLogin.unstash_state(request) return complete_social_login(request, login) except (PermissionDenied, OAuth2Error, RequestException, ProviderException) as e: return render_authentication_error( request, self.adapter.provider_id, exception=e ) google_callback = CallbackView.adapter_view(GoogleOAuth2Adapter) google_yolo_login = OAuth2LoginView.adapter_view(GoogleOAuth2AdapterIdToken) google_yolo_callback = CallbackView.adapter_view(GoogleOAuth2AdapterIdToken) orcid_callback = CallbackView.adapter_view(OrcidOAuth2Adapter) @api_view([RequestMethods.POST]) @permission_classes([IsAuthenticated]) def orcid_connect(request): success = False status = 400 try: orcid = request.data.get('orcid') access_token = request.data.get('access_token') url = f'https://pub.orcid.org/v3.0/{orcid}/record' headers = { 'Accept': 'application/json', 'Authorization': f'Bearer {access_token}' } # Raise for status because we need to make sure we can authenticate # correctly with orcid. Without this check, anyone could make a post # request to connect any other orcid account to their own. response = http_request(RequestMethods.GET, url=url, headers=headers) response.raise_for_status() user = request.user save_orcid_author(user, orcid, response.json()) events_api.track_account(user, request, update=True) success = True status = 201 data = { 'success': success, 'orcid_profile': f'https://orcid.org/{orcid}' } except Exception as e: data = str(e) sentry.log_error(e) print(e) return Response(data, status=status) def save_orcid_author(user, orcid_id, orcid_data): orcid_account = SocialAccount.objects.create( user=user, uid=orcid_id, provider=OrcidProvider.id, extra_data=orcid_data ) update_author_profile(user, orcid_id, orcid_data, orcid_account) def update_author_profile(user, orcid_id, orcid_data, orcid_account): first_name, last_name = get_orcid_names(orcid_data) try: author = Author.objects.get(orcid_id=orcid_id) except Author.DoesNotExist: user.author_profile.orcid_id = orcid_id else: user.author_profile = merge_author_profiles( author, user.author_profile ) user.author_profile.orcid_account = orcid_account user.author_profile.first_name = first_name user.author_profile.last_name = last_name user.author_profile.save() user.save() @receiver(user_signed_up) @receiver(user_logged_in) def user_signed_up_(request, user, **kwargs): """ After a user signs up with social account, set their profile image. """ queryset = SocialAccount.objects.filter( provider='google', user=user ) if queryset.exists(): if queryset.count() > 1: raise Exception( f'Expected 1 item in the queryset. Found {queryset.count()}.' ) google_account = queryset.first() url = google_account.extra_data.get('picture', None) if user.author_profile and not user.author_profile.profile_image: user.author_profile.profile_image = url user.author_profile.save() return None else: return None @receiver(user_signed_up) def mailchimp_add_user(request, user, **kwargs): """Adds user email to MailChimp""" mailchimp = Client() mailchimp.set_config({ 'api_key': keys.MAILCHIMP_KEY, 'server': MAILCHIMP_SERVER }) try: member_info = {'email_address': user.email, 'status': 'subscribed'} mailchimp.lists.add_list_member(MAILCHIMP_LIST_ID, member_info) except Exception as error: sentry.log_error(error, message=error.text)
import socket # Networking support import time # Current time from library import id_generate host = None port = None log_th = None conf_th = None header_th = None command_w_th = None data_w_th = None class HTTPServer: def __init__(self): global host, port, log_th, conf_th, header_th, command_w_th, data_w_th self.host = host self.port = port self.conf_th_ic = conf_th self.header_th_ic = header_th self.command_w_th_inc = command_w_th self.data_w_th_inc = data_w_th self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.log_th = log_th self.id = None self.client_ip = None self.client_port = None self.hostname = conf_th.get_item(q_key='general').get('hostname') self.http_queue_size = int(conf_th.get_item(q_key='general').get('http_queue_size')) self.http_recv_size = int(conf_th.get_item(q_key='general').get('http_recv_size')) self.server_header_information = conf_th.get_item(q_key='general').get('server_header_information') self.html_message = conf_th.get_item(q_key='general').get('html_message') self.post_message = conf_th.get_item(q_key='general').get('post_after_message') self.sleep_between = int(conf_th.get_item(q_key='general').get('sleep_between')) self.no_answer = int(conf_th.get_item(q_key='general').get('no_answer')) def activate_server(self): try: self.socket.bind((self.host, self.port)) except Exception as e: self.log_th.log_error("Warning: Could not aquite port:" + str(self.port) + "\n") graceful_shutdown(s=self.socket) self._wait_for_connections() def shutdown(self): try: self.log_th.log_info("Shutting down the server") self.socket.shutdown() except Exception as e: self.log_th.log_error("Warning: could not shut down the socket. Maybe it was already closed? : " + e) def _gen_headers(self, code): h = '' if code == 200: h = 'HTTP/1.1 200 OK\n' elif code == 404: h = 'HTTP/1.1 404 Not Found\n' current_date = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime()) h += 'Date: ' + current_date + ' GMT' + '\n' h += 'Server: ' + self.server_header_information + '\n' # h += 'Connection: close\n\n' h += '\n\n' return h def _wait_for_connections(self): while True: self.socket.listen(self.http_queue_size) # maximum number of queued connections conn, addr = self.socket.accept() self.client_ip = addr.__getitem__(0) self.client_port = addr.__getitem__(1) self.id = id_generate(size=16) self.log_th.log_info('{}:{} connected'.format(self.client_ip, self.client_port)) header_th.write_header(ip=addr.__getitem__(0), qid=self.id) if self.no_answer != 0: while True: conn.recv(self.http_recv_size) if self.sleep_between != 0: time.sleep(self.sleep_between) data = conn.recv(self.http_recv_size) string = bytes.decode(data) request_method = string.split(' ')[0] file_requested = string.split(' ') file_requested = file_requested[1] file_requested = file_requested.split('?')[0] if file_requested == '/': file_requested = '/index.html' url_path = "http://" + self.hostname + ":" + str(self.port) + file_requested commands = "Request : " + request_method + ", Access Path : " + url_path self.command_w_th_inc.write_commands(data=commands, qid=self.id) self.log_th.log_info('{} - {} client request {} - {} '.format( self.id, self.client_ip, request_method, url_path)) self.data_w_th_inc.write_data(data=string, qid=self.id) response_headers = self._gen_headers(200) if file_requested.split('/')[1] == 'robots.txt': response_content = 'User-agent: *' + '\n' + 'Disallow: /' + '\n' response_content = response_content.encode() elif file_requested.split('/')[1] == 'favicon.ico': response_headers = self._gen_headers(404) response_content = ''.encode() elif request_method == 'POST': response_content = self.post_message.encode() else: response_content = self.html_message.encode() server_response = response_headers.encode() server_response += response_content conn.send(server_response) self.log_th.log_info('{}:{} disconnected'.format(self.client_ip, self.client_port)) conn.shutdown(socket.SHUT_RD) conn.close() def graceful_shutdown(s, sig, dummy): s.socket.shutdown() import sys sys.exit(1) def server_init(log_set, conf_set, header_set, commands_w_set, data_w_set): global log_th, conf_th, header_th, command_w_th, data_w_th, host, port log_th = log_set conf_th = conf_set header_th = header_set command_w_th = commands_w_set data_w_th = data_w_set host = conf_set.get_item(q_key='general').get('sock_ip') port = int(conf_set.get_item(q_key='general').get('port'))
# pylint: disable=unused-argument,unused-variable,expression-not-assigned import os from datetime import datetime import pytest from expecter import expect import xlrd from dwellingplace.models._utils import parse_xlsx_into_dicts, get_value DATA = os.path.join(os.path.dirname(__file__), "data") def test_load(): xl = xlrd.open_workbook(os.path.join(DATA, 'sample.xlsx')) output = list(parse_xlsx_into_dicts(xl)) assert output[0]['Curb Appeal'] == 4.3 assert output[0]['Date'] == datetime(2016, 9, 1) def describe_get_value(): @pytest.fixture def datum(): return dict( _int=1, _float=2.3, _float_percent=0.5, _str="Hello, world!", _bool=True, _date=datetime(2016, 11, 5), ) def when_int(datum): expect(get_value(datum, '_int')) == (1, None) def when_float(datum): expect(get_value(datum, '_float')) == (2.3, None) def when_float_as_a_percentage(datum): expect(get_value(datum, '_float_percent')) == \ (0.5, {'num_format': "0.00%"}) def when_bool(datum): expect(get_value(datum, '_bool')) == (True, None) def when_date(datum): expect(get_value(datum, '_date')) == \ (datetime(2016, 11, 5), {'num_format': "mmm yyyy"})
from tests import ScraperTest from recipe_scrapers.cdkitchen import CdKitchen class TestCdKitchen(ScraperTest): scraper_class = CdKitchen def test_host(self): self.assertEqual("cdkitchen.com", self.harvester_class.host()) def test_canonical_url(self): self.assertEqual( "https://www.cdkitchen.com/recipes/recs/473/Veal-Steak-Vesuvio92364.shtml", self.harvester_class.canonical_url(), ) def test_title(self): self.assertEqual("Veal Steak Vesuvio", self.harvester_class.title()) def test_total_time(self): self.assertEqual(45, self.harvester_class.total_time()) def test_yields(self): self.assertEqual("4 serving(s)", self.harvester_class.yields()) def test_ingredients(self): self.assertCountEqual( [ "2 veal shoulder arm or blade steaks, cut 1 inch thick", "2 baking potatoes, cut lengthwise into 8 wedges", "1 lemon, cut lengthwise into 8 wedges", "1/2 cup frozen peas, cooked", "Seasoning", "2 tablespoons olive oil", "3 cloves garlic, minced", "1 teaspoon dried oregano", "1/2 teaspoon black pepper", ], self.harvester_class.ingredients(), ) def test_instructions(self): return self.assertEqual( "Combine seasoning ingredients. Brush 1/2 of seasoning on veal steaks. Toss remaining seasoning with potatoes.\nPlace steaks and potatoes on rack in broiler pan so surface of veal is 3 to 4 inches from heat. Squeeze juice from lemon wedges over steaks and potatoes; place wedges on rack. Broil 26 to 28 minutes for medium doneness, turning steaks, potatoes and lemon once. Remove steaks.\nContinue broiling potatoes and lemon 3 to 5 minutes or until lightly browned. Carve veal; season with salt. Serve with potatoes, lemon and peas.", self.harvester_class.instructions(), ) def test_image(self): self.assertEqual( "https://cdn.cdkitchen.com/recipes/images/sharing/25/veal-steak-vesuvio-63237-small.png", self.harvester_class.image(), )
from typing import Any, List from boa3.builtin import public @public def Main() -> List[Any]: a: List[Any] = [1, 2, 3] a.append('4') return a
import discord from gamestonk_terminal.economy import wsj_model import discordbot.config_discordbot as cfg from discordbot.run_discordbot import logger async def currencies_command(ctx): """Currencies overview [Wall St. Journal]""" try: # Retrieve data df_data = wsj_model.global_currencies() # Debug user output if cfg.DEBUG: logger.debug(df_data.to_string()) # Output data if df_data.empty: df_data_str = "No currencies data available" else: df_data_str = "```" + df_data.to_string(index=False) + "```" embed = discord.Embed( title="Economy: [WSJ] Currencies", description=df_data_str, colour=cfg.COLOR, ) embed.set_author( name=cfg.AUTHOR_NAME, icon_url=cfg.AUTHOR_ICON_URL, ) await ctx.send(embed=embed) except Exception as e: embed = discord.Embed( title="ERROR Economy: [WSJ] Currencies", colour=cfg.COLOR, description=e, ) embed.set_author( name=cfg.AUTHOR_NAME, icon_url=cfg.AUTHOR_ICON_URL, ) await ctx.send(embed=embed)
# 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. from magnumclient.common import cliutils as utils from magnumclient.i18n import _ @utils.arg('--project-id', required=False, metavar='<project-id>', help=_('Project ID')) @utils.deprecated(utils.MAGNUM_CLIENT_DEPRECATION_WARNING) def do_stats_list(cs, args): """Show stats for the given project_id""" opts = { 'project_id': args.project_id } stats = cs.stats.list(**opts) utils.print_dict(stats._info)
import numpy as np import torch from torch.autograd import Variable import os import glob import h5py import configs import backbone from data.datamgr import SimpleDataManager from methods.baselinetrain import BaselineTrain from methods.baselinefinetune import BaselineFinetune from methods.protonet import ProtoNet from methods.matchingnet import MatchingNet from methods.relationnet import RelationNet from methods.maml import MAML from io_utils import model_dict, parse_args, get_resume_file, get_best_file, get_assigned_file def save_features(model, data_loader, outfile ): f = h5py.File(outfile, 'w') max_count = len(data_loader)*data_loader.batch_size all_labels = f.create_dataset('all_labels',(max_count,), dtype='i') all_feats=None count=0 for i, (x,y) in enumerate(data_loader): if i%10 == 0: print('{:d}/{:d}'.format(i, len(data_loader))) x = x.cuda() x_var = Variable(x) feats = model(x_var) if all_feats is None: all_feats = f.create_dataset('all_feats', [max_count] + list( feats.size()[1:]) , dtype='f') all_feats[count:count+feats.size(0)] = feats.data.cpu().numpy() all_labels[count:count+feats.size(0)] = y.cpu().numpy() count = count + feats.size(0) count_var = f.create_dataset('count', (1,), dtype='i') count_var[0] = count f.close() if __name__ == '__main__': params = parse_args('save_features') assert params.method != 'maml' and params.method != 'maml_approx', 'maml do not support save_feature and run' if 'Conv' in params.model: image_size = 40 split = params.split loadfile = configs.data_dir[params.dataset] + split + '.json' loadfile_unk = configs.data_dir[params.dataset] + split + '_unk.json' loadfile_sil = configs.data_dir[params.dataset] + split + '_sil.json' checkpoint_dir = '%s/checkpoints/%s/%s_%s_regularizer' %(configs.save_dir, params.dataset, params.model, params.method) #checkpoint_dir = '%s/checkpoints/%s/%s_%s' %(configs.save_dir, params.dataset, params.model, params.method) if params.train_aug: checkpoint_dir += '_aug' if not params.method in ['baseline', 'baseline++'] : if params.train_n_way != -1: checkpoint_dir += '_%d-way_' %( params.train_n_way ) else: checkpoint_dir += '_random-way_' if params.train_n_shot != -1: checkpoint_dir += '%d-shot' % ( params.train_n_shot ) else: checkpoint_dir += 'random-shot' if params.save_iter != -1: modelfile = get_assigned_file(checkpoint_dir,params.save_iter) # elif params.method in ['baseline', 'baseline++'] : # modelfile = get_resume_file(checkpoint_dir) #comment in 2019/08/03 updates as the validation of baseline/baseline++ is added else: modelfile = get_best_file(checkpoint_dir, params.test_n_way) if params.save_iter != -1: outfile = os.path.join( checkpoint_dir.replace("checkpoints","features"), split + "_" + str(params.save_iter)+ ".hdf5") else: outfile = os.path.join( checkpoint_dir.replace("checkpoints","features"), split + ".hdf5") #outfile = os.path.join( checkpoint_dir.replace("checkpoints","features"), split + "_test_random-way.hdf5") datamgr = SimpleDataManager(image_size, batch_size = 64) data_loader = datamgr.get_data_loader(loadfile, [loadfile_unk, loadfile_sil], aug = False) if params.method in ['relationnet', 'relationnet_softmax']: if params.model == 'Conv4': model = backbone.Conv4NP() elif params.model == 'Conv6': model = backbone.Conv6NP() elif params.model == 'Conv4S': model = backbone.Conv4SNP() else: model = model_dict[params.model]( flatten = False ) elif params.method in ['maml' , 'maml_approx']: raise ValueError('MAML do not support save feature') else: model = model_dict[params.model]() model = model.cuda() tmp = torch.load(modelfile) state = tmp['state'] state_keys = list(state.keys()) for i, key in enumerate(state_keys): if "feature." in key: newkey = key.replace("feature.","") # an architecture model has attribute 'feature', load architecture feature to backbone by casting name from 'feature.trunk.xx' to 'trunk.xx' state[newkey] = state.pop(key) else: state.pop(key) model.load_state_dict(state) model.eval() dirname = os.path.dirname(outfile) if not os.path.isdir(dirname): os.makedirs(dirname) save_features(model, data_loader, outfile)
#!/usr/bin/env python # # Use the raw transactions API to spend bitcoins received on particular addresses, # and send any change back to that same address. # # Example usage: # spendfrom.py # Lists available funds # spendfrom.py --from=ADDRESS --to=ADDRESS --amount=11.00 # # Assumes it will talk to a bitcoind or Bitcoin-Qt running # on localhost. # # Depends on jsonrpc # from decimal import * import getpass import math import os import os.path import platform import sys import time from jsonrpc import ServiceProxy, json BASE_FEE=Decimal("0.001") def check_json_precision(): """Make sure json library being used does not lose precision converting BTC values""" n = Decimal("20000000.00000003") satoshis = int(json.loads(json.dumps(float(n)))*1.0e8) if satoshis != 2000000000000003: raise RuntimeError("JSON encode/decode loses precision") def determine_db_dir(): """Return the default location of the bitcoin data directory""" if platform.system() == "Darwin": return os.path.expanduser("~/Library/Application Support/Bitcoin/") elif platform.system() == "Windows": return os.path.join(os.environ['APPDATA'], "Bitcoin") return os.path.expanduser("~/.bitcoin") def read_bitcoin_config(dbdir): """Read the bitcoin.conf file from dbdir, returns dictionary of settings""" from ConfigParser import SafeConfigParser class FakeSecHead(object): def __init__(self, fp): self.fp = fp self.sechead = '[all]\n' def readline(self): if self.sechead: try: return self.sechead finally: self.sechead = None else: s = self.fp.readline() if s.find('#') != -1: s = s[0:s.find('#')].strip() +"\n" return s config_parser = SafeConfigParser() config_parser.readfp(FakeSecHead(open(os.path.join(dbdir, "bitcoin.conf")))) return dict(config_parser.items("all")) def connect_JSON(config): """Connect to a bitcoin JSON-RPC server""" testnet = config.get('testnet', '0') testnet = (int(testnet) > 0) # 0/1 in config file, convert to True/False if not 'rpcport' in config: config['rpcport'] = 118823 if testnet else 18823 connect = "http://%s:%s@127.0.0.1:%s"%(config['rpcuser'], config['rpcpassword'], config['rpcport']) try: result = ServiceProxy(connect) # ServiceProxy is lazy-connect, so send an RPC command mostly to catch connection errors, # but also make sure the bitcoind we're talking to is/isn't testnet: if result.getmininginfo()['testnet'] != testnet: sys.stderr.write("RPC server at "+connect+" testnet setting mismatch\n") sys.exit(1) return result except: sys.stderr.write("Error connecting to RPC server at "+connect+"\n") sys.exit(1) def unlock_wallet(bitcoind): info = bitcoind.getinfo() if 'unlocked_until' not in info: return True # wallet is not encrypted t = int(info['unlocked_until']) if t <= time.time(): try: passphrase = getpass.getpass("Wallet is locked; enter passphrase: ") bitcoind.walletpassphrase(passphrase, 5) except: sys.stderr.write("Wrong passphrase\n") info = bitcoind.getinfo() return int(info['unlocked_until']) > time.time() def list_available(bitcoind): address_summary = dict() address_to_account = dict() for info in bitcoind.listreceivedbyaddress(0): address_to_account[info["address"]] = info["account"] unspent = bitcoind.listunspent(0) for output in unspent: # listunspent doesn't give addresses, so: rawtx = bitcoind.getrawtransaction(output['txid'], 1) vout = rawtx["vout"][output['vout']] pk = vout["scriptPubKey"] # This code only deals with ordinary pay-to-bitcoin-address # or pay-to-script-hash outputs right now; anything exotic is ignored. if pk["type"] != "pubkeyhash" and pk["type"] != "scripthash": continue address = pk["addresses"][0] if address in address_summary: address_summary[address]["total"] += vout["value"] address_summary[address]["outputs"].append(output) else: address_summary[address] = { "total" : vout["value"], "outputs" : [output], "account" : address_to_account.get(address, "") } return address_summary def select_coins(needed, inputs): # Feel free to improve this, this is good enough for my simple needs: outputs = [] have = Decimal("0.0") n = 0 while have < needed and n < len(inputs): outputs.append({ "txid":inputs[n]["txid"], "vout":inputs[n]["vout"]}) have += inputs[n]["amount"] n += 1 return (outputs, have-needed) def create_tx(bitcoind, fromaddresses, toaddress, amount, fee): all_coins = list_available(bitcoind) total_available = Decimal("0.0") needed = amount+fee potential_inputs = [] for addr in fromaddresses: if addr not in all_coins: continue potential_inputs.extend(all_coins[addr]["outputs"]) total_available += all_coins[addr]["total"] if total_available < needed: sys.stderr.write("Error, only %f BTC available, need %f\n"%(total_available, needed)); sys.exit(1) # # Note: # Python's json/jsonrpc modules have inconsistent support for Decimal numbers. # Instead of wrestling with getting json.dumps() (used by jsonrpc) to encode # Decimals, I'm casting amounts to float before sending them to bitcoind. # outputs = { toaddress : float(amount) } (inputs, change_amount) = select_coins(needed, potential_inputs) if change_amount > BASE_FEE: # don't bother with zero or tiny change change_address = fromaddresses[-1] if change_address in outputs: outputs[change_address] += float(change_amount) else: outputs[change_address] = float(change_amount) rawtx = bitcoind.createrawtransaction(inputs, outputs) signed_rawtx = bitcoind.signrawtransaction(rawtx) if not signed_rawtx["complete"]: sys.stderr.write("signrawtransaction failed\n") sys.exit(1) txdata = signed_rawtx["hex"] return txdata def compute_amount_in(bitcoind, txinfo): result = Decimal("0.0") for vin in txinfo['vin']: in_info = bitcoind.getrawtransaction(vin['txid'], 1) vout = in_info['vout'][vin['vout']] result = result + vout['value'] return result def compute_amount_out(txinfo): result = Decimal("0.0") for vout in txinfo['vout']: result = result + vout['value'] return result def sanity_test_fee(bitcoind, txdata_hex, max_fee): class FeeError(RuntimeError): pass try: txinfo = bitcoind.decoderawtransaction(txdata_hex) total_in = compute_amount_in(bitcoind, txinfo) total_out = compute_amount_out(txinfo) if total_in-total_out > max_fee: raise FeeError("Rejecting transaction, unreasonable fee of "+str(total_in-total_out)) tx_size = len(txdata_hex)/2 kb = tx_size/1000 # integer division rounds down if kb > 1 and fee < BASE_FEE: raise FeeError("Rejecting no-fee transaction, larger than 1000 bytes") if total_in < 0.01 and fee < BASE_FEE: raise FeeError("Rejecting no-fee, tiny-amount transaction") # Exercise for the reader: compute transaction priority, and # warn if this is a very-low-priority transaction except FeeError as err: sys.stderr.write((str(err)+"\n")) sys.exit(1) def main(): import optparse parser = optparse.OptionParser(usage="%prog [options]") parser.add_option("--from", dest="fromaddresses", default=None, help="addresses to get bitcoins from") parser.add_option("--to", dest="to", default=None, help="address to get send bitcoins to") parser.add_option("--amount", dest="amount", default=None, help="amount to send") parser.add_option("--fee", dest="fee", default="0.0", help="fee to include") parser.add_option("--datadir", dest="datadir", default=determine_db_dir(), help="location of bitcoin.conf file with RPC username/password (default: %default)") parser.add_option("--testnet", dest="testnet", default=False, action="store_true", help="Use the test network") parser.add_option("--dry_run", dest="dry_run", default=False, action="store_true", help="Don't broadcast the transaction, just create and print the transaction data") (options, args) = parser.parse_args() check_json_precision() config = read_bitcoin_config(options.datadir) if options.testnet: config['testnet'] = True bitcoind = connect_JSON(config) if options.amount is None: address_summary = list_available(bitcoind) for address,info in address_summary.iteritems(): n_transactions = len(info['outputs']) if n_transactions > 1: print("%s %.8f %s (%d transactions)"%(address, info['total'], info['account'], n_transactions)) else: print("%s %.8f %s"%(address, info['total'], info['account'])) else: fee = Decimal(options.fee) amount = Decimal(options.amount) while unlock_wallet(bitcoind) == False: pass # Keep asking for passphrase until they get it right txdata = create_tx(bitcoind, options.fromaddresses.split(","), options.to, amount, fee) sanity_test_fee(bitcoind, txdata, amount*Decimal("0.01")) if options.dry_run: print(txdata) else: txid = bitcoind.sendrawtransaction(txdata) print(txid) if __name__ == '__main__': main()
import sys from .data import REPLACEMENTS, COMBININGMARKS, SUBSUPERSCRIPTS if __name__ == "__main__": outname = 'ts_src/data.ts' if len(sys.argv) == 2: outname = sys.argv[1] with open(outname, 'w') as f: f.write('// autogenerated with python -m unicodeit.export_data\n\n') f.write('export const replacements = [\n') for l, u in REPLACEMENTS: l = l.replace('\\', '\\\\') l = l.replace('\'', '\\\'') f.write(' [\'{}\', \'{}\'],\n'.format(l, u)) f.write('];\n\n') f.write('export const combiningmarks = [\n') for l, u in COMBININGMARKS: l = l.replace('\\', '\\\\') l = l.replace('\'', '\\\'') f.write(' [\'{}\', \'{}\'],\n' ''.format(l, u.encode('ascii', 'backslashreplace').decode())) f.write('];\n\n') f.write('export const subsuperscripts = [\n') for l, u in SUBSUPERSCRIPTS: f.write(' [\'{}\', \'{}\'],\n'.format(l, u)) f.write('];\n')
# -*- coding: utf-8 -*- u"""pytest for `pykern.pkplatform` :copyright: Copyright (c) 2015 Bivio Software, Inc. All Rights Reserved. :license: http://www.apache.org/licenses/LICENSE-2.0.html """ from __future__ import absolute_import, division, print_function import pytest def test_conformance1(): """Verify the platforms based on other calls""" import re import sys import platform from pykern import pkplatform if platform.system() == 'Linux': assert pkplatform.is_linux() assert pkplatform.is_unix() assert not pkplatform.is_darwin() assert not pkplatform.is_windows() elif platform.system().startswith('CYGWIN'): assert not pkplatform.is_linux() assert pkplatform.is_unix() assert not pkplatform.is_darwin() assert pkplatform.is_windows() elif platform.system() == 'Windows': assert not pkplatform.is_linux() assert not pkplatform.is_unix() assert not pkplatform.is_darwin() assert pkplatform.is_windows() elif platform.system() == 'Darwin': assert not pkplatform.is_linux() assert pkplatform.is_unix() assert pkplatform.is_darwin() assert not pkplatform.is_windows() else: assert not pkplatform.is_windows() assert not pkplatform.is_darwin() assert not pkplatform.is_linux() # Not sure if it would be unix
import math import numpy as np import sncosmo from baselayer.app.env import load_env from skyportal.models import DBSession, Token from skyportal.tests import api _, cfg = load_env() PHOT_DETECTION_THRESHOLD = cfg["misc.photometry_detection_threshold_nsigma"] def test_token_user_post_get_photometry_data( upload_data_token, public_source, public_group, ztf_camera ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' assert data['data']['ra'] is None assert data['data']['dec'] is None assert data['data']['ra_unc'] is None assert data['data']['dec_unc'] is None np.testing.assert_allclose( data['data']['flux'], 12.24 * 10 ** (-0.4 * (25.0 - 23.9)) ) def test_token_user_post_put_photometry_data( upload_data_token, public_source, public_group, ztf_camera ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'instrument_id': ztf_camera.id, "mjd": [59400, 59401, 59402], "mag": [19.2, 19.3, np.random.uniform(19, 20)], "magerr": [0.05, 0.06, np.random.uniform(0.01, 0.1)], "limiting_mag": [20.0, 20.1, 20.2], "magsys": ["ab", "ab", "ab"], "filter": ["ztfr", "ztfg", "ztfr"], "ra": [42.01, 42.01, 42.02], "dec": [42.02, 42.01, 42.03], "origin": [None, "lol", "lol"], 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' ids = data["data"]["ids"] assert len(ids) == 3 # POSTing photometry that contains the same first two points should fail: status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'instrument_id': ztf_camera.id, "mjd": [59400, 59401, 59402], "mag": [19.2, 19.3, np.random.uniform(19, 20)], "magerr": [0.05, 0.06, np.random.uniform(0.01, 0.1)], "limiting_mag": [20.0, 20.1, 20.2], "magsys": ["ab", "ab", "ab"], "filter": ["ztfr", "ztfg", "ztfr"], "ra": [42.01, 42.01, 42.02], "dec": [42.02, 42.01, 42.03], "origin": [None, "lol", "lol"], 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 400 assert data['status'] == 'error' # PUTing photometry that contains # the same first point, the second point with a different origin, and a new third point should succeed # only the last two points will be ingested status, data = api( 'PUT', 'photometry', data={ 'obj_id': str(public_source.id), 'instrument_id': ztf_camera.id, "mjd": [59400, 59401, 59402], "mag": [19.2, 19.3, np.random.uniform(19, 20)], "magerr": [0.05, 0.06, np.random.uniform(0.01, 0.1)], "limiting_mag": [20.0, 20.1, 20.2], "magsys": ["ab", "ab", "ab"], "filter": ["ztfr", "ztfg", "ztfr"], "ra": [42.01, 42.01, 42.02], "dec": [42.02, 42.01, 42.03], "origin": [None, "omg", "lol"], 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' new_ids = data["data"]["ids"] assert len(new_ids) == 3 assert len(set(new_ids).intersection(set(ids))) == 1 def test_token_user_post_put_get_photometry_data( upload_data_token_two_groups, public_source, public_group, public_group2, ztf_camera ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'instrument_id': ztf_camera.id, "mjd": [59400, 59401, 59402], "mag": [19.2, 19.3, np.random.uniform(19, 20)], "magerr": [0.05, 0.06, np.random.uniform(0.01, 0.1)], "limiting_mag": [20.0, 20.1, 20.2], "magsys": ["ab", "ab", "ab"], "filter": ["ztfr", "ztfg", "ztfr"], "ra": [42.01, 42.01, 42.02], "dec": [42.02, 42.01, 42.03], "origin": [None, "lol", "lol"], 'group_ids': [public_group.id], }, token=upload_data_token_two_groups, ) assert status == 200 assert data['status'] == 'success' ids = data["data"]["ids"] assert len(ids) == 3 status, data = api( 'GET', f'photometry/{ids[0]}?format=flux', token=upload_data_token_two_groups ) assert status == 200 assert data['status'] == 'success' group_ids = [g["id"] for g in data['data']['groups']] assert len(group_ids) == 2 assert public_group.id in group_ids # PUTing photometry that contains # the same first point, the second point with a different origin, and a new third point should succeed # only the last two points will be ingested status, data = api( 'PUT', 'photometry', data={ 'obj_id': str(public_source.id), 'instrument_id': ztf_camera.id, "mjd": [59400, 59401], "mag": [19.2, 19.3], "magerr": [0.05, 0.06], "limiting_mag": [20.0, 20.1], "magsys": ["ab", "ab"], "filter": ["ztfr", "ztfg"], "ra": [42.01, 42.01], "dec": [42.02, 42.01], "origin": [None, "lol"], 'group_ids': [public_group.id, public_group2.id], }, token=upload_data_token_two_groups, ) assert status == 200 assert data['status'] == 'success' new_ids = data["data"]["ids"] assert len(new_ids) == 2 assert len(set(new_ids).intersection(set(ids))) == 2 status, data = api( 'GET', f'photometry/{ids[0]}?format=flux', token=upload_data_token_two_groups ) assert status == 200 assert data['status'] == 'success' group_ids = [g["id"] for g in data['data']['groups']] assert len(group_ids) == 3 token_object = ( DBSession() .query(Token) .filter(Token.id == upload_data_token_two_groups) .first() ) assert sorted(group_ids) == sorted( [ public_group.id, public_group2.id, token_object.created_by.single_user_group.id, ] ) def test_post_photometry_multiple_groups( upload_data_token_two_groups, public_source_two_groups, public_group, public_group2, ztf_camera, ): upload_data_token = upload_data_token_two_groups public_source = public_source_two_groups status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id, public_group2.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' assert data['data']['ra'] is None assert data['data']['dec'] is None assert data['data']['ra_unc'] is None assert data['data']['dec_unc'] is None assert len(data['data']['groups']) == 3 np.testing.assert_allclose( data['data']['flux'], 12.24 * 10 ** (-0.4 * (25.0 - 23.9)) ) def test_post_photometry_all_groups( upload_data_token_two_groups, super_admin_token, public_source_two_groups, public_group, public_group2, ztf_camera, ): upload_data_token = upload_data_token_two_groups public_source = public_source_two_groups status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': "all", }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=super_admin_token, ) assert status == 200 assert data['status'] == 'success' assert data['data']['ra'] is None assert data['data']['dec'] is None assert data['data']['ra_unc'] is None assert data['data']['dec_unc'] is None assert len(data['data']['groups']) == 2 assert data['data']['groups'][0]['name'] == cfg['misc']['public_group_name'] np.testing.assert_allclose( data['data']['flux'], 12.24 * 10 ** (-0.4 * (25.0 - 23.9)) ) def test_retrieve_photometry_group_membership_posted_by_other( upload_data_token_two_groups, view_only_token, public_source_two_groups, public_group, public_group2, ztf_camera, ): upload_data_token = upload_data_token_two_groups public_source = public_source_two_groups status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id, public_group2.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=view_only_token ) assert status == 200 assert data['status'] == 'success' assert data['data']['ra'] is None assert data['data']['dec'] is None assert data['data']['ra_unc'] is None assert data['data']['dec_unc'] is None np.testing.assert_allclose( data['data']['flux'], 12.24 * 10 ** (-0.4 * (25.0 - 23.9)) ) def test_retrieve_photometry_error_group_membership_posted_by_other( upload_data_token_two_groups, view_only_token, public_source_two_groups, public_group, public_group2, ztf_camera, ): upload_data_token = upload_data_token_two_groups public_source = public_source_two_groups status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group2.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=view_only_token ) # `view_only_token only` belongs to `public_group`, not `public_group2` assert status == 400 assert data['status'] == 'error' assert "Insufficient permissions" in data['message'] def test_can_post_photometry_no_groups( upload_data_token, public_source, public_group, ztf_camera ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfg', }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' assert len(data['data']['groups']) == 1 def test_can_post_photometry_empty_groups_list( upload_data_token, public_source, public_group, ztf_camera ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' assert len(data['data']['groups']) == 1 def test_token_user_post_mag_photometry_data_and_convert( upload_data_token, public_source, ztf_camera, public_group ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'mag': 21.0, 'magerr': 0.2, 'limiting_mag': 22.3, 'magsys': 'vega', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' ab = sncosmo.get_magsystem('ab') vega = sncosmo.get_magsystem('vega') correction = 2.5 * np.log10(vega.zpbandflux('ztfg') / ab.zpbandflux('ztfg')) np.testing.assert_allclose( data['data']['flux'], 10 ** (-0.4 * (21.0 - correction - 23.9)) ) np.testing.assert_allclose( data['data']['fluxerr'], 0.2 / (2.5 / np.log(10)) * data['data']['flux'] ) status, data = api('GET', f'photometry/{photometry_id}', token=upload_data_token) assert status == 200 assert data['status'] == 'success' np.testing.assert_allclose(data['data']['mag'], 21.0 - correction) np.testing.assert_allclose(data['data']['magerr'], 0.2) def test_token_user_post_and_get_different_systems_mag( upload_data_token, public_source, ztf_camera, public_group ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'mag': 21.0, 'magerr': 0.2, 'limiting_mag': 22.3, 'magsys': 'vega', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=mag&magsys=vega', token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' assert data['data']['magsys'] == 'vega' ab = sncosmo.get_magsystem('ab') vega = sncosmo.get_magsystem('vega') correction = 2.5 * np.log10(vega.zpbandflux('ztfg') / ab.zpbandflux('ztfg')) np.testing.assert_allclose(data['data']['mag'], 21.0) np.testing.assert_allclose(data['data']['magerr'], 0.2) np.testing.assert_allclose(data['data']['limiting_mag'], 22.3) status, data = api( 'GET', f'photometry/{photometry_id}?format=mag&magsys=ab', token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' np.testing.assert_allclose(data['data']['mag'], 21.0 - correction) np.testing.assert_allclose(data['data']['magerr'], 0.2) np.testing.assert_allclose(data['data']['limiting_mag'], 22.3 - correction) def test_token_user_post_and_get_different_systems_flux( upload_data_token, public_source, ztf_camera, public_group ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'mag': 21.0, 'magerr': 0.2, 'limiting_mag': 22.3, 'magsys': 'vega', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux&magsys=vega', token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' ab = sncosmo.get_magsystem('ab') vega = sncosmo.get_magsystem('vega') correction = 2.5 * np.log10(vega.zpbandflux('ztfg') / ab.zpbandflux('ztfg')) np.testing.assert_allclose( data['data']['flux'], 10 ** (-0.4 * (21 - correction - 23.9)) ) np.testing.assert_allclose( data['data']['fluxerr'], 0.2 / (2.5 / np.log(10)) * data['data']['flux'] ) np.testing.assert_allclose(data['data']['zp'], 23.9 + correction) status, data = api( 'GET', f'photometry/{photometry_id}?format=flux&magsys=ab', token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' np.testing.assert_allclose( data['data']['flux'], 10 ** (-0.4 * (21 - correction - 23.9)) ) np.testing.assert_allclose( data['data']['fluxerr'], 0.2 / (2.5 / np.log(10)) * data['data']['flux'] ) np.testing.assert_allclose(data['data']['zp'], 23.9) def test_token_user_mixed_photometry_post( upload_data_token, public_source, ztf_camera, public_group ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'mag': 21.0, 'magerr': [0.2, 0.1], 'limiting_mag': 22.3, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][1] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' np.testing.assert_allclose(data['data']['flux'], 10 ** (-0.4 * (21.0 - 23.9))) np.testing.assert_allclose( data['data']['fluxerr'], 0.1 / (2.5 / np.log(10)) * data['data']['flux'] ) # should fail as len(mag) != len(magerr) status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'mag': [21.0], 'magerr': [0.2, 0.1], 'limiting_mag': 22.3, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 400 assert data['status'] == 'error' def test_token_user_mixed_mag_none_photometry_post( upload_data_token, public_source, ztf_camera, public_group ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'mag': None, 'magerr': [0.2, 0.1], 'limiting_mag': 22.3, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 400 assert data['status'] == 'error' status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'mag': [21.3, None], 'magerr': [0.2, 0.1], 'limiting_mag': 22.3, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 400 assert data['status'] == 'error' status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'mag': [21.3, None], 'magerr': [None, 0.1], 'limiting_mag': 22.3, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 400 assert data['status'] == 'error' def test_token_user_post_photometry_limits( upload_data_token, public_source, ztf_camera, public_group ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'mag': None, 'magerr': None, 'limiting_mag': 22.3, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' assert data['data']['flux'] is None np.testing.assert_allclose( data['data']['fluxerr'], 10 ** (-0.4 * (22.3 - 23.9)) / PHOT_DETECTION_THRESHOLD ) status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'flux': None, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' assert data['data']['flux'] is None np.testing.assert_allclose( data['data']['fluxerr'], 0.031 * 10 ** (-0.4 * (25.0 - 23.9)) ) def test_token_user_post_invalid_filter( upload_data_token, public_source, ztf_camera, public_group ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'mag': None, 'magerr': None, 'limiting_mag': 22.3, 'magsys': 'ab', 'filter': 'bessellv', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 400 assert data['status'] == 'error' def test_token_user_post_photometry_data_series( upload_data_token, public_source, ztf_camera, public_group ): # valid request status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': [58000.0, 58001.0, 58002.0], 'instrument_id': ztf_camera.id, 'flux': [12.24, 15.24, 12.24], 'fluxerr': [0.031, 0.029, 0.030], 'filter': ['ztfg', 'ztfg', 'ztfg'], 'zp': [25.0, 30.0, 21.2], 'magsys': ['ab', 'ab', 'ab'], 'ra': 264.1947917, 'dec': [50.5478333, 50.5478333 + 0.00001, 50.5478333], 'dec_unc': 0.2, 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' assert len(data['data']['ids']) == 3 photometry_id = data['data']['ids'][1] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' assert np.allclose(data['data']['flux'], 15.24 * 10 ** (-0.4 * (30 - 23.9))) assert np.allclose(data['data']['dec'], 50.5478333 + 0.00001) assert np.allclose(data['data']['dec_unc'], 0.2) assert data['data']['ra_unc'] is None # invalid request status, data = api( 'POST', 'photometry', data=[ { 'obj_id': str(public_source.id), 'mjd': 58000, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'filter': 'ztfg', 'zp': 25.0, 'magsys': 'ab', 'group_ids': [public_group.id], }, { 'obj_id': str(public_source.id), 'mjd': 58001, 'instrument_id': ztf_camera.id, 'flux': 15.24, 'fluxerr': 0.031, 'filter': 'ztfg', 'zp': 30.0, 'magsys': 'ab', 'group_ids': [public_group.id], }, { 'obj_id': str(public_source.id), 'mjd': 58002, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'filter': 'ztfg', 'zp': 21.2, 'magsys': 'vega', 'group_ids': [public_group.id], }, ], token=upload_data_token, ) assert status == 400 assert data['status'] == 'error' def test_post_photometry_no_access_token( view_only_token, public_source, ztf_camera, public_group ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=view_only_token, ) assert status == 400 assert data['status'] == 'error' def test_token_user_update_photometry( upload_data_token, public_source, ztf_camera, public_group ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfi', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' np.testing.assert_allclose(data['data']['flux'], 12.24 * 10 ** (-0.4 * (25 - 23.9))) status, data = api( 'PATCH', f'photometry/{photometry_id}', data={ 'obj_id': str(public_source.id), 'flux': 11.0, 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfi', }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) np.testing.assert_allclose(data['data']['flux'], 11.0 * 10 ** (-0.4 * (25 - 23.9))) def test_token_user_cannot_update_unowned_photometry( upload_data_token, manage_sources_token, public_source, ztf_camera, public_group ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfi', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' np.testing.assert_allclose(data['data']['flux'], 12.24 * 10 ** (-0.4 * (25 - 23.9))) status, data = api( 'PATCH', f'photometry/{photometry_id}', data={ 'obj_id': str(public_source.id), 'flux': 11.0, 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfi', }, token=manage_sources_token, ) assert status == 400 def test_token_user_update_photometry_groups( upload_data_token_two_groups, manage_sources_token_two_groups, public_source_two_groups, ztf_camera, public_group, public_group2, view_only_token, ): upload_data_token = upload_data_token_two_groups public_source = public_source_two_groups status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfi', 'group_ids': [public_group.id, public_group2.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=view_only_token ) assert status == 200 assert data['status'] == 'success' status, data = api( 'PATCH', f'photometry/{photometry_id}', data={ 'obj_id': str(public_source.id), 'flux': 11.0, 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfi', 'group_ids': [public_group2.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=view_only_token ) assert status == 400 assert data['status'] == 'error' assert "Insufficient permissions" in data["message"] def test_user_can_delete_owned_photometry_data( upload_data_token, public_source, ztf_camera, public_group ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfi', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' np.testing.assert_allclose(data['data']['flux'], 12.24 * 10 ** (-0.4 * (25 - 23.9))) status, data = api('DELETE', f'photometry/{photometry_id}', token=upload_data_token) assert status == 200 status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 400 def test_user_cannot_delete_unowned_photometry_data( upload_data_token, manage_sources_token, public_source, ztf_camera, public_group ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfi', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' np.testing.assert_allclose(data['data']['flux'], 12.24 * 10 ** (-0.4 * (25 - 23.9))) status, data = api( 'DELETE', f'photometry/{photometry_id}', token=manage_sources_token ) assert status == 400 def test_admin_can_delete_unowned_photometry_data( upload_data_token, super_admin_token, public_source, ztf_camera, public_group ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfi', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' np.testing.assert_allclose(data['data']['flux'], 12.24 * 10 ** (-0.4 * (25 - 23.9))) status, data = api('DELETE', f'photometry/{photometry_id}', token=super_admin_token) assert status == 200 status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 400 def test_token_user_retrieving_source_photometry_and_convert( view_only_token, public_source ): status, data = api( 'GET', f'sources/{public_source.id}/photometry?format=flux&magsys=ab', token=view_only_token, ) assert status == 200 assert data['status'] == 'success' assert isinstance(data['data'], list) assert 'mjd' in data['data'][0] assert 'ra_unc' in data['data'][0] data['data'] = sorted(data['data'], key=lambda d: d['mjd']) mag1_ab = -2.5 * np.log10(data['data'][0]['flux']) + data['data'][0]['zp'] magerr1_ab = 2.5 / np.log(10) * data['data'][0]['fluxerr'] / data['data'][0]['flux'] maglast_ab = -2.5 * np.log10(data['data'][-1]['flux']) + data['data'][-1]['zp'] magerrlast_ab = ( 2.5 / np.log(10) * data['data'][-1]['fluxerr'] / data['data'][-1]['flux'] ) status, data = api( 'GET', f'sources/{public_source.id}/photometry?format=mag&magsys=ab', token=view_only_token, ) assert status == 200 assert data['status'] == 'success' data['data'] = sorted(data['data'], key=lambda d: d['mjd']) assert np.allclose(mag1_ab, data['data'][0]['mag']) assert np.allclose(magerr1_ab, data['data'][0]['magerr']) assert np.allclose(maglast_ab, data['data'][-1]['mag']) assert np.allclose(magerrlast_ab, data['data'][-1]['magerr']) status, data = api( 'GET', f'sources/{public_source.id}/photometry?format=flux&magsys=vega', token=view_only_token, ) data['data'] = sorted(data['data'], key=lambda d: d['mjd']) mag1_vega = -2.5 * np.log10(data['data'][0]['flux']) + data['data'][0]['zp'] magerr1_vega = ( 2.5 / np.log(10) * data['data'][0]['fluxerr'] / data['data'][0]['flux'] ) maglast_vega = -2.5 * np.log10(data['data'][-1]['flux']) + data['data'][-1]['zp'] magerrlast_vega = ( 2.5 / np.log(10) * data['data'][-1]['fluxerr'] / data['data'][-1]['flux'] ) assert status == 200 assert data['status'] == 'success' ab = sncosmo.get_magsystem('ab') vega = sncosmo.get_magsystem('vega') vega_to_ab = { filter: 2.5 * np.log10(ab.zpbandflux(filter) / vega.zpbandflux(filter)) for filter in ['ztfg', 'ztfr', 'ztfi'] } assert np.allclose(mag1_ab, mag1_vega + vega_to_ab[data['data'][0]['filter']]) assert np.allclose(magerr1_ab, magerr1_vega) assert np.allclose( maglast_ab, maglast_vega + vega_to_ab[data['data'][-1]['filter']] ) assert np.allclose(magerrlast_ab, magerrlast_vega) def test_token_user_retrieve_null_photometry( upload_data_token, public_source, ztf_camera, public_group ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'mag': None, 'magerr': None, 'limiting_mag': 22.3, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' assert data['data']['flux'] is None np.testing.assert_allclose( data['data']['fluxerr'], 10 ** (-0.4 * (22.3 - 23.9)) / PHOT_DETECTION_THRESHOLD ) status, data = api( 'GET', f'photometry/{photometry_id}?format=mag', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' assert data['data']['mag'] is None assert data['data']['magerr'] is None def test_token_user_big_post( upload_data_token, public_source, ztf_camera, public_group ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': [58000 + i for i in range(50000)], 'instrument_id': ztf_camera.id, 'mag': np.random.uniform(low=18, high=22, size=50000).tolist(), 'magerr': np.random.uniform(low=0.1, high=0.3, size=50000).tolist(), 'limiting_mag': 22.3, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' def test_token_user_get_range_photometry( upload_data_token, public_source, public_group, ztf_camera ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': [58000.0, 58500.0, 59000.0], 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' status, data = api( 'GET', 'photometry/range', token=upload_data_token, data={'instrument_ids': [ztf_camera.id], 'max_date': '2018-05-15T00:00:00'}, ) assert status == 200 assert data['status'] == 'success' assert len(data['data']) == 1 status, data = api( 'GET', 'photometry/range?format=flux&magsys=vega', token=upload_data_token, data={'instrument_ids': [ztf_camera.id], 'max_date': '2019-02-01T00:00:00'}, ) assert status == 200 assert data['status'] == 'success' assert len(data['data']) == 2 def test_reject_photometry_inf( upload_data_token, public_source, public_group, ztf_camera ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': [58000.0, 58500.0, 59000.0], 'instrument_id': ztf_camera.id, 'flux': math.inf, 'fluxerr': math.inf, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 400 assert data['status'] == 'error' status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'mag': math.inf, 'magerr': math.inf, 'limiting_mag': 22.3, 'magsys': 'vega', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 400 assert data['status'] == 'error' status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'mag': 2.0, 'magerr': 23.0, 'limiting_mag': math.inf, 'magsys': 'vega', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 400 assert data['status'] == 'error' status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': 58000.0, 'instrument_id': ztf_camera.id, 'mag': None, 'magerr': None, 'limiting_mag': -math.inf, 'magsys': 'vega', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 400 assert data['status'] == 'error' status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source.id), 'mjd': [58000.0, 58500.0, 59000.0], 'instrument_id': ztf_camera.id, 'flux': None, 'fluxerr': math.inf, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group.id], }, token=upload_data_token, ) assert status == 400 assert data['status'] == 'error' def test_token_user_post_to_foreign_group_and_retrieve( upload_data_token, public_source_two_groups, public_group2, ztf_camera ): status, data = api( 'POST', 'photometry', data={ 'obj_id': str(public_source_two_groups.id), 'mjd': [58000.0, 58500.0, 59000.0], 'instrument_id': ztf_camera.id, 'flux': 12.24, 'fluxerr': 0.031, 'zp': 25.0, 'magsys': 'ab', 'filter': 'ztfg', 'group_ids': [public_group2.id], }, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' photometry_id = data['data']['ids'][0] status, data = api( 'GET', f'photometry/{photometry_id}?format=flux', token=upload_data_token ) assert status == 200 def test_problematic_photometry_1263( upload_data_token, public_source, public_group, ztf_camera, public_group2 ): payload = { "obj_id": public_source.id, "group_ids": [public_group.id, public_group2.id], "magsys": "ab", "zp": 23.9, "instrument_id": ztf_camera.id, 'mjd': [ 59145.46447, 59149.50347, 59149.50347, 59150.50872, 59150.50872, 59152.51631, 59155.50801, 59152.51631, 59155.50801, 59156.48479, 59156.48479, 59126.48693, 59128.46834, 59130.50257, 59135.47329, 59137.4758, 59139.45454, 59141.47449, 59143.50987, 59143.50987, 59145.46447, 59145.50556, 59150.52806, 59150.52806, 59151.52116, 59151.52116, 59152.48332, 59152.48332, 59155.50022, 59155.50022, 59156.5383, 59126.53144, 59128.51928, 59130.53196, 59135.51196, 59137.51334, 59139.51507, 59141.51422, 59143.48529, 59143.48529, 59145.50556, ], 'filter': [ 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfg', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', 'ztfr', ], 'flux': [ 105.4095462, 100.4989583, 100.4986052, 97.45052422, 97.45411937, 91.71425204, 81.08011148, 91.71489652, 81.08110854, 59.37327478, 59.37452643, None, None, None, 73.17457336, 82.20150344, 89.14970986, 102.1692537, 98.6103674, 98.60984771, 105.4086204, 100.8602976, 94.84847105, 94.85063718, 104.8945366, 104.8961951, 101.6093671, 101.6061542, 82.34545782, 82.34560248, 72.48165796, None, None, None, 61.60270207, 72.73101786, 83.83015488, 98.70066264, 99.85275375, 99.84977174, 100.8608292, ], 'fluxerr': [ 8.416851743, 10.10817406, 10.10811785, 11.74314252, 11.74356103, 11.40505647, 10.61680918, 11.40514417, 10.61696199, 10.6736128, 10.67382477, 13.51668635, 18.71327665, 9.509339593, 9.374956127, 9.638764985, 11.98599464, 10.42671307, 9.666542673, 9.666476165, 8.41682049, 8.680180822, 9.926401394, 9.926617677, 8.494021784, 8.494115051, 9.984017125, 9.983686084, 7.964270439, 7.964306468, 8.499519049, 12.65289244, 11.39803573, 9.771246706, 7.839855173, 7.592658663, 8.674127848, 8.965488502, 7.69135795, 7.691126885, 8.680212034, ], } status, data = api( 'POST', 'photometry', data=payload, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' payload = { "obj_id": public_source.id, "group_ids": "all", "magsys": "ab", "instrument_id": ztf_camera.id, "filter": [ "ztfr", "ztfg", "ztfr", "ztfg", "ztfr", "ztfg", "ztfr", "ztfg", "ztfr", "ztfr", "ztfg", "ztfg", "ztfr", "ztfg", "ztfg", "ztfr", "ztfr", "ztfr", "ztfg", "ztfr", "ztfg", "ztfg", "ztfr", ], "mjd": [ 59130.53195599979, 59135.473286999855, 59135.51195599977, 59137.47579859989, 59137.51334490022, 59139.45453700004, 59139.51506939996, 59141.474490699824, 59141.51422449993, 59143.48528939998, 59143.50987270009, 59145.46446759999, 59145.50555559993, 59149.50347220013, 59150.50871529989, 59150.52805559989, 59151.52115740022, 59152.4833217999, 59152.516307900194, 59155.50021990016, 59155.5080093001, 59156.4847916998, 59156.53829859989, ], "limiting_mag": [ 19.67770004272461, 20.11709976196289, 20.059200286865234, 20.281099319458008, 20.224000930786133, 19.809099197387695, 20.236799240112305, 20.57659912109375, 20.31290054321289, 20.414499282836914, 20.680700302124023, 20.57069969177246, 20.48349952697754, 20.242000579833984, 20.642900466918945, 20.029699325561523, 20.11090087890625, 19.808948516845703, 19.819171905517578, 19.9112606048584, 19.913991928100586, 19.600677490234375, 20.005773544311523, ], "mag": [ None, 19.239099502563477, 19.426000595092773, 19.11280059814453, 19.24570083618164, 19.024700164794922, 19.09149932861328, 18.876699447631836, 18.914199829101562, 18.901599884033203, 18.915199279785156, 18.84280014038086, 18.89069938659668, 18.89459991455078, 18.92799949645996, 18.957399368286133, 18.848100662231445, 18.882665634155273, 18.993907928466797, 19.110898971557617, 19.127714157104492, 19.466022491455078, 19.24942970275879, ], "magerr": [ None, 0.1391019970178604, 0.13817599415779114, 0.12731100618839264, 0.11334399878978729, 0.1459749937057495, 0.11234399676322937, 0.11080300062894821, 0.09862300008535385, 0.0836310014128685, 0.1064319983124733, 0.08669500052928925, 0.09344000369310379, 0.10920300334692001, 0.13083499670028687, 0.11362800002098083, 0.08791899681091309, 0.1066831648349762, 0.13501590490341187, 0.10501029342412949, 0.14216870069503784, 0.19518424570560455, 0.12731821835041046, ], "ra": [ None, 134.5934039, 134.5934169, 134.5933773, 134.593404, 134.593372, 134.5933825, 134.5933984, 134.5933945, 134.5933917, 134.5933988, 134.5933848, 134.5933991, 134.5933909, 134.5934048, 134.5934296, 134.5934341, 134.593388, 134.5933606, 134.5933857, 134.5933939, 134.5933847, 134.5933954, ], "dec": [ None, 15.0412865, 15.041256, 15.0412686, 15.0412482, 15.0412709, 15.0412572, 15.0412656, 15.0412765, 15.0412744, 15.0412673, 15.041271, 15.0412726, 15.0413061, 15.0412751, 15.041267, 15.0412856, 15.0412655, 15.0412913, 15.0412952, 15.0412737, 15.0411913, 15.0412605, ], } status, data = api( 'POST', 'photometry', data=payload, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' payload['group_ids'] = 'all' status, data = api( 'PUT', 'photometry', data=payload, token=upload_data_token, ) assert status == 200 assert data['status'] == 'success' for id in data['data']['ids']: status, data = api( 'GET', f'photometry/{id}?format=flux', token=upload_data_token ) assert status == 200 assert data['status'] == 'success' assert len(data['data']['groups']) == 2 def test_problematic_photometry_1276( public_source, public_group, super_admin_token, ztf_camera ): payload = { "obj_id": public_source.id, "group_ids": [public_group.id], "magsys": "ab", "instrument_id": ztf_camera.id, "filter": [ "ztfg", "ztfr", "ztfr", "ztfr", "ztfr", "ztfr", "ztfr", "ztfr", "ztfg", "ztfr", "ztfr", "ztfg", "ztfg", "ztfr", "ztfg", "ztfr", "ztfr", "ztfr", "ztfg", "ztfg", "ztfg", "ztfg", "ztfr", "ztfr", "ztfg", "ztfg", "ztfr", "ztfg", "ztfr", ], "mjd": [ 59123.41299769981, 59129.472291700076, 59134.451203700155, 59136.46903940011, 59136.46903940011, 59139.295057899784, 59139.295057899784, 59139.295057899784, 59139.389629600104, 59141.36341439979, 59141.36341439979, 59141.414189800154, 59141.414189800154, 59143.318460599985, 59143.39145829994, 59145.34545140015, 59145.34545140015, 59145.34545140015, 59145.41583329998, 59145.41583329998, 59149.4703819002, 59151.32671299996, 59151.33918979997, 59153.33692129981, 59153.404351899866, 59155.220972199924, 59155.290161999874, 59157.360347200185, 59157.433634299785, ], "limiting_mag": [ 19.396099090576172, 20.23240089416504, 20.129100799560547, 20.493600845336914, 20.493600845336914, 20.422000885009766, 20.422000885009766, 20.422000885009766, 20.272199630737305, 20.18910026550293, 20.18910026550293, 20.846799850463867, 20.846799850463867, 20.624300003051758, 20.854000091552734, 20.628799438476562, 20.628799438476562, 20.628799438476562, 20.840900421142578, 20.840900421142578, 20.32859992980957, 19.60849952697754, 19.705799102783203, 19.47800064086914, 19.409400939941406, 19.462600708007812, 19.77630043029785, 19.678672790527344, 19.754121780395508, ], "mag": [ 18.43560028076172, 17.338199615478516, 16.25189971923828, 16.011999130249023, 16.09589958190918, 15.974100112915039, 15.891500473022461, 15.891500473022461, None, 15.753999710083008, 15.819600105285645, 18.528499603271484, 18.57939910888672, 15.781000137329102, 18.309499740600586, 15.692399978637695, 15.692399978637695, 15.790599822998047, 18.305700302124023, 18.31529998779297, 18.13994026184082, 18.040000915527344, 15.505499839782715, 15.569299697875977, 17.812599182128906, 18.046100616455078, None, 17.95865249633789, 15.475956916809082, ], "magerr": [ 0.18098600208759308, 0.12704600393772125, 0.03412500023841858, 0.018530000001192093, 0.09321600198745728, 0.1358170062303543, 0.017785999923944473, 0.017785999923944473, None, 0.017010999843478203, 0.0650859996676445, 0.1969199925661087, 0.08772700279951096, 0.05595200136303902, 0.17250700294971466, 0.0137339998036623, 0.0137339998036623, 0.06520400196313858, 0.06727799773216248, 0.13235700130462646, 0.12975013256072998, 0.11010699719190598, 0.04597700014710426, 0.049855999648571014, 0.10752200335264206, 0.13239599764347076, None, 0.139614999294281, 0.042450759559869766, ], "ra": [ 56.0478815, 56.0468989, 56.0478, 56.0478343, 56.0480658, 56.0475873, 56.047908, 56.0480877, None, 56.0476469, 56.0477499, 56.047177, 56.0469751, 56.0480999, 56.0470656, 56.0477652, 56.0476761, 56.0476218, 56.0469908, 56.0472491, 56.0467978, 56.0472009, 56.0478524, 56.0476997, 56.0471999, 56.0476057, None, 56.0473734, 56.0477336, ], "dec": [ 71.6368125, 71.6367721, 71.6367167, 71.6367615, 71.6367048, 71.6368681, 71.6368457, 71.6368389, None, 71.6367596, 71.6365229, 71.6367611, 71.6368439, 71.6367764, 71.6368222, 71.6367943, 71.6368108, 71.6367366, 71.6368412, 71.6367895, 71.6368039, 71.6367984, 71.6367866, 71.6367788, 71.6368348, 71.6367571, None, 71.6367753, 71.6367119, ], } status, data = api( 'PUT', 'photometry', data=payload, token=super_admin_token, ) assert status == 400 assert data['status'] == 'error'
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def rotateRight(self, head: ListNode, k: int) -> ListNode: if not (head and head.next and k) : return head fast = head cnt = 1 while fast.next: fast = fast.next cnt += 1 fast.next = head slow = head for i in range(cnt - k%cnt - 1): slow = slow.next second = slow.next slow.next = None return second
# coding=utf-8 # Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, unicode_literals, with_statement) from pants.backend.python.tasks import SelectInterpreter from pants.base.deprecated import deprecated_module deprecated_module('1.7.0.dev0', 'Use pants.backend.python.tasks instead') SelectInterpreter = SelectInterpreter
import sys #For CLI input from decimal import Decimal, getcontext """I wanted to avoid importing this module but, the floats were messing up like >>> 1-0.8 0.19999999999999996 So, I used it. Round function could helped. But using that produce -0.000, which seemed unaesthetic to me.""" getcontext().prec= 3 #Useless, since used %.3f at end. inputlist = list(map(float,sys.argv[1:]))#Putting almk input in a list u = inputlist.pop(-3)#Lower limit and starting point v = inputlist.pop(-2) #Upper limit s = inputlist.pop(-1) #Step deviation def table (start, end, step, coefficient_list): y = 0 xlist=[] fxlist=[] x = start while start<= x and x<= end: for j in range(len(coefficient_list)): y = coefficient_list[j]*x**(len(coefficient_list) -1 -j) + y xlist.append(x) fxlist.append(y) y = 0 x = float(Decimal(x) + Decimal(step)) print ("x\tf(x)") for i in range(len(xlist)): #Printing in two columns, each column is 1 tab appart. (As long as the value of x lesser than 7 character. print ( "%.3f\t%.3f" %(xlist[i], fxlist[i])) table(u,v,s,inputlist)
import re from typing import NamedTuple from adventofcode2020.utils.abstract import FileReaderSolution class PassPol(NamedTuple): at_least: int at_most: int letter: str password: str class Day02: @staticmethod def split(input_password) -> PassPol: """ Input `7-9 r: rrrkrrrrrnrrmj`, output is PassPol namedtuple """ results = re.match(r"(\d*)-(\d*) (.): (\w*)", input_password) # Make mypy happy assert results passpol = PassPol( at_least=int(results[1]), at_most=int(results[2]), letter=results[3], password=results[4], ) return passpol class Day02PartA(Day02, FileReaderSolution): def validate_passwords(self, policy: PassPol) -> bool: """ Validate that `password` is valid, with the PassPol policy list """ at_least = policy.at_least at_most = policy.at_most letter = policy.letter # `letter` must be `at_least` time in the list, and at most `at_most` times counts = policy.password.count(letter) if counts < at_least: # To little return False if counts > at_most: # To much return False return True def solve(self, input_data: str) -> int: password_list = [ self.split(x.strip()) for x in input_data.split("\n") if len(x.strip()) >= 1 ] results = [self.validate_passwords(policy=x) for x in password_list] return sum(results) class Day02PartB(Day02, FileReaderSolution): def validate_passwords(self, policy: PassPol) -> bool: """ Validate that `password` is valid, with the PassPol policy list """ first_char = policy.at_least second_char = policy.at_most letter = policy.letter # `letter` must be at place first_char - 1 and second_char - 1, # since it's 1-indexed and not zero indexed # Exactly one of these positions must contain the given letter, xor. if (policy.password[first_char - 1] == letter) ^ ( policy.password[second_char - 1] == letter ): return True else: return False def solve(self, input_data: str) -> int: password_list = [ self.split(x.strip()) for x in input_data.split("\n") if len(x.strip()) >= 1 ] results = [self.validate_passwords(policy=x) for x in password_list] return sum(results)
# Escreva um programa que leia um valor em metros e o exiba convertido em milímetros n1=int(input('Coloque o(s) valor(es): ')) print ('O valor em metros: ', n1) print ('O valore em centimetros: ', n1 * 100) print ('O valor em milimetros: ', n1*1000)
# Copyright 1999-2021 Alibaba Group Holding Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import logging from typing import List from .... import oscar as mo from ..core import NodeRole, NodeStatus from ..locator import SupervisorLocatorActor logger = logging.getLogger(__name__) class WorkerSupervisorLocatorActor(SupervisorLocatorActor): _node_role = NodeRole.WORKER def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._node_info_ref = None @classmethod def default_uid(cls): return SupervisorLocatorActor.__name__ async def _set_supervisors(self, supervisors: List[str]): await super()._set_supervisors(supervisors) if supervisors and self._node_info_ref is None: from ..supervisor.node_info import NodeInfoCollectorActor supervisor_addr = self.get_supervisor( NodeInfoCollectorActor.default_uid()) try: self._node_info_ref = await mo.actor_ref( uid=NodeInfoCollectorActor.default_uid(), address=supervisor_addr ) except (OSError, mo.ServerClosed, mo.ActorNotExist): self._node_info_ref = None async def _get_supervisors_from_backend(self, filter_ready: bool = True): try: assert self._node_info_ref is not None statuses = {NodeStatus.READY} if filter_ready \ else {NodeStatus.READY, NodeStatus.STARTING} infos = await self._node_info_ref.get_nodes_info( role=NodeRole.SUPERVISOR, statuses=statuses) return list(infos) except (AssertionError, OSError, mo.ServerClosed, mo.ActorNotExist): self._node_info_ref = None return await self._backend.get_supervisors(filter_ready=filter_ready) async def _watch_supervisor_from_node_info(self): assert self._node_info_ref is not None version = None while True: version, infos = await self._node_info_ref.watch_nodes( role=NodeRole.SUPERVISOR, version=version) yield list(infos) async def _watch_supervisors_from_backend(self): while True: try: async for supervisors in self._watch_supervisor_from_node_info(): yield supervisors except (AssertionError, OSError, mo.ServerClosed, mo.ActorNotExist): self._node_info_ref = None async for supervisors in self._backend.watch_supervisors(): yield supervisors if self._node_info_ref is not None: break
import pandas as pd from sklearn.preprocessing import LabelEncoder def categorical_features(data, features): features['vehicleType'] = data['vehicleType'] features['vehicleOption'] = data['vehicleOption'] features['vehicleTypeOption'] = [a + '_' + b for a, b in zip(data['vehicleType'].values, data['vehicleOption'].values)] cat_columns_clusters = ['cluster_dest_db', 'cluster_src_db', 'cluster_src_km', 'cluster_dest_km'] cat_columns_date = ['day', 'month'] cat_columns = ['vehicleType', 'vehicleOption', 'vehicleTypeOption'] # cat_columns += cat_columns_clusters # cat_columns += cat_columns_date features = pd.get_dummies(features, columns=cat_columns, drop_first=True) features['day'] = LabelEncoder().fit_transform(features['day']) features['month'] = LabelEncoder().fit_transform(features['month']) return features def raw_features(data, features): features['weight'] = data['weight'] features['distanceKM'] = data['distanceKM'] features['taxiDurationMin'] = data['taxiDurationMin'] features['sourceLatitude'] = data['sourceLatitude'] features['sourceLongitude'] = data['sourceLongitude'] features['destinationLatitude'] = data['destinationLatitude'] features['destinationLongitude'] = data['destinationLongitude'] features['src_dest'] = (data['SourceState'] == data['destinationState']) features['ave_speed'] = data['distanceKM'] / data['taxiDurationMin'] import numpy as np features['weight_dur'] = np.log((data['taxiDurationMin'] + 30 * data['weight'])) features['weight_dist_dur'] = np.log(1. + (10. + data['weight']) * (100. + data['distanceKM']) * (1000. + data['taxiDurationMin'])) features['price'] = data['price'] return features
from direct.distributed.DistributedObjectAI import DistributedObjectAI from direct.directnotify import DirectNotifyGlobal class DistributedLockAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('DistributedLockAI') def __init__(self, air): DistributedObjectAI.__init__(self, air)
""" PASSENGERS """ numPassengers = 7667 passenger_arriving = ( (2, 0, 1, 3, 1, 1, 2, 1, 0, 1, 0, 0, 0, 3, 1, 3, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0), # 0 (2, 2, 4, 2, 0, 1, 0, 1, 2, 0, 0, 1, 0, 4, 6, 1, 2, 3, 0, 1, 1, 1, 0, 0, 0, 0), # 1 (2, 2, 3, 3, 0, 2, 0, 1, 1, 0, 1, 0, 0, 2, 1, 4, 2, 2, 0, 3, 1, 1, 0, 0, 1, 0), # 2 (6, 1, 2, 1, 3, 1, 0, 1, 2, 1, 0, 0, 0, 2, 1, 2, 3, 1, 0, 0, 1, 0, 1, 0, 1, 0), # 3 (2, 5, 3, 5, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 5, 1, 1, 2, 1, 1, 1, 0, 1, 2, 0, 0), # 4 (2, 2, 3, 1, 1, 1, 0, 1, 1, 0, 2, 0, 0, 1, 1, 1, 1, 1, 3, 3, 2, 0, 0, 0, 1, 0), # 5 (4, 5, 1, 4, 0, 2, 0, 1, 1, 2, 2, 1, 0, 4, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0), # 6 (1, 2, 3, 6, 0, 1, 2, 1, 0, 0, 2, 1, 0, 1, 2, 2, 1, 5, 1, 0, 4, 2, 0, 3, 0, 0), # 7 (1, 4, 1, 3, 1, 2, 1, 0, 0, 1, 0, 0, 0, 4, 3, 4, 4, 1, 0, 0, 0, 2, 0, 2, 1, 0), # 8 (4, 0, 1, 2, 1, 2, 2, 1, 1, 1, 0, 0, 0, 3, 5, 2, 3, 2, 3, 1, 3, 0, 0, 1, 0, 0), # 9 (1, 0, 0, 4, 2, 2, 2, 1, 0, 0, 1, 0, 0, 7, 3, 4, 0, 0, 5, 1, 2, 0, 2, 0, 0, 0), # 10 (3, 3, 3, 4, 3, 1, 0, 0, 2, 1, 0, 0, 0, 5, 3, 4, 1, 1, 1, 1, 2, 1, 3, 1, 0, 0), # 11 (3, 3, 4, 2, 3, 0, 0, 1, 2, 2, 1, 0, 0, 2, 3, 3, 4, 3, 3, 0, 1, 0, 0, 1, 0, 0), # 12 (3, 3, 1, 1, 3, 1, 1, 0, 2, 2, 1, 1, 0, 4, 4, 1, 2, 1, 1, 0, 2, 3, 3, 1, 0, 0), # 13 (3, 2, 3, 3, 1, 1, 1, 1, 1, 1, 0, 0, 0, 3, 2, 2, 6, 7, 2, 3, 1, 1, 0, 1, 1, 0), # 14 (6, 1, 1, 2, 2, 1, 0, 1, 2, 0, 0, 0, 0, 3, 4, 4, 0, 4, 1, 3, 0, 2, 1, 0, 0, 0), # 15 (4, 3, 0, 3, 0, 1, 3, 1, 1, 2, 1, 1, 0, 2, 6, 2, 3, 2, 2, 2, 0, 1, 2, 0, 0, 0), # 16 (5, 11, 1, 7, 4, 2, 0, 1, 3, 0, 1, 0, 0, 3, 1, 5, 2, 6, 0, 1, 2, 1, 0, 0, 0, 0), # 17 (6, 4, 2, 4, 1, 1, 2, 0, 0, 0, 0, 0, 0, 5, 2, 0, 1, 5, 0, 1, 0, 0, 0, 2, 2, 0), # 18 (6, 6, 3, 3, 4, 0, 2, 2, 2, 1, 0, 1, 0, 3, 3, 5, 2, 4, 3, 0, 1, 1, 0, 0, 1, 0), # 19 (8, 6, 3, 4, 2, 2, 4, 3, 3, 1, 0, 1, 0, 3, 0, 1, 4, 3, 1, 3, 1, 2, 3, 2, 0, 0), # 20 (5, 4, 2, 6, 2, 2, 1, 1, 4, 2, 3, 0, 0, 4, 4, 2, 2, 8, 4, 1, 2, 0, 0, 2, 0, 0), # 21 (3, 4, 4, 3, 4, 1, 1, 0, 1, 2, 1, 0, 0, 3, 2, 0, 1, 2, 2, 2, 1, 1, 2, 2, 0, 0), # 22 (1, 2, 5, 4, 3, 0, 2, 4, 3, 2, 0, 0, 0, 7, 5, 2, 3, 6, 3, 2, 3, 3, 1, 0, 0, 0), # 23 (2, 8, 1, 3, 1, 3, 1, 3, 2, 1, 1, 1, 0, 6, 5, 0, 3, 2, 3, 1, 0, 1, 4, 1, 0, 0), # 24 (7, 3, 3, 3, 3, 0, 1, 0, 2, 1, 1, 0, 0, 4, 0, 2, 4, 4, 4, 0, 0, 0, 1, 0, 1, 0), # 25 (4, 0, 2, 3, 2, 4, 1, 1, 1, 2, 1, 0, 0, 5, 1, 3, 2, 1, 1, 1, 0, 0, 1, 0, 0, 0), # 26 (5, 4, 6, 4, 1, 1, 1, 2, 3, 2, 4, 0, 0, 3, 4, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0), # 27 (3, 5, 4, 2, 3, 2, 1, 1, 2, 0, 2, 1, 0, 3, 4, 6, 2, 6, 1, 1, 0, 1, 0, 1, 0, 0), # 28 (3, 4, 2, 9, 0, 2, 2, 2, 4, 1, 0, 0, 0, 5, 3, 3, 1, 5, 2, 0, 2, 1, 2, 0, 0, 0), # 29 (6, 4, 1, 2, 4, 1, 1, 3, 1, 0, 1, 1, 0, 5, 4, 3, 2, 2, 1, 3, 0, 3, 1, 0, 3, 0), # 30 (1, 4, 4, 5, 1, 2, 2, 2, 3, 1, 1, 0, 0, 9, 4, 1, 4, 4, 1, 1, 1, 5, 2, 0, 0, 0), # 31 (8, 4, 5, 0, 3, 1, 1, 1, 1, 1, 1, 1, 0, 3, 1, 4, 1, 5, 2, 1, 3, 0, 0, 1, 0, 0), # 32 (3, 6, 2, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 4, 8, 2, 4, 7, 2, 5, 1, 1, 3, 1, 0, 0), # 33 (5, 4, 3, 2, 4, 1, 4, 2, 0, 0, 1, 0, 0, 2, 5, 9, 4, 2, 1, 4, 0, 2, 1, 0, 0, 0), # 34 (3, 3, 3, 2, 4, 3, 2, 3, 2, 0, 0, 0, 0, 5, 3, 1, 3, 0, 1, 1, 1, 1, 1, 0, 0, 0), # 35 (4, 3, 2, 8, 3, 2, 2, 1, 2, 0, 0, 0, 0, 3, 2, 2, 5, 3, 1, 1, 0, 2, 0, 0, 0, 0), # 36 (5, 2, 2, 2, 7, 1, 0, 3, 2, 1, 0, 0, 0, 7, 2, 4, 1, 4, 4, 3, 0, 3, 0, 2, 0, 0), # 37 (2, 6, 4, 10, 3, 1, 3, 0, 4, 0, 0, 1, 0, 3, 2, 4, 0, 3, 1, 0, 2, 2, 0, 0, 0, 0), # 38 (3, 2, 5, 1, 5, 3, 4, 1, 0, 0, 2, 0, 0, 4, 4, 3, 3, 5, 4, 1, 0, 0, 1, 0, 1, 0), # 39 (3, 5, 1, 5, 1, 2, 4, 3, 2, 2, 0, 0, 0, 1, 5, 1, 1, 3, 2, 0, 0, 1, 1, 0, 1, 0), # 40 (3, 1, 2, 7, 5, 1, 2, 1, 1, 1, 0, 0, 0, 0, 3, 5, 3, 6, 4, 1, 2, 1, 1, 0, 0, 0), # 41 (5, 3, 4, 4, 4, 3, 1, 0, 1, 1, 1, 0, 0, 4, 4, 1, 4, 2, 1, 3, 0, 2, 1, 1, 0, 0), # 42 (3, 9, 6, 6, 3, 2, 5, 4, 1, 4, 0, 0, 0, 1, 1, 4, 2, 2, 0, 2, 2, 0, 1, 2, 1, 0), # 43 (2, 2, 1, 3, 1, 2, 4, 0, 2, 0, 2, 0, 0, 3, 4, 2, 1, 2, 1, 3, 2, 1, 2, 0, 0, 0), # 44 (8, 6, 1, 3, 3, 2, 3, 0, 1, 0, 0, 1, 0, 4, 8, 2, 3, 4, 2, 3, 0, 1, 1, 1, 0, 0), # 45 (5, 6, 2, 0, 2, 1, 1, 2, 0, 0, 0, 1, 0, 6, 3, 3, 3, 4, 2, 1, 1, 1, 2, 1, 0, 0), # 46 (6, 5, 3, 5, 4, 2, 0, 2, 1, 2, 2, 0, 0, 0, 3, 3, 2, 6, 2, 2, 2, 0, 2, 0, 0, 0), # 47 (3, 6, 0, 3, 5, 2, 1, 2, 3, 1, 0, 0, 0, 4, 4, 4, 0, 3, 2, 1, 2, 2, 1, 0, 0, 0), # 48 (4, 3, 5, 7, 3, 2, 1, 1, 2, 1, 0, 0, 0, 2, 4, 3, 1, 4, 2, 1, 1, 2, 2, 0, 0, 0), # 49 (5, 7, 1, 3, 6, 2, 0, 1, 2, 1, 1, 1, 0, 7, 4, 3, 2, 3, 5, 4, 0, 0, 1, 0, 1, 0), # 50 (5, 3, 3, 7, 2, 1, 3, 0, 0, 0, 0, 0, 0, 1, 4, 1, 4, 3, 1, 0, 2, 2, 3, 1, 1, 0), # 51 (1, 4, 4, 9, 3, 4, 1, 1, 2, 0, 2, 0, 0, 3, 5, 3, 1, 6, 1, 0, 0, 0, 1, 0, 0, 0), # 52 (4, 3, 4, 3, 5, 2, 2, 2, 4, 1, 1, 2, 0, 2, 7, 2, 3, 2, 2, 1, 0, 1, 1, 1, 0, 0), # 53 (7, 6, 7, 4, 5, 2, 2, 2, 0, 0, 0, 1, 0, 5, 1, 2, 1, 3, 4, 2, 2, 1, 0, 0, 0, 0), # 54 (5, 4, 2, 5, 4, 0, 2, 1, 1, 0, 0, 0, 0, 3, 2, 3, 3, 5, 1, 3, 0, 1, 0, 0, 0, 0), # 55 (3, 3, 4, 4, 4, 2, 0, 1, 1, 0, 1, 0, 0, 5, 3, 2, 1, 3, 5, 0, 2, 0, 2, 1, 0, 0), # 56 (3, 4, 0, 5, 2, 3, 1, 1, 3, 1, 0, 1, 0, 4, 3, 7, 1, 2, 2, 1, 1, 2, 0, 0, 0, 0), # 57 (7, 3, 6, 3, 2, 0, 4, 0, 1, 0, 0, 0, 0, 6, 3, 2, 0, 2, 0, 3, 3, 2, 0, 0, 0, 0), # 58 (5, 6, 5, 3, 4, 1, 3, 2, 1, 0, 0, 0, 0, 4, 1, 0, 1, 3, 1, 0, 0, 2, 0, 1, 1, 0), # 59 (7, 4, 4, 4, 2, 0, 0, 0, 2, 1, 3, 0, 0, 0, 6, 0, 1, 4, 0, 1, 1, 2, 2, 1, 0, 0), # 60 (5, 1, 0, 3, 0, 0, 1, 0, 4, 1, 1, 0, 0, 1, 5, 3, 1, 3, 1, 2, 3, 3, 1, 1, 1, 0), # 61 (5, 3, 2, 4, 2, 3, 1, 1, 3, 0, 0, 0, 0, 6, 4, 5, 1, 2, 2, 2, 1, 1, 3, 1, 0, 0), # 62 (7, 3, 8, 5, 3, 0, 1, 1, 1, 1, 0, 1, 0, 3, 1, 0, 0, 2, 1, 0, 0, 0, 2, 1, 0, 0), # 63 (5, 4, 1, 4, 3, 1, 5, 1, 2, 2, 0, 0, 0, 6, 1, 2, 5, 3, 1, 1, 0, 1, 2, 1, 0, 0), # 64 (2, 3, 4, 3, 2, 3, 3, 2, 2, 1, 0, 0, 0, 5, 3, 1, 3, 3, 1, 0, 1, 0, 1, 2, 1, 0), # 65 (3, 6, 6, 6, 3, 0, 5, 1, 1, 1, 0, 0, 0, 6, 2, 3, 0, 4, 4, 5, 0, 1, 1, 0, 0, 0), # 66 (1, 3, 3, 8, 2, 0, 2, 2, 3, 2, 1, 0, 0, 7, 2, 2, 1, 1, 1, 0, 0, 0, 2, 1, 0, 0), # 67 (6, 5, 1, 2, 4, 2, 0, 1, 2, 1, 0, 0, 0, 4, 3, 5, 3, 3, 0, 1, 1, 3, 1, 0, 0, 0), # 68 (4, 1, 2, 3, 7, 0, 3, 4, 1, 4, 0, 0, 0, 2, 3, 2, 2, 7, 1, 4, 0, 1, 0, 0, 0, 0), # 69 (6, 5, 6, 1, 5, 1, 0, 0, 2, 1, 1, 0, 0, 3, 4, 1, 2, 3, 1, 1, 0, 0, 1, 0, 0, 0), # 70 (4, 6, 3, 4, 4, 0, 0, 0, 1, 1, 0, 1, 0, 3, 3, 2, 1, 3, 2, 0, 0, 1, 0, 0, 3, 0), # 71 (3, 3, 2, 7, 2, 0, 0, 3, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, 1, 4, 1, 0, 0, 0, 0, 0), # 72 (4, 4, 4, 2, 3, 1, 2, 0, 1, 2, 0, 1, 0, 5, 3, 1, 1, 5, 1, 2, 1, 1, 0, 0, 1, 0), # 73 (2, 1, 6, 2, 4, 3, 1, 1, 1, 1, 0, 0, 0, 2, 3, 1, 3, 3, 1, 2, 0, 4, 0, 1, 1, 0), # 74 (4, 2, 3, 2, 4, 1, 0, 0, 3, 1, 0, 0, 0, 3, 8, 5, 0, 5, 1, 1, 1, 0, 1, 4, 0, 0), # 75 (4, 3, 6, 6, 2, 1, 1, 2, 2, 1, 1, 0, 0, 11, 3, 2, 4, 3, 2, 0, 2, 2, 1, 0, 0, 0), # 76 (3, 8, 4, 2, 4, 2, 0, 1, 1, 0, 1, 0, 0, 4, 3, 3, 4, 2, 0, 1, 2, 1, 0, 0, 0, 0), # 77 (2, 5, 5, 1, 0, 2, 3, 1, 3, 2, 1, 0, 0, 4, 5, 3, 2, 2, 1, 4, 1, 2, 0, 0, 1, 0), # 78 (3, 3, 3, 1, 0, 1, 1, 1, 2, 0, 0, 2, 0, 3, 2, 4, 0, 8, 1, 1, 1, 1, 2, 1, 0, 0), # 79 (3, 3, 2, 3, 2, 2, 1, 2, 1, 3, 0, 0, 0, 4, 4, 3, 1, 4, 0, 2, 1, 0, 3, 4, 0, 0), # 80 (2, 2, 3, 2, 2, 1, 0, 0, 3, 1, 0, 1, 0, 2, 4, 3, 5, 6, 1, 4, 1, 0, 0, 1, 1, 0), # 81 (6, 4, 4, 2, 3, 0, 2, 0, 4, 0, 0, 0, 0, 3, 1, 3, 3, 4, 6, 1, 0, 3, 3, 1, 0, 0), # 82 (2, 6, 4, 2, 3, 1, 3, 1, 3, 1, 0, 0, 0, 6, 0, 2, 0, 3, 2, 0, 0, 2, 2, 0, 0, 0), # 83 (4, 5, 7, 1, 3, 1, 1, 0, 2, 1, 1, 0, 0, 4, 3, 3, 3, 6, 3, 1, 0, 2, 1, 1, 0, 0), # 84 (2, 3, 6, 4, 2, 1, 1, 1, 2, 0, 0, 1, 0, 9, 1, 0, 3, 4, 1, 3, 1, 2, 1, 1, 0, 0), # 85 (3, 8, 4, 3, 2, 1, 2, 0, 3, 0, 1, 0, 0, 2, 2, 1, 2, 4, 2, 2, 3, 2, 2, 1, 0, 0), # 86 (4, 3, 2, 4, 1, 1, 2, 0, 2, 0, 0, 0, 0, 2, 8, 4, 4, 2, 3, 1, 1, 0, 0, 2, 0, 0), # 87 (9, 0, 2, 4, 2, 0, 1, 0, 2, 1, 0, 0, 0, 0, 4, 4, 4, 1, 1, 1, 0, 2, 1, 2, 0, 0), # 88 (6, 3, 2, 4, 7, 4, 1, 0, 3, 2, 0, 2, 0, 4, 5, 2, 4, 4, 2, 1, 1, 1, 1, 1, 0, 0), # 89 (5, 3, 3, 5, 4, 2, 1, 1, 4, 0, 0, 0, 0, 5, 5, 1, 2, 4, 4, 0, 0, 2, 3, 0, 0, 0), # 90 (5, 4, 0, 2, 4, 1, 1, 0, 2, 2, 0, 0, 0, 4, 6, 2, 3, 6, 0, 4, 1, 2, 1, 0, 1, 0), # 91 (5, 5, 4, 2, 3, 1, 2, 2, 1, 0, 0, 0, 0, 6, 3, 2, 2, 2, 1, 1, 1, 0, 2, 0, 0, 0), # 92 (3, 1, 4, 4, 1, 1, 3, 2, 2, 0, 2, 0, 0, 4, 5, 1, 3, 1, 0, 2, 0, 0, 1, 1, 0, 0), # 93 (5, 4, 11, 4, 4, 1, 0, 1, 3, 1, 0, 0, 0, 5, 6, 2, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0), # 94 (5, 4, 2, 1, 4, 3, 1, 0, 0, 1, 0, 0, 0, 0, 2, 1, 0, 2, 1, 1, 0, 2, 0, 0, 0, 0), # 95 (5, 4, 4, 3, 3, 1, 2, 1, 2, 0, 1, 1, 0, 6, 2, 2, 0, 3, 3, 0, 2, 1, 1, 2, 0, 0), # 96 (1, 4, 1, 3, 5, 1, 1, 1, 3, 1, 0, 0, 0, 3, 5, 2, 1, 1, 2, 3, 0, 2, 1, 1, 0, 0), # 97 (5, 0, 7, 5, 3, 0, 1, 0, 3, 0, 2, 1, 0, 4, 1, 3, 3, 1, 2, 2, 0, 4, 2, 1, 0, 0), # 98 (6, 4, 2, 2, 5, 2, 1, 4, 2, 1, 0, 0, 0, 4, 3, 3, 1, 3, 3, 0, 0, 2, 1, 0, 2, 0), # 99 (5, 2, 1, 2, 2, 0, 0, 3, 0, 0, 1, 1, 0, 6, 4, 1, 1, 3, 1, 1, 3, 1, 0, 0, 1, 0), # 100 (2, 5, 6, 4, 2, 0, 2, 2, 1, 0, 0, 1, 0, 4, 5, 2, 2, 1, 5, 0, 0, 3, 3, 0, 0, 0), # 101 (3, 5, 6, 7, 5, 1, 0, 0, 4, 1, 0, 1, 0, 6, 2, 4, 1, 2, 3, 2, 0, 3, 0, 1, 0, 0), # 102 (5, 2, 3, 5, 3, 1, 2, 0, 4, 0, 0, 1, 0, 3, 2, 0, 3, 1, 1, 1, 1, 0, 0, 3, 0, 0), # 103 (6, 5, 6, 4, 3, 1, 2, 1, 3, 1, 0, 0, 0, 8, 2, 3, 2, 0, 1, 4, 0, 1, 1, 0, 0, 0), # 104 (4, 4, 6, 6, 1, 0, 3, 1, 1, 0, 0, 0, 0, 4, 1, 4, 1, 4, 2, 6, 2, 0, 0, 0, 0, 0), # 105 (1, 6, 2, 5, 4, 2, 1, 0, 2, 1, 1, 0, 0, 1, 3, 4, 2, 3, 1, 0, 1, 1, 0, 0, 0, 0), # 106 (0, 5, 4, 2, 5, 1, 0, 1, 1, 0, 1, 1, 0, 4, 5, 3, 0, 2, 3, 0, 1, 0, 2, 1, 0, 0), # 107 (3, 5, 4, 2, 2, 1, 1, 1, 3, 0, 1, 0, 0, 4, 4, 2, 2, 2, 1, 2, 0, 0, 2, 2, 0, 0), # 108 (5, 2, 3, 2, 2, 1, 1, 1, 2, 1, 1, 0, 0, 2, 6, 2, 4, 5, 0, 3, 1, 2, 1, 1, 0, 0), # 109 (5, 4, 5, 1, 1, 3, 1, 1, 0, 1, 1, 0, 0, 7, 2, 1, 0, 1, 2, 0, 0, 1, 1, 0, 0, 0), # 110 (1, 4, 2, 1, 3, 0, 4, 2, 1, 0, 0, 1, 0, 2, 2, 2, 5, 2, 3, 2, 0, 0, 3, 0, 0, 0), # 111 (3, 5, 3, 6, 2, 0, 1, 1, 0, 1, 0, 0, 0, 3, 2, 2, 0, 2, 1, 1, 0, 2, 0, 1, 0, 0), # 112 (1, 2, 1, 2, 2, 2, 0, 1, 5, 1, 0, 0, 0, 2, 3, 2, 0, 3, 2, 1, 1, 1, 0, 0, 0, 0), # 113 (5, 2, 1, 6, 2, 0, 1, 0, 2, 1, 0, 0, 0, 4, 4, 1, 2, 1, 2, 2, 1, 1, 2, 0, 1, 0), # 114 (3, 8, 1, 8, 2, 0, 1, 2, 2, 1, 0, 0, 0, 6, 2, 3, 3, 3, 1, 2, 2, 2, 1, 1, 1, 0), # 115 (2, 1, 1, 4, 3, 2, 3, 1, 2, 0, 2, 0, 0, 4, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0, 0), # 116 (4, 5, 2, 5, 3, 2, 0, 1, 5, 0, 0, 1, 0, 6, 3, 1, 1, 5, 2, 2, 0, 2, 2, 0, 1, 0), # 117 (2, 5, 4, 8, 1, 4, 1, 0, 1, 1, 2, 0, 0, 2, 6, 2, 2, 1, 0, 3, 1, 2, 0, 1, 0, 0), # 118 (2, 2, 1, 3, 2, 0, 0, 0, 1, 0, 0, 0, 0, 4, 3, 1, 2, 1, 2, 2, 2, 2, 0, 1, 0, 0), # 119 (0, 1, 1, 4, 2, 2, 1, 0, 1, 0, 1, 0, 0, 3, 4, 1, 1, 2, 0, 0, 0, 2, 0, 0, 0, 0), # 120 (3, 0, 2, 2, 2, 2, 2, 0, 2, 0, 0, 0, 0, 3, 1, 3, 1, 3, 0, 1, 0, 3, 1, 0, 1, 0), # 121 (2, 2, 4, 1, 3, 0, 1, 0, 1, 0, 1, 0, 0, 3, 6, 4, 1, 1, 2, 1, 0, 1, 2, 0, 0, 0), # 122 (1, 3, 5, 4, 3, 0, 4, 0, 2, 0, 0, 0, 0, 7, 3, 3, 2, 1, 0, 0, 2, 0, 0, 0, 0, 0), # 123 (4, 3, 2, 6, 3, 4, 0, 2, 1, 0, 0, 0, 0, 4, 0, 1, 2, 2, 2, 3, 0, 2, 1, 1, 1, 0), # 124 (1, 0, 0, 4, 2, 2, 1, 0, 0, 0, 0, 0, 0, 3, 2, 3, 0, 2, 1, 2, 1, 1, 1, 1, 0, 0), # 125 (0, 1, 3, 3, 1, 2, 1, 1, 2, 2, 0, 0, 0, 5, 3, 3, 4, 4, 2, 0, 0, 2, 2, 1, 0, 0), # 126 (2, 3, 0, 5, 6, 1, 1, 1, 1, 2, 1, 0, 0, 0, 3, 2, 1, 4, 4, 2, 2, 1, 0, 0, 0, 0), # 127 (1, 1, 5, 5, 3, 2, 0, 0, 1, 1, 0, 1, 0, 2, 1, 5, 1, 4, 1, 2, 2, 2, 2, 1, 1, 0), # 128 (1, 2, 3, 3, 5, 1, 1, 2, 1, 0, 0, 0, 0, 6, 1, 1, 2, 2, 3, 3, 0, 2, 1, 0, 0, 0), # 129 (6, 2, 3, 2, 3, 4, 1, 1, 1, 1, 0, 0, 0, 7, 1, 3, 1, 2, 1, 3, 1, 1, 2, 0, 0, 0), # 130 (5, 5, 0, 4, 4, 1, 2, 0, 2, 2, 0, 0, 0, 4, 1, 0, 2, 1, 0, 0, 2, 3, 0, 2, 0, 0), # 131 (2, 2, 2, 4, 2, 2, 0, 1, 1, 1, 1, 0, 0, 5, 2, 4, 4, 0, 0, 5, 1, 2, 1, 3, 0, 0), # 132 (3, 1, 3, 7, 2, 2, 2, 1, 2, 0, 2, 0, 0, 4, 4, 2, 2, 3, 0, 0, 2, 0, 1, 1, 0, 0), # 133 (2, 4, 4, 0, 2, 0, 4, 0, 1, 0, 0, 0, 0, 1, 3, 1, 1, 3, 0, 1, 0, 3, 2, 0, 0, 0), # 134 (3, 1, 3, 5, 4, 1, 3, 0, 3, 1, 0, 0, 0, 4, 3, 2, 1, 2, 0, 1, 0, 0, 0, 1, 0, 0), # 135 (8, 2, 3, 2, 2, 2, 2, 0, 3, 0, 0, 0, 0, 3, 2, 2, 0, 4, 0, 1, 0, 2, 2, 0, 0, 0), # 136 (2, 1, 4, 5, 2, 3, 1, 2, 1, 0, 0, 2, 0, 7, 0, 2, 3, 4, 1, 2, 1, 1, 2, 1, 0, 0), # 137 (2, 3, 6, 2, 2, 0, 2, 0, 1, 1, 0, 0, 0, 2, 2, 6, 2, 4, 1, 1, 0, 0, 3, 2, 0, 0), # 138 (2, 4, 3, 4, 1, 0, 1, 1, 1, 0, 0, 1, 0, 5, 3, 1, 1, 4, 1, 1, 2, 0, 1, 1, 0, 0), # 139 (6, 3, 2, 3, 2, 3, 0, 2, 1, 0, 0, 0, 0, 0, 3, 4, 1, 3, 1, 1, 0, 4, 1, 1, 0, 0), # 140 (7, 6, 2, 0, 4, 0, 2, 0, 1, 2, 0, 0, 0, 5, 4, 2, 2, 4, 0, 0, 1, 2, 1, 0, 0, 0), # 141 (6, 1, 1, 5, 5, 6, 1, 0, 1, 0, 1, 1, 0, 3, 1, 2, 1, 2, 4, 2, 0, 1, 0, 0, 0, 0), # 142 (7, 3, 2, 3, 2, 3, 0, 1, 1, 0, 0, 1, 0, 2, 2, 3, 2, 3, 0, 3, 1, 6, 0, 2, 0, 0), # 143 (4, 0, 2, 3, 3, 1, 1, 0, 2, 1, 1, 0, 0, 3, 0, 1, 3, 2, 0, 0, 3, 1, 2, 0, 1, 0), # 144 (6, 2, 4, 2, 3, 1, 1, 3, 4, 0, 1, 1, 0, 1, 2, 1, 1, 4, 1, 0, 0, 1, 0, 3, 0, 0), # 145 (4, 1, 4, 4, 2, 1, 1, 0, 0, 0, 1, 0, 0, 10, 1, 2, 1, 1, 0, 2, 0, 0, 2, 0, 1, 0), # 146 (1, 3, 1, 1, 3, 2, 1, 2, 1, 1, 0, 0, 0, 0, 3, 2, 2, 0, 1, 0, 1, 1, 0, 0, 0, 0), # 147 (6, 1, 1, 5, 4, 1, 0, 1, 2, 0, 0, 0, 0, 4, 1, 1, 2, 1, 3, 1, 1, 1, 1, 1, 0, 0), # 148 (5, 4, 0, 4, 2, 0, 3, 0, 0, 0, 1, 1, 0, 5, 3, 1, 2, 4, 1, 1, 1, 0, 1, 2, 1, 0), # 149 (2, 2, 5, 5, 2, 2, 0, 1, 1, 1, 0, 0, 0, 2, 1, 2, 4, 2, 1, 2, 0, 1, 0, 1, 0, 0), # 150 (5, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 8, 3, 2, 4, 3, 2, 0, 3, 1, 2, 1, 0, 0), # 151 (6, 3, 4, 2, 3, 0, 4, 0, 3, 0, 1, 0, 0, 3, 0, 0, 2, 2, 2, 1, 0, 1, 1, 1, 1, 0), # 152 (3, 0, 1, 2, 2, 1, 1, 2, 0, 0, 1, 0, 0, 1, 2, 1, 4, 4, 1, 2, 1, 3, 1, 2, 0, 0), # 153 (4, 1, 2, 4, 1, 3, 0, 2, 2, 0, 2, 1, 0, 1, 8, 1, 0, 1, 3, 4, 0, 1, 1, 1, 1, 0), # 154 (3, 3, 4, 1, 3, 2, 0, 1, 1, 0, 0, 0, 0, 6, 4, 2, 1, 3, 1, 0, 0, 1, 1, 0, 2, 0), # 155 (2, 2, 2, 8, 2, 1, 2, 1, 1, 3, 1, 0, 0, 3, 1, 3, 1, 2, 1, 0, 0, 2, 0, 0, 0, 0), # 156 (7, 0, 5, 5, 3, 2, 1, 1, 1, 1, 0, 0, 0, 4, 2, 4, 3, 4, 2, 0, 0, 0, 1, 1, 0, 0), # 157 (4, 3, 2, 3, 2, 0, 1, 0, 2, 0, 1, 0, 0, 4, 4, 1, 0, 4, 2, 1, 0, 0, 0, 0, 0, 0), # 158 (4, 0, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 3, 0, 1, 1, 2, 0, 0, 0, 2, 0, 3, 0, 0), # 159 (1, 0, 0, 2, 3, 4, 0, 1, 2, 1, 0, 1, 0, 7, 3, 2, 0, 3, 3, 2, 0, 0, 0, 0, 0, 0), # 160 (5, 0, 3, 2, 2, 3, 3, 1, 1, 2, 0, 0, 0, 4, 3, 1, 0, 5, 0, 1, 0, 1, 0, 1, 0, 0), # 161 (2, 0, 2, 3, 2, 0, 0, 1, 0, 0, 0, 0, 0, 2, 1, 2, 2, 2, 0, 1, 0, 1, 1, 0, 0, 0), # 162 (3, 3, 1, 6, 5, 1, 1, 1, 0, 1, 1, 1, 0, 5, 4, 1, 0, 3, 0, 0, 0, 2, 1, 0, 0, 0), # 163 (4, 3, 4, 3, 2, 1, 1, 1, 3, 1, 1, 0, 0, 3, 2, 3, 2, 5, 0, 0, 1, 3, 0, 0, 0, 0), # 164 (4, 0, 1, 5, 2, 0, 0, 0, 3, 0, 0, 0, 0, 4, 3, 3, 1, 3, 1, 0, 4, 1, 2, 1, 0, 0), # 165 (2, 2, 1, 2, 2, 3, 1, 0, 1, 0, 0, 0, 0, 5, 2, 1, 1, 3, 0, 2, 1, 2, 1, 3, 0, 0), # 166 (3, 1, 3, 2, 4, 3, 1, 0, 0, 0, 0, 0, 0, 9, 2, 2, 1, 2, 0, 0, 0, 0, 1, 0, 0, 0), # 167 (1, 1, 6, 1, 2, 1, 0, 1, 1, 0, 0, 1, 0, 7, 3, 2, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0), # 168 (0, 0, 5, 5, 2, 0, 2, 1, 0, 1, 1, 0, 0, 4, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0), # 169 (1, 3, 1, 1, 3, 0, 0, 1, 0, 0, 0, 1, 0, 2, 1, 5, 0, 1, 0, 0, 2, 1, 1, 1, 0, 0), # 170 (5, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2, 0, 2, 5, 1, 2, 0, 0, 0, 0, 0, 0), # 171 (3, 0, 2, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 2, 1, 1, 2, 1, 1, 1, 2, 2, 0, 0, 0), # 172 (2, 1, 1, 3, 0, 1, 0, 1, 2, 0, 0, 0, 0, 2, 2, 1, 2, 1, 2, 2, 0, 4, 2, 1, 1, 0), # 173 (0, 1, 3, 4, 3, 0, 1, 2, 2, 0, 0, 0, 0, 1, 3, 1, 1, 2, 0, 1, 0, 0, 2, 0, 0, 0), # 174 (2, 2, 2, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 2, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0), # 175 (2, 2, 1, 0, 2, 1, 1, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 1, 0, 2, 1, 1, 0, 0, 0, 0), # 176 (1, 0, 3, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 3, 2, 0, 2, 1, 0, 0, 1, 2, 0, 0, 0), # 177 (2, 0, 1, 0, 0, 0, 0, 2, 0, 1, 0, 1, 0, 4, 2, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0), # 178 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # 179 ) station_arriving_intensity = ( (2.0083462313487073, 2.2101154238772667, 2.0845132918450027, 2.485867109545373, 2.2218742430438447, 1.2554619728149357, 1.6584142461495661, 1.8612704691917692, 2.436039624867203, 1.583206006208948, 1.6821060655542412, 1.9591660313224695, 2.0335520850313453), # 0 (2.1417308608079897, 2.3560242776579035, 2.222138636532061, 2.6500577013106468, 2.3689961349896946, 1.3383934336170222, 1.7677875765054776, 1.9838054891622834, 2.5968981305331638, 1.68759227691086, 1.7932384543824527, 2.088486664325742, 2.1679166589759418), # 1 (2.2746892035918926, 2.5013540683563917, 2.3592169142189654, 2.813595081865918, 2.5155851894998977, 1.420994045804978, 1.8767274031842818, 2.105850099161768, 2.7571147227510195, 1.7915655100082184, 1.9039292595105253, 2.217293060821222, 2.301745931283876), # 2 (2.406703117258625, 2.645528200774579, 2.4952043477279418, 2.9758305630128294, 2.661064670400761, 1.5029362490340452, 1.9848014566591823, 2.226920462997803, 2.916054064368437, 1.8947130793704723, 2.013739364730953, 2.3450742739721844, 2.4345091225016904), # 3 (2.537254459366393, 2.78797007971431, 2.6295571598812146, 3.136115456553028, 2.804857841518597, 1.5838924829594672, 2.0915774674033836, 2.3465327444779662, 3.073080818233083, 1.9966223588670715, 2.12222965383623, 2.4713193569419056, 2.565675453175927), # 4 (2.6658250874734044, 2.9281031099774353, 2.7617315735010073, 3.2938010742881576, 2.946387966679712, 1.6635351872364859, 2.1966231658900894, 2.464203107409837, 3.227559647192624, 2.0968807223674655, 2.228961010618853, 2.595517362893659, 2.694714143853131), # 5 (2.7918968591378666, 3.0653506963658006, 2.8911838114095465, 3.448238728019861, 3.0850783097104175, 1.7415368015203456, 2.299506282592505, 2.5794477156009954, 3.378855214094726, 2.1950755437411034, 2.333494318871313, 2.7171573449907234, 2.821094415079843), # 6 (2.9149516319179876, 3.1991362436812527, 3.017370096429054, 3.598779729549785, 3.2203521344370216, 1.8175697654662883, 2.399794547983834, 2.691782732859021, 3.526332181787058, 2.290794196857435, 2.4353904623861076, 2.8357283563963716, 2.944285487402608), # 7 (3.034471263371974, 3.32888315672564, 3.1397466513817585, 3.744775390679571, 3.3516327046858345, 1.891306518729556, 2.497055692537279, 2.80072432299149, 3.6693552131172824, 2.38362405558591, 2.5342103249557284, 2.950719450273881, 3.063756581367967), # 8 (3.149937611058034, 3.4540148403008093, 3.2577696990898817, 3.8855770232108675, 3.478343284283164, 1.9624195009653935, 2.590857446726048, 2.9057886498059853, 3.8072889709330697, 2.473152493795977, 2.629514790372671, 3.0616196797865256, 3.178976917522465), # 9 (3.2608325325343728, 3.573954699208606, 3.3708954623756497, 4.020535938945315, 3.5999071370553204, 2.030581151829043, 2.680767541023342, 3.0064918771100846, 3.939498118082086, 2.5589668853570857, 2.7208647424294297, 3.167918098097581, 3.2894157164126443), # 10 (3.3666378853592023, 3.6881261382508828, 3.4785801640612863, 4.149003449684559, 3.7157475268286135, 2.0954639109757474, 2.7663537059023664, 3.102350168711366, 4.065347317411997, 2.6406546041386876, 2.8078210649184996, 3.269103758370324, 3.394542198585045), # 11 (3.466835527090725, 3.795952562229479, 3.580280026969016, 4.270330867230245, 3.825287717429351, 2.156740218060748, 2.8471836718363246, 3.1928796884174084, 4.184201231770472, 2.717803024010229, 2.8899446416323737, 3.3646657137680274, 3.493825584586214), # 12 (3.5609073152871504, 3.896857375946248, 3.6754512739210647, 4.383869503384018, 3.9279509726838406, 2.2140825127392896, 2.9228251692984224, 3.2775966000357926, 4.295424524005173, 2.789999518841162, 2.9667963563635475, 3.4540930174539684, 3.586735094962694), # 13 (3.6483351075066865, 3.9902639842030356, 3.763550127739659, 4.488970669947517, 4.023160556418396, 2.2671632346666137, 2.9928459287618647, 3.3560170673740988, 4.398381856963769, 2.8568314625009337, 3.0379370929045137, 3.536874722591424, 3.6727399502610254), # 14 (3.728600761307542, 4.075595791801687, 3.844032811247017, 4.584985678722394, 4.110339732459323, 2.315654823497965, 3.0568136806998503, 3.4276572542399024, 4.4924378934939275, 2.9178862288589964, 3.1029277350477678, 3.6124998823436685, 3.7513093710277525), # 15 (3.8011861342479203, 4.152276203544053, 3.91635554726537, 4.671265841510286, 4.188911764632933, 2.359229718888584, 3.1142961555855906, 3.4920333244407846, 4.5769572964433145, 2.9727511917847984, 3.161329166585805, 3.680457549873976, 3.8219125778094183), # 16 (3.86557308388603, 4.219728624231979, 3.979974558616941, 4.747162470112845, 4.2582999167655355, 2.3975603604937143, 3.1648610838922844, 3.5486614417843274, 4.651304728659594, 3.021013725147787, 3.2127022713111195, 3.740236778345622, 3.8840187911525663), # 17 (3.921243467780082, 4.27737645866731, 4.034346068123952, 4.8120268763317116, 4.317927452683436, 2.4303191879686015, 3.2080761960931405, 3.5970577700781043, 4.7148448529904385, 3.0622612028174148, 3.2566079330162037, 3.791326620921886, 3.9370972316037385), # 18 (3.9676791434882794, 4.3246431116518975, 4.078926298608631, 4.8652103719685265, 4.3672176362129465, 2.4571786409684835, 3.2435092226613578, 3.6367384731296983, 4.766942332283512, 3.0960809986631315, 3.2926070354935515, 3.8332161307660386, 3.9806171197094784), # 19 (4.0043619685688325, 4.360951987987585, 4.113171472893201, 4.906064268824942, 4.405593731180377, 2.4778111591486076, 3.270727894070145, 3.667219714746687, 4.80696182938648, 3.1220604865543837, 3.32026046253566, 3.8653943610413566, 4.01404767601633), # 20 (4.030773800579946, 4.385726492476223, 4.136537813799888, 4.933939878702595, 4.432479001412036, 2.4918891821642144, 3.289299940792704, 3.6880176587366496, 4.834268007147009, 3.139787040360622, 3.339129097935024, 3.8873503649111174, 4.036858121070831), # 21 (4.046396497079832, 4.398390029919658, 4.148481544150914, 4.948188513403135, 4.44729671073423, 2.499085149670547, 3.29879309330224, 3.698648468907166, 4.848225528412766, 3.148848033951297, 3.348773825484136, 3.898573195538596, 4.048517675419531), # 22 (4.052157345337056, 4.399889437585734, 4.149969272976681, 4.949972325102881, 4.451092822413039, 2.5, 3.2999216009037355, 3.6997975308641977, 4.849970493827161, 3.149916909007773, 3.349983214864696, 3.8999590306355736, 4.05), # 23 (4.056404965213662, 4.399014814814815, 4.149725925925926, 4.949752777777778, 4.453243045445941, 2.5, 3.299301525054467, 3.6982, 4.849736666666667, 3.14926024691358, 3.3498498316498324, 3.8996345679012343, 4.05), # 24 (4.060562892084632, 4.397290809327846, 4.149245541838135, 4.949318415637861, 4.455345978237801, 2.5, 3.298079561042524, 3.6950617283950624, 4.849274691358025, 3.1479675354366714, 3.349585359770545, 3.898994055784179, 4.05), # 25 (4.0646308076192135, 4.394743758573389, 4.148534705075447, 4.948674176954732, 4.457401547368442, 2.5, 3.2962746873234887, 3.6904419753086426, 4.84859049382716, 3.14606028349337, 3.349192193540342, 3.8980462734339287, 4.05), # 26 (4.068608393486655, 4.3914, 4.1476, 4.947825, 4.459409679417686, 2.5, 3.2939058823529415, 3.6844, 4.84769, 3.14356, 3.3486727272727275, 3.8968000000000007, 4.05), # 27 (4.0724953313562, 4.387285871056242, 4.146448010973937, 4.946775823045268, 4.461370300965361, 2.5, 3.2909921245864604, 3.6769950617283955, 4.846579135802469, 3.1404881938728852, 3.3480293552812075, 3.895264014631916, 4.05), # 28 (4.0762913028971, 4.382427709190672, 4.145085322359397, 4.94553158436214, 4.463283338591288, 2.5, 3.2875523924796264, 3.6682864197530862, 4.845263827160494, 3.1368663740283496, 3.3472644718792868, 3.893447096479195, 4.05), # 29 (4.079995989778599, 4.376851851851852, 4.143518518518518, 4.944097222222222, 4.4651487188752945, 2.5, 3.2836056644880176, 3.658333333333333, 4.84375, 3.1327160493827164, 3.3463804713804715, 3.8913580246913577, 4.05), # 30 (4.083609073669943, 4.370584636488341, 4.141754183813443, 4.94247767489712, 4.466966368397204, 2.5, 3.279170919067216, 3.6471950617283952, 4.842043580246914, 3.1280587288523094, 3.3453797480982668, 3.8890055784179247, 4.05), # 31 (4.087130236240382, 4.363652400548697, 4.13979890260631, 4.940677880658437, 4.468736213736839, 2.5, 3.2742671346727996, 3.6349308641975315, 4.840150493827161, 3.1229159213534525, 3.344264696346178, 3.886398536808414, 4.05), # 32 (4.090559159159159, 4.356081481481481, 4.13765925925926, 4.938702777777777, 4.470458181474025, 2.5, 3.2689132897603486, 3.6216000000000004, 4.838076666666667, 3.1173091358024694, 3.3430377104377103, 3.8835456790123453, 4.05), # 33 (4.093895524095524, 4.347898216735254, 4.135341838134431, 4.936557304526749, 4.472132198188587, 2.5, 3.263128362785444, 3.6072617283950614, 4.835828024691359, 3.111259881115684, 3.34170118468637, 3.880455784179241, 4.05), # 34 (4.097139012718723, 4.339128943758573, 4.132853223593965, 4.9342463991769545, 4.473758190460348, 2.5, 3.2569313322036635, 3.5919753086419757, 4.833410493827161, 3.1047896662094194, 3.3402575134056613, 3.8771376314586194, 4.05), # 35 (4.100289306698002, 4.3298, 4.1302, 4.931775, 4.475336084869134, 2.5, 3.250341176470588, 3.5758000000000005, 4.83083, 3.0979200000000002, 3.338709090909091, 3.8736000000000006, 4.05), # 36 (4.10334608770261, 4.319937722908093, 4.127388751714678, 4.92914804526749, 4.476865807994769, 2.5, 3.2433768740417976, 3.558795061728395, 4.828092469135803, 3.09067239140375, 3.337058311510164, 3.869851668952904, 4.05), # 37 (4.1063090374017905, 4.3095684499314135, 4.124426063100137, 4.92637047325103, 4.478347286417076, 2.5, 3.2360574033728717, 3.5410197530864203, 4.825203827160494, 3.0830683493369917, 3.3353075695223846, 3.86590141746685, 4.05), # 38 (4.109177837464794, 4.298718518518519, 4.121318518518519, 4.923447222222222, 4.479780446715881, 2.5, 3.2284017429193903, 3.5225333333333335, 4.822170000000001, 3.0751293827160495, 3.3334592592592593, 3.861758024691358, 4.05), # 39 (4.111952169560865, 4.2874142661179695, 4.118072702331961, 4.920383230452675, 4.481165215471008, 2.5, 3.2204288711369324, 3.503395061728396, 4.818996913580247, 3.066877000457248, 3.3315157750342936, 3.8574302697759495, 4.05), # 40 (4.114631715359251, 4.275682030178326, 4.114695198902607, 4.917183436213993, 4.482501519262281, 2.5, 3.212157766481078, 3.4836641975308646, 4.8156904938271605, 3.058332711476909, 3.329479511160993, 3.852926931870142, 4.05), # 41 (4.1172161565292, 4.263548148148149, 4.111192592592594, 4.9138527777777785, 4.483789284669523, 2.5, 3.2036074074074072, 3.4634, 4.812256666666667, 3.0495180246913582, 3.3273528619528623, 3.848256790123457, 4.05), # 42 (4.119705174739957, 4.251038957475995, 4.1075714677640605, 4.910396193415639, 4.485028438272561, 2.5, 3.1947967723715003, 3.4426617283950622, 4.808701358024692, 3.0404544490169183, 3.3251382217234067, 3.8434286236854143, 4.05), # 43 (4.122098451660771, 4.238180795610425, 4.10383840877915, 4.906818621399178, 4.486218906651218, 2.5, 3.185744839828936, 3.4215086419753096, 4.805030493827161, 3.031163493369913, 3.322837984786133, 3.838451211705533, 4.05), # 44 (4.1243956689608865, 4.2250000000000005, 4.1000000000000005, 4.903125, 4.487360616385319, 2.5, 3.1764705882352944, 3.4000000000000004, 4.80125, 3.021666666666667, 3.3204545454545453, 3.833333333333333, 4.05), # 45 (4.126596508309553, 4.211522908093278, 4.096062825788752, 4.8993202674897125, 4.488453494054687, 2.5, 3.1669929960461554, 3.3781950617283956, 4.797365802469136, 3.0119854778235027, 3.3179902980421496, 3.828083767718336, 4.05), # 46 (4.128700651376014, 4.19777585733882, 4.092033470507545, 4.895409362139918, 4.489497466239147, 2.5, 3.1573310417170988, 3.356153086419753, 4.793383827160494, 3.0021414357567444, 3.3154476368624515, 3.82271129401006, 4.05), # 47 (4.130707779829518, 4.183785185185186, 4.087918518518519, 4.891397222222223, 4.490492459518524, 2.5, 3.1475037037037037, 3.333933333333334, 4.78931, 2.992156049382716, 3.312828956228956, 3.8172246913580246, 4.05), # 48 (4.132617575339315, 4.169577229080932, 4.083724554183814, 4.887288786008231, 4.491438400472643, 2.5, 3.137529960461551, 3.3115950617283954, 4.78515024691358, 2.9820508276177415, 3.3101366504551692, 3.8116327389117517, 4.05), # 49 (4.134429719574647, 4.155178326474624, 4.07945816186557, 4.883088991769547, 4.492335215681326, 2.5, 3.12742879044622, 3.2891975308641976, 4.78091049382716, 2.9718472793781436, 3.307373113854595, 3.8059442158207597, 4.05), # 50 (4.136143894204764, 4.140614814814815, 4.075125925925926, 4.8788027777777785, 4.4931828317244, 2.5, 3.11721917211329, 3.2668, 4.776596666666667, 2.961566913580247, 3.304540740740741, 3.8001679012345684, 4.05), # 51 (4.137759780898912, 4.125913031550069, 4.070734430727024, 4.874435082304527, 4.493981175181686, 2.5, 3.1069200839183413, 3.2444617283950614, 4.772214691358025, 2.951231239140375, 3.301641925427111, 3.7943125743026984, 4.05), # 52 (4.139277061326338, 4.1110993141289445, 4.0662902606310025, 4.869990843621399, 4.4947301726330116, 2.5, 3.0965505043169532, 3.222241975308642, 4.767770493827161, 2.9408617649748514, 3.2986790622272104, 3.7883870141746687, 4.05), # 53 (4.140695417156286, 4.0962000000000005, 4.0618, 4.865475, 4.495429750658201, 2.5, 3.086129411764706, 3.2001999999999997, 4.76327, 2.93048, 3.295654545454545, 3.7824, 4.05), # 54 (4.142014530058009, 4.081241426611797, 4.057270233196159, 4.860892489711934, 4.496079835837076, 2.5, 3.075675784717179, 3.178395061728395, 4.758719135802469, 2.920107453132145, 3.292570769422621, 3.7763603109282124, 4.05), # 55 (4.143234081700749, 4.066249931412894, 4.052707544581619, 4.8562482510288065, 4.496680354749464, 2.5, 3.0652086016299527, 3.1568864197530866, 4.754123827160494, 2.909765633287609, 3.2894301284449434, 3.770276726108825, 4.05), # 56 (4.144353753753753, 4.051251851851852, 4.048118518518519, 4.851547222222223, 4.497231233975187, 2.5, 3.0547468409586056, 3.135733333333334, 4.749490000000001, 2.8994760493827165, 3.286235016835017, 3.764158024691358, 4.05), # 57 (4.145373227886272, 4.036273525377229, 4.043509739368999, 4.846794341563786, 4.49773240009407, 2.5, 3.044309481158719, 3.1149950617283952, 4.744823580246914, 2.889260210333791, 3.2829878289063483, 3.7580129858253315, 4.05), # 58 (4.146292185767549, 4.0213412894375855, 4.038887791495199, 4.841994547325103, 4.498183779685938, 2.5, 3.0339155006858713, 3.094730864197531, 4.740130493827161, 2.8791396250571566, 3.27969095897244, 3.7518503886602654, 4.05), # 59 (4.147110309066831, 4.006481481481482, 4.034259259259259, 4.837152777777778, 4.498585299330615, 2.5, 3.0235838779956428, 3.075, 4.7354166666666675, 2.869135802469136, 3.2763468013468016, 3.745679012345679, 4.05), # 60 (4.147827279453366, 3.9917204389574765, 4.02963072702332, 4.832273971193416, 4.498936885607924, 2.5, 3.0133335915436135, 3.0558617283950618, 4.730688024691358, 2.859270251486054, 3.2729577503429357, 3.7395076360310933, 4.05), # 61 (4.148442778596402, 3.977084499314129, 4.025008779149521, 4.827363065843622, 4.499238465097694, 2.5, 3.0031836197853625, 3.0373753086419755, 4.725950493827161, 2.8495644810242347, 3.2695262002743486, 3.7333450388660268, 4.05), # 62 (4.148956488165184, 3.9626, 4.0204, 4.822425000000001, 4.499489964379743, 2.5, 2.9931529411764703, 3.0196000000000005, 4.72121, 2.84004, 3.266054545454546, 3.7272, 4.05), # 63 (4.149368089828959, 3.948293278463649, 4.0158109739369, 4.817464711934157, 4.499691310033899, 2.5, 2.983260534172517, 3.0025950617283956, 4.716472469135803, 2.8307183173296755, 3.2625451801970318, 3.7210812985825337, 4.05), # 64 (4.149677265256975, 3.934190672153635, 4.01124828532236, 4.812487139917696, 4.499842428639987, 2.5, 2.9735253772290813, 2.9864197530864196, 4.711743827160494, 2.821620941929584, 3.2590004988153143, 3.7149977137631454, 4.05), # 65 (4.149883696118478, 3.920318518518519, 4.006718518518519, 4.8074972222222225, 4.499943246777829, 2.5, 2.963966448801743, 2.971133333333334, 4.7070300000000005, 2.8127693827160494, 3.2554228956228957, 3.7089580246913587, 4.05), # 66 (4.149987064082717, 3.9067031550068587, 4.002228257887517, 4.8024998971193416, 4.499993691027252, 2.5, 2.9546027273460824, 2.956795061728396, 4.702336913580247, 2.804185148605396, 3.2518147649332843, 3.7029710105166895, 4.05), # 67 (4.14991664579233, 3.8932994557281293, 3.9977623799725652, 4.797456696188943, 4.499951182118938, 2.49995360463344, 2.9454060779318585, 2.943337540009145, 4.6976351394604485, 2.7958481766588665, 3.2481143954161507, 3.697012008759897, 4.0499500600137175), # 68 (4.149256682769726, 3.879698207885305, 3.99319537037037, 4.792113405797101, 4.499564270152505, 2.4995868312757206, 2.9361072725386457, 2.9300395061728395, 4.692719135802469, 2.787522556281772, 3.243945135566188, 3.69088758934373, 4.049554398148149), # 69 (4.147954315023558, 3.865836983937342, 3.9885073731138543, 4.7864348497047775, 4.498799725651577, 2.4988645023624447, 2.926664053824548, 2.916780978509374, 4.687561156835849, 2.779167809785094, 3.239259554610432, 3.6845691045171236, 4.048772933813444), # 70 (4.146027864257172, 3.851724067436612, 3.9837000342935527, 4.7804294015029525, 4.497667231501654, 2.497798323426307, 2.9170806638155953, 2.9035663465935073, 4.6821688843164155, 2.770784143737056, 3.2340749483135447, 3.678061174885086, 4.047615955075446), # 71 (4.143495652173914, 3.8373677419354837, 3.9787749999999997, 4.774105434782609, 4.496176470588235, 2.4964000000000004, 2.907361344537815, 2.8904, 4.676550000000001, 2.7623717647058825, 3.228408612440192, 3.671368421052632, 4.04609375), # 72 (4.140376000477128, 3.8227762909863268, 3.973733916323731, 4.767471323134729, 4.494337125796821, 2.494681237616217, 2.897510338017237, 2.8772863283036125, 4.670712185642433, 2.7539308792597974, 3.2222778427550356, 3.6644954636247675, 4.04421660665295), # 73 (4.136687230870161, 3.807957998141511, 3.968578429355281, 4.760535440150295, 4.49215888001291, 2.4926537418076515, 2.887531886279889, 2.864229721079104, 4.664663122999543, 2.745461693967025, 3.2156999350227427, 3.657446923206507, 4.041994813100138), # 74 (4.13244766505636, 3.7929211469534048, 3.963310185185185, 4.75330615942029, 4.489651416122005, 2.4903292181069965, 2.8774302313518003, 2.8512345679012348, 4.65841049382716, 2.736964415395788, 3.2086921850079744, 3.650227420402859, 4.039438657407408), # 75 (4.127675624739071, 3.77767402097438, 3.957930829903978, 4.745791854535695, 4.486824417009602, 2.4877193720469446, 2.8672096152589983, 2.8383052583447648, 4.651961979881116, 2.7284392501143118, 3.2012718884753966, 3.6428415758188333, 4.036558427640603), # 76 (4.122389431621637, 3.7622249037568043, 3.952442009602194, 4.738000899087493, 4.483687565561204, 2.4848359091601893, 2.8568742800275118, 2.825446181984454, 4.645325262917239, 2.71988640469082, 3.193456341189675, 3.6352940100594426, 4.03336441186557), # 77 (4.1166074074074075, 3.7465820788530473, 3.9468453703703705, 4.729941666666667, 4.48025054466231, 2.481690534979424, 2.84642846768337, 2.812661728395062, 4.638508024691357, 2.7113060856935367, 3.1852628389154707, 3.6275893437296953, 4.029866898148149), # 78 (4.110347873799726, 3.730753829815479, 3.94114255829904, 4.721622530864198, 4.476523037198419, 2.4782949550373417, 2.8358764202526006, 2.7999562871513493, 4.631517946959305, 2.7026984996906855, 3.176708677417449, 3.619732197434602, 4.026076174554183), # 79 (4.103629152501939, 3.714748440196469, 3.9353352194787377, 4.713051865271068, 4.4725147260550315, 2.474660874866636, 2.8252223797612324, 2.7873342478280754, 4.624362711476909, 2.6940638532504906, 3.1678111524602754, 3.611727191779174, 4.02200252914952), # 80 (4.096469565217392, 3.6985741935483873, 3.929425, 4.704238043478262, 4.468235294117647, 2.4708, 2.8144705882352943, 2.7748000000000004, 4.61705, 2.6854023529411766, 3.1585875598086126, 3.603578947368421, 4.01765625), # 81 (4.088887433649431, 3.682239373423603, 3.9234135459533612, 4.695189439076758, 4.463694424271766, 2.466724035970127, 2.8036252877008145, 2.762357933241884, 4.6095874942844075, 2.6767142053309665, 3.1490551952271253, 3.5952920848073546, 4.013047625171469), # 82 (4.080901079501402, 3.6657522633744857, 3.9173025034293554, 4.685914425657542, 4.458901799402889, 2.4624446883097093, 2.7926907201838214, 2.7500124371284866, 4.6019828760859625, 2.6679996169880846, 3.1392313544804775, 3.586871224700985, 4.008186942729767), # 83 (4.072528824476651, 3.649121146953405, 3.9110935185185185, 4.676421376811595, 4.453867102396514, 2.4579736625514403, 2.7816711277103434, 2.7377679012345677, 4.5942438271604935, 2.6592587944807557, 3.1291333333333333, 3.578320987654321, 4.003084490740741), # 84 (4.063788990278524, 3.6323543077127307, 3.904788237311385, 4.666718666129898, 4.448600016138143, 2.4533226642280144, 2.77057075230641, 2.7256287151348886, 4.586378029263831, 2.6504919443772024, 3.1187784275503576, 3.569645994272375, 3.9977505572702334), # 85 (4.054699898610365, 3.6154600292048324, 3.8983883058984916, 4.656814667203436, 4.443110223513274, 2.4485033988721234, 2.7593938359980483, 2.7135992684042067, 4.578393164151807, 2.6416992732456497, 3.108183932896214, 3.5608508651601576, 3.992195430384088), # 86 (4.045279871175523, 3.5984465949820788, 3.8918953703703703, 4.6467177536231885, 4.437407407407409, 2.443527572016461, 2.7481446208112876, 2.701683950617284, 4.570296913580248, 2.632880987654321, 3.097367145135566, 3.551940220922677, 3.9864293981481485), # 87 (4.035547229677343, 3.5813222885968403, 3.8853110768175583, 4.63643629898014, 4.431501250706044, 2.4384068891937205, 2.7368273487721564, 2.68988715134888, 4.562096959304984, 2.6240372941714405, 3.0863453600330795, 3.542918682164946, 3.9804627486282587), # 88 (4.025520295819169, 3.564095393601487, 3.87863707133059, 4.625978676865271, 4.425401436294683, 2.4331530559365953, 2.7254462619066833, 2.678213260173754, 4.553800983081848, 2.615168399365233, 3.0751358733534175, 3.533790869491974, 3.9743057698902606), # 89 (4.015217391304348, 3.546774193548387, 3.871875, 4.615353260869566, 4.419117647058824, 2.427777777777778, 2.7140056022408965, 2.6666666666666665, 4.545416666666667, 2.6062745098039217, 3.0637559808612442, 3.524561403508772, 3.9679687500000003), # 90 (4.004656837836225, 3.529366971989911, 3.8650265089163236, 4.604568424584005, 4.412659565883966, 2.4222927602499618, 2.7025096118008247, 2.6552517604023778, 4.536951691815273, 2.5973558320557304, 3.052222978321224, 3.5152349048203497, 3.961461977023319), # 91 (3.9938569571181493, 3.511882012478429, 3.858093244170096, 4.593632541599571, 4.406036875655611, 2.4167097088858407, 2.690962532612497, 2.6439729309556474, 4.528413740283494, 2.588412572688884, 3.0405541614980214, 3.5058159940317193, 3.954795739026063), # 92 (3.982836070853462, 3.4943275985663087, 3.851076851851852, 4.582553985507247, 4.399259259259259, 2.411040329218107, 2.6793686067019404, 2.632834567901235, 4.519810493827161, 2.579444938271605, 3.0287668261563, 3.496309291747888, 3.9479803240740736), # 93 (3.971612500745512, 3.476712013805921, 3.8439789780521267, 4.571341129898014, 4.392336399580408, 2.4052963267794545, 2.6677320760951844, 2.621841060813901, 4.511149634202104, 2.570453135372119, 3.016878268060724, 3.4867194185738697, 3.9410260202331964), # 94 (3.960204568497644, 3.4590435417496352, 3.8368012688614543, 4.560002348362856, 4.3852779795045596, 2.399489407102576, 2.6560571828182575, 2.6109967992684044, 4.502438843164152, 2.5614373705586484, 3.0049057829759587, 3.477050995114672, 3.933943115569273), # 95 (3.948630595813205, 3.4413304659498216, 3.829545370370371, 4.548546014492754, 4.378093681917211, 2.3936312757201645, 2.6443481688971886, 2.6003061728395065, 4.493685802469136, 2.5523978503994194, 2.992866666666667, 3.4673086419753094, 3.9267418981481486), # 96 (3.936908904395539, 3.4235810699588485, 3.82221292866941, 4.53698050187869, 4.370793189703866, 2.3877336381649137, 2.6326092763580053, 2.5897735711019667, 4.484898193872886, 2.543334781462654, 2.980778214897513, 3.457496979760788, 3.919432656035666), # 97 (3.925057815947994, 3.4058036373290856, 3.814805589849108, 4.525314184111648, 4.363386185750021, 2.3818081999695173, 2.6208447472267373, 2.5794033836305443, 4.476083699131229, 2.534248370316577, 2.9686577234331626, 3.4476206290761193, 3.9120256772976685), # 98 (3.9130956521739133, 3.3880064516129034, 3.8073250000000005, 4.513555434782609, 4.355882352941177, 2.3758666666666666, 2.6090588235294123, 2.5692000000000004, 4.46725, 2.525138823529412, 2.956522488038278, 3.437684210526316, 3.9045312500000002), # 99 (3.901040734776645, 3.3701977963626706, 3.79977280521262, 4.501712627482555, 4.348291374162834, 2.3699207437890566, 2.597255747292058, 2.559167809785094, 4.458404778235026, 2.5160063476693835, 2.944389804477524, 3.427692344716387, 3.896959662208505), # 100 (3.888911385459534, 3.3523859551307584, 3.792150651577504, 4.4897941358024696, 4.340622932300493, 2.3639821368693794, 2.585439760540705, 2.549311202560585, 4.449555715592136, 2.5068511493047154, 2.932276968515565, 3.4176496522513413, 3.8893212019890258), # 101 (3.8767259259259266, 3.3345792114695345, 3.784460185185185, 4.477808333333334, 4.332886710239651, 2.3580625514403297, 2.5736151053013803, 2.539634567901235, 4.440710493827161, 2.4976734350036316, 2.9202012759170657, 3.4075607537361927, 3.881626157407408), # 102 (3.864502677879168, 3.316785848931369, 3.7767030521262, 4.46576359366613, 4.325092390865811, 2.3521736930345987, 2.561786023600112, 2.530142295381802, 4.43187679469593, 2.488473411334356, 2.9081800224466896, 3.397430269775949, 3.873884816529492), # 103 (3.852259963022604, 3.2990141510686315, 3.7688808984910835, 4.453668290391842, 4.317249657064472, 2.3463272671848805, 2.5499567574629305, 2.5208387745770464, 4.4230622999542755, 2.4792512848651125, 2.8962305038691003, 3.3872628209756215, 3.8661074674211253), # 104 (3.840016103059581, 3.2812724014336916, 3.7609953703703702, 4.441530797101449, 4.309368191721133, 2.3405349794238686, 2.5381315489158633, 2.511728395061729, 4.414274691358025, 2.4700072621641254, 2.8843700159489636, 3.3770630279402214, 3.858304398148148), # 105 (3.8277894196934454, 3.2635688835789196, 3.7530481138545952, 4.429359487385937, 4.301457677721294, 2.3348085352842554, 2.526314639984938, 2.5028155464106083, 4.405521650663008, 2.460741549799618, 2.872615854450942, 3.3668355112747577, 3.850485896776406), # 106 (3.8155982346275423, 3.2459118810566845, 3.745040775034294, 4.417162734836285, 4.293527797950456, 2.329159640298735, 2.5145102726961848, 2.494104618198446, 4.396810859625058, 2.4514543543398157, 2.860985315139701, 3.356584891584242, 3.842662251371742), # 107 (3.8034608695652175, 3.2283096774193556, 3.7369750000000006, 4.404948913043479, 4.285588235294117, 2.3236000000000003, 2.5027226890756302, 2.4856000000000003, 4.38815, 2.4421458823529414, 2.8494956937799043, 3.346315789473685, 3.8348437500000006), # 108 (3.7913956462098173, 3.210770556219302, 3.72885243484225, 4.392726395598497, 4.27764867263778, 2.318141319920744, 2.490956131149305, 2.4773060813900325, 4.379546753543667, 2.432816340407219, 2.838164286136216, 3.336032825548095, 3.8270406807270234), # 109 (3.7794208862646865, 3.193302801008895, 3.7206747256515786, 4.380503556092324, 4.269718792866942, 2.3127953055936596, 2.4792148409432357, 2.4692272519433014, 4.371008802011889, 2.4234659350708734, 2.8270083879733003, 3.3257406204124855, 3.819263331618656), # 110 (3.7675549114331726, 3.175914695340502, 3.712443518518519, 4.368288768115942, 4.261808278867103, 2.3075736625514405, 2.4675030604834527, 2.461367901234568, 4.362543827160494, 2.414094872912128, 2.8160452950558215, 3.3154437946718653, 3.811521990740741), # 111 (3.75581604341862, 3.1586145227664937, 3.7041604595336084, 4.356090405260333, 4.253926813523764, 2.3024880963267798, 2.4558250317959835, 2.453732418838592, 4.354159510745313, 2.4047033604992065, 2.805292303148444, 3.3051469689312443, 3.803826946159122), # 112 (3.744201689481218, 3.141439447514381, 3.6958471313008276, 4.343933552996816, 4.246070272069482, 2.2975479076858054, 2.444210385462708, 2.4463410275122426, 4.345885124503448, 2.395321894645092, 2.7947695624611466, 3.2948771746017713, 3.7961775603372887), # 113 (3.732592359160026, 3.1245588734102143, 3.6876182700086475, 4.331915768510934, 4.238157341826531, 2.2927418434119606, 2.432807283364232, 2.439284503802048, 4.3378476142852245, 2.386126067165113, 2.784497734845279, 3.28476486884519, 3.788510165664014), # 114 (3.720953961201598, 3.107978879473219, 3.679478773082927, 4.320033802072712, 4.230163071155441, 2.2880574049995057, 2.421623860076625, 2.4325610617114837, 4.330049991467516, 2.377130131195231, 2.7744618045708376, 3.2748150330235406, 3.7808026526641507), # 115 (3.709271949295054, 3.091675312516681, 3.6714128759935494, 4.3082664601065614, 4.222075410553511, 2.283483550914839, 2.4106419270111576, 2.4261521251595974, 4.322472535691133, 2.368317343379819, 2.7646423725085927, 3.2650092789949383, 3.7730429039023563), # 116 (3.697531777129509, 3.0756240193538886, 3.6634048142103945, 4.296592549036897, 4.213882310518044, 2.279009239624356, 2.399843295579101, 2.420039118065434, 4.315095526596881, 2.3596709603632515, 2.755020039529313, 3.2553292186175002, 3.76521880194329), # 117 (3.6857188983940845, 3.0598008467981295, 3.655438823203347, 4.284990875288133, 4.205571721546337, 2.2746234295944556, 2.3892097771917262, 2.414203464348039, 4.307899243825574, 2.3511742387899037, 2.74557540650377, 3.24575646374934, 3.75731822935161), # 118 (3.673818766777897, 3.044181641662692, 3.6474991384422895, 4.273440245284682, 4.197131594135689, 2.270315079291533, 2.3787231832603024, 2.408626587926458, 4.300863967018017, 2.342810435304149, 2.7362890743027313, 3.236272626248574, 3.749329068691973), # 119 (3.6618168359700647, 3.0287422507608635, 3.639569995397105, 4.261919465450958, 4.188549878783399, 2.266073147181986, 2.3683653251961014, 2.403289912719737, 4.293969975815023, 2.334562806550362, 2.7271416437969664, 3.226859317973319, 3.741239202529039), # 120 (3.6496985596597074, 3.0134585209059317, 3.631635629537675, 4.250407342211374, 4.179814525986767, 2.261886591732212, 2.358118014410392, 2.398174862646923, 4.2871975498573995, 2.3264146091729185, 2.7181137158572466, 3.217498150781689, 3.7330365134274643), # 121 (3.6374493915359416, 2.9983062989111846, 3.6236802763338845, 4.238882681990343, 4.170913486243093, 2.2577443714086076, 2.347963062314447, 2.3932628616270595, 4.2805269687859555, 2.318349099816191, 2.7091858913543407, 3.2081707365318004, 3.7247088839519082), # 122 (3.6250547852878876, 2.9832614315899098, 3.6156881712556146, 4.227324291212278, 4.161834710049677, 2.25363544467757, 2.3378822803195356, 2.3885353335791932, 4.273938512241502, 2.310349535124555, 2.700338771159018, 3.198858687081769, 3.716244196667029), # 123 (3.612500194604662, 2.968299765755395, 3.607643549772748, 4.215710976301595, 4.152566147903815, 2.2495487700054957, 2.327857479836928, 2.3839737024223706, 4.267412459864846, 2.3023991717423846, 2.691552956142048, 3.1895436142897102, 3.7076303341374848), # 124 (3.5997710731753836, 2.9533971482209282, 3.5995306473551696, 4.204021543682704, 4.143095750302809, 2.2454733058587824, 2.3178704722778956, 2.3795593920756364, 4.260929091296798, 2.2944812663140537, 2.6828090471742008, 3.1802071300137396, 3.6988551789279316), # 125 (3.5868528746891712, 2.938529425799798, 3.5913336994727594, 4.192234799780022, 4.133411467743957, 2.241398010703827, 2.307903069053708, 2.375273826458037, 4.254468686178167, 2.286579075483937, 2.6740876451262454, 3.170830846111974, 3.6899066136030316), # 126 (3.5737310528351447, 2.92367244530529, 3.583036941595402, 4.18032955101796, 4.123501250724559, 2.237311843007026, 2.2979370815756375, 2.3710984294886184, 4.248011524149763, 2.2786758558964095, 2.6653693508689518, 3.1613963744425266, 3.6807725207274395), # 127 (3.5603910613024183, 2.908802053550694, 3.57462460919298, 4.168284603820933, 4.113353049741916, 2.2332037612347775, 2.287954321254953, 2.367014625086425, 4.241537884852394, 2.2707548641958453, 2.6566347652730897, 3.1518853268635154, 3.671440782865815), # 128 (3.546818353780113, 2.8938940973492966, 3.566080937735376, 4.156078764613353, 4.102954815293325, 2.229062723853478, 2.2779365995029255, 2.363003837170504, 4.23502804792687, 2.2627993570266183, 2.6478644892094287, 3.1422793152330546, 3.6618992825828154), # 129 (3.532998383957347, 2.8789244235143867, 3.5573901626924718, 4.143690839819635, 4.092294497876085, 2.2248776893295235, 2.267865727730825, 2.3590474896599, 4.228462293014, 2.254792591033103, 2.639039123548738, 3.1325599514092612, 3.6521359024430993), # 130 (3.5189166055232377, 2.863868878859251, 3.5485365195341525, 4.1310996358641905, 4.081360047987498, 2.2206376161293124, 2.2577235173499237, 2.35512700647366, 4.2218208997545945, 2.246717822859674, 2.6301392691617873, 3.1227088472502498, 3.6421385250113247), # 131 (3.504558472166904, 2.8487033101971777, 3.5395042437302986, 4.118283959171435, 4.070139416124862, 2.216331462719241, 2.24749177977149, 2.3512238115308293, 4.215084147789462, 2.2385583091507057, 2.6211455269193458, 3.112707614614137, 3.6318950328521504), # 132 (3.4899094375774653, 2.833403564341454, 3.5302775707507936, 4.105222616165781, 4.058620552785475, 2.2119481875657065, 2.237152326406796, 2.347319328750453, 4.2082323167594105, 2.230297306550573, 2.6120384976921844, 3.102537865359037, 3.6213933085302346), # 133 (3.474954955444038, 2.8179454881053694, 3.5208407360655216, 4.091894413271642, 4.046791408466637, 2.207476749135106, 2.2266869686671114, 2.3433949820515774, 4.201245686305252, 2.2219180717036493, 2.6027987823510714, 3.0921812113430667, 3.6106212346102335), # 134 (3.4596804794557414, 2.8023049283022097, 3.5111779751443635, 4.078278156913432, 4.034639933665648, 2.202906105893837, 2.2160775179637073, 2.339432195353248, 4.194104536067792, 2.2134038612543105, 2.593406981766777, 3.081619264424341, 3.599566693656808), # 135 (3.444071463301694, 2.786457731745264, 3.5012735234572037, 4.064352653515562, 4.022154078879807, 2.198225216308296, 2.205305785707854, 2.335412392574511, 4.186789145687842, 2.204737931846929, 2.583843696810071, 3.0708336364609767, 3.5882175682346147), # 136 (3.4281133606710137, 2.770379745247819, 3.4911116164739244, 4.0500967095024505, 4.0093217946064135, 2.1934230388448794, 2.1943535833108223, 2.3313169976344117, 4.179279794806213, 2.195903540125881, 2.5740895283517222, 3.059805939311088, 3.5765617409083106), # 137 (3.4117916252528193, 2.7540468156231634, 3.480676489664407, 4.0354891312985055, 3.9961310313427676, 2.1884885319699854, 2.1832027221838817, 2.327127434451996, 4.1715567630637125, 2.186883942735539, 2.564125077262501, 3.048517784832791, 3.5645870942425564), # 138 (3.3950917107362275, 2.7374347896845848, 3.469952378498536, 4.020508725328144, 3.9825697395861663, 2.1834106541500105, 2.171835013738304, 2.32282512694631, 4.163600330101149, 2.177662396320279, 2.5539309444131764, 3.0369507848842026, 3.5522815108020076), # 139 (3.3779990708103593, 2.72051951424537, 3.458923518446195, 4.005134298015778, 3.968625869833912, 2.1781783638513517, 2.1602322693853586, 2.3183914990363985, 4.155390775559333, 2.1682221575244744, 2.5434877306745176, 3.0250865513234366, 3.539632873151326), # 140 (3.3604991591643323, 2.7032768361188086, 3.4475741449772643, 3.989344655785821, 3.9542873725833014, 2.172780619540406, 2.148376300536318, 2.3138079746413083, 4.146908379079072, 2.1585464829925005, 2.5327760369172956, 3.01290669600861, 3.5266290638551654), # 141 (3.3425774294872626, 2.6856826021181863, 3.4358884935616283, 3.9731186050626883, 3.939542198331635, 2.167206379683571, 2.1362489186024507, 2.3090559776800847, 4.138133420301177, 2.1486186293687313, 2.521776464012279, 3.000392830797838, 3.5132579654781866), # 142 (3.32421933546827, 2.6677126590567926, 3.4238507996691703, 3.95643495227079, 3.9243782975762116, 2.1614446027472427, 2.1238319349950276, 2.3041169320717727, 4.129046178866459, 2.138421853297541, 2.5104696128302373, 2.987526567549236, 3.499507460585047), # 143 (3.305410330796474, 2.6493428537479145, 3.411445298769771, 3.939272503834543, 3.9087836208143316, 2.1554842471978186, 2.1111071611253194, 2.2989722617354196, 4.119626934415724, 2.127939411423304, 2.4988360842419404, 2.9742895181209197, 3.485365431740406), # 144 (3.286135869160991, 2.63054903300484, 3.3986562263333155, 3.921610066178358, 3.892746118543293, 2.149314271501696, 2.0980564084045974, 2.2936033905900706, 4.109855966589782, 2.117154560390395, 2.486856479118158, 2.9606632943710056, 3.47081976150892), # 145 (3.2663814042509403, 2.6113070436408568, 3.385467817829687, 3.9034264457266503, 3.8762537412603972, 2.1429236341252724, 2.084661488244132, 2.287991742554771, 4.099713555029442, 2.106050556843188, 2.4745113983296596, 2.946629508157608, 3.4558583324552474), # 146 (3.24613238975544, 2.5915927324692523, 3.371864308728764, 3.884700448903832, 3.859294439462941, 2.136301293534943, 2.0709042120551926, 2.282118741548566, 4.089179979375516, 2.0946106574260583, 2.4617814427472147, 2.9321697713388444, 3.4404690271440472), # 147 (3.2253742793636087, 2.5713819463033154, 3.357829934500433, 3.8654108821343187, 3.8418561636482247, 2.129436208197107, 2.0567663912490506, 2.275965811490503, 4.078235519268811, 2.0828181187833787, 2.448647213241593, 2.9172656957728282, 3.4246397281399767), # 148 (3.204092526764565, 2.5506505319563324, 3.3433489306145776, 3.845536551842521, 3.8239268643135484, 2.12231733657816, 2.0422298372369765, 2.2695143762996266, 4.066860454350135, 2.0706561975595252, 2.435089310683564, 2.901898893317677, 3.408358318007695), # 149 (3.182272585647426, 2.5293743362415917, 3.328405532541078, 3.825056264452855, 3.8054944919562104, 2.1149336371444996, 2.0272763614302405, 2.2627458598949826, 4.055035064260301, 2.0581081503988705, 2.4210883359438973, 2.8860509758315054, 3.3916126793118586), # 150 (3.15989990970131, 2.5075292059723817, 3.312983975749817, 3.803948826389732, 3.786546997073511, 2.107274068362522, 2.011887775240113, 2.2556416861956174, 4.042739628640116, 2.0451572339457913, 2.406624889893362, 2.869703555172429, 3.3743906946171274), # 151 (3.1369599526153373, 2.485090987961989, 3.297068495710681, 3.7821930440775677, 3.7670723301627476, 2.0993275886986256, 1.996045890077866, 2.2481832791205765, 4.029954427130388, 2.03178670484466, 2.3916795734027287, 2.8528382431985637, 3.356680246488159), # 152 (3.1134381680786243, 2.462035529023703, 3.2806433278935474, 3.759767723940773, 3.7470584417212223, 2.0910831566192063, 1.9797325173547677, 2.240352062588905, 4.01665973937193, 2.0179798197398515, 2.3762329873427666, 2.835436651768026, 3.338469217489611), # 153 (3.0893200097802915, 2.43833867597081, 3.2636927077683033, 3.736651672403764, 3.726493282246232, 2.082529730590662, 1.9629294684820913, 2.232129460519649, 4.002835845005547, 2.0037198352757413, 2.360265732584245, 2.81748039273893, 3.319745490186143), # 154 (3.0645909314094544, 2.413976275616598, 3.2462008708048304, 3.7128236958909513, 3.7053648022350787, 2.0736562690793887, 1.9456185548711045, 2.2234968968318545, 3.9884630236720513, 1.9889900080967018, 2.343758409997933, 2.798951077969393, 3.3004969471424106), # 155 (3.0392363866552325, 2.3889241747743553, 3.2281520524730105, 3.68826260082675, 3.6836609521850594, 2.0644517305517844, 1.92778158793308, 2.2144357954445675, 3.9735215550122507, 1.9737735948471091, 2.3266916204546018, 2.7798303193175293, 3.280711470923074), # 156 (3.013241829206745, 2.3631582202573695, 3.209530488242727, 3.662947193635575, 3.661369682593474, 2.0549050734742456, 1.9094003790792877, 2.204927580276833, 3.9579917186669555, 1.9580538521713367, 2.3090459648250197, 2.760099728641455, 3.2603769440927906), # 157 (2.985872378562096, 2.3361812483089035, 3.1894367815609423, 3.6359078326604974, 3.637472442348399, 2.044409790526844, 1.890042688371143, 2.194318780939749, 3.9406648366396393, 1.9413463665164574, 2.290238301015577, 2.739039825677736, 3.238594343766138), # 158 (2.9529147067913613, 2.305226127839791, 3.162695127361195, 3.6015908635153817, 3.6060765239126513, 2.0294758592028415, 1.8672851053542865, 2.178885413105753, 3.914570904488858, 1.9209123976394982, 2.2669667742475976, 2.7125450094732435, 3.210171058768078), # 159 (2.913948837961724, 2.2700386914162856, 3.1287683831823556, 3.559431004163544, 3.5665680525387184, 2.0097365184190736, 1.8408974993535137, 2.158239675810939, 3.8789700908914604, 1.8964822607451575, 2.238903803443816, 2.680200779555139, 3.1745682435574323), # 160 (2.869288821834384, 2.2308483472321874, 3.0880187887641237, 3.509829001502691, 3.5193572497128454, 1.9854308966281256, 1.8110725784027506, 2.132640213243912, 3.834331906799607, 1.8682632772683752, 2.206296661839883, 2.6423069875630283, 3.132149617927639), # 161 (2.8192487081705426, 2.1878845034812957, 3.0408085838461982, 3.4531856024305307, 3.464854336921282, 1.9567981222825823, 1.7780030505359237, 2.102345669593281, 3.781125863165455, 1.8364627686440926, 2.1693926226714484, 2.5991634851365175, 3.0832789016721334), # 162 (2.7641425467313994, 2.1413765683574097, 2.987500008168281, 3.3899015538447737, 3.4034695356502755, 1.924077323835029, 1.7418816237869603, 2.06761468904765, 3.7198214709411626, 1.80128805630725, 2.1284389591741633, 2.5510701239152134, 3.0283198145843517), # 163 (2.704284387278154, 2.0915539500543283, 2.9284553014700707, 3.320377602643127, 3.3356130673860758, 1.8875076297380518, 1.7029010061897865, 2.0287059157956278, 3.6508882410788894, 1.7629464616927875, 2.0836829445836784, 2.4983267555387214, 2.9676360764577314), # 164 (2.639988279572007, 2.038646056765853, 2.8640367034912675, 3.245014495723301, 3.2616951536149297, 1.8473281684442346, 1.6612539057783289, 1.9858779940258184, 3.574795684530792, 1.7216453062356454, 2.0353718521356448, 2.441233231646648, 2.901591407085708), # 165 (2.571568273374159, 1.9828822966857818, 2.7946064539715714, 3.1642129799830006, 3.1821260158230857, 1.8037780684061635, 1.6171330305865146, 1.939389567926831, 3.4920133122490293, 1.677591911370765, 1.9837529550657118, 2.3800894038786007, 2.830549526261718), # 166 (2.4993384184458094, 1.9244920780079149, 2.720526792650682, 3.0783738023199376, 3.097315875496792, 1.7570964580764235, 1.57073108864827, 1.8894992816872707, 3.40301063518576, 1.6309935985330857, 1.929073526609531, 2.3151951238741835, 2.7548741537791983), # 167 (2.4236127645481584, 1.8637048089260515, 2.6421599592682994, 2.9878977096318184, 3.007674954122297, 1.7075224659075996, 1.5222407879975217, 1.836465779495744, 3.308257164293142, 1.5820576891575489, 1.8715808400027525, 2.2468502432730046, 2.674929009431585), # 168 (2.344705361442406, 1.8007498976339917, 2.5598681935641237, 2.8931854488163533, 2.913613473185848, 1.655295220352278, 1.4718548366681967, 1.780547705540858, 3.2082224105233355, 1.5309915046790947, 1.8115221684810274, 2.175354613714669, 2.591077813012314), # 169 (2.2629302588897535, 1.735856752325535, 2.474013735277854, 2.794637766771248, 2.8155416541736935, 1.6006538498630427, 1.4197659426942213, 1.722003704011219, 3.1033758848284956, 1.4780023665326631, 1.7491447852800066, 2.1010080868387835, 2.503684284314822), # 170 (2.1786015066514, 1.6692547811944802, 2.3849588241491912, 2.6926554103942144, 2.7138697185720826, 1.5438374828924795, 1.3661668141095222, 1.6610924190954333, 2.9941870981607828, 1.4232975961531955, 1.6846959636353394, 2.0241105142849545, 2.413112143132546), # 171 (2.092033154488546, 1.6011733924346279, 2.2930656999178347, 2.5876391265829586, 2.6090078878672616, 1.4850852478931735, 1.3112501589480263, 1.5980724949821083, 2.8811255614723543, 1.367084514975632, 1.6184229767826777, 1.9449617476927885, 2.3197251092589215), # 172 (2.003539252162392, 1.531841994239777, 2.198696602323485, 2.4799896622351905, 2.5013663835454807, 1.42463627331771, 1.25520868524366, 1.5332025758598495, 2.7646607857153693, 1.3095704444349128, 1.5505730979576713, 1.86386163870189, 2.223886902487385), # 173 (1.9134338494341376, 1.4614899948037272, 2.102213771105841, 2.3701077642486164, 2.3913554270929867, 1.362729687618674, 1.1982351010303502, 1.4667413059172643, 2.6452622818419855, 1.2509627059659787, 1.4813936003959711, 1.7811100389518673, 2.1259612426113734), # 174 (1.8220309960649823, 1.3903468023202779, 2.003979446004603, 2.258394179520947, 2.2793852399960275, 1.2996046192486514, 1.1405221143420232, 1.3989473293429584, 2.5233995608043625, 1.1914686210037697, 1.4111317573332278, 1.6970068000823257, 2.026311849424323), # 175 (1.7296447418161276, 1.3186418249832292, 1.9043558667594713, 2.14524965494989, 2.165866043740852, 1.2355001966602268, 1.082262433212606, 1.3300792903255396, 2.399542133554657, 1.1312955109832268, 1.340034842005092, 1.6118517737328717, 1.9253024427196697), # 176 (1.636589136448773, 1.2466044709863806, 1.8037052731101455, 2.031074937433153, 2.0512080598137095, 1.1706555483059853, 1.0236487656760251, 1.2603958330536131, 2.274159511045028, 1.0706506973392897, 1.2683501276472144, 1.5259448115431116, 1.82329674229085), # 177 (1.5431782297241188, 1.1744641485235314, 1.7023899047963256, 1.9162707738684466, 1.9358215097008455, 1.105309802638513, 0.964873819766207, 1.1901556017157862, 2.147721204227634, 1.0097415015069, 1.196324887495245, 1.439585765152651, 1.7206584679313008), # 178 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), # 179 ) passenger_arriving_acc = ( (2, 0, 1, 3, 1, 1, 2, 1, 0, 1, 0, 0, 0, 3, 1, 3, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0), # 0 (4, 2, 5, 5, 1, 2, 2, 2, 2, 1, 0, 1, 0, 7, 7, 4, 3, 3, 1, 1, 1, 2, 0, 0, 0, 0), # 1 (6, 4, 8, 8, 1, 4, 2, 3, 3, 1, 1, 1, 0, 9, 8, 8, 5, 5, 1, 4, 2, 3, 0, 0, 1, 0), # 2 (12, 5, 10, 9, 4, 5, 2, 4, 5, 2, 1, 1, 0, 11, 9, 10, 8, 6, 1, 4, 3, 3, 1, 0, 2, 0), # 3 (14, 10, 13, 14, 4, 5, 2, 4, 6, 2, 1, 2, 0, 12, 14, 11, 9, 8, 2, 5, 4, 3, 2, 2, 2, 0), # 4 (16, 12, 16, 15, 5, 6, 2, 5, 7, 2, 3, 2, 0, 13, 15, 12, 10, 9, 5, 8, 6, 3, 2, 2, 3, 0), # 5 (20, 17, 17, 19, 5, 8, 2, 6, 8, 4, 5, 3, 0, 17, 16, 13, 10, 10, 6, 9, 7, 3, 3, 3, 3, 0), # 6 (21, 19, 20, 25, 5, 9, 4, 7, 8, 4, 7, 4, 0, 18, 18, 15, 11, 15, 7, 9, 11, 5, 3, 6, 3, 0), # 7 (22, 23, 21, 28, 6, 11, 5, 7, 8, 5, 7, 4, 0, 22, 21, 19, 15, 16, 7, 9, 11, 7, 3, 8, 4, 0), # 8 (26, 23, 22, 30, 7, 13, 7, 8, 9, 6, 7, 4, 0, 25, 26, 21, 18, 18, 10, 10, 14, 7, 3, 9, 4, 0), # 9 (27, 23, 22, 34, 9, 15, 9, 9, 9, 6, 8, 4, 0, 32, 29, 25, 18, 18, 15, 11, 16, 7, 5, 9, 4, 0), # 10 (30, 26, 25, 38, 12, 16, 9, 9, 11, 7, 8, 4, 0, 37, 32, 29, 19, 19, 16, 12, 18, 8, 8, 10, 4, 0), # 11 (33, 29, 29, 40, 15, 16, 9, 10, 13, 9, 9, 4, 0, 39, 35, 32, 23, 22, 19, 12, 19, 8, 8, 11, 4, 0), # 12 (36, 32, 30, 41, 18, 17, 10, 10, 15, 11, 10, 5, 0, 43, 39, 33, 25, 23, 20, 12, 21, 11, 11, 12, 4, 0), # 13 (39, 34, 33, 44, 19, 18, 11, 11, 16, 12, 10, 5, 0, 46, 41, 35, 31, 30, 22, 15, 22, 12, 11, 13, 5, 0), # 14 (45, 35, 34, 46, 21, 19, 11, 12, 18, 12, 10, 5, 0, 49, 45, 39, 31, 34, 23, 18, 22, 14, 12, 13, 5, 0), # 15 (49, 38, 34, 49, 21, 20, 14, 13, 19, 14, 11, 6, 0, 51, 51, 41, 34, 36, 25, 20, 22, 15, 14, 13, 5, 0), # 16 (54, 49, 35, 56, 25, 22, 14, 14, 22, 14, 12, 6, 0, 54, 52, 46, 36, 42, 25, 21, 24, 16, 14, 13, 5, 0), # 17 (60, 53, 37, 60, 26, 23, 16, 14, 22, 14, 12, 6, 0, 59, 54, 46, 37, 47, 25, 22, 24, 16, 14, 15, 7, 0), # 18 (66, 59, 40, 63, 30, 23, 18, 16, 24, 15, 12, 7, 0, 62, 57, 51, 39, 51, 28, 22, 25, 17, 14, 15, 8, 0), # 19 (74, 65, 43, 67, 32, 25, 22, 19, 27, 16, 12, 8, 0, 65, 57, 52, 43, 54, 29, 25, 26, 19, 17, 17, 8, 0), # 20 (79, 69, 45, 73, 34, 27, 23, 20, 31, 18, 15, 8, 0, 69, 61, 54, 45, 62, 33, 26, 28, 19, 17, 19, 8, 0), # 21 (82, 73, 49, 76, 38, 28, 24, 20, 32, 20, 16, 8, 0, 72, 63, 54, 46, 64, 35, 28, 29, 20, 19, 21, 8, 0), # 22 (83, 75, 54, 80, 41, 28, 26, 24, 35, 22, 16, 8, 0, 79, 68, 56, 49, 70, 38, 30, 32, 23, 20, 21, 8, 0), # 23 (85, 83, 55, 83, 42, 31, 27, 27, 37, 23, 17, 9, 0, 85, 73, 56, 52, 72, 41, 31, 32, 24, 24, 22, 8, 0), # 24 (92, 86, 58, 86, 45, 31, 28, 27, 39, 24, 18, 9, 0, 89, 73, 58, 56, 76, 45, 31, 32, 24, 25, 22, 9, 0), # 25 (96, 86, 60, 89, 47, 35, 29, 28, 40, 26, 19, 9, 0, 94, 74, 61, 58, 77, 46, 32, 32, 24, 26, 22, 9, 0), # 26 (101, 90, 66, 93, 48, 36, 30, 30, 43, 28, 23, 9, 0, 97, 78, 61, 59, 78, 46, 34, 32, 24, 26, 22, 9, 0), # 27 (104, 95, 70, 95, 51, 38, 31, 31, 45, 28, 25, 10, 0, 100, 82, 67, 61, 84, 47, 35, 32, 25, 26, 23, 9, 0), # 28 (107, 99, 72, 104, 51, 40, 33, 33, 49, 29, 25, 10, 0, 105, 85, 70, 62, 89, 49, 35, 34, 26, 28, 23, 9, 0), # 29 (113, 103, 73, 106, 55, 41, 34, 36, 50, 29, 26, 11, 0, 110, 89, 73, 64, 91, 50, 38, 34, 29, 29, 23, 12, 0), # 30 (114, 107, 77, 111, 56, 43, 36, 38, 53, 30, 27, 11, 0, 119, 93, 74, 68, 95, 51, 39, 35, 34, 31, 23, 12, 0), # 31 (122, 111, 82, 111, 59, 44, 37, 39, 54, 31, 28, 12, 0, 122, 94, 78, 69, 100, 53, 40, 38, 34, 31, 24, 12, 0), # 32 (125, 117, 84, 113, 61, 46, 38, 40, 55, 31, 28, 12, 0, 126, 102, 80, 73, 107, 55, 45, 39, 35, 34, 25, 12, 0), # 33 (130, 121, 87, 115, 65, 47, 42, 42, 55, 31, 29, 12, 0, 128, 107, 89, 77, 109, 56, 49, 39, 37, 35, 25, 12, 0), # 34 (133, 124, 90, 117, 69, 50, 44, 45, 57, 31, 29, 12, 0, 133, 110, 90, 80, 109, 57, 50, 40, 38, 36, 25, 12, 0), # 35 (137, 127, 92, 125, 72, 52, 46, 46, 59, 31, 29, 12, 0, 136, 112, 92, 85, 112, 58, 51, 40, 40, 36, 25, 12, 0), # 36 (142, 129, 94, 127, 79, 53, 46, 49, 61, 32, 29, 12, 0, 143, 114, 96, 86, 116, 62, 54, 40, 43, 36, 27, 12, 0), # 37 (144, 135, 98, 137, 82, 54, 49, 49, 65, 32, 29, 13, 0, 146, 116, 100, 86, 119, 63, 54, 42, 45, 36, 27, 12, 0), # 38 (147, 137, 103, 138, 87, 57, 53, 50, 65, 32, 31, 13, 0, 150, 120, 103, 89, 124, 67, 55, 42, 45, 37, 27, 13, 0), # 39 (150, 142, 104, 143, 88, 59, 57, 53, 67, 34, 31, 13, 0, 151, 125, 104, 90, 127, 69, 55, 42, 46, 38, 27, 14, 0), # 40 (153, 143, 106, 150, 93, 60, 59, 54, 68, 35, 31, 13, 0, 151, 128, 109, 93, 133, 73, 56, 44, 47, 39, 27, 14, 0), # 41 (158, 146, 110, 154, 97, 63, 60, 54, 69, 36, 32, 13, 0, 155, 132, 110, 97, 135, 74, 59, 44, 49, 40, 28, 14, 0), # 42 (161, 155, 116, 160, 100, 65, 65, 58, 70, 40, 32, 13, 0, 156, 133, 114, 99, 137, 74, 61, 46, 49, 41, 30, 15, 0), # 43 (163, 157, 117, 163, 101, 67, 69, 58, 72, 40, 34, 13, 0, 159, 137, 116, 100, 139, 75, 64, 48, 50, 43, 30, 15, 0), # 44 (171, 163, 118, 166, 104, 69, 72, 58, 73, 40, 34, 14, 0, 163, 145, 118, 103, 143, 77, 67, 48, 51, 44, 31, 15, 0), # 45 (176, 169, 120, 166, 106, 70, 73, 60, 73, 40, 34, 15, 0, 169, 148, 121, 106, 147, 79, 68, 49, 52, 46, 32, 15, 0), # 46 (182, 174, 123, 171, 110, 72, 73, 62, 74, 42, 36, 15, 0, 169, 151, 124, 108, 153, 81, 70, 51, 52, 48, 32, 15, 0), # 47 (185, 180, 123, 174, 115, 74, 74, 64, 77, 43, 36, 15, 0, 173, 155, 128, 108, 156, 83, 71, 53, 54, 49, 32, 15, 0), # 48 (189, 183, 128, 181, 118, 76, 75, 65, 79, 44, 36, 15, 0, 175, 159, 131, 109, 160, 85, 72, 54, 56, 51, 32, 15, 0), # 49 (194, 190, 129, 184, 124, 78, 75, 66, 81, 45, 37, 16, 0, 182, 163, 134, 111, 163, 90, 76, 54, 56, 52, 32, 16, 0), # 50 (199, 193, 132, 191, 126, 79, 78, 66, 81, 45, 37, 16, 0, 183, 167, 135, 115, 166, 91, 76, 56, 58, 55, 33, 17, 0), # 51 (200, 197, 136, 200, 129, 83, 79, 67, 83, 45, 39, 16, 0, 186, 172, 138, 116, 172, 92, 76, 56, 58, 56, 33, 17, 0), # 52 (204, 200, 140, 203, 134, 85, 81, 69, 87, 46, 40, 18, 0, 188, 179, 140, 119, 174, 94, 77, 56, 59, 57, 34, 17, 0), # 53 (211, 206, 147, 207, 139, 87, 83, 71, 87, 46, 40, 19, 0, 193, 180, 142, 120, 177, 98, 79, 58, 60, 57, 34, 17, 0), # 54 (216, 210, 149, 212, 143, 87, 85, 72, 88, 46, 40, 19, 0, 196, 182, 145, 123, 182, 99, 82, 58, 61, 57, 34, 17, 0), # 55 (219, 213, 153, 216, 147, 89, 85, 73, 89, 46, 41, 19, 0, 201, 185, 147, 124, 185, 104, 82, 60, 61, 59, 35, 17, 0), # 56 (222, 217, 153, 221, 149, 92, 86, 74, 92, 47, 41, 20, 0, 205, 188, 154, 125, 187, 106, 83, 61, 63, 59, 35, 17, 0), # 57 (229, 220, 159, 224, 151, 92, 90, 74, 93, 47, 41, 20, 0, 211, 191, 156, 125, 189, 106, 86, 64, 65, 59, 35, 17, 0), # 58 (234, 226, 164, 227, 155, 93, 93, 76, 94, 47, 41, 20, 0, 215, 192, 156, 126, 192, 107, 86, 64, 67, 59, 36, 18, 0), # 59 (241, 230, 168, 231, 157, 93, 93, 76, 96, 48, 44, 20, 0, 215, 198, 156, 127, 196, 107, 87, 65, 69, 61, 37, 18, 0), # 60 (246, 231, 168, 234, 157, 93, 94, 76, 100, 49, 45, 20, 0, 216, 203, 159, 128, 199, 108, 89, 68, 72, 62, 38, 19, 0), # 61 (251, 234, 170, 238, 159, 96, 95, 77, 103, 49, 45, 20, 0, 222, 207, 164, 129, 201, 110, 91, 69, 73, 65, 39, 19, 0), # 62 (258, 237, 178, 243, 162, 96, 96, 78, 104, 50, 45, 21, 0, 225, 208, 164, 129, 203, 111, 91, 69, 73, 67, 40, 19, 0), # 63 (263, 241, 179, 247, 165, 97, 101, 79, 106, 52, 45, 21, 0, 231, 209, 166, 134, 206, 112, 92, 69, 74, 69, 41, 19, 0), # 64 (265, 244, 183, 250, 167, 100, 104, 81, 108, 53, 45, 21, 0, 236, 212, 167, 137, 209, 113, 92, 70, 74, 70, 43, 20, 0), # 65 (268, 250, 189, 256, 170, 100, 109, 82, 109, 54, 45, 21, 0, 242, 214, 170, 137, 213, 117, 97, 70, 75, 71, 43, 20, 0), # 66 (269, 253, 192, 264, 172, 100, 111, 84, 112, 56, 46, 21, 0, 249, 216, 172, 138, 214, 118, 97, 70, 75, 73, 44, 20, 0), # 67 (275, 258, 193, 266, 176, 102, 111, 85, 114, 57, 46, 21, 0, 253, 219, 177, 141, 217, 118, 98, 71, 78, 74, 44, 20, 0), # 68 (279, 259, 195, 269, 183, 102, 114, 89, 115, 61, 46, 21, 0, 255, 222, 179, 143, 224, 119, 102, 71, 79, 74, 44, 20, 0), # 69 (285, 264, 201, 270, 188, 103, 114, 89, 117, 62, 47, 21, 0, 258, 226, 180, 145, 227, 120, 103, 71, 79, 75, 44, 20, 0), # 70 (289, 270, 204, 274, 192, 103, 114, 89, 118, 63, 47, 22, 0, 261, 229, 182, 146, 230, 122, 103, 71, 80, 75, 44, 23, 0), # 71 (292, 273, 206, 281, 194, 103, 114, 92, 118, 63, 47, 22, 0, 264, 232, 185, 147, 231, 123, 107, 72, 80, 75, 44, 23, 0), # 72 (296, 277, 210, 283, 197, 104, 116, 92, 119, 65, 47, 23, 0, 269, 235, 186, 148, 236, 124, 109, 73, 81, 75, 44, 24, 0), # 73 (298, 278, 216, 285, 201, 107, 117, 93, 120, 66, 47, 23, 0, 271, 238, 187, 151, 239, 125, 111, 73, 85, 75, 45, 25, 0), # 74 (302, 280, 219, 287, 205, 108, 117, 93, 123, 67, 47, 23, 0, 274, 246, 192, 151, 244, 126, 112, 74, 85, 76, 49, 25, 0), # 75 (306, 283, 225, 293, 207, 109, 118, 95, 125, 68, 48, 23, 0, 285, 249, 194, 155, 247, 128, 112, 76, 87, 77, 49, 25, 0), # 76 (309, 291, 229, 295, 211, 111, 118, 96, 126, 68, 49, 23, 0, 289, 252, 197, 159, 249, 128, 113, 78, 88, 77, 49, 25, 0), # 77 (311, 296, 234, 296, 211, 113, 121, 97, 129, 70, 50, 23, 0, 293, 257, 200, 161, 251, 129, 117, 79, 90, 77, 49, 26, 0), # 78 (314, 299, 237, 297, 211, 114, 122, 98, 131, 70, 50, 25, 0, 296, 259, 204, 161, 259, 130, 118, 80, 91, 79, 50, 26, 0), # 79 (317, 302, 239, 300, 213, 116, 123, 100, 132, 73, 50, 25, 0, 300, 263, 207, 162, 263, 130, 120, 81, 91, 82, 54, 26, 0), # 80 (319, 304, 242, 302, 215, 117, 123, 100, 135, 74, 50, 26, 0, 302, 267, 210, 167, 269, 131, 124, 82, 91, 82, 55, 27, 0), # 81 (325, 308, 246, 304, 218, 117, 125, 100, 139, 74, 50, 26, 0, 305, 268, 213, 170, 273, 137, 125, 82, 94, 85, 56, 27, 0), # 82 (327, 314, 250, 306, 221, 118, 128, 101, 142, 75, 50, 26, 0, 311, 268, 215, 170, 276, 139, 125, 82, 96, 87, 56, 27, 0), # 83 (331, 319, 257, 307, 224, 119, 129, 101, 144, 76, 51, 26, 0, 315, 271, 218, 173, 282, 142, 126, 82, 98, 88, 57, 27, 0), # 84 (333, 322, 263, 311, 226, 120, 130, 102, 146, 76, 51, 27, 0, 324, 272, 218, 176, 286, 143, 129, 83, 100, 89, 58, 27, 0), # 85 (336, 330, 267, 314, 228, 121, 132, 102, 149, 76, 52, 27, 0, 326, 274, 219, 178, 290, 145, 131, 86, 102, 91, 59, 27, 0), # 86 (340, 333, 269, 318, 229, 122, 134, 102, 151, 76, 52, 27, 0, 328, 282, 223, 182, 292, 148, 132, 87, 102, 91, 61, 27, 0), # 87 (349, 333, 271, 322, 231, 122, 135, 102, 153, 77, 52, 27, 0, 328, 286, 227, 186, 293, 149, 133, 87, 104, 92, 63, 27, 0), # 88 (355, 336, 273, 326, 238, 126, 136, 102, 156, 79, 52, 29, 0, 332, 291, 229, 190, 297, 151, 134, 88, 105, 93, 64, 27, 0), # 89 (360, 339, 276, 331, 242, 128, 137, 103, 160, 79, 52, 29, 0, 337, 296, 230, 192, 301, 155, 134, 88, 107, 96, 64, 27, 0), # 90 (365, 343, 276, 333, 246, 129, 138, 103, 162, 81, 52, 29, 0, 341, 302, 232, 195, 307, 155, 138, 89, 109, 97, 64, 28, 0), # 91 (370, 348, 280, 335, 249, 130, 140, 105, 163, 81, 52, 29, 0, 347, 305, 234, 197, 309, 156, 139, 90, 109, 99, 64, 28, 0), # 92 (373, 349, 284, 339, 250, 131, 143, 107, 165, 81, 54, 29, 0, 351, 310, 235, 200, 310, 156, 141, 90, 109, 100, 65, 28, 0), # 93 (378, 353, 295, 343, 254, 132, 143, 108, 168, 82, 54, 29, 0, 356, 316, 237, 201, 310, 157, 142, 91, 110, 101, 65, 28, 0), # 94 (383, 357, 297, 344, 258, 135, 144, 108, 168, 83, 54, 29, 0, 356, 318, 238, 201, 312, 158, 143, 91, 112, 101, 65, 28, 0), # 95 (388, 361, 301, 347, 261, 136, 146, 109, 170, 83, 55, 30, 0, 362, 320, 240, 201, 315, 161, 143, 93, 113, 102, 67, 28, 0), # 96 (389, 365, 302, 350, 266, 137, 147, 110, 173, 84, 55, 30, 0, 365, 325, 242, 202, 316, 163, 146, 93, 115, 103, 68, 28, 0), # 97 (394, 365, 309, 355, 269, 137, 148, 110, 176, 84, 57, 31, 0, 369, 326, 245, 205, 317, 165, 148, 93, 119, 105, 69, 28, 0), # 98 (400, 369, 311, 357, 274, 139, 149, 114, 178, 85, 57, 31, 0, 373, 329, 248, 206, 320, 168, 148, 93, 121, 106, 69, 30, 0), # 99 (405, 371, 312, 359, 276, 139, 149, 117, 178, 85, 58, 32, 0, 379, 333, 249, 207, 323, 169, 149, 96, 122, 106, 69, 31, 0), # 100 (407, 376, 318, 363, 278, 139, 151, 119, 179, 85, 58, 33, 0, 383, 338, 251, 209, 324, 174, 149, 96, 125, 109, 69, 31, 0), # 101 (410, 381, 324, 370, 283, 140, 151, 119, 183, 86, 58, 34, 0, 389, 340, 255, 210, 326, 177, 151, 96, 128, 109, 70, 31, 0), # 102 (415, 383, 327, 375, 286, 141, 153, 119, 187, 86, 58, 35, 0, 392, 342, 255, 213, 327, 178, 152, 97, 128, 109, 73, 31, 0), # 103 (421, 388, 333, 379, 289, 142, 155, 120, 190, 87, 58, 35, 0, 400, 344, 258, 215, 327, 179, 156, 97, 129, 110, 73, 31, 0), # 104 (425, 392, 339, 385, 290, 142, 158, 121, 191, 87, 58, 35, 0, 404, 345, 262, 216, 331, 181, 162, 99, 129, 110, 73, 31, 0), # 105 (426, 398, 341, 390, 294, 144, 159, 121, 193, 88, 59, 35, 0, 405, 348, 266, 218, 334, 182, 162, 100, 130, 110, 73, 31, 0), # 106 (426, 403, 345, 392, 299, 145, 159, 122, 194, 88, 60, 36, 0, 409, 353, 269, 218, 336, 185, 162, 101, 130, 112, 74, 31, 0), # 107 (429, 408, 349, 394, 301, 146, 160, 123, 197, 88, 61, 36, 0, 413, 357, 271, 220, 338, 186, 164, 101, 130, 114, 76, 31, 0), # 108 (434, 410, 352, 396, 303, 147, 161, 124, 199, 89, 62, 36, 0, 415, 363, 273, 224, 343, 186, 167, 102, 132, 115, 77, 31, 0), # 109 (439, 414, 357, 397, 304, 150, 162, 125, 199, 90, 63, 36, 0, 422, 365, 274, 224, 344, 188, 167, 102, 133, 116, 77, 31, 0), # 110 (440, 418, 359, 398, 307, 150, 166, 127, 200, 90, 63, 37, 0, 424, 367, 276, 229, 346, 191, 169, 102, 133, 119, 77, 31, 0), # 111 (443, 423, 362, 404, 309, 150, 167, 128, 200, 91, 63, 37, 0, 427, 369, 278, 229, 348, 192, 170, 102, 135, 119, 78, 31, 0), # 112 (444, 425, 363, 406, 311, 152, 167, 129, 205, 92, 63, 37, 0, 429, 372, 280, 229, 351, 194, 171, 103, 136, 119, 78, 31, 0), # 113 (449, 427, 364, 412, 313, 152, 168, 129, 207, 93, 63, 37, 0, 433, 376, 281, 231, 352, 196, 173, 104, 137, 121, 78, 32, 0), # 114 (452, 435, 365, 420, 315, 152, 169, 131, 209, 94, 63, 37, 0, 439, 378, 284, 234, 355, 197, 175, 106, 139, 122, 79, 33, 0), # 115 (454, 436, 366, 424, 318, 154, 172, 132, 211, 94, 65, 37, 0, 443, 381, 285, 234, 357, 200, 176, 106, 141, 125, 80, 33, 0), # 116 (458, 441, 368, 429, 321, 156, 172, 133, 216, 94, 65, 38, 0, 449, 384, 286, 235, 362, 202, 178, 106, 143, 127, 80, 34, 0), # 117 (460, 446, 372, 437, 322, 160, 173, 133, 217, 95, 67, 38, 0, 451, 390, 288, 237, 363, 202, 181, 107, 145, 127, 81, 34, 0), # 118 (462, 448, 373, 440, 324, 160, 173, 133, 218, 95, 67, 38, 0, 455, 393, 289, 239, 364, 204, 183, 109, 147, 127, 82, 34, 0), # 119 (462, 449, 374, 444, 326, 162, 174, 133, 219, 95, 68, 38, 0, 458, 397, 290, 240, 366, 204, 183, 109, 149, 127, 82, 34, 0), # 120 (465, 449, 376, 446, 328, 164, 176, 133, 221, 95, 68, 38, 0, 461, 398, 293, 241, 369, 204, 184, 109, 152, 128, 82, 35, 0), # 121 (467, 451, 380, 447, 331, 164, 177, 133, 222, 95, 69, 38, 0, 464, 404, 297, 242, 370, 206, 185, 109, 153, 130, 82, 35, 0), # 122 (468, 454, 385, 451, 334, 164, 181, 133, 224, 95, 69, 38, 0, 471, 407, 300, 244, 371, 206, 185, 111, 153, 130, 82, 35, 0), # 123 (472, 457, 387, 457, 337, 168, 181, 135, 225, 95, 69, 38, 0, 475, 407, 301, 246, 373, 208, 188, 111, 155, 131, 83, 36, 0), # 124 (473, 457, 387, 461, 339, 170, 182, 135, 225, 95, 69, 38, 0, 478, 409, 304, 246, 375, 209, 190, 112, 156, 132, 84, 36, 0), # 125 (473, 458, 390, 464, 340, 172, 183, 136, 227, 97, 69, 38, 0, 483, 412, 307, 250, 379, 211, 190, 112, 158, 134, 85, 36, 0), # 126 (475, 461, 390, 469, 346, 173, 184, 137, 228, 99, 70, 38, 0, 483, 415, 309, 251, 383, 215, 192, 114, 159, 134, 85, 36, 0), # 127 (476, 462, 395, 474, 349, 175, 184, 137, 229, 100, 70, 39, 0, 485, 416, 314, 252, 387, 216, 194, 116, 161, 136, 86, 37, 0), # 128 (477, 464, 398, 477, 354, 176, 185, 139, 230, 100, 70, 39, 0, 491, 417, 315, 254, 389, 219, 197, 116, 163, 137, 86, 37, 0), # 129 (483, 466, 401, 479, 357, 180, 186, 140, 231, 101, 70, 39, 0, 498, 418, 318, 255, 391, 220, 200, 117, 164, 139, 86, 37, 0), # 130 (488, 471, 401, 483, 361, 181, 188, 140, 233, 103, 70, 39, 0, 502, 419, 318, 257, 392, 220, 200, 119, 167, 139, 88, 37, 0), # 131 (490, 473, 403, 487, 363, 183, 188, 141, 234, 104, 71, 39, 0, 507, 421, 322, 261, 392, 220, 205, 120, 169, 140, 91, 37, 0), # 132 (493, 474, 406, 494, 365, 185, 190, 142, 236, 104, 73, 39, 0, 511, 425, 324, 263, 395, 220, 205, 122, 169, 141, 92, 37, 0), # 133 (495, 478, 410, 494, 367, 185, 194, 142, 237, 104, 73, 39, 0, 512, 428, 325, 264, 398, 220, 206, 122, 172, 143, 92, 37, 0), # 134 (498, 479, 413, 499, 371, 186, 197, 142, 240, 105, 73, 39, 0, 516, 431, 327, 265, 400, 220, 207, 122, 172, 143, 93, 37, 0), # 135 (506, 481, 416, 501, 373, 188, 199, 142, 243, 105, 73, 39, 0, 519, 433, 329, 265, 404, 220, 208, 122, 174, 145, 93, 37, 0), # 136 (508, 482, 420, 506, 375, 191, 200, 144, 244, 105, 73, 41, 0, 526, 433, 331, 268, 408, 221, 210, 123, 175, 147, 94, 37, 0), # 137 (510, 485, 426, 508, 377, 191, 202, 144, 245, 106, 73, 41, 0, 528, 435, 337, 270, 412, 222, 211, 123, 175, 150, 96, 37, 0), # 138 (512, 489, 429, 512, 378, 191, 203, 145, 246, 106, 73, 42, 0, 533, 438, 338, 271, 416, 223, 212, 125, 175, 151, 97, 37, 0), # 139 (518, 492, 431, 515, 380, 194, 203, 147, 247, 106, 73, 42, 0, 533, 441, 342, 272, 419, 224, 213, 125, 179, 152, 98, 37, 0), # 140 (525, 498, 433, 515, 384, 194, 205, 147, 248, 108, 73, 42, 0, 538, 445, 344, 274, 423, 224, 213, 126, 181, 153, 98, 37, 0), # 141 (531, 499, 434, 520, 389, 200, 206, 147, 249, 108, 74, 43, 0, 541, 446, 346, 275, 425, 228, 215, 126, 182, 153, 98, 37, 0), # 142 (538, 502, 436, 523, 391, 203, 206, 148, 250, 108, 74, 44, 0, 543, 448, 349, 277, 428, 228, 218, 127, 188, 153, 100, 37, 0), # 143 (542, 502, 438, 526, 394, 204, 207, 148, 252, 109, 75, 44, 0, 546, 448, 350, 280, 430, 228, 218, 130, 189, 155, 100, 38, 0), # 144 (548, 504, 442, 528, 397, 205, 208, 151, 256, 109, 76, 45, 0, 547, 450, 351, 281, 434, 229, 218, 130, 190, 155, 103, 38, 0), # 145 (552, 505, 446, 532, 399, 206, 209, 151, 256, 109, 77, 45, 0, 557, 451, 353, 282, 435, 229, 220, 130, 190, 157, 103, 39, 0), # 146 (553, 508, 447, 533, 402, 208, 210, 153, 257, 110, 77, 45, 0, 557, 454, 355, 284, 435, 230, 220, 131, 191, 157, 103, 39, 0), # 147 (559, 509, 448, 538, 406, 209, 210, 154, 259, 110, 77, 45, 0, 561, 455, 356, 286, 436, 233, 221, 132, 192, 158, 104, 39, 0), # 148 (564, 513, 448, 542, 408, 209, 213, 154, 259, 110, 78, 46, 0, 566, 458, 357, 288, 440, 234, 222, 133, 192, 159, 106, 40, 0), # 149 (566, 515, 453, 547, 410, 211, 213, 155, 260, 111, 78, 46, 0, 568, 459, 359, 292, 442, 235, 224, 133, 193, 159, 107, 40, 0), # 150 (571, 516, 454, 548, 410, 212, 213, 155, 260, 111, 78, 46, 0, 576, 462, 361, 296, 445, 237, 224, 136, 194, 161, 108, 40, 0), # 151 (577, 519, 458, 550, 413, 212, 217, 155, 263, 111, 79, 46, 0, 579, 462, 361, 298, 447, 239, 225, 136, 195, 162, 109, 41, 0), # 152 (580, 519, 459, 552, 415, 213, 218, 157, 263, 111, 80, 46, 0, 580, 464, 362, 302, 451, 240, 227, 137, 198, 163, 111, 41, 0), # 153 (584, 520, 461, 556, 416, 216, 218, 159, 265, 111, 82, 47, 0, 581, 472, 363, 302, 452, 243, 231, 137, 199, 164, 112, 42, 0), # 154 (587, 523, 465, 557, 419, 218, 218, 160, 266, 111, 82, 47, 0, 587, 476, 365, 303, 455, 244, 231, 137, 200, 165, 112, 44, 0), # 155 (589, 525, 467, 565, 421, 219, 220, 161, 267, 114, 83, 47, 0, 590, 477, 368, 304, 457, 245, 231, 137, 202, 165, 112, 44, 0), # 156 (596, 525, 472, 570, 424, 221, 221, 162, 268, 115, 83, 47, 0, 594, 479, 372, 307, 461, 247, 231, 137, 202, 166, 113, 44, 0), # 157 (600, 528, 474, 573, 426, 221, 222, 162, 270, 115, 84, 47, 0, 598, 483, 373, 307, 465, 249, 232, 137, 202, 166, 113, 44, 0), # 158 (604, 528, 477, 576, 428, 223, 224, 163, 271, 116, 85, 47, 0, 601, 483, 374, 308, 467, 249, 232, 137, 204, 166, 116, 44, 0), # 159 (605, 528, 477, 578, 431, 227, 224, 164, 273, 117, 85, 48, 0, 608, 486, 376, 308, 470, 252, 234, 137, 204, 166, 116, 44, 0), # 160 (610, 528, 480, 580, 433, 230, 227, 165, 274, 119, 85, 48, 0, 612, 489, 377, 308, 475, 252, 235, 137, 205, 166, 117, 44, 0), # 161 (612, 528, 482, 583, 435, 230, 227, 166, 274, 119, 85, 48, 0, 614, 490, 379, 310, 477, 252, 236, 137, 206, 167, 117, 44, 0), # 162 (615, 531, 483, 589, 440, 231, 228, 167, 274, 120, 86, 49, 0, 619, 494, 380, 310, 480, 252, 236, 137, 208, 168, 117, 44, 0), # 163 (619, 534, 487, 592, 442, 232, 229, 168, 277, 121, 87, 49, 0, 622, 496, 383, 312, 485, 252, 236, 138, 211, 168, 117, 44, 0), # 164 (623, 534, 488, 597, 444, 232, 229, 168, 280, 121, 87, 49, 0, 626, 499, 386, 313, 488, 253, 236, 142, 212, 170, 118, 44, 0), # 165 (625, 536, 489, 599, 446, 235, 230, 168, 281, 121, 87, 49, 0, 631, 501, 387, 314, 491, 253, 238, 143, 214, 171, 121, 44, 0), # 166 (628, 537, 492, 601, 450, 238, 231, 168, 281, 121, 87, 49, 0, 640, 503, 389, 315, 493, 253, 238, 143, 214, 172, 121, 44, 0), # 167 (629, 538, 498, 602, 452, 239, 231, 169, 282, 121, 87, 50, 0, 647, 506, 391, 315, 495, 255, 238, 143, 214, 172, 121, 44, 0), # 168 (629, 538, 503, 607, 454, 239, 233, 170, 282, 122, 88, 50, 0, 651, 506, 392, 316, 496, 256, 239, 144, 214, 172, 121, 44, 0), # 169 (630, 541, 504, 608, 457, 239, 233, 171, 282, 122, 88, 51, 0, 653, 507, 397, 316, 497, 256, 239, 146, 215, 173, 122, 44, 0), # 170 (635, 542, 505, 609, 458, 240, 234, 172, 282, 122, 88, 51, 0, 654, 509, 397, 318, 502, 257, 241, 146, 215, 173, 122, 44, 0), # 171 (638, 542, 507, 610, 458, 240, 234, 172, 283, 122, 89, 51, 0, 656, 511, 398, 319, 504, 258, 242, 147, 217, 175, 122, 44, 0), # 172 (640, 543, 508, 613, 458, 241, 234, 173, 285, 122, 89, 51, 0, 658, 513, 399, 321, 505, 260, 244, 147, 221, 177, 123, 45, 0), # 173 (640, 544, 511, 617, 461, 241, 235, 175, 287, 122, 89, 51, 0, 659, 516, 400, 322, 507, 260, 245, 147, 221, 179, 123, 45, 0), # 174 (642, 546, 513, 617, 461, 242, 236, 175, 287, 122, 89, 51, 0, 661, 517, 401, 322, 508, 261, 245, 147, 221, 179, 123, 45, 0), # 175 (644, 548, 514, 617, 463, 243, 237, 176, 288, 122, 89, 51, 0, 664, 518, 401, 322, 509, 261, 247, 148, 222, 179, 123, 45, 0), # 176 (645, 548, 517, 618, 464, 243, 238, 176, 288, 122, 89, 52, 0, 665, 521, 403, 322, 511, 262, 247, 148, 223, 181, 123, 45, 0), # 177 (647, 548, 518, 618, 464, 243, 238, 178, 288, 123, 89, 53, 0, 669, 523, 404, 322, 512, 262, 247, 148, 224, 181, 123, 45, 0), # 178 (647, 548, 518, 618, 464, 243, 238, 178, 288, 123, 89, 53, 0, 669, 523, 404, 322, 512, 262, 247, 148, 224, 181, 123, 45, 0), # 179 ) passenger_arriving_rate = ( (2.0083462313487073, 2.025939138554161, 1.7370944098708356, 1.86440033215903, 1.481249495362563, 0.7323528174753792, 0.8292071230747831, 0.7755293621632372, 0.8120132082890676, 0.3958015015522371, 0.2803510109257069, 0.16326383594353913, 0.0, 2.0335520850313453, 1.7959021953789303, 1.4017550546285344, 1.187404504656711, 1.6240264165781353, 1.085741107028532, 0.8292071230747831, 0.5231091553395566, 0.7406247476812815, 0.6214667773863434, 0.34741888197416715, 0.18417628532310557, 0.0), # 0 (2.1417308608079897, 2.159688921186411, 1.851782197110051, 1.987543275982985, 1.5793307566597963, 0.780729502943263, 0.8838937882527388, 0.8265856204842847, 0.8656327101777213, 0.4218980692277151, 0.29887307573040883, 0.17404055536047852, 0.0, 2.1679166589759418, 1.9144461089652633, 1.4943653786520439, 1.265694207683145, 1.7312654203554425, 1.1572198686779986, 0.8838937882527388, 0.5576639306737593, 0.7896653783298981, 0.6625144253276618, 0.3703564394220102, 0.19633535647149197, 0.0), # 1 (2.2746892035918926, 2.292907895993359, 1.9660140951824712, 2.1101963113994384, 1.6770567929999318, 0.8289131933862371, 0.9383637015921409, 0.8774375413174034, 0.9190382409170065, 0.4478913775020547, 0.31732154325175427, 0.18477442173510186, 0.0, 2.301745931283876, 2.03251863908612, 1.586607716258771, 1.3436741325061639, 1.838076481834013, 1.2284125578443648, 0.9383637015921409, 0.5920808524187409, 0.8385283964999659, 0.7033987704664796, 0.3932028190364943, 0.20844617236303267, 0.0), # 2 (2.406703117258625, 2.4250675173766973, 2.0793369564399518, 2.231872922259622, 1.774043113600507, 0.8767128119365264, 0.9924007283295911, 0.9278835262490847, 0.9720180214561457, 0.4736782698426182, 0.3356232274551589, 0.1954228561643487, 0.0, 2.4345091225016904, 2.1496514178078354, 1.6781161372757945, 1.4210348095278542, 1.9440360429122914, 1.2990369367487185, 0.9924007283295911, 0.6262234370975188, 0.8870215568002535, 0.7439576407532075, 0.41586739128799033, 0.2204606833978816, 0.0), # 3 (2.537254459366393, 2.555639239738117, 2.1912976332343455, 2.352086592414771, 1.8699052276790646, 0.9239372817263559, 1.0457887337016918, 0.9777219768658193, 1.024360272744361, 0.499155589716768, 0.3537049423060384, 0.20594327974515883, 0.0, 2.565675453175927, 2.2653760771967466, 1.7685247115301916, 1.4974667691503036, 2.048720545488722, 1.368810767612147, 1.0457887337016918, 0.6599552012331114, 0.9349526138395323, 0.7840288641382572, 0.4382595266468692, 0.23233083997619253, 0.0), # 4 (2.6658250874734044, 2.6840945174793154, 2.3014429779175063, 2.470350805716118, 1.9642586444531411, 0.9703955258879502, 1.0983115829450447, 1.0267512947540989, 1.0758532157308744, 0.5242201805918665, 0.37149350176980883, 0.21629311357447162, 0.0, 2.694714143853131, 2.3792242493191873, 1.8574675088490442, 1.572660541775599, 2.151706431461749, 1.4374518126557383, 1.0983115829450447, 0.6931396613485358, 0.9821293222265706, 0.8234502685720396, 0.46028859558350127, 0.24400859249811963, 0.0), # 5 (2.7918968591378666, 2.8099048050019837, 2.4093198428412888, 2.586179046014896, 2.0567188731402783, 1.015896467553535, 1.1497531412962525, 1.0747698815004147, 1.1262850713649086, 0.548768885935276, 0.3889157198118855, 0.22642977874922698, 0.0, 2.821094415079843, 2.4907275662414965, 1.9445785990594275, 1.6463066578058276, 2.2525701427298173, 1.5046778341005806, 1.1497531412962525, 0.7256403339668107, 1.0283594365701392, 0.8620596820049655, 0.4818639685682578, 0.25544589136381673, 0.0), # 6 (2.9149516319179876, 2.932541556707815, 2.514475080357545, 2.699084797162339, 2.146901422958014, 1.0602490298553349, 1.199897273991917, 1.1215761386912588, 1.175444060595686, 0.5726985492143588, 0.40589841039768465, 0.23631069636636431, 0.0, 2.944285487402608, 2.599417660030007, 2.029492051988423, 1.718095647643076, 2.350888121191372, 1.5702065941677623, 1.199897273991917, 0.7573207356109535, 1.073450711479007, 0.8996949323874465, 0.5028950160715091, 0.26659468697343774, 0.0), # 7 (3.034471263371974, 3.051476226998503, 2.616455542818132, 2.8085815430096783, 2.2344218031238894, 1.1032621359255743, 1.2485278462686396, 1.166968467913121, 1.2231184043724275, 0.5959060138964776, 0.42236838749262146, 0.24589328752282347, 0.0, 3.063756581367967, 2.7048261627510577, 2.111841937463107, 1.7877180416894323, 2.446236808744855, 1.6337558550783693, 1.2485278462686396, 0.7880443828039817, 1.1172109015619447, 0.936193847669893, 0.5232911085636265, 0.2774069297271367, 0.0), # 8 (3.149937611058034, 3.1661802702757416, 2.7148080825749017, 2.9141827674081506, 2.3188955228554424, 1.1447447088964797, 1.295428723363024, 1.210745270752494, 1.2690963236443564, 0.6182881234489943, 0.4382524650621119, 0.25513497331554386, 0.0, 3.178976917522465, 2.8064847064709815, 2.1912623253105594, 1.8548643703469825, 2.538192647288713, 1.6950433790534916, 1.295428723363024, 0.817674792068914, 1.1594477614277212, 0.9713942558027171, 0.5429616165149803, 0.28783457002506746, 0.0), # 9 (3.2608325325343728, 3.276125140941222, 2.8090795519797083, 3.0154019542089863, 2.3999380913702133, 1.1845056719002751, 1.340383770511671, 1.2527049487958686, 1.3131660393606952, 0.6397417213392715, 0.45347745707157167, 0.2639931748414651, 0.0, 3.2894157164126443, 2.903924923256116, 2.267387285357858, 1.9192251640178144, 2.6263320787213904, 1.7537869283142162, 1.340383770511671, 0.8460754799287679, 1.1999690456851067, 1.005133984736329, 0.5618159103959417, 0.2978295582673839, 0.0), # 10 (3.3666378853592023, 3.3807822933966425, 2.8988168033844053, 3.1117525872634193, 2.477165017885742, 1.222353948069186, 1.3831768529511832, 1.292645903629736, 1.3551157724706657, 0.660163651034672, 0.46797017748641667, 0.27242531319752705, 0.0, 3.394542198585045, 2.996678445172797, 2.339850887432083, 1.9804909531040158, 2.7102315449413314, 1.8097042650816304, 1.3831768529511832, 0.8731099629065614, 1.238582508942871, 1.03725086242114, 0.5797633606768812, 0.30734384485424027, 0.0), # 11 (3.466835527090725, 3.479623182043689, 2.9835666891408468, 3.202748150422684, 2.550191811619567, 1.2580984605354364, 1.4235918359181623, 1.3303665368405868, 1.3947337439234906, 0.6794507560025573, 0.48165744027206236, 0.28038880948066897, 0.0, 3.493825584586214, 3.0842769042873583, 2.4082872013603116, 2.0383522680076718, 2.789467487846981, 1.8625131515768216, 1.4235918359181623, 0.8986417575253116, 1.2750959058097835, 1.0675827168075616, 0.5967133378281694, 0.31632938018579, 0.0), # 12 (3.5609073152871504, 3.572119261284061, 3.062876061600887, 3.2879021275380134, 2.618633981789227, 1.2915481324312523, 1.4614125846492112, 1.3656652500149136, 1.431808174668391, 0.6974998797102906, 0.49446605939392463, 0.2878410847878307, 0.0, 3.586735094962694, 3.1662519326661376, 2.472330296969623, 2.0924996391308714, 2.863616349336782, 1.9119313500208792, 1.4614125846492112, 0.9225343803080374, 1.3093169908946134, 1.0959673758460047, 0.6125752123201775, 0.3247381146621874, 0.0), # 13 (3.6483351075066865, 3.6577419855194493, 3.1362917731163824, 3.366728002460638, 2.6821070376122638, 1.3225118868888581, 1.4964229643809324, 1.3983404447392078, 1.4661272856545895, 0.7142078656252335, 0.5063228488174191, 0.29473956021595205, 0.0, 3.6727399502610254, 3.242135162375472, 2.531614244087095, 2.1426235968757004, 2.932254571309179, 1.9576766226348912, 1.4964229643809324, 0.9446513477777557, 1.3410535188061319, 1.1222426674868795, 0.6272583546232765, 0.33252199868358634, 0.0), # 14 (3.728600761307542, 3.7359628091515464, 3.203360676039181, 3.438739259041796, 2.7402264883062153, 1.3507986470404796, 1.5284068403499251, 1.4281905225999594, 1.4974792978313092, 0.7294715572147492, 0.5171546225079614, 0.30104165686197243, 0.0, 3.7513093710277525, 3.311458225481696, 2.5857731125398065, 2.188414671644247, 2.9949585956626184, 1.9994667316399433, 1.5284068403499251, 0.9648561764574853, 1.3701132441531076, 1.1462464196805988, 0.6406721352078363, 0.33963298265014064, 0.0), # 15 (3.8011861342479203, 3.806253186582049, 3.263629622721142, 3.5034493811327145, 2.792607843088622, 1.3762173360183407, 1.5571480777927953, 1.4550138851836603, 1.5256524321477714, 0.7431877979461997, 0.5268881944309676, 0.3067047958228314, 0.0, 3.8219125778094183, 3.3737527540511447, 2.6344409721548376, 2.229563393838599, 3.0513048642955427, 2.0370194392571244, 1.5571480777927953, 0.9830123828702433, 1.396303921544311, 1.1678164603775718, 0.6527259245442284, 0.3460230169620045, 0.0), # 16 (3.86557308388603, 3.868084572212647, 3.3166454655141178, 3.560371852584634, 2.8388666111770235, 1.3985768769546667, 1.5824305419461422, 1.4786089340768032, 1.5504349095531977, 0.755253431286947, 0.5354503785518533, 0.31168639819546856, 0.0, 3.8840187911525663, 3.4285503801501536, 2.6772518927592666, 2.2657602938608403, 3.1008698191063955, 2.0700525077075245, 1.5824305419461422, 0.9989834835390476, 1.4194333055885118, 1.1867906175282115, 0.6633290931028236, 0.35164405201933163, 0.0), # 17 (3.921243467780082, 3.920928420445034, 3.3619550567699603, 3.609020157248784, 2.878618301788957, 1.4176861929816842, 1.6040380980465703, 1.4987740708658768, 1.5716149509968127, 0.7655653007043539, 0.542767988836034, 0.31594388507682386, 0.0, 3.9370972316037385, 3.475382735845062, 2.7138399441801697, 2.2966959021130613, 3.1432299019936254, 2.0982836992122276, 1.6040380980465703, 1.0126329949869173, 1.4393091508944784, 1.203006719082928, 0.672391011353992, 0.35644803822227583, 0.0), # 18 (3.9676791434882794, 3.964256185680906, 3.399105248840526, 3.648907778976395, 2.911478424141964, 1.4333542072316154, 1.6217546113306789, 1.5153076971373745, 1.5889807774278373, 0.7740202496657831, 0.5487678392489254, 0.3194346775638366, 0.0, 3.9806171197094784, 3.513781453202202, 2.7438391962446262, 2.3220607489973486, 3.1779615548556746, 2.1214307759923243, 1.6217546113306789, 1.0238244337368683, 1.455739212070982, 1.2163025929921318, 0.6798210497681053, 0.3603869259709915, 0.0), # 19 (4.0043619685688325, 3.997539322321953, 3.427642894077668, 3.679548201618706, 2.9370624874535847, 1.4453898428366878, 1.6353639470350725, 1.5280082144777862, 1.6023206097954932, 0.7805151216385962, 0.5533767437559435, 0.32211619675344644, 0.0, 4.01404767601633, 3.54327816428791, 2.766883718779717, 2.341545364915788, 3.2046412195909864, 2.139211500268901, 1.6353639470350725, 1.0324213163119198, 1.4685312437267923, 1.2265160672062356, 0.6855285788155336, 0.36341266566563213, 0.0), # 20 (4.030773800579946, 4.020249284769871, 3.44711484483324, 3.700454909026946, 2.954986000941357, 1.453602022929125, 1.644649970396352, 1.5366740244736041, 1.611422669049003, 0.7849467600901557, 0.556521516322504, 0.32394586374259315, 0.0, 4.036858121070831, 3.5634045011685243, 2.78260758161252, 2.3548402802704667, 3.222845338098006, 2.151343634263046, 1.644649970396352, 1.0382871592350893, 1.4774930004706786, 1.233484969675649, 0.689422968966648, 0.365477207706352, 0.0), # 21 (4.046396497079832, 4.031857527426353, 3.457067953459095, 3.7111413850523514, 2.96486447382282, 1.4577996706411525, 1.64939654665112, 1.5411035287113193, 1.6160751761375887, 0.7872120084878245, 0.5581289709140228, 0.3248810996282164, 0.0, 4.048517675419531, 3.5736920959103795, 2.7906448545701137, 2.361636025463473, 3.2321503522751773, 2.157544940195847, 1.64939654665112, 1.0412854790293946, 1.48243223691141, 1.237047128350784, 0.6914135906918191, 0.3665325024933049, 0.0), # 22 (4.052157345337056, 4.0332319844535895, 3.4583077274805674, 3.712479243827161, 2.9673952149420257, 1.4583333333333335, 1.6499608004518678, 1.5415823045267492, 1.6166568312757204, 0.7874792272519435, 0.5583305358107827, 0.3249965858862978, 0.0, 4.05, 3.574962444749276, 2.7916526790539136, 2.36243768175583, 3.2333136625514407, 2.158215226337449, 1.6499608004518678, 1.0416666666666667, 1.4836976074710129, 1.2374930812757206, 0.6916615454961136, 0.36665745313214454, 0.0), # 23 (4.056404965213662, 4.03243024691358, 3.4581049382716054, 3.7123145833333338, 2.9688286969639606, 1.4583333333333335, 1.6496507625272334, 1.5409166666666667, 1.6165788888888888, 0.7873150617283953, 0.5583083052749721, 0.3249695473251029, 0.0, 4.05, 3.5746650205761314, 2.7915415263748606, 2.361945185185185, 3.2331577777777776, 2.1572833333333334, 1.6496507625272334, 1.0416666666666667, 1.4844143484819803, 1.2374381944444448, 0.6916209876543211, 0.3665845679012346, 0.0), # 24 (4.060562892084632, 4.030849908550525, 3.457704618198446, 3.7119888117283955, 2.970230652158534, 1.4583333333333335, 1.649039780521262, 1.5396090534979427, 1.6164248971193418, 0.7869918838591681, 0.5582642266284242, 0.3249161713153483, 0.0, 4.05, 3.5740778844688306, 2.7913211331421213, 2.3609756515775038, 3.2328497942386836, 2.15545267489712, 1.649039780521262, 1.0416666666666667, 1.485115326079267, 1.2373296039094654, 0.6915409236396892, 0.36644090077732056, 0.0), # 25 (4.0646308076192135, 4.028515112025606, 3.457112254229539, 3.711505632716049, 2.9716010315789614, 1.4583333333333335, 1.6481373436617444, 1.5376841563786012, 1.61619683127572, 0.7865150708733427, 0.5581986989233904, 0.3248371894528274, 0.0, 4.05, 3.573209083981101, 2.7909934946169517, 2.3595452126200276, 3.23239366255144, 2.152757818930042, 1.6481373436617444, 1.0416666666666667, 1.4858005157894807, 1.2371685442386833, 0.6914224508459078, 0.3662286465477825, 0.0), # 26 (4.068608393486655, 4.02545, 3.4563333333333333, 3.71086875, 2.972939786278457, 1.4583333333333335, 1.6469529411764707, 1.5351666666666668, 1.6158966666666665, 0.7858900000000002, 0.5581121212121213, 0.32473333333333343, 0.0, 4.05, 3.572066666666667, 2.7905606060606063, 2.3576699999999997, 3.231793333333333, 2.1492333333333336, 1.6469529411764707, 1.0416666666666667, 1.4864698931392284, 1.2369562500000002, 0.6912666666666667, 0.36595000000000005, 0.0), # 27 (4.0724953313562, 4.021678715134888, 3.4553733424782807, 3.710081867283951, 2.9742468673102405, 1.4583333333333335, 1.6454960622932302, 1.532081275720165, 1.615526378600823, 0.7851220484682215, 0.558004892546868, 0.3246053345526597, 0.0, 4.05, 3.5706586800792564, 2.7900244627343396, 2.355366145404664, 3.231052757201646, 2.144913786008231, 1.6454960622932302, 1.0416666666666667, 1.4871234336551202, 1.2366939557613172, 0.6910746684956562, 0.3656071559213535, 0.0), # 28 (4.0762913028971, 4.01722540009145, 3.4542377686328307, 3.709148688271605, 2.9755222257275253, 1.4583333333333335, 1.6437761962398132, 1.5284526748971192, 1.6150879423868312, 0.7842165935070876, 0.5578774119798812, 0.3244539247065996, 0.0, 4.05, 3.568993171772595, 2.789387059899406, 2.3526497805212623, 3.2301758847736624, 2.139833744855967, 1.6437761962398132, 1.0416666666666667, 1.4877611128637627, 1.2363828960905352, 0.6908475537265663, 0.36520230909922274, 0.0), # 29 (4.079995989778599, 4.012114197530865, 3.452932098765432, 3.7080729166666666, 2.9767658125835297, 1.4583333333333335, 1.6418028322440088, 1.5243055555555556, 1.6145833333333333, 0.7831790123456793, 0.557730078563412, 0.3242798353909465, 0.0, 4.05, 3.5670781893004113, 2.78865039281706, 2.349537037037037, 3.2291666666666665, 2.134027777777778, 1.6418028322440088, 1.0416666666666667, 1.4883829062917648, 1.2360243055555558, 0.6905864197530864, 0.36473765432098776, 0.0), # 30 (4.083609073669943, 4.006369250114313, 3.4514618198445364, 3.70685825617284, 2.977977578931469, 1.4583333333333335, 1.639585459533608, 1.519664609053498, 1.6140145267489712, 0.7820146822130776, 0.5575632913497112, 0.32408379820149374, 0.0, 4.05, 3.564921780216431, 2.7878164567485557, 2.346044046639232, 3.2280290534979423, 2.1275304526748973, 1.639585459533608, 1.0416666666666667, 1.4889887894657345, 1.2356194187242802, 0.6902923639689073, 0.36421538637402845, 0.0), # 31 (4.087130236240382, 4.000014700502972, 3.4498324188385916, 3.7055084104938274, 2.979157475824559, 1.4583333333333335, 1.6371335673363998, 1.5145545267489715, 1.613383497942387, 0.7807289803383634, 0.5573774493910297, 0.32386654473403453, 0.0, 4.05, 3.5625319920743794, 2.7868872469551484, 2.3421869410150893, 3.226766995884774, 2.12037633744856, 1.6371335673363998, 1.0416666666666667, 1.4895787379122796, 1.2351694701646094, 0.6899664837677183, 0.3636377000457248, 0.0), # 32 (4.090559159159159, 3.993074691358024, 3.4480493827160497, 3.704027083333333, 2.9803054543160163, 1.4583333333333335, 1.6344566448801743, 1.5090000000000001, 1.6126922222222222, 0.7793272839506176, 0.5571729517396184, 0.32362880658436216, 0.0, 4.05, 3.559916872427983, 2.785864758698092, 2.3379818518518523, 3.2253844444444444, 2.1126000000000005, 1.6344566448801743, 1.0416666666666667, 1.4901527271580082, 1.2346756944444446, 0.68960987654321, 0.36300679012345677, 0.0), # 33 (4.093895524095524, 3.985573365340649, 3.446118198445359, 3.702417978395062, 2.9814214654590576, 1.4583333333333335, 1.631564181392722, 1.503025720164609, 1.6119426748971197, 0.7778149702789212, 0.5569501974477283, 0.3233713153482701, 0.0, 4.05, 3.557084468830971, 2.784750987238642, 2.333444910836763, 3.2238853497942395, 2.1042360082304525, 1.631564181392722, 1.0416666666666667, 1.4907107327295288, 1.2341393261316875, 0.6892236396890719, 0.3623248513946045, 0.0), # 34 (4.097139012718723, 3.977534865112025, 3.4440443529949705, 3.700684799382716, 2.9825054603068986, 1.4583333333333335, 1.6284656661018317, 1.4966563786008233, 1.6111368312757204, 0.7761974165523551, 0.5567095855676103, 0.32309480262155166, 0.0, 4.05, 3.554042828837068, 2.7835479278380513, 2.3285922496570644, 3.2222736625514408, 2.0953189300411528, 1.6284656661018317, 1.0416666666666667, 1.4912527301534493, 1.2335615997942388, 0.6888088705989942, 0.3615940786465478, 0.0), # 35 (4.100289306698002, 3.9689833333333326, 3.4418333333333337, 3.69883125, 2.983557389912756, 1.4583333333333335, 1.625170588235294, 1.489916666666667, 1.6102766666666666, 0.7744800000000003, 0.5564515151515153, 0.3228000000000001, 0.0, 4.05, 3.5508000000000006, 2.782257575757576, 2.32344, 3.220553333333333, 2.0858833333333338, 1.625170588235294, 1.0416666666666667, 1.491778694956378, 1.2329437500000002, 0.6883666666666668, 0.3608166666666667, 0.0), # 36 (4.10334608770261, 3.9599429126657517, 3.4394906264288982, 3.6968610339506176, 2.984577205329846, 1.4583333333333335, 1.6216884370208988, 1.4828312757201647, 1.609364156378601, 0.7726680978509377, 0.5561763852516941, 0.3224876390794087, 0.0, 4.05, 3.547364029873495, 2.7808819262584703, 2.3180042935528125, 3.218728312757202, 2.0759637860082307, 1.6216884370208988, 1.0416666666666667, 1.492288602664923, 1.2322870113168727, 0.6878981252857798, 0.3599948102423411, 0.0), # 37 (4.1063090374017905, 3.9504377457704623, 3.4370217192501147, 3.6947778549382724, 2.985564857611384, 1.4583333333333335, 1.6180287016864359, 1.4754248971193418, 1.6084012757201647, 0.7707670873342481, 0.5558845949203975, 0.32215845145557087, 0.0, 4.05, 3.543742966011279, 2.7794229746019874, 2.3123012620027437, 3.2168025514403293, 2.0655948559670785, 1.6180287016864359, 1.0416666666666667, 1.492782428805692, 1.2315926183127577, 0.6874043438500229, 0.35913070416095116, 0.0), # 38 (4.109177837464794, 3.940491975308642, 3.434432098765433, 3.6925854166666667, 2.9865202978105874, 1.4583333333333335, 1.6142008714596952, 1.4677222222222224, 1.60739, 0.7687823456790126, 0.5555765432098766, 0.32181316872427984, 0.0, 4.05, 3.539944855967078, 2.777882716049383, 2.306347037037037, 3.21478, 2.0548111111111114, 1.6142008714596952, 1.0416666666666667, 1.4932601489052937, 1.2308618055555558, 0.6868864197530866, 0.3582265432098766, 0.0), # 39 (4.111952169560865, 3.930129743941472, 3.4317272519433013, 3.690287422839506, 2.9874434769806717, 1.4583333333333335, 1.6102144355684662, 1.4597479423868318, 1.606332304526749, 0.7667192501143122, 0.5552526291723824, 0.32145252248132916, 0.0, 4.05, 3.5359777472946203, 2.7762631458619116, 2.300157750342936, 3.212664609053498, 2.0436471193415646, 1.6102144355684662, 1.0416666666666667, 1.4937217384903358, 1.230095807613169, 0.6863454503886602, 0.3572845221764975, 0.0), # 40 (4.114631715359251, 3.919375194330132, 3.4289126657521725, 3.6878875771604944, 2.988334346174854, 1.4583333333333335, 1.606078883240539, 1.4515267489711936, 1.6052301646090534, 0.7645831778692275, 0.5549132518601656, 0.3210772443225119, 0.0, 4.05, 3.53184968754763, 2.7745662593008276, 2.2937495336076816, 3.210460329218107, 2.0321374485596713, 1.606078883240539, 1.0416666666666667, 1.494167173087427, 1.2292958590534984, 0.6857825331504345, 0.3563068358481939, 0.0), # 41 (4.1172161565292, 3.908252469135803, 3.425993827160495, 3.685389583333334, 2.9891928564463486, 1.4583333333333335, 1.6018037037037036, 1.4430833333333335, 1.6040855555555558, 0.7623795061728398, 0.5545588103254772, 0.3206880658436215, 0.0, 4.05, 3.5275687242798353, 2.7727940516273852, 2.2871385185185185, 3.2081711111111115, 2.020316666666667, 1.6018037037037036, 1.0416666666666667, 1.4945964282231743, 1.2284631944444449, 0.685198765432099, 0.35529567901234577, 0.0), # 42 (4.119705174739957, 3.8967857110196618, 3.4229762231367173, 3.6827971450617287, 2.990018958848374, 1.4583333333333335, 1.5973983861857501, 1.434442386831276, 1.6029004526748971, 0.7601136122542298, 0.5541897036205679, 0.32028571864045124, 0.0, 4.05, 3.523142905044963, 2.770948518102839, 2.2803408367626887, 3.2058009053497942, 2.0082193415637866, 1.5973983861857501, 1.0416666666666667, 1.495009479424187, 1.2275990483539099, 0.6845952446273434, 0.35425324645633294, 0.0), # 43 (4.122098451660771, 3.8849990626428896, 3.4198653406492916, 3.680113966049383, 2.9908126044341454, 1.4583333333333335, 1.592872419914468, 1.4256286008230457, 1.6016768312757201, 0.7577908733424785, 0.5538063307976889, 0.3198709343087945, 0.0, 4.05, 3.5185802773967385, 2.7690316539884443, 2.273372620027435, 3.2033536625514403, 1.9958800411522641, 1.592872419914468, 1.0416666666666667, 1.4954063022170727, 1.2267046553497947, 0.6839730681298584, 0.35318173296753547, 0.0), # 44 (4.1243956689608865, 3.872916666666667, 3.4166666666666674, 3.6773437500000004, 2.991573744256879, 1.4583333333333335, 1.5882352941176472, 1.416666666666667, 1.6004166666666664, 0.755416666666667, 0.553409090909091, 0.3194444444444445, 0.0, 4.05, 3.5138888888888884, 2.7670454545454546, 2.2662500000000003, 3.2008333333333328, 1.9833333333333336, 1.5882352941176472, 1.0416666666666667, 1.4957868721284395, 1.2257812500000003, 0.6833333333333335, 0.3520833333333334, 0.0), # 45 (4.126596508309553, 3.8605626657521714, 3.4133856881572933, 3.674490200617284, 2.992302329369791, 1.4583333333333335, 1.5834964980230777, 1.407581275720165, 1.5991219341563785, 0.7529963694558759, 0.552998383007025, 0.3190069806431947, 0.0, 4.05, 3.509076787075141, 2.7649919150351248, 2.258989108367627, 3.198243868312757, 1.970613786008231, 1.5834964980230777, 1.0416666666666667, 1.4961511646848955, 1.2248300668724283, 0.6826771376314588, 0.35096024234110657, 0.0), # 46 (4.128700651376014, 3.8479612025605854, 3.4100278920896208, 3.6715570216049382, 2.992998310826098, 1.4583333333333335, 1.5786655208585494, 1.3983971193415639, 1.597794609053498, 0.7505353589391863, 0.552574606143742, 0.3185592745008384, 0.0, 4.05, 3.5041520195092213, 2.7628730307187097, 2.2516060768175583, 3.195589218106996, 1.9577559670781894, 1.5786655208585494, 1.0416666666666667, 1.496499155413049, 1.2238523405349797, 0.6820055784179242, 0.3498146547782351, 0.0), # 47 (4.130707779829518, 3.835136419753087, 3.4065987654320993, 3.6685479166666672, 2.993661639679016, 1.4583333333333335, 1.5737518518518518, 1.3891388888888891, 1.5964366666666667, 0.7480390123456792, 0.5521381593714928, 0.31810205761316873, 0.0, 4.05, 3.4991226337448555, 2.7606907968574634, 2.244117037037037, 3.1928733333333335, 1.944794444444445, 1.5737518518518518, 1.0416666666666667, 1.496830819839508, 1.222849305555556, 0.6813197530864199, 0.34864876543209883, 0.0), # 48 (4.132617575339315, 3.8221124599908545, 3.403103795153178, 3.665466589506173, 2.9942922669817618, 1.4583333333333335, 1.5687649802307755, 1.3798312757201647, 1.5950500823045266, 0.7455127069044355, 0.5516894417425283, 0.31763606157597934, 0.0, 4.05, 3.4939966773357725, 2.7584472087126413, 2.2365381207133064, 3.190100164609053, 1.9317637860082308, 1.5687649802307755, 1.0416666666666667, 1.4971461334908809, 1.221822196502058, 0.6806207590306357, 0.34746476909007773, 0.0), # 49 (4.134429719574647, 3.8089134659350714, 3.399548468221308, 3.6623167438271604, 2.9948901437875506, 1.4583333333333335, 1.56371439522311, 1.3704989711934157, 1.5936368312757199, 0.742961819844536, 0.5512288523090992, 0.3171620179850633, 0.0, 4.05, 3.4887821978356963, 2.7561442615454963, 2.2288854595336076, 3.1872736625514397, 1.9186985596707822, 1.56371439522311, 1.0416666666666667, 1.4974450718937753, 1.220772247942387, 0.6799096936442617, 0.346264860539552, 0.0), # 50 (4.136143894204764, 3.7955635802469136, 3.3959382716049387, 3.659102083333334, 2.9954552211495997, 1.4583333333333335, 1.558609586056645, 1.3611666666666666, 1.592198888888889, 0.7403917283950618, 0.5507567901234569, 0.31668065843621407, 0.0, 4.05, 3.483487242798354, 2.7537839506172843, 2.221175185185185, 3.184397777777778, 1.9056333333333335, 1.558609586056645, 1.0416666666666667, 1.4977276105747999, 1.2197006944444448, 0.6791876543209877, 0.34505123456790127, 0.0), # 51 (4.137759780898912, 3.782086945587563, 3.39227869227252, 3.6558263117283953, 2.995987450121124, 1.4583333333333335, 1.5534600419591706, 1.3518590534979422, 1.590738230452675, 0.7378078097850939, 0.5502736542378519, 0.3161927145252249, 0.0, 4.05, 3.4781198597774736, 2.7513682711892593, 2.2134234293552812, 3.18147646090535, 1.8926026748971192, 1.5534600419591706, 1.0416666666666667, 1.497993725060562, 1.218608770576132, 0.678455738454504, 0.3438260859625058, 0.0), # 52 (4.139277061326338, 3.768507704618199, 3.388575217192502, 3.6524931327160495, 2.996486781755341, 1.4583333333333335, 1.5482752521584766, 1.3426008230452677, 1.5892568312757203, 0.735215441243713, 0.5497798437045351, 0.3156989178478891, 0.0, 4.05, 3.4726880963267797, 2.7488992185226753, 2.2056463237311386, 3.1785136625514405, 1.8796411522633747, 1.5482752521584766, 1.0416666666666667, 1.4982433908776704, 1.21749771090535, 0.6777150434385005, 0.3425916095107454, 0.0), # 53 (4.140695417156286, 3.7548500000000002, 3.3848333333333334, 3.64910625, 2.996953167105467, 1.4583333333333335, 1.543064705882353, 1.3334166666666667, 1.5877566666666667, 0.7326200000000002, 0.5492757575757575, 0.31520000000000004, 0.0, 4.05, 3.4672, 2.7463787878787875, 2.1978600000000004, 3.1755133333333334, 1.8667833333333332, 1.543064705882353, 1.0416666666666667, 1.4984765835527336, 1.2163687500000002, 0.6769666666666667, 0.3413500000000001, 0.0), # 54 (4.142014530058009, 3.741137974394147, 3.381058527663466, 3.6456693672839506, 2.997386557224717, 1.4583333333333335, 1.5378378923585896, 1.3243312757201646, 1.5862397119341562, 0.7300268632830363, 0.5487617949037703, 0.31469669257735106, 0.0, 4.05, 3.4616636183508613, 2.743808974518851, 2.1900805898491087, 3.1724794238683125, 1.8540637860082305, 1.5378378923585896, 1.0416666666666667, 1.4986932786123586, 1.2152231224279837, 0.6762117055326933, 0.34010345221764976, 0.0), # 55 (4.143234081700749, 3.7273957704618197, 3.377256287151349, 3.642186188271605, 2.9977869031663094, 1.4583333333333335, 1.5326043008149763, 1.3153693415637862, 1.584707942386831, 0.7274414083219024, 0.5482383547408239, 0.31418972717573546, 0.0, 4.05, 3.4560869989330896, 2.7411917737041196, 2.182324224965707, 3.169415884773662, 1.8415170781893007, 1.5326043008149763, 1.0416666666666667, 1.4988934515831547, 1.2140620627572019, 0.6754512574302699, 0.33885416095107457, 0.0), # 56 (4.144353753753753, 3.7136475308641974, 3.373432098765433, 3.638660416666667, 2.9981541559834577, 1.4583333333333335, 1.5273734204793028, 1.306555555555556, 1.5831633333333335, 0.7248690123456792, 0.5477058361391696, 0.3136798353909465, 0.0, 4.05, 3.4504781893004113, 2.7385291806958474, 2.1746070370370374, 3.166326666666667, 1.8291777777777782, 1.5273734204793028, 1.0416666666666667, 1.4990770779917288, 1.212886805555556, 0.6746864197530866, 0.33760432098765436, 0.0), # 57 (4.145373227886272, 3.69991739826246, 3.369591449474166, 3.6350957561728396, 2.99848826672938, 1.4583333333333335, 1.5221547405793594, 1.297914609053498, 1.5816078600823045, 0.7223150525834479, 0.5471646381510581, 0.3131677488187777, 0.0, 4.05, 3.444845237006554, 2.7358231907552906, 2.166945157750343, 3.163215720164609, 1.8170804526748974, 1.5221547405793594, 1.0416666666666667, 1.49924413336469, 1.2116985853909468, 0.6739182898948333, 0.33635612711476914, 0.0), # 58 (4.146292185767549, 3.6862295153177866, 3.365739826245999, 3.631495910493827, 2.9987891864572918, 1.4583333333333335, 1.5169577503429357, 1.289471193415638, 1.580043497942387, 0.7197849062642893, 0.5466151598287401, 0.3126541990550222, 0.0, 4.05, 3.439196189605243, 2.7330757991437, 2.1593547187928674, 3.160086995884774, 1.8052596707818933, 1.5169577503429357, 1.0416666666666667, 1.4993945932286459, 1.210498636831276, 0.6731479652492, 0.3351117741197988, 0.0), # 59 (4.147110309066831, 3.6726080246913586, 3.3618827160493825, 3.6278645833333334, 2.9990568662204096, 1.4583333333333335, 1.5117919389978214, 1.2812500000000002, 1.5784722222222225, 0.7172839506172841, 0.546057800224467, 0.3121399176954733, 0.0, 4.05, 3.4335390946502056, 2.7302890011223346, 2.151851851851852, 3.156944444444445, 1.7937500000000002, 1.5117919389978214, 1.0416666666666667, 1.4995284331102048, 1.2092881944444447, 0.6723765432098766, 0.33387345679012354, 0.0), # 60 (4.147827279453366, 3.6590770690443533, 3.3580256058527667, 3.624205478395062, 2.9992912570719494, 1.4583333333333335, 1.5066667957718067, 1.2732757201646092, 1.5768960082304526, 0.7148175628715137, 0.5454929583904894, 0.3116256363359245, 0.0, 4.05, 3.4278819996951686, 2.7274647919524466, 2.1444526886145407, 3.1537920164609052, 1.7825860082304528, 1.5066667957718067, 1.0416666666666667, 1.4996456285359747, 1.2080684927983543, 0.6716051211705534, 0.3326433699131231, 0.0), # 61 (4.148442778596402, 3.6456607910379515, 3.3541739826246006, 3.6205222993827166, 2.999492310065129, 1.4583333333333335, 1.5015918098926813, 1.2655730452674898, 1.5753168312757202, 0.7123911202560588, 0.5449210333790582, 0.31111208657216893, 0.0, 4.05, 3.4222329522938577, 2.7246051668952904, 2.137173360768176, 3.1506336625514404, 1.7718022633744859, 1.5015918098926813, 1.0416666666666667, 1.4997461550325646, 1.2068407664609058, 0.6708347965249202, 0.33142370827617745, 0.0), # 62 (4.148956488165184, 3.6323833333333333, 3.350333333333334, 3.6168187500000006, 2.9996599762531617, 1.4583333333333335, 1.4965764705882352, 1.2581666666666669, 1.5737366666666666, 0.7100100000000001, 0.5443424242424244, 0.31060000000000004, 0.0, 4.05, 3.4166, 2.721712121212122, 2.13003, 3.147473333333333, 1.7614333333333339, 1.4965764705882352, 1.0416666666666667, 1.4998299881265809, 1.2056062500000004, 0.6700666666666668, 0.3302166666666667, 0.0), # 63 (4.149368089828959, 3.6192688385916783, 3.346509144947417, 3.613098533950618, 2.999794206689266, 1.4583333333333335, 1.4916302670862585, 1.2510812757201648, 1.5721574897119341, 0.707679579332419, 0.5437575300328387, 0.31009010821521116, 0.0, 4.05, 3.4109911903673225, 2.7187876501641934, 2.1230387379972564, 3.1443149794238683, 1.7515137860082308, 1.4916302670862585, 1.0416666666666667, 1.499897103344633, 1.2043661779835395, 0.6693018289894834, 0.3290244398719708, 0.0), # 64 (4.149677265256975, 3.6063414494741655, 3.3427069044352997, 3.609365354938272, 2.999894952426658, 1.4583333333333335, 1.4867626886145406, 1.2443415637860082, 1.5705812757201647, 0.7054052354823961, 0.5431667498025524, 0.3095831428135955, 0.0, 4.05, 3.40541457094955, 2.715833749012762, 2.116215706447188, 3.1411625514403294, 1.7420781893004116, 1.4867626886145406, 1.0416666666666667, 1.499947476213329, 1.2031217849794242, 0.66854138088706, 0.32784922267946964, 0.0), # 65 (4.149883696118478, 3.593625308641976, 3.3389320987654325, 3.605622916666667, 2.9999621645185526, 1.4583333333333335, 1.4819832244008715, 1.2379722222222225, 1.56901, 0.7031923456790125, 0.542570482603816, 0.3090798353909466, 0.0, 4.05, 3.399878189300412, 2.7128524130190796, 2.1095770370370373, 3.13802, 1.7331611111111116, 1.4819832244008715, 1.0416666666666667, 1.4999810822592763, 1.2018743055555559, 0.6677864197530866, 0.3266932098765433, 0.0), # 66 (4.149987064082717, 3.581144558756287, 3.3351902149062647, 3.601874922839506, 2.999995794018168, 1.4583333333333335, 1.4773013636730412, 1.2319979423868317, 1.5674456378600823, 0.7010462871513491, 0.5419691274888808, 0.3085809175430575, 0.0, 4.05, 3.394390092973632, 2.7098456374444035, 2.103138861454047, 3.1348912757201646, 1.7247971193415643, 1.4773013636730412, 1.0416666666666667, 1.499997897009084, 1.2006249742798356, 0.6670380429812529, 0.3255585962505716, 0.0), # 67 (4.14991664579233, 3.5688578344174515, 3.331468649977138, 3.5980925221417075, 2.9999674547459585, 1.4583062693695066, 1.4727030389659292, 1.226390641670477, 1.5658783798201494, 0.6989620441647167, 0.5413523992360252, 0.3080843340633248, 0.0, 4.0499500600137175, 3.388927674696572, 2.7067619961801257, 2.09688613249415, 3.131756759640299, 1.716946898338668, 1.4727030389659292, 1.0416473352639333, 1.4999837273729792, 1.199364174047236, 0.6662937299954276, 0.3244416213106775, 0.0), # 68 (4.149256682769726, 3.5563900238948625, 3.3276628086419753, 3.594085054347826, 2.999709513435003, 1.4580923182441705, 1.4680536362693228, 1.2208497942386831, 1.5642397119341562, 0.6968806390704431, 0.5406575225943647, 0.3075739657786442, 0.0, 4.049554398148149, 3.3833136235650856, 2.7032876129718235, 2.090641917211329, 3.1284794238683125, 1.7091897119341564, 1.4680536362693228, 1.0414945130315503, 1.4998547567175016, 1.1980283514492756, 0.665532561728395, 0.3233081839904421, 0.0), # 69 (4.147954315023558, 3.5436839019425634, 3.3237561442615453, 3.589826137278583, 2.999199817101051, 1.4576709597114261, 1.463332026912274, 1.2153254077122393, 1.5625203856119496, 0.6947919524462736, 0.539876592435072, 0.307047425376427, 0.0, 4.048772933813444, 3.3775216791406963, 2.6993829621753602, 2.0843758573388205, 3.1250407712238992, 1.701455570797135, 1.463332026912274, 1.0411935426510186, 1.4995999085505256, 1.1966087124261946, 0.6647512288523091, 0.32215308199477855, 0.0), # 70 (4.146027864257172, 3.5307470618168946, 3.319750028577961, 3.585322051127214, 2.9984448210011028, 1.4570490219986791, 1.4585403319077976, 1.2098193110806281, 1.5607229614388052, 0.6926960359342641, 0.5390124913855908, 0.3065050979070905, 0.0, 4.047615955075446, 3.3715560769779955, 2.695062456927954, 2.0780881078027917, 3.1214459228776104, 1.6937470355128794, 1.4585403319077976, 1.040749301427628, 1.4992224105005514, 1.1951073503757383, 0.6639500057155922, 0.3209770056197177, 0.0), # 71 (4.143495652173914, 3.5175870967741933, 3.3156458333333334, 3.5805790760869565, 2.9974509803921565, 1.4562333333333337, 1.4536806722689075, 1.2043333333333335, 1.55885, 0.6905929411764707, 0.5380681020733654, 0.3059473684210527, 0.0, 4.04609375, 3.365421052631579, 2.6903405103668265, 2.071778823529412, 3.1177, 1.6860666666666668, 1.4536806722689075, 1.040166666666667, 1.4987254901960783, 1.1935263586956524, 0.6631291666666667, 0.31978064516129034, 0.0), # 72 (4.140376000477128, 3.5042116000707995, 3.3114449302697757, 3.575603492351047, 2.996224750531214, 1.4552307219427933, 1.4487551690086184, 1.1988693034598386, 1.556904061880811, 0.6884827198149495, 0.5370463071258393, 0.30537462196873066, 0.0, 4.04421660665295, 3.3591208416560367, 2.6852315356291965, 2.065448159444848, 3.113808123761622, 1.678417024843774, 1.4487551690086184, 1.0394505156734237, 1.498112375265607, 1.1918678307836825, 0.6622889860539553, 0.31856469091552725, 0.0), # 73 (4.136687230870161, 3.4906281649630513, 3.307148691129401, 3.570401580112721, 2.9947725866752735, 1.4540480160544635, 1.4437659431399446, 1.1934290504496268, 1.5548877076665142, 0.6863654234917563, 0.5359499891704572, 0.30478724360054227, 0.0, 4.041994813100138, 3.3526596796059644, 2.6797499458522855, 2.0590962704752687, 3.1097754153330284, 1.6708006706294773, 1.4437659431399446, 1.0386057257531882, 1.4973862933376367, 1.190133860037574, 0.6614297382258802, 0.31732983317845925, 0.0), # 74 (4.13244766505636, 3.4768443847072876, 3.302758487654321, 3.564979619565217, 2.9931009440813363, 1.452692043895748, 1.4387151156759002, 1.188014403292181, 1.5528034979423868, 0.6842411038489471, 0.5347820308346625, 0.30418561836690494, 0.0, 4.039438657407408, 3.3460418020359537, 2.673910154173312, 2.052723311546841, 3.1056069958847736, 1.6632201646090536, 1.4387151156759002, 1.0376371742112487, 1.4965504720406682, 1.1883265398550726, 0.6605516975308642, 0.3160767622461171, 0.0), # 75 (4.127675624739071, 3.462867852559848, 3.2982756915866487, 3.559343890901771, 2.9912162780064016, 1.4511696336940512, 1.4336048076294992, 1.1826271909769854, 1.5506539932937051, 0.682109812528578, 0.5335453147458995, 0.3035701313182361, 0.0, 4.036558427640603, 3.339271444500597, 2.6677265737294973, 2.046329437585734, 3.1013079865874102, 1.6556780673677796, 1.4336048076294992, 1.0365497383528937, 1.4956081390032008, 1.186447963633924, 0.6596551383173298, 0.31480616841453174, 0.0), # 76 (4.122389431621637, 3.4487061617770705, 3.2937016746684953, 3.55350067431562, 2.9891250437074692, 1.4494876136767771, 1.4284371400137559, 1.1772692424935225, 1.5484417543057463, 0.6799716011727052, 0.5322427235316126, 0.3029411675049536, 0.0, 4.03336441186557, 3.332352842554489, 2.6612136176580625, 2.039914803518115, 3.0968835086114925, 1.6481769394909316, 1.4284371400137559, 1.0353482954834123, 1.4945625218537346, 1.1845002247718734, 0.6587403349336991, 0.31351874197973373, 0.0), # 77 (4.1166074074074075, 3.4343669056152932, 3.2890378086419756, 3.54745625, 2.98683369644154, 1.4476528120713306, 1.423214233841685, 1.171942386831276, 1.5461693415637856, 0.6778265214233843, 0.5308771398192452, 0.30229911197747467, 0.0, 4.029866898148149, 3.3252902317522204, 2.654385699096226, 2.0334795642701526, 3.092338683127571, 1.6407193415637862, 1.423214233841685, 1.0340377229080933, 1.49341684822077, 1.182485416666667, 0.6578075617283952, 0.312215173237754, 0.0), # 78 (4.110347873799726, 3.4198576773308558, 3.2842854652492, 3.541216898148148, 2.9843486914656125, 1.445672057105116, 1.4179382101263003, 1.166648452979729, 1.5438393156531016, 0.6756746249226715, 0.5294514462362415, 0.30164434978621685, 0.0, 4.026076174554183, 3.318087847648385, 2.6472572311812077, 2.0270238747680143, 3.0876786313062032, 1.6333078341716205, 1.4179382101263003, 1.0326228979322258, 1.4921743457328063, 1.1804056327160497, 0.6568570930498401, 0.31089615248462327, 0.0), # 79 (4.103629152501939, 3.4051860701800964, 3.2794460162322814, 3.534788898953301, 2.9816764840366874, 1.4435521770055377, 1.4126111898806162, 1.1613892699283648, 1.5414542371589697, 0.6735159633126228, 0.527968525410046, 0.30097726598159785, 0.0, 4.02200252914952, 3.310749925797576, 2.6398426270502298, 2.020547889937868, 3.0829084743179394, 1.6259449778997108, 1.4126111898806162, 1.0311086978610984, 1.4908382420183437, 1.1782629663177673, 0.6558892032464564, 0.3095623700163725, 0.0), # 80 (4.096469565217392, 3.390359677419355, 3.2745208333333338, 3.5281785326086963, 2.9788235294117644, 1.4413000000000002, 1.4072352941176471, 1.1561666666666668, 1.5390166666666665, 0.6713505882352943, 0.5264312599681021, 0.3002982456140351, 0.0, 4.01765625, 3.303280701754386, 2.632156299840511, 2.0140517647058824, 3.078033333333333, 1.6186333333333336, 1.4072352941176471, 1.0295, 1.4894117647058822, 1.1760595108695657, 0.6549041666666667, 0.30821451612903233, 0.0), # 81 (4.088887433649431, 3.3753860923049697, 3.269511288294468, 3.5213920793075686, 2.975796282847844, 1.4389223543159075, 1.4018126438504073, 1.1509824721841184, 1.5365291647614692, 0.6691785513327417, 0.5248425325378543, 0.29960767373394626, 0.0, 4.013047625171469, 3.2956844110734083, 2.624212662689271, 2.0075356539982248, 3.0730583295229383, 1.6113754610577657, 1.4018126438504073, 1.0278016816542197, 1.487898141423922, 1.1737973597691898, 0.6539022576588936, 0.30685328111863364, 0.0), # 82 (4.080901079501402, 3.3602729080932785, 3.264418752857796, 3.514435819243156, 2.9726011996019257, 1.4364260681806638, 1.3963453600919107, 1.1458385154702029, 1.533994292028654, 0.6669999042470213, 0.5232052257467463, 0.29890593539174876, 0.0, 4.008186942729767, 3.287965289309236, 2.6160261287337314, 2.0009997127410637, 3.067988584057308, 1.604173921658284, 1.3963453600919107, 1.0260186201290455, 1.4863005998009629, 1.1714786064143856, 0.6528837505715593, 0.3054793552812072, 0.0), # 83 (4.072528824476651, 3.345027718040621, 3.259244598765432, 3.507316032608696, 2.969244734931009, 1.4338179698216735, 1.3908355638551717, 1.1407366255144034, 1.5314146090534977, 0.664814698620189, 0.5215222222222223, 0.2981934156378601, 0.0, 4.003084490740741, 3.280127572016461, 2.6076111111111113, 1.9944440958605667, 3.0628292181069954, 1.5970312757201646, 1.3908355638551717, 1.0241556927297668, 1.4846223674655046, 1.169105344202899, 0.6518489197530865, 0.3040934289127838, 0.0), # 84 (4.063788990278524, 3.3296581154033364, 3.253990197759488, 3.5000389995974235, 2.9657333440920954, 1.431104887466342, 1.385285376153205, 1.1356786313062037, 1.528792676421277, 0.6626229860943007, 0.5197964045917264, 0.29747049952269794, 0.0, 3.9977505572702334, 3.272175494749677, 2.5989820229586313, 1.9878689582829017, 3.057585352842554, 1.589950083828685, 1.385285376153205, 1.0222177767616727, 1.4828666720460477, 1.1666796665324748, 0.6507980395518976, 0.30269619230939426, 0.0), # 85 (4.054699898610365, 3.3141716934377627, 3.2486569215820764, 3.492611000402577, 2.9620734823421824, 1.4282936493420721, 1.3796969179990242, 1.1306663618350863, 1.5261310547172688, 0.6604248183114125, 0.5180306554827024, 0.29673757209667984, 0.0, 3.992195430384088, 3.2641132930634775, 2.5901532774135116, 1.9812744549342374, 3.0522621094345377, 1.5829329065691207, 1.3796969179990242, 1.0202097495300515, 1.4810367411710912, 1.1642036668008593, 0.6497313843164153, 0.3012883357670694, 0.0), # 86 (4.045279871175523, 3.298576045400239, 3.2432461419753085, 3.485038315217391, 2.9582716049382722, 1.4253910836762689, 1.3740723104056438, 1.1257016460905351, 1.5234323045267493, 0.6582202469135804, 0.5162278575225944, 0.29599501841022313, 0.0, 3.9864293981481485, 3.255945202512454, 2.581139287612972, 1.9746607407407408, 3.0468646090534985, 1.5759823045267491, 1.3740723104056438, 1.018136488340192, 1.4791358024691361, 1.1616794384057973, 0.6486492283950618, 0.29987054958183995, 0.0), # 87 (4.035547229677343, 3.2828787645471036, 3.2377592306812986, 3.477327224235105, 2.954334167137363, 1.4224040186963371, 1.3684136743860782, 1.1207863130620332, 1.5206989864349947, 0.6560093235428602, 0.5143908933388467, 0.29524322351374555, 0.0, 3.9804627486282587, 3.2476754586512007, 2.571954466694233, 1.9680279706285804, 3.0413979728699894, 1.5691008382868465, 1.3684136743860782, 1.0160028704973836, 1.4771670835686814, 1.1591090747450352, 0.6475518461362598, 0.29844352404973673, 0.0), # 88 (4.025520295819169, 3.267087444134696, 3.2321975594421586, 3.4694840076489535, 2.950267624196455, 1.4193392826296807, 1.3627231309533416, 1.1159221917390643, 1.5179336610272824, 0.6537920998413084, 0.512522645558903, 0.29448257245766457, 0.0, 3.9743057698902606, 3.2393082970343094, 2.5626132277945146, 1.9613762995239248, 3.035867322054565, 1.56229106843469, 1.3627231309533416, 1.0138137733069148, 1.4751338120982276, 1.156494669216318, 0.6464395118884317, 0.2970079494667906, 0.0), # 89 (4.015217391304348, 3.2512096774193546, 3.2265625000000004, 3.4615149456521745, 2.946078431372549, 1.4162037037037039, 1.3570028011204482, 1.1111111111111112, 1.515138888888889, 0.6515686274509805, 0.5106259968102075, 0.2937134502923977, 0.0, 3.9679687500000003, 3.230847953216374, 2.553129984051037, 1.9547058823529413, 3.030277777777778, 1.5555555555555556, 1.3570028011204482, 1.0115740740740742, 1.4730392156862746, 1.1538383152173917, 0.6453125000000001, 0.2955645161290323, 0.0), # 90 (4.004656837836225, 3.235253057657418, 3.2208554240969365, 3.4534263184380034, 2.9417730439226437, 1.413004110145811, 1.3512548059004124, 1.1063549001676574, 1.512317230605091, 0.6493389580139327, 0.5087038297202041, 0.2929362420683625, 0.0, 3.961461977023319, 3.222298662751987, 2.5435191486010202, 1.9480168740417978, 3.024634461210182, 1.5488968602347204, 1.3512548059004124, 1.0092886501041507, 1.4708865219613219, 1.1511421061460014, 0.6441710848193873, 0.2941139143324926, 0.0), # 91 (3.9938569571181493, 3.2192251781052263, 3.21507770347508, 3.445224406199678, 2.937357917103741, 1.4097473301834071, 1.3454812663062485, 1.1016553878981865, 1.5094712467611644, 0.6471031431722211, 0.506759026916337, 0.29215133283597666, 0.0, 3.954795739026063, 3.2136646611957427, 2.5337951345816845, 1.9413094295166629, 3.018942493522329, 1.5423175430574612, 1.3454812663062485, 1.0069623787024338, 1.4686789585518705, 1.148408135399893, 0.6430155406950161, 0.29265683437320245, 0.0), # 92 (3.982836070853462, 3.2031336320191164, 3.2092307098765436, 3.4369154891304357, 2.932839506172839, 1.4064401920438958, 1.3396843033509702, 1.0970144032921811, 1.506603497942387, 0.6448612345679013, 0.50479447102605, 0.29135910764565737, 0.0, 3.9479803240740736, 3.2049501841022305, 2.52397235513025, 1.9345837037037037, 3.013206995884774, 1.5358201646090537, 1.3396843033509702, 1.0046001371742113, 1.4664197530864196, 1.145638496376812, 0.6418461419753088, 0.29119396654719243, 0.0), # 93 (3.971612500745512, 3.1869860126554275, 3.203315815043439, 3.428505847423511, 2.9282242663869384, 1.403089523954682, 1.3338660380475922, 1.0924337753391253, 1.5037165447340346, 0.6426132838430298, 0.5028130446767874, 0.2905599515478225, 0.0, 3.9410260202331964, 3.196159467026047, 2.5140652233839367, 1.927839851529089, 3.007433089468069, 1.5294072854747756, 1.3338660380475922, 1.0022068028247728, 1.4641121331934692, 1.1428352824745038, 0.6406631630086879, 0.28972600115049346, 0.0), # 94 (3.960204568497644, 3.170789913270499, 3.1973343907178786, 3.420001761272142, 2.9235186530030397, 1.3997021541431696, 1.3280285914091288, 1.0879153330285019, 1.500812947721384, 0.6403593426396622, 0.5008176304959931, 0.28975424959288937, 0.0, 3.933943115569273, 3.187296745521783, 2.504088152479966, 1.9210780279189863, 3.001625895442768, 1.5230814662399026, 1.3280285914091288, 0.9997872529594067, 1.4617593265015199, 1.1400005870907142, 0.6394668781435758, 0.2882536284791363, 0.0), # 95 (3.948630595813205, 3.15455292712067, 3.1912878086419756, 3.4114095108695652, 2.9187291212781408, 1.3962849108367628, 1.3221740844485943, 1.0834609053497943, 1.497895267489712, 0.638099462599855, 0.4988111111111112, 0.2889423868312758, 0.0, 3.9267418981481486, 3.1783662551440335, 2.494055555555556, 1.9142983877995645, 2.995790534979424, 1.5168452674897122, 1.3221740844485943, 0.9973463648834019, 1.4593645606390704, 1.1371365036231886, 0.6382575617283952, 0.28677753882915186, 0.0), # 96 (3.936908904395539, 3.138282647462278, 3.185177440557842, 3.4027353764090176, 2.913862126469244, 1.3928446222628663, 1.3163046381790027, 1.0790723212924862, 1.4949660646242953, 0.6358336953656636, 0.4967963691495856, 0.288124748313399, 0.0, 3.919432656035666, 3.169372231447389, 2.4839818457479277, 1.9075010860969903, 2.9899321292485905, 1.5107012498094807, 1.3163046381790027, 0.9948890159020474, 1.456931063234622, 1.1342451254696728, 0.6370354881115684, 0.2852984224965707, 0.0), # 97 (3.925057815947994, 3.1219866675516617, 3.17900465820759, 3.3939856380837363, 2.908924123833347, 1.3893881166488853, 1.3104223736133687, 1.0747514098460602, 1.4920278997104097, 0.6335620925791443, 0.49477628723886047, 0.28730171908967667, 0.0, 3.9120256772976685, 3.1603189099864424, 2.4738814361943025, 1.9006862777374325, 2.9840557994208194, 1.5046519737844843, 1.3104223736133687, 0.9924200833206323, 1.4544620619166735, 1.1313285460279123, 0.6358009316415181, 0.2838169697774238, 0.0), # 98 (3.9130956521739133, 3.1056725806451615, 3.1727708333333338, 3.3851665760869567, 2.9039215686274513, 1.3859222222222223, 1.3045294117647062, 1.0705000000000002, 1.4890833333333333, 0.6312847058823531, 0.4927537480063797, 0.2864736842105264, 0.0, 3.9045312500000002, 3.1512105263157895, 2.4637687400318984, 1.893854117647059, 2.9781666666666666, 1.4987000000000004, 1.3045294117647062, 0.9899444444444444, 1.4519607843137257, 1.1283888586956525, 0.6345541666666669, 0.282333870967742, 0.0), # 99 (3.901040734776645, 3.0893479799991144, 3.1664773376771835, 3.3762844706119166, 2.8988609161085557, 1.382453767210283, 1.298627873646029, 1.0663199207437892, 1.4861349260783419, 0.629001586917346, 0.49073163407958736, 0.2856410287263656, 0.0, 3.896959662208505, 3.142051315990021, 2.4536581703979365, 1.8870047607520375, 2.9722698521566837, 1.492847889041305, 1.298627873646029, 0.9874669765787736, 1.4494304580542778, 1.125428156870639, 0.6332954675354368, 0.28084981636355594, 0.0), # 100 (3.888911385459534, 3.0730204588698617, 3.160125542981253, 3.367345601851852, 2.8937486215336614, 1.3789895798404714, 1.2927198802703526, 1.0622130010669104, 1.4831852385307118, 0.626712787326179, 0.48871282808592753, 0.2848041376876118, 0.0, 3.8893212019890258, 3.1328455145637295, 2.4435641404296375, 1.8801383619785366, 2.9663704770614236, 1.4870982014936747, 1.2927198802703526, 0.9849925570289081, 1.4468743107668307, 1.1224485339506176, 0.6320251085962507, 0.2793654962608966, 0.0), # 101 (3.8767259259259266, 3.05669761051374, 3.1537168209876545, 3.3583562500000004, 2.8885911401597673, 1.3755364883401924, 1.2868075526506901, 1.0581810699588479, 1.4802368312757201, 0.624418358750908, 0.48670021265284436, 0.28396339614468274, 0.0, 3.881626157407408, 3.12359735759151, 2.4335010632642216, 1.8732550762527236, 2.9604736625514403, 1.481453497942387, 1.2868075526506901, 0.9825260631001375, 1.4442955700798836, 1.1194520833333337, 0.630743364197531, 0.27788160095579456, 0.0), # 102 (3.864502677879168, 3.040387028187088, 3.1472525434385004, 3.349322695249598, 2.883394927243874, 1.3721013209368493, 1.280893011800056, 1.0542259564090841, 1.4772922648986433, 0.6221183528335891, 0.48469667040778164, 0.2831191891479958, 0.0, 3.873884816529492, 3.114311080627953, 2.4234833520389083, 1.8663550585007669, 2.9545845297972866, 1.475916338972718, 1.280893011800056, 0.9800723720977494, 1.441697463621937, 1.1164408984165328, 0.6294505086877001, 0.2763988207442808, 0.0), # 103 (3.852259963022604, 3.0240963051462453, 3.140734082075903, 3.340251217793881, 2.878166438042981, 1.3686909058578471, 1.2749783787314652, 1.0503494894071028, 1.4743540999847584, 0.6198128212162782, 0.48270508397818346, 0.2822719017479685, 0.0, 3.8661074674211253, 3.104990919227653, 2.413525419890917, 1.8594384636488344, 2.948708199969517, 1.4704892851699438, 1.2749783787314652, 0.9776363613270336, 1.4390832190214904, 1.1134170725979606, 0.6281468164151807, 0.274917845922386, 0.0), # 104 (3.840016103059581, 3.0078330346475504, 3.1341628086419755, 3.3311480978260866, 2.8729121278140886, 1.3653120713305902, 1.2690657744579317, 1.0465534979423872, 1.4714248971193415, 0.6175018155410315, 0.480728335991494, 0.2814219189950185, 0.0, 3.858304398148148, 3.0956411089452027, 2.40364167995747, 1.852505446623094, 2.942849794238683, 1.465174897119342, 1.2690657744579317, 0.9752229080932786, 1.4364560639070443, 1.1103826992753625, 0.6268325617283951, 0.273439366786141, 0.0), # 105 (3.8277894196934454, 2.9916048099473427, 3.1275400948788294, 3.3220196155394524, 2.867638451814196, 1.3619716455824824, 1.263157319992469, 1.0428398110044201, 1.4685072168876694, 0.6151853874499046, 0.4787693090751571, 0.2805696259395632, 0.0, 3.850485896776406, 3.0862658853351945, 2.3938465453757853, 1.8455561623497134, 2.9370144337753388, 1.4599757354061882, 1.263157319992469, 0.9728368897017731, 1.433819225907098, 1.1073398718464844, 0.6255080189757659, 0.27196407363157665, 0.0), # 106 (3.8155982346275423, 2.9754192243019606, 3.1208673125285786, 3.312872051127214, 2.8623518653003037, 1.3586764568409289, 1.2572551363480924, 1.0392102575826858, 1.465603619875019, 0.612863588584954, 0.47683088585661687, 0.2797154076320202, 0.0, 3.842662251371742, 3.0768694839522217, 2.3841544292830843, 1.8385907657548617, 2.931207239750038, 1.4548943606157603, 1.2572551363480924, 0.9704831834578064, 1.4311759326501519, 1.1042906837090716, 0.6241734625057157, 0.2704926567547237, 0.0), # 107 (3.8034608695652175, 2.9592838709677425, 3.114145833333334, 3.303711684782609, 2.857058823529411, 1.3554333333333337, 1.2513613445378151, 1.0356666666666667, 1.4627166666666667, 0.6105364705882355, 0.47491594896331746, 0.2788596491228071, 0.0, 3.8348437500000006, 3.0674561403508775, 2.374579744816587, 1.8316094117647062, 2.9254333333333333, 1.4499333333333335, 1.2513613445378151, 0.9681666666666668, 1.4285294117647056, 1.10123722826087, 0.6228291666666669, 0.269025806451613, 0.0), # 108 (3.7913956462098173, 2.9432063432010267, 3.1073770290352085, 3.2945447966988723, 2.85176578175852, 1.3522491032871007, 1.2454780655746525, 1.032210867245847, 1.4598489178478888, 0.6082040851018049, 0.4730273810227027, 0.2780027354623413, 0.0, 3.8270406807270234, 3.0580300900857535, 2.3651369051135136, 1.8246122553054143, 2.9196978356957777, 1.4450952141441857, 1.2454780655746525, 0.9658922166336433, 1.42588289087926, 1.0981815988996244, 0.6214754058070417, 0.2675642130182752, 0.0), # 109 (3.7794208862646865, 2.9271942342581534, 3.1005622713763157, 3.285377667069243, 2.846479195244628, 1.3491305949296348, 1.2396074204716179, 1.0288446883097089, 1.4570029340039627, 0.6058664837677185, 0.4711680646622168, 0.2771450517010405, 0.0, 3.819263331618656, 3.0485955687114448, 2.355840323311084, 1.817599451303155, 2.9140058680079255, 1.4403825636335925, 1.2396074204716179, 0.9636647106640249, 1.423239597622314, 1.0951258890230813, 0.6201124542752632, 0.2661085667507413, 0.0), # 110 (3.7675549114331726, 2.91125513739546, 3.093702932098766, 3.2762165760869566, 2.841205519244735, 1.3460846364883403, 1.2337515302417263, 1.0255699588477367, 1.4541812757201646, 0.6035237182280321, 0.4693408825093036, 0.27628698288932213, 0.0, 3.811521990740741, 3.039156811782543, 2.346704412546518, 1.810571154684096, 2.9083625514403293, 1.4357979423868314, 1.2337515302417263, 0.9614890260631003, 1.4206027596223676, 1.0920721920289858, 0.6187405864197533, 0.26465955794504187, 0.0), # 111 (3.75581604341862, 2.895396645869286, 3.086800382944674, 3.26706780394525, 2.8359512090158425, 1.3431180561906215, 1.2279125158979918, 1.0223885078494133, 1.4513865035817708, 0.6011758401248017, 0.46754871719140734, 0.2754289140776037, 0.0, 3.803826946159122, 3.0297180548536407, 2.337743585957037, 1.8035275203744048, 2.9027730071635416, 1.4313439109891786, 1.2279125158979918, 0.9593700401361582, 1.4179756045079213, 1.0890226013150834, 0.6173600765889348, 0.2632178768972078, 0.0), # 112 (3.744201689481218, 2.8796528268881825, 3.0798726094173565, 3.257950164747612, 2.830713514712988, 1.3402362794833866, 1.222105192731354, 1.0193087614634344, 1.4486283748344828, 0.5988304736612731, 0.4657949270768578, 0.274573097883481, 0.0, 3.7961775603372887, 3.0203040767182903, 2.328974635384289, 1.796491420983819, 2.8972567496689656, 1.4270322660488082, 1.222105192731354, 0.957311628202419, 1.415356757356494, 1.0859833882492043, 0.6159745218834713, 0.26178662062619845, 0.0), # 113 (3.732592359160026, 2.8641789672926965, 3.0730152250072065, 3.2489368263832006, 2.8254382278843537, 1.3374327419903105, 1.216403641682116, 1.0163685432508534, 1.4459492047617415, 0.5965315167912784, 0.46408295580754655, 0.2737304057370992, 0.0, 3.788510165664014, 3.0110344631080905, 2.3204147790377325, 1.7895945503738346, 2.891898409523483, 1.4229159605511947, 1.216403641682116, 0.9553091014216503, 1.4127191139421769, 1.0829789421277338, 0.6146030450014414, 0.2603799061175179, 0.0), # 114 (3.720953961201598, 2.848980639517117, 3.066232310902439, 3.240025351554534, 2.820108714103627, 1.3347001529163784, 1.2108119300383124, 1.0135671090464515, 1.4433499971558386, 0.5942825327988078, 0.46241030076180634, 0.27290125275196175, 0.0, 3.7808026526641507, 3.001913780271579, 2.3120515038090312, 1.7828475983964231, 2.886699994311677, 1.4189939526650321, 1.2108119300383124, 0.9533572520831274, 1.4100543570518136, 1.0800084505181782, 0.613246462180488, 0.2589982399561016, 0.0), # 115 (3.709271949295054, 2.8340357031402905, 3.0595107299946247, 3.231199845079921, 2.8147169403690073, 1.3320320713669895, 1.2053209635055788, 1.010896718816499, 1.4408241785637108, 0.5920793358449549, 0.4607737287514322, 0.27208410658291154, 0.0, 3.7730429039023563, 2.9929251724120265, 2.3038686437571605, 1.7762380075348643, 2.8816483571274216, 1.4152554063430987, 1.2053209635055788, 0.9514514795478496, 1.4073584701845037, 1.0770666150266406, 0.611902145998925, 0.25763960937639013, 0.0), # 116 (3.697531777129509, 2.8193220177410643, 3.052837345175329, 3.2224444117776727, 2.8092548736786958, 1.3294220564475412, 1.1999216477895505, 1.0083496325272643, 1.4383651755322937, 0.589917740090813, 0.45917000658821894, 0.2712774348847917, 0.0, 3.76521880194329, 2.9840517837327085, 2.2958500329410945, 1.7697532202724386, 2.8767303510645874, 1.4116894855381699, 1.1999216477895505, 0.9495871831768151, 1.4046274368393479, 1.0741481372592245, 0.6105674690350659, 0.25630200161282407, 0.0), # 117 (3.6857188983940845, 2.804817442898285, 3.0461990193361226, 3.2137431564660996, 2.8037144810308914, 1.3268636672634326, 1.1946048885958631, 1.0059181101450163, 1.4359664146085245, 0.587793559697476, 0.4575959010839617, 0.27047970531244503, 0.0, 3.75731822935161, 2.9752767584368947, 2.287979505419808, 1.7633806790924278, 2.871932829217049, 1.4082853542030227, 1.1946048885958631, 0.9477597623310232, 1.4018572405154457, 1.0712477188220335, 0.6092398038672245, 0.25498340389984414, 0.0), # 118 (3.673818766777897, 2.790499838190801, 3.0395826153685745, 3.2050801839635117, 2.7980877294237922, 1.324350462920061, 1.1893615916301512, 1.0035944116360243, 1.433621322339339, 0.5857026088260373, 0.45604817905045525, 0.26968938552071453, 0.0, 3.749329068691973, 2.9665832407278594, 2.2802408952522764, 1.7571078264781117, 2.867242644678678, 1.405032176290434, 1.1893615916301512, 0.9459646163714721, 1.3990438647118961, 1.0683600613211708, 0.607916523073715, 0.253681803471891, 0.0), # 119 (3.6618168359700647, 2.776347063197458, 3.0329749961642545, 3.196439599088218, 2.792366585855599, 1.3218760025228253, 1.1841826625980507, 1.0013707969665573, 1.4313233252716744, 0.5836407016375906, 0.4545236072994945, 0.2689049431644433, 0.0, 3.741239202529039, 2.9579543748088755, 2.272618036497472, 1.7509221049127714, 2.8626466505433488, 1.40191911575318, 1.1841826625980507, 0.9441971446591609, 1.3961832929277995, 1.0654798663627396, 0.6065949992328509, 0.25239518756340534, 0.0), # 120 (3.6496985596597074, 2.762336977497104, 3.0263630246147293, 3.1878055066585302, 2.7865430173245116, 1.319433845177124, 1.179059007205196, 0.9992395261028846, 1.4290658499524664, 0.5816036522932297, 0.4530189526428745, 0.26812484589847413, 0.0, 3.7330365134274643, 2.9493733048832147, 2.265094763214372, 1.744810956879689, 2.858131699904933, 1.3989353365440385, 1.179059007205196, 0.9424527465550885, 1.3932715086622558, 1.0626018355528437, 0.6052726049229459, 0.2511215434088277, 0.0), # 121 (3.6374493915359416, 2.7484474406685857, 3.0197335636115703, 3.179162011492757, 2.780608990828729, 1.3170175499883545, 1.1739815311572235, 0.9971928590112749, 1.4268423229286518, 0.5795872749540478, 0.45153098189239016, 0.2673475613776501, 0.0, 3.7247088839519082, 2.9408231751541503, 2.2576549094619507, 1.7387618248621433, 2.8536846458573035, 1.3960700026157848, 1.1739815311572235, 0.9407268214202532, 1.3903044954143644, 1.059720670497586, 0.6039467127223141, 0.24985885824259874, 0.0), # 122 (3.6250547852878876, 2.7346563122907503, 3.013073476046346, 3.1704932184092085, 2.774556473366451, 1.314620676061916, 1.1689411401597678, 0.9952230556579972, 1.4246461707471672, 0.5775873837811388, 0.4500564618598364, 0.2665715572568141, 0.0, 3.716244196667029, 2.9322871298249544, 2.2502823092991817, 1.7327621513434162, 2.8492923414943343, 1.3933122779211962, 1.1689411401597678, 0.9390147686156541, 1.3872782366832255, 1.0568310728030696, 0.6026146952092691, 0.24860511929915918, 0.0), # 123 (3.612500194604662, 2.7209414519424455, 3.0063696248106235, 3.1617832322261963, 2.7683774319358765, 1.312236782503206, 1.163928739918464, 0.9933223760093212, 1.4224708199549485, 0.5755997929355963, 0.448592159357008, 0.26579530119080924, 0.0, 3.7076303341374848, 2.923748313098901, 2.2429607967850402, 1.7267993788067884, 2.844941639909897, 1.3906513264130496, 1.163928739918464, 0.93731198750229, 1.3841887159679382, 1.053927744075399, 0.6012739249621247, 0.24735831381294962, 0.0), # 124 (3.5997710731753836, 2.7072807192025174, 2.999608872795975, 3.1530161577620284, 2.7620638335352057, 1.309859428417623, 1.1589352361389478, 0.9914830800315152, 1.4203096970989324, 0.5736203165785135, 0.4471348411957002, 0.26501726083447835, 0.0, 3.6988551789279316, 2.9151898691792613, 2.235674205978501, 1.7208609497355403, 2.840619394197865, 1.3880763120441213, 1.1589352361389478, 0.9356138774411593, 1.3810319167676028, 1.0510053859206763, 0.599921774559195, 0.24611642901841072, 0.0), # 125 (3.5868528746891712, 2.6936519736498146, 2.9927780828939663, 3.1441760998350166, 2.755607645162638, 1.307482172910566, 1.153951534526854, 0.9896974276908488, 1.4181562287260556, 0.5716447688709844, 0.44568127418770764, 0.26423590384266454, 0.0, 3.6899066136030316, 2.9065949422693094, 2.2284063709385378, 1.7149343066129528, 2.8363124574521112, 1.3855763987671883, 1.153951534526854, 0.9339158377932613, 1.377803822581319, 1.0480586999450057, 0.5985556165787933, 0.2448774521499832, 0.0), # 126 (3.5737310528351447, 2.680033074863182, 2.9858641179961682, 3.13524716326347, 2.749000833816373, 1.305098575087432, 1.1489685407878187, 0.987957678953591, 1.416003841383254, 0.5696689639741025, 0.44422822514482535, 0.2634496978702106, 0.0, 3.6807725207274395, 2.897946676572316, 2.2211411257241265, 1.7090068919223071, 2.832007682766508, 1.3831407505350275, 1.1489685407878187, 0.9322132679195942, 1.3745004169081865, 1.0450823877544901, 0.5971728235992337, 0.2436393704421075, 0.0), # 127 (3.5603910613024183, 2.6664018824214697, 2.9788538409941503, 3.1262134528656995, 2.7422353664946106, 1.3027021940536203, 1.1439771606274765, 0.9862560937860104, 1.4138459616174646, 0.5676887160489614, 0.44277246087884836, 0.2626571105719597, 0.0, 3.671440782865815, 2.8892282162915555, 2.2138623043942416, 1.7030661481468838, 2.827691923234929, 1.3807585313004147, 1.1439771606274765, 0.9305015671811573, 1.3711176832473053, 1.0420711509552334, 0.5957707681988301, 0.24240017112922455, 0.0), # 128 (3.546818353780113, 2.652736255903522, 2.9717341147794802, 3.1170590734600148, 2.73530321019555, 1.300286588914529, 1.1389682997514627, 0.9845849321543767, 1.4116760159756234, 0.5656998392566547, 0.4413107482015715, 0.2618566096027546, 0.0, 3.6618992825828154, 2.8804227056303, 2.2065537410078573, 1.6970995177699637, 2.823352031951247, 1.3784189050161275, 1.1389682997514627, 0.9287761349389492, 1.367651605097775, 1.0390196911533385, 0.594346822955896, 0.24115784144577473, 0.0), # 129 (3.532998383957347, 2.6390140548881877, 2.9644918022437268, 3.107768129864726, 2.72819633191739, 1.2978453187755554, 1.1339328638654125, 0.9829364540249584, 1.4094874310046666, 0.5636981477582759, 0.4398398539247897, 0.2610466626174385, 0.0, 3.6521359024430993, 2.8715132887918227, 2.199199269623948, 1.6910944432748272, 2.818974862009333, 1.3761110356349417, 1.1339328638654125, 0.9270323705539681, 1.364098165958695, 1.0359227099549089, 0.5928983604487453, 0.2399103686261989, 0.0), # 130 (3.5189166055232377, 2.625213138954313, 2.9571137662784603, 3.098324726898143, 2.7209066986583315, 1.295371942742099, 1.1288617586749619, 0.9813029193640249, 1.4072736332515314, 0.5616794557149186, 0.43835654486029796, 0.2602257372708542, 0.0, 3.6421385250113247, 2.8624831099793955, 2.1917827243014893, 1.6850383671447555, 2.814547266503063, 1.373824087109635, 1.1288617586749619, 0.9252656733872135, 1.3604533493291657, 1.0327749089660478, 0.5914227532556922, 0.2386557399049376, 0.0), # 131 (3.504558472166904, 2.611311367680746, 2.9495868697752488, 3.0887129693785758, 2.7134262774165743, 1.2928600199195572, 1.123745889885745, 0.9796765881378455, 1.4050280492631537, 0.5596395772876765, 0.43685758781989104, 0.2593923012178448, 0.0, 3.6318950328521504, 2.853315313396292, 2.184287939099455, 1.6789187318630292, 2.8100560985263074, 1.3715472233929837, 1.123745889885745, 0.9234714427996837, 1.3567131387082871, 1.0295709897928589, 0.5899173739550498, 0.2373919425164315, 0.0), # 132 (3.4899094375774653, 2.5972866006463327, 2.9418979756256616, 3.0789169621243357, 2.705747035190316, 1.2903031094133288, 1.118576163203398, 0.9780497203126887, 1.40274410558647, 0.5575743266376434, 0.43533974961536415, 0.25854482211325314, 0.0, 3.6213933085302346, 2.843993043245784, 2.1766987480768205, 1.6727229799129297, 2.80548821117294, 1.3692696084377642, 1.118576163203398, 0.9216450781523777, 1.352873517595158, 1.0263056540414455, 0.5883795951251324, 0.2361169636951212, 0.0), # 133 (3.474954955444038, 2.583116697429922, 2.934033946721268, 3.068920809953731, 2.697860938977758, 1.287694770328812, 1.1133434843335557, 0.9764145758548239, 1.4004152287684173, 0.5554795179259124, 0.43379979705851196, 0.25768176761192224, 0.0, 3.6106212346102335, 2.8344994437311444, 2.1689989852925597, 1.6664385537777369, 2.8008304575368346, 1.3669804061967537, 1.1133434843335557, 0.9197819788062943, 1.348930469488879, 1.0229736033179107, 0.5868067893442537, 0.23482879067544749, 0.0), # 134 (3.4596804794557414, 2.5687795176103587, 2.9259816459536365, 3.058708617685074, 2.689759955777099, 1.285028561771405, 1.1080387589818537, 0.9747634147305201, 1.3980348453559306, 0.5533509653135777, 0.4322344969611296, 0.2568016053686951, 0.0, 3.599566693656808, 2.824817659055646, 2.1611724848056477, 1.660052895940733, 2.796069690711861, 1.3646687806227282, 1.1080387589818537, 0.917877544122432, 1.3448799778885494, 1.0195695392283581, 0.5851963291907273, 0.23352541069185084, 0.0), # 135 (3.444071463301694, 2.554252920766492, 2.9177279362143365, 3.0482644901366713, 2.681436052586538, 1.282298042846506, 1.102652892853927, 0.9730884969060463, 1.3955963818959474, 0.5511844829617324, 0.43064061613501187, 0.2559028030384148, 0.0, 3.5882175682346147, 2.814930833422562, 2.153203080675059, 1.6535534488851968, 2.7911927637918947, 1.362323895668465, 1.102652892853927, 0.9159271734617901, 1.340718026293269, 1.0160881633788907, 0.5835455872428673, 0.23220481097877202, 0.0), # 136 (3.4281133606710137, 2.5395147664771676, 2.9092596803949373, 3.0375725321268376, 2.6728811964042754, 1.279496772659513, 1.0971767916554112, 0.9713820823476715, 1.3930932649354042, 0.5489758850314703, 0.42901492139195374, 0.25498382827592403, 0.0, 3.5765617409083106, 2.804822111035164, 2.145074606959769, 1.6469276550944105, 2.7861865298708084, 1.3599349152867402, 1.0971767916554112, 0.9139262661853664, 1.3364405982021377, 1.0125241773756128, 0.5818519360789874, 0.23086497877065162, 0.0), # 137 (3.4117916252528193, 2.5245429143212332, 2.900563741387006, 3.0266168484738794, 2.6640873542285117, 1.2766183103158248, 1.0916013610919408, 0.9696364310216651, 1.3905189210212374, 0.5467209856838848, 0.4273541795437502, 0.254043148736066, 0.0, 3.5645870942425564, 2.794474636096725, 2.136770897718751, 1.640162957051654, 2.781037842042475, 1.3574910034303311, 1.0916013610919408, 0.9118702216541607, 1.3320436771142559, 1.0088722828246266, 0.5801127482774012, 0.22950390130193032, 0.0), # 138 (3.3950917107362275, 2.509315223877536, 2.8916269820821134, 3.015381543996108, 2.6550464930574442, 1.2736562149208395, 1.085917506869152, 0.9678438028942958, 1.387866776700383, 0.5444155990800699, 0.4256551574021961, 0.2530792320736836, 0.0, 3.5522815108020076, 2.7838715528105187, 2.1282757870109803, 1.6332467972402092, 2.775733553400766, 1.354981324052014, 1.085917506869152, 0.9097544392291711, 1.3275232465287221, 1.0051271813320362, 0.5783253964164228, 0.22811956580704876, 0.0), # 139 (3.3779990708103593, 2.4938095547249226, 2.882436265371829, 3.0038507235118335, 2.6457505798892744, 1.2706040455799552, 1.0801161346926793, 0.9659964579318328, 1.3851302585197776, 0.5420555393811187, 0.42391462177908634, 0.25209054594361974, 0.0, 3.539632873151326, 2.7729960053798166, 2.1195731088954313, 1.6261666181433558, 2.770260517039555, 1.352395041104566, 1.0801161346926793, 0.9075743182713966, 1.3228752899446372, 1.0012835745039448, 0.5764872530743659, 0.22670995952044753, 0.0), # 140 (3.3604991591643323, 2.478003766442241, 2.8729784541477206, 2.992008491839366, 2.636191581722201, 1.2674553613985702, 1.074188150268159, 0.9640866561005451, 1.3823027930263572, 0.5396366207481252, 0.422129339486216, 0.2510755580007175, 0.0, 3.5266290638551654, 2.761831138007892, 2.1106466974310796, 1.6189098622443754, 2.7646055860527143, 1.3497213185407633, 1.074188150268159, 0.9053252581418358, 1.3180957908611004, 0.9973361639464555, 0.5745956908295441, 0.2252730696765674, 0.0), # 141 (3.3425774294872626, 2.4618757186083373, 2.863240411301357, 2.9798389537970165, 2.626361465554423, 1.2642037214820832, 1.0681244593012253, 0.962106657366702, 1.3793778067670588, 0.5371546573421829, 0.4202960773353799, 0.25003273589981984, 0.0, 3.5132579654781866, 2.750360094898018, 2.101480386676899, 1.6114639720265485, 2.7587556135341176, 1.3469493203133829, 1.0681244593012253, 0.903002658201488, 1.3131807327772116, 0.9932796512656723, 0.5726480822602714, 0.2238068835098489, 0.0), # 142 (3.32421933546827, 2.4454032708020597, 2.8532089997243086, 2.9673262142030925, 2.616252198384141, 1.2608426849358916, 1.0619159674975138, 0.960048721696572, 1.3763487262888197, 0.5346054633243854, 0.4184116021383729, 0.2489605472957697, 0.0, 3.499507460585047, 2.738566020253466, 2.0920580106918645, 1.603816389973156, 2.7526974525776393, 1.3440682103752009, 1.0619159674975138, 0.9006019178113511, 1.3081260991920705, 0.9891087380676977, 0.5706417999448617, 0.22230938825473273, 0.0), # 143 (3.305410330796474, 2.4285642826022547, 2.8428710823081427, 2.954454377875907, 2.6058557472095543, 1.2573658108653942, 1.0555535805626597, 0.9579051090564249, 1.3732089781385746, 0.5319848528558261, 0.4164726807069901, 0.24785745984341, 0.0, 3.485365431740406, 2.7264320582775095, 2.0823634035349503, 1.595954558567478, 2.746417956277149, 1.3410671526789948, 1.0555535805626597, 0.8981184363324245, 1.3029278736047771, 0.9848181259586359, 0.5685742164616286, 0.22077857114565957, 0.0), # 144 (3.286135869160991, 2.41133661358777, 2.8322135219444298, 2.9412075496337686, 2.595164079028862, 1.2537666583759894, 1.0490282042022987, 0.9556680794125294, 1.3699519888632605, 0.5292886400975989, 0.41447607985302637, 0.24672194119758384, 0.0, 3.47081976150892, 2.7139413531734218, 2.072380399265132, 1.5878659202927965, 2.739903977726521, 1.3379353111775412, 1.0490282042022987, 0.8955476131257067, 1.297582039514431, 0.9804025165445898, 0.566442704388886, 0.21921241941707004, 0.0), # 145 (3.2663814042509403, 2.393698123337452, 2.821223181524739, 2.927569834294988, 2.584169160840265, 1.2500387865730758, 1.042330744122066, 0.9533298927311545, 1.3665711850098141, 0.5265126392107972, 0.4124185663882766, 0.24555245901313405, 0.0, 3.4558583324552474, 2.701077049144474, 2.062092831941383, 1.5795379176323912, 2.7331423700196282, 1.3346618498236165, 1.042330744122066, 0.8928848475521969, 1.2920845804201324, 0.9758566114316628, 0.5642446363049479, 0.21760892030340476, 0.0), # 146 (3.24613238975544, 2.375626671430148, 2.8098869239406365, 2.913525336677874, 2.5728629596419603, 1.2461757545620502, 1.0354521060275963, 0.9508828089785692, 1.3630599931251721, 0.5236526643565147, 0.4102969071245358, 0.24434748094490372, 0.0, 3.4404690271440472, 2.6878222903939406, 2.051484535622679, 1.5709579930695439, 2.7261199862503442, 1.331235932569997, 1.0354521060275963, 0.8901255389728929, 1.2864314798209802, 0.9711751122259582, 0.5619773847881274, 0.21596606103910437, 0.0), # 147 (3.2253742793636087, 2.3571001174447055, 2.7981916120836945, 2.899058161600739, 2.56123744243215, 1.2421711214483127, 1.0283831956245253, 0.9483190881210429, 1.3594118397562704, 0.5207045296958448, 0.4081078688735989, 0.24310547464773571, 0.0, 3.4246397281399767, 2.6741602211250926, 2.0405393443679944, 1.562113589087534, 2.718823679512541, 1.3276467233694602, 1.0283831956245253, 0.8872650867487947, 1.280618721216075, 0.9663527205335799, 0.5596383224167389, 0.21428182885860964, 0.0), # 148 (3.204092526764565, 2.338096320959971, 2.7861241088454816, 2.884152413881891, 2.549284576209032, 1.2380184463372599, 1.0211149186184882, 0.9456309901248444, 1.355620151450045, 0.5176640493898814, 0.40584821844726066, 0.24182490777647309, 0.0, 3.408358318007695, 2.6600739855412034, 2.0292410922363033, 1.5529921481696438, 2.71124030290009, 1.3238833861747823, 1.0211149186184882, 0.8842988902408999, 1.274642288104516, 0.9613841379606305, 0.5572248217690964, 0.21255421099636107, 0.0), # 149 (3.182272585647426, 2.3185931415547922, 2.773671277117565, 2.8687921983396416, 2.5369963279708068, 1.2337112883342916, 1.0136381807151202, 0.9428107749562428, 1.3516783547534337, 0.5145270375997177, 0.40351472265731625, 0.24050424798595882, 0.0, 3.3916126793118586, 2.6455467278455465, 2.017573613286581, 1.5435811127991528, 2.7033567095068674, 1.31993508493874, 1.0136381807151202, 0.8812223488102082, 1.2684981639854034, 0.956264066113214, 0.5547342554235131, 0.21078119468679934, 0.0), # 150 (3.15989990970131, 2.2985684388080165, 2.7608199797915143, 2.852961619792299, 2.524364664715674, 1.2292432065448047, 1.0059438876200566, 0.9398507025815073, 1.347579876213372, 0.5112893084864479, 0.40110414831556035, 0.23914196293103576, 0.0, 3.3743906946171274, 2.630561592241393, 2.0055207415778016, 1.5338679254593435, 2.695159752426744, 1.3157909836141102, 1.0059438876200566, 0.8780308618177176, 1.262182332357837, 0.9509872065974332, 0.5521639959583029, 0.20896076716436518, 0.0), # 151 (3.1369599526153373, 2.27800007229849, 2.747557079758901, 2.836644783058176, 2.5113815534418316, 1.2246077600741982, 0.998022945038933, 0.9367430329669069, 1.343318142376796, 0.5079466762111651, 0.3986132622337882, 0.237736520266547, 0.0, 3.356680246488159, 2.6151017229320166, 1.9930663111689406, 1.523840028633495, 2.686636284753592, 1.3114402461536696, 0.998022945038933, 0.8747198286244273, 1.2556907767209158, 0.9455482610193922, 0.5495114159517802, 0.2070909156634991, 0.0), # 152 (3.1134381680786243, 2.2568659016050607, 2.7338694399112895, 2.81982579295558, 2.4980389611474814, 1.2197985080278704, 0.9898662586773839, 0.9334800260787104, 1.338886579790643, 0.504494954934963, 0.39603883122379446, 0.2362863876473355, 0.0, 3.338469217489611, 2.59915026412069, 1.9801941561189722, 1.5134848648048886, 2.677773159581286, 1.3068720365101947, 0.9898662586773839, 0.871284648591336, 1.2490194805737407, 0.9399419309851935, 0.546773887982258, 0.20516962741864192, 0.0), # 153 (3.0893200097802915, 2.2351437863065757, 2.719743923140253, 2.802488754302823, 2.4843288548308213, 1.2148090095112194, 0.9814647342410456, 0.9300539418831871, 1.3342786150018489, 0.5009299588189354, 0.3933776220973742, 0.2347900327282442, 0.0, 3.319745490186143, 2.5826903600106856, 1.9668881104868707, 1.502789876456806, 2.6685572300036977, 1.302075518636462, 0.9814647342410456, 0.8677207210794424, 1.2421644274154107, 0.9341629181009412, 0.5439487846280506, 0.20319488966423419, 0.0), # 154 (3.0645909314094544, 2.212811585981881, 2.705167392337359, 2.7846177719182137, 2.470243201490052, 1.2096328236296434, 0.9728092774355522, 0.926457040346606, 1.3294876745573503, 0.49724750202417556, 0.39062640166632223, 0.2332459231641161, 0.0, 3.3004969471424106, 2.565705154805277, 1.953132008331611, 1.4917425060725265, 2.6589753491147006, 1.2970398564852486, 0.9728092774355522, 0.8640234454497453, 1.235121600745026, 0.928205923972738, 0.5410334784674719, 0.2011646896347165, 0.0), # 155 (3.0392363866552325, 2.1898471602098257, 2.6901267103941757, 2.7661969506200625, 2.455773968123373, 1.204263509488541, 0.96389079396654, 0.9226815814352365, 1.3245071850040835, 0.4934433987117774, 0.38778193674243366, 0.23165252660979413, 0.0, 3.280711470923074, 2.548177792707735, 1.9389096837121682, 1.480330196135332, 2.649014370008167, 1.2917542140093312, 0.96389079396654, 0.8601882210632436, 1.2278869840616864, 0.9220656502066877, 0.5380253420788351, 0.19907701456452961, 0.0), # 156 (3.013241829206745, 2.1662283685692554, 2.674608740202273, 2.7472103952266815, 2.4409131217289826, 1.19869462619331, 0.9547001895396439, 0.9187198251153471, 1.319330572888985, 0.4895134630428343, 0.38484099413750333, 0.2300083107201213, 0.0, 3.2603769440927906, 2.5300914179213336, 1.9242049706875164, 1.4685403891285025, 2.63866114577797, 1.2862077551614859, 0.9547001895396439, 0.8562104472809356, 1.2204565608644913, 0.915736798408894, 0.5349217480404546, 0.19692985168811414, 0.0), # 157 (2.985872378562096, 2.141499477616495, 2.6578639846341185, 2.7269308744953733, 2.424981628232266, 1.1925723778073256, 0.9450213441855715, 0.9142994920582287, 1.3135549455465463, 0.48533659162911447, 0.38170638350259617, 0.22825331880647803, 0.0, 3.238594343766138, 2.510786506871258, 1.908531917512981, 1.456009774887343, 2.6271098910930926, 1.2800192888815203, 0.9450213441855715, 0.8518374127195183, 1.212490814116133, 0.9089769581651246, 0.5315727969268238, 0.19468177069240863, 0.0), # 158 (2.9529147067913613, 2.1131239505198085, 2.635579272800996, 2.7011931476365363, 2.4040510159417674, 1.1838609178683244, 0.9336425526771432, 0.9078689221273971, 1.3048569681629525, 0.48022809940987465, 0.37782779570793296, 0.22604541745610365, 0.0, 3.210171058768078, 2.48649959201714, 1.8891389785396648, 1.4406842982296237, 2.609713936325905, 1.271016490978356, 0.9336425526771432, 0.8456149413345173, 1.2020255079708837, 0.9003977158788457, 0.5271158545601993, 0.1921021773199826, 0.0), # 159 (2.913948837961724, 2.0808688004649283, 2.6073069859852964, 2.669573253122658, 2.3777120350258123, 1.1723463024111265, 0.9204487496767568, 0.8992665315878912, 1.2929900302971533, 0.4741205651862895, 0.3731506339073027, 0.22335006496292825, 0.0, 3.1745682435574323, 2.4568507145922105, 1.8657531695365135, 1.422361695558868, 2.5859800605943066, 1.2589731442230476, 0.9204487496767568, 0.8373902160079474, 1.1888560175129061, 0.8898577510408863, 0.5214613971970593, 0.18916989095135714, 0.0), # 160 (2.869288821834384, 2.0449443182961717, 2.5733489906367697, 2.6323717511270184, 2.34623816647523, 1.1581680230330733, 0.9055362892013753, 0.8886000888516301, 1.278110635599869, 0.4670658193170939, 0.3677161103066472, 0.22019224896358572, 0.0, 3.132149617927639, 2.4221147385994426, 1.8385805515332359, 1.4011974579512814, 2.556221271199738, 1.2440401243922823, 0.9055362892013753, 0.8272628735950524, 1.173119083237615, 0.877457250375673, 0.514669798127354, 0.18590402893601563, 0.0), # 161 (2.8192487081705426, 2.005560794857854, 2.5340071532051653, 2.5898892018228983, 2.3099028912808546, 1.1414655713315065, 0.8890015252679618, 0.8759773623305338, 1.2603752877218182, 0.45911569216102327, 0.3615654371119081, 0.21659695709470983, 0.0, 3.0832789016721334, 2.382566528041808, 1.8078271855595405, 1.3773470764830695, 2.5207505754436363, 1.2263683072627474, 0.8890015252679618, 0.815332550951076, 1.1549514456404273, 0.8632964006076329, 0.5068014306410331, 0.18232370862344133, 0.0), # 162 (2.7641425467313994, 1.9629285209942922, 2.4895833401402343, 2.5424261653835805, 2.268979690433517, 1.122378438903767, 0.8709408118934802, 0.8615061204365209, 1.2399404903137208, 0.4503220140768126, 0.35473982652902725, 0.21258917699293448, 0.0, 3.0283198145843517, 2.338480946922279, 1.7736991326451361, 1.3509660422304375, 2.4798809806274416, 1.2061085686111293, 0.8709408118934802, 0.8016988849312622, 1.1344898452167584, 0.8474753884611936, 0.4979166680280469, 0.1784480473631175, 0.0), # 163 (2.704284387278154, 1.917257787549801, 2.4403794178917257, 2.4902832019823453, 2.2237420449240504, 1.1010461173471968, 0.8514505030948932, 0.8452941315815116, 1.2169627470262965, 0.440736615423197, 0.34728049076394646, 0.20819389629489346, 0.0, 2.9676360764577314, 2.290132859243828, 1.736402453819732, 1.3222098462695906, 2.433925494052593, 1.1834117842141163, 0.8514505030948932, 0.7864615123908549, 1.1118710224620252, 0.830094400660782, 0.4880758835783452, 0.17429616250452737, 0.0), # 164 (2.639988279572007, 1.8687588853686983, 2.3866972529093897, 2.433760871792476, 2.174463435743286, 1.077608098259137, 0.8306269528891644, 0.8274491641774244, 1.191598561510264, 0.43041132655891146, 0.3392286420226075, 0.2034361026372207, 0.0, 2.901591407085708, 2.237797129009427, 1.6961432101130374, 1.291233979676734, 2.383197123020528, 1.1584288298483942, 0.8306269528891644, 0.7697200701850978, 1.087231717871643, 0.8112536239308255, 0.477339450581878, 0.16988717139715442, 0.0), # 165 (2.571568273374159, 1.8176421052952998, 2.3288387116429763, 2.3731597349872504, 2.121417343882057, 1.0522038732369288, 0.8085665152932573, 0.8080789866361796, 1.164004437416343, 0.41939797784269134, 0.330625492510952, 0.19834078365655008, 0.0, 2.830549526261718, 2.1817486202220504, 1.6531274625547598, 1.2581939335280736, 2.328008874832686, 1.1313105812906514, 0.8085665152932573, 0.7515741951692348, 1.0607086719410286, 0.7910532449957504, 0.4657677423285953, 0.16524019139048182, 0.0), # 166 (2.4993384184458094, 1.764117738173922, 2.267105660542235, 2.308780351739953, 2.0648772503311945, 1.0249729338779137, 0.785365544324135, 0.7872913673696962, 1.1343368783952532, 0.40774839963327153, 0.3215122544349219, 0.1929329269895153, 0.0, 2.7548741537791983, 2.122262196884668, 1.607561272174609, 1.2232451988998143, 2.2686737567905064, 1.1022079143175747, 0.785365544324135, 0.7321235241985098, 1.0324386251655973, 0.7695934505799846, 0.45342113210844703, 0.16037433983399293, 0.0), # 167 (2.4236127645481584, 1.7083960748488805, 2.201799966056916, 2.240923282223864, 2.005116636081531, 0.9960547717794331, 0.7611203939987609, 0.7651940747898933, 1.102752388097714, 0.3955144222893873, 0.31193014000045877, 0.1872375202727504, 0.0, 2.674929009431585, 2.0596127230002543, 1.5596507000022939, 1.1865432668681617, 2.205504776195428, 1.0712717047058506, 0.7611203939987609, 0.7114676941281666, 1.0025583180407656, 0.7469744274079547, 0.4403599932113833, 0.15530873407717097, 0.0), # 168 (2.344705361442406, 1.6506874061644923, 2.13322349463677, 2.169889086612265, 1.9424089821238986, 0.9655888785388289, 0.7359274183340984, 0.7418948773086909, 1.0694074701744452, 0.3827478761697738, 0.3019203614135046, 0.1812795511428891, 0.0, 2.591077813012314, 1.9940750625717798, 1.509601807067523, 1.148243628509321, 2.1388149403488903, 1.0386528282321672, 0.7359274183340984, 0.6897063418134491, 0.9712044910619493, 0.7232963622040884, 0.426644698927354, 0.15006249146949932, 0.0), # 169 (2.2629302588897535, 1.5912020229650736, 2.061678112731545, 2.095978325078436, 1.8770277694491289, 0.9337147457534416, 0.7098829713471106, 0.717501543338008, 1.0344586282761652, 0.36950059163316584, 0.2915241308800011, 0.1750840072365653, 0.0, 2.503684284314822, 1.9259240796022181, 1.4576206544000057, 1.1085017748994974, 2.0689172565523304, 1.0045021606732112, 0.7098829713471106, 0.6669391041096011, 0.9385138847245644, 0.6986594416928121, 0.412335622546309, 0.14465472936046128, 0.0), # 170 (2.1786015066514, 1.53015021609494, 1.9874656867909928, 2.0194915577956607, 1.809246479048055, 0.900571865020613, 0.6830834070547611, 0.6921218412897638, 0.9980623660535942, 0.35582439903829893, 0.2807826606058899, 0.16867587619041288, 0.0, 2.413112143132546, 1.8554346380945415, 1.4039133030294495, 1.0674731971148965, 1.9961247321071884, 0.9689705778056694, 0.6830834070547611, 0.6432656178718664, 0.9046232395240275, 0.6731638525985537, 0.3974931373581986, 0.13910456509954003, 0.0), # 171 (2.092033154488546, 1.4677422763984087, 1.9108880832648623, 1.940729344937219, 1.7393385919115076, 0.8662997279376846, 0.6556250794740132, 0.6658635395758785, 0.9603751871574514, 0.3417711287439081, 0.26973716279711296, 0.16208014564106574, 0.0, 2.3197251092589215, 1.7828816020517226, 1.3486858139855649, 1.025313386231724, 1.9207503743149028, 0.9322089554062299, 0.6556250794740132, 0.618785519955489, 0.8696692959557538, 0.6469097816457398, 0.3821776166529725, 0.13343111603621902, 0.0), # 172 (2.003539252162392, 1.4041884947197956, 1.832247168602904, 1.8599922466763927, 1.6675775890303204, 0.8310378261019976, 0.62760434262183, 0.6388344066082706, 0.9215535952384564, 0.32739261110872825, 0.25842884965961194, 0.1553218032251575, 0.0, 2.223886902487385, 1.7085398354767325, 1.2921442482980594, 0.9821778333261846, 1.8431071904769127, 0.8943681692515789, 0.62760434262183, 0.5935984472157125, 0.8337887945151602, 0.6199974155587977, 0.36644943372058086, 0.12765349951998142, 0.0), # 173 (1.9134338494341376, 1.3396991619034166, 1.7518448092548675, 1.7775808231864623, 1.5942369513953243, 0.7949256511108933, 0.5991175505151751, 0.6111422107988601, 0.8817540939473285, 0.31274067649149473, 0.24689893339932856, 0.1484258365793223, 0.0, 2.1259612426113734, 1.632684202372545, 1.2344946669966426, 0.9382220294744841, 1.763508187894657, 0.8555990951184042, 0.5991175505151751, 0.5678040365077809, 0.7971184756976621, 0.5925269410621542, 0.3503689618509735, 0.12179083290031062, 0.0), # 174 (1.8220309960649823, 1.274484568793588, 1.6699828716705027, 1.6937956346407104, 1.5195901599973516, 0.7581026945617134, 0.5702610571710116, 0.582894720559566, 0.8411331869347874, 0.2978671552509425, 0.23518862622220466, 0.14141723334019382, 0.0, 2.026311849424323, 1.5555895667421318, 1.1759431311110233, 0.8936014657528273, 1.682266373869575, 0.8160526087833925, 0.5702610571710116, 0.5415019246869381, 0.7597950799986758, 0.5645985448802369, 0.33399657433410057, 0.11586223352668984, 0.0), # 175 (1.7296447418161276, 1.2087550062346268, 1.5869632222995596, 1.6089372412124177, 1.4439106958272347, 0.720708448051799, 0.541131216606303, 0.5541997043023082, 0.7998473778515522, 0.28282387774580675, 0.22333914033418203, 0.134320981144406, 0.0, 1.9253024427196697, 1.4775307925884658, 1.11669570167091, 0.84847163323742, 1.5996947557031045, 0.7758795860232315, 0.541131216606303, 0.5147917486084279, 0.7219553479136174, 0.5363124137374726, 0.31739264445991194, 0.10988681874860246, 0.0), # 176 (1.636589136448773, 1.1427207650708489, 1.503087727591788, 1.5233062030748648, 1.3674720398758062, 0.6828824031784915, 0.5118243828380126, 0.5251649304390055, 0.7580531703483426, 0.2676626743348225, 0.21139168794120244, 0.12716206762859264, 0.0, 1.82329674229085, 1.3987827439145188, 1.056958439706012, 0.8029880230044673, 1.5161063406966853, 0.7352309026146077, 0.5118243828380126, 0.48777314512749387, 0.6837360199379031, 0.5077687343582884, 0.3006175455183576, 0.10388370591553173, 0.0), # 177 (1.5431782297241188, 1.0765921361465705, 1.4186582539969381, 1.437203080401335, 1.290547673133897, 0.6447640515391326, 0.4824369098831035, 0.4958981673815776, 0.715907068075878, 0.25243537537672506, 0.19938748124920752, 0.1199654804293876, 0.0, 1.7206584679313008, 1.3196202847232632, 0.9969374062460375, 0.757306126130175, 1.431814136151756, 0.6942574343342086, 0.4824369098831035, 0.46054575109938045, 0.6452738365669485, 0.47906769346711175, 0.2837316507993876, 0.09787201237696096, 0.0), # 178 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), # 179 ) passenger_allighting_rate = ( (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 0 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 1 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 2 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 3 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 4 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 5 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 6 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 7 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 8 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 9 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 10 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 11 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 12 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 13 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 14 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 15 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 16 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 17 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 18 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 19 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 20 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 21 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 22 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 23 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 24 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 25 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 26 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 27 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 28 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 29 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 30 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 31 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 32 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 33 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 34 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 35 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 36 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 37 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 38 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 39 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 40 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 41 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 42 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 43 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 44 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 45 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 46 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 47 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 48 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 49 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 50 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 51 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 52 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 53 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 54 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 55 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 56 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 57 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 58 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 59 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 60 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 61 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 62 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 63 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 64 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 65 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 66 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 67 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 68 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 69 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 70 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 71 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 72 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 73 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 74 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 75 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 76 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 77 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 78 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 79 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 80 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 81 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 82 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 83 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 84 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 85 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 86 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 87 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 88 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 89 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 90 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 91 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 92 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 93 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 94 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 95 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 96 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 97 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 98 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 99 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 100 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 101 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 102 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 103 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 104 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 105 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 106 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 107 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 108 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 109 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 110 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 111 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 112 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 113 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 114 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 115 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 116 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 117 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 118 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 119 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 120 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 121 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 122 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 123 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 124 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 125 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 126 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 127 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 128 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 129 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 130 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 131 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 132 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 133 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 134 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 135 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 136 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 137 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 138 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 139 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 140 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 141 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 142 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 143 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 144 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 145 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 146 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 147 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 148 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 149 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 150 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 151 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 152 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 153 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 154 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 155 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 156 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 157 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 158 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 159 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 160 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 161 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 162 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 163 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 164 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 165 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 166 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 167 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 168 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 169 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 170 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 171 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 172 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 173 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 174 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 175 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 176 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 177 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 178 (0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1, 0, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 0.07692307692307693, 1), # 179 ) """ parameters for reproducibiliy. More information: https://numpy.org/doc/stable/reference/random/parallel.html """ #initial entropy entropy = 8991598675325360468762009371570610170 #index for seed sequence child child_seed_index = ( 1, # 0 59, # 1 )
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the Spotlight Volume configuration plist plugin.""" from __future__ import unicode_literals import unittest from plaso.parsers.plist_plugins import spotlight_volume from tests.parsers.plist_plugins import test_lib class SpotlightVolumePluginTest(test_lib.PlistPluginTestCase): """Tests for the Spotlight Volume configuration plist plugin.""" def testProcess(self): """Tests the Process function.""" plist_name = 'VolumeConfiguration.plist' plugin = spotlight_volume.SpotlightVolumePlugin() storage_writer = self._ParsePlistFileWithPlugin( plugin, [plist_name], plist_name) self.assertEqual(storage_writer.number_of_warnings, 0) self.assertEqual(storage_writer.number_of_events, 2) # The order in which PlistParser generates events is nondeterministic # hence we sort the events. events = list(storage_writer.GetSortedEvents()) expected_timestamps = [1369657656000000, 1372139683000000] timestamps = sorted([event.timestamp for event in events]) self.assertEqual(timestamps, expected_timestamps) event = events[1] event_data = self._GetEventDataOfEvent(storage_writer, event) self.assertEqual(event_data.key, '') self.assertEqual(event_data.root, '/Stores') expected_description = ( 'Spotlight Volume 4D4BFEB5-7FE6-4033-AAAA-AAAABBBBCCCCDDDD ' '(/.MobileBackups) activated.') self.assertEqual(event_data.desc, expected_description) expected_message = '/Stores/ {0:s}'.format(expected_description) expected_short_message = '{0:s}...'.format(expected_message[:77]) self._TestGetMessageStrings( event_data, expected_message, expected_short_message) if __name__ == '__main__': unittest.main()
"""Error handling for the tilesets CLI""" class TilesetsError(Exception): """Base Tilesets error Deriving errors from this base isolates module development problems from Python usage problems. """ exit_code = 1 def __init__(self, message): """Error constructor Parameters ---------- message: str Error description """ self.message = message class TilesetNameError(TilesetsError): """Not a valid tileset id """
import pytest from webdriver.transport import Response from tests.support.asserts import assert_error, assert_same_element, assert_success def find_elements(session, shadow_id, using, value): return session.transport.send( "POST", "session/{session_id}/shadow/{shadow_id}/elements".format( session_id=session.session_id, shadow_id=shadow_id), {"using": using, "value": value}) def test_null_parameter_value(session, http, inline): session.url = inline("<div><a href=# id=linkText>full link text</a></div>") custom_element = session.find.css("custom-shadow-element", all=False) shadow_root = custom_element.shadow_root path = "/session/{session_id}/shadow/{shadow_id}/elements".format( session_id=session.session_id, shadow_id=shadow_root.id) with http.post(path, None) as response: assert_error(Response.from_http(response), "invalid argument") def test_no_top_browsing_context(session, closed_window): response = find_elements(session, "notReal", "css selector", "foo") assert_error(response, "no such window") def test_no_browsing_context(session, closed_frame): response = find_elements(session, "notReal", "css selector", "foo") assert_error(response, "no such window") @pytest.mark.parametrize("using", [("a"), (True), (None), (1), ([]), ({})]) def test_invalid_using_argument(session, using): # Step 1 - 2 response = find_elements(session, "notReal", using, "value") assert_error(response, "invalid argument") @pytest.mark.parametrize("value", [None, [], {}]) def test_invalid_selector_argument(session, value): # Step 3 - 4 response = find_elements(session, "notReal", "css selector", value) assert_error(response, "invalid argument") def test_detached_shadow_root(session, get_shadow_page): session.url = get_shadow_page("<div><input type='checkbox'/></div>") custom_element = session.find.css("custom-shadow-element", all=False) shadow_root = custom_element.shadow_root session.refresh() response = find_elements(session, shadow_root.id, "css", "input") assert_error(response, "detached shadow root") def test_find_elements_equivalence(session, get_shadow_page): session.url = get_shadow_page("<div><input id='check' type='checkbox'/><input id='text'/></div>") custom_element = session.find.css("custom-shadow-element", all=False) shadow_root = custom_element.shadow_root response = find_elements(session, shadow_root.id, "css", "input") assert_success(response) @pytest.mark.parametrize("using,value", [("css selector", "#linkText"), ("link text", "full link text"), ("partial link text", "link text"), ("tag name", "a"), ("xpath", "//a")]) def test_find_elements(session, get_shadow_page, using, value): # Step 8 - 9 session.url = get_shadow_page("<div><a href=# id=linkText>full link text</a></div>") custom_element = session.find.css("custom-shadow-element", all=False) shadow_root = custom_element.shadow_root response = find_elements(session, shadow_root.id, using, value) assert_success(response) @pytest.mark.parametrize("document,value", [ ("<a href=#>link text</a>", "link text"), ("<a href=#>&nbsp;link text&nbsp;</a>", "link text"), ("<a href=#>link<br>text</a>", "link\ntext"), ("<a href=#>link&amp;text</a>", "link&text"), ("<a href=#>LINK TEXT</a>", "LINK TEXT"), ("<a href=# style='text-transform: uppercase'>link text</a>", "LINK TEXT"), ]) def test_find_elements_link_text(session, get_shadow_page, document, value): # Step 8 - 9 session.url = get_shadow_page("<div><a href=#>not wanted</a><br/>{0}</div>".format(document)) element = session.find.css("div", all=False) custom_element = session.find.css("custom-shadow-element", all=False) shadow_root = custom_element.shadow_root expected = session.execute_script("return arguments[0].shadowRoot.querySelectorAll('a')[1]", args=(custom_element,)) response = find_elements(session, shadow_root.id, "link text", value) value = assert_success(response) assert isinstance(value, list) assert len(value) == 1 found_element = value[0] assert_same_element(session, found_element, expected) @pytest.mark.parametrize("document,value", [ ("<a href=#>partial link text</a>", "link"), ("<a href=#>&nbsp;partial link text&nbsp;</a>", "link"), ("<a href=#>partial link text</a>", "k t"), ("<a href=#>partial link<br>text</a>", "k\nt"), ("<a href=#>partial link&amp;text</a>", "k&t"), ("<a href=#>PARTIAL LINK TEXT</a>", "LINK"), ("<a href=# style='text-transform: uppercase'>partial link text</a>", "LINK"), ]) def test_find_elements_partial_link_text(session, get_shadow_page, document, value): # Step 8 - 9 session.url = get_shadow_page("<div><a href=#>not wanted</a><br/>{0}</div>".format(document)) element = session.find.css("div", all=False) custom_element = session.find.css("custom-shadow-element", all=False) shadow_root = custom_element.shadow_root expected = session.execute_script("return arguments[0].shadowRoot.querySelectorAll('a')[1]", args=(custom_element,)) response = find_elements(session, shadow_root.id, "partial link text", value) value = assert_success(response) assert isinstance(value, list) assert len(value) == 1 found_element = value[0] assert_same_element(session, found_element, expected) @pytest.mark.parametrize("using,value", [("css selector", "#wontExist")]) def test_no_element(session, get_shadow_page, using, value): # Step 8 - 9 session.url = get_shadow_page("<div></div>") custom_element = session.find.css("custom-shadow-element", all=False) shadow_root = custom_element.shadow_root response = find_elements(session, shadow_root.id, using, value) assert response.body["value"] == []
import sys import subprocess import yaml if len(sys.argv) != 4: print('usage: delegate.py [val1_stake] [val2_stake] [val3_stake]') exit(0) # Load config confFile = open('./conf.yml') conf = yaml.safe_load(confFile) def delegate_cmd(valNumber, amount): cmd = ["spnd", "tx", "staking", "delegate"] cmd.append(conf['validator_addresses'][valNumber]) stake = amount + conf['staking_denom'] cmd.append(stake) cmd.append('--from') cmd.append(conf['validator_names'][valNumber]) cmd.append('--chain-id') cmd.append(conf['chain_id']) cmd.append('-y') return cmd # Perform delegation for s in sys.argv[1:]: if not s.isnumeric(): print(s + ' must be a number') exit(1) i = 0 for s in sys.argv[1:]: if int(s) > 0: print(i) cmd = delegate_cmd(i, s) print('running: ' + " ".join(cmd)) subprocess.run(cmd, check=True) i += 1 print() print() print('delegation performed, to show validator set:') print('spnd q tendermint-validator-set') print() print('to show consensus state') print('spnd q ibc client self-consensus-state')
''' Description: email: 359066432@qq.com Author: lhj software: vscode Date: 2021-09-19 17:28:48 platform: windows 10 LastEditors: lhj LastEditTime: 2021-09-20 20:01:05 ''' from dataclasses import dataclass @dataclass class UserBriefInfo(object): user_id:str user_name:str @classmethod def from_user(cls,user): return cls(user_id=user.id,user_name=user.username) @property def cache_permission_key(self): return f"user:{self.user_name}:permissions" @property def cache_roles_key(self): return f"user:{self.user_name}:roles"
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import paste import subprocess from multiprocessing import Process from pathlib import Path import tkinter.messagebox as messagebox from shutil import copy from appdirs import user_config_dir import logging as log from globe import Globe as globe from util import StrUtil as strutil import workspace SYSTEM = globe.SYSTEM if SYSTEM == "Darwin": from pynput import keyboard elif SYSTEM == "Windows": import keyboard import mouse as w_mouse user_dir = Path(user_config_dir("project", "ww")) if not user_dir.is_dir(): user_dir.mkdir(parents=True) roots_file = user_dir / 'roots' template = user_dir / 'template.svg' config = user_dir / 'config.py' if not template.is_file(): source = str(Path(__file__).parent / 'template.svg') destination = str(template) copy(source, destination) def inkscape(path): log.info("Inkscape function started") # # def for_canonical(f): # log.info("for_canonical") # return lambda k: f(l.canonical(k)) # hotkey = keyboard.HotKey( # keyboard.HotKey.parse('<cmd>+u'), # on_activate) if SYSTEM == "Darwin": processOpen = subprocess.Popen(['/Applications/Inkscape.app/Contents/MacOS/inkscape', str(path)]) log.info("Opening file") elif SYSTEM == "Windows": processOpen = subprocess.Popen(['inkscape', str(path)]) log.info("Opening file") # with keyboard.GlobalHotKeys({'<cmd>+i': paste.open_vim}) as hotkey: # hotkey.join() # l = keyboard.Listener( # on_press=for_canonical(hotkey.press), # on_release=for_canonical(hotkey.release), # # suppress=True # ) # l.start() processOpen.wait() log.info("Inkscape terminated") if SYSTEM == "Darwin": version = os.popen('/Applications/Inkscape.app/Contents/MacOS/inkscape --version').readlines() if '4035a4f' not in str(version): messagebox.showinfo('警告!', 'inkscape版本可能不兼容!导致并没有生成latex能识别的文件,请检查是否为1.0 (4035a4f, 2020-05-01)') inkscape_name = '/Applications/Inkscape.app/Contents/MacOS/inkscape' subprocess.Popen([inkscape_name, str(path), '-o', str(path.with_suffix(".pdf")), '--export-latex']) #else: #os.system('/Applications/Inkscape.app/Contents/MacOS/inkscape '+ str(path)+ ' --export-file='+str(path.with_suffix(".pdf"))+' --export-latex') elif SYSTEM == "Windows": subprocess.Popen(['inkscape', str(path), '-o', str(path.with_suffix(".pdf")), '--export-latex']) log.info("Export to pdf_tex process and InkscapeProcess terminated") def create(factor): # """ # Creates a figure. # First argument is the title of the figure # Second argument is the figure directory. # """ # title = title.strip() # file_name = title.replace(' ', '-').lower() + '.svg' # figures = root + os.path.sep + 'figures'+os.path.sep # figure_path = figures + file_name # # If a file with this name already exists, append a '2'. # if Path(figure_path).exists(): # title = title + '-2' # create(title,root) # else: # figure_path = Path(figure_path).absolute() # inkscape(figure_path) """ Creates a figure. First argument is the title of the figure Second argument is the figure directory. """ workspace.sub('figures') log.debug("File name without extension " + factor['fileName']) file_fullname = factor['fileName'] + '.svg' log.debug("File name " + file_fullname) figures_dir = Path(globe.workspace['sub']['figures']) figure_path = figures_dir / file_fullname # If a file with this name already exists, quit #TODO: 查重工作应该放在paste中完成,也许可以将功能封装,放在util里 if figure_path.exists(): log.warning("{} already exists. Edit but not create.".format(str(figure_path))) else: copy(str(template), str(figure_path)) log.info("Template copied") log.info("Starting Inkscape") process_inkscape = Process(target=inkscape, args=(figure_path,)) process_inkscape.start() return
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by 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. # ============================================================================== """Batching dataset transformations.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.python.data.experimental.ops import get_single_element from tensorflow.python.data.experimental.ops import grouping from tensorflow.python.data.ops import dataset_ops from tensorflow.python.data.util import convert from tensorflow.python.data.util import nest from tensorflow.python.data.util import sparse from tensorflow.python.data.util import structure from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import sparse_tensor from tensorflow.python.framework import tensor_shape from tensorflow.python.framework import tensor_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import check_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import gen_array_ops from tensorflow.python.ops import gen_experimental_dataset_ops as ged_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import sparse_ops from tensorflow.python.util.tf_export import tf_export def batch_window(dataset): """Batches a window of tensors. Args: dataset: the input dataset. Returns: A `Tensor` representing the batch of the entire input dataset. """ if isinstance(dataset.output_classes, tuple): raise TypeError("Input dataset expected to have a single component") if dataset.output_classes is ops.Tensor: return _batch_dense_window(dataset) elif dataset.output_classes is sparse_tensor.SparseTensor: return _batch_sparse_window(dataset) else: raise TypeError("Unsupported dataset type: %s" % dataset.output_classes) def _batch_dense_window(dataset): """Batches a window of dense tensors.""" def key_fn(_): return np.int64(0) def shape_init_fn(_): return array_ops.shape(first_element) def shape_reduce_fn(state, value): check_ops.assert_equal(state, array_ops.shape(value)) return state def finalize_fn(state): return state if dataset.output_shapes.is_fully_defined(): shape = dataset.output_shapes else: first_element = get_single_element.get_single_element(dataset.take(1)) shape_reducer = grouping.Reducer(shape_init_fn, shape_reduce_fn, finalize_fn) shape = get_single_element.get_single_element( dataset.apply(grouping.group_by_reducer(key_fn, shape_reducer))) def batch_init_fn(_): batch_shape = array_ops.concat([[0], shape], 0) return gen_array_ops.empty(batch_shape, dtype=dataset.output_types) def batch_reduce_fn(state, value): return array_ops.concat([state, [value]], 0) batch_reducer = grouping.Reducer(batch_init_fn, batch_reduce_fn, finalize_fn) return get_single_element.get_single_element( dataset.apply(grouping.group_by_reducer(key_fn, batch_reducer))) def _batch_sparse_window(dataset): """Batches a window of sparse tensors.""" def key_fn(_): return np.int64(0) def shape_init_fn(_): return first_element.dense_shape def shape_reduce_fn(state, value): check_ops.assert_equal(state, value.dense_shape) return state def finalize_fn(state): return state if dataset.output_shapes.is_fully_defined(): shape = dataset.output_shapes else: first_element = get_single_element.get_single_element(dataset.take(1)) shape_reducer = grouping.Reducer(shape_init_fn, shape_reduce_fn, finalize_fn) shape = get_single_element.get_single_element( dataset.apply(grouping.group_by_reducer(key_fn, shape_reducer))) def batch_init_fn(_): indices_shape = array_ops.concat([[0], [array_ops.size(shape) + 1]], 0) return sparse_tensor.SparseTensor( indices=gen_array_ops.empty(indices_shape, dtype=dtypes.int64), values=constant_op.constant([], shape=[0], dtype=dataset.output_types), dense_shape=array_ops.concat( [np.array([0], dtype=np.int64), math_ops.cast(shape, dtypes.int64)], 0)) def batch_reduce_fn(state, value): return sparse_ops.sparse_concat(0, [state, value]) def reshape_fn(value): return sparse_ops.sparse_reshape( value, array_ops.concat([np.array([1], dtype=np.int64), value.dense_shape], 0)) batch_reducer = grouping.Reducer(batch_init_fn, batch_reduce_fn, finalize_fn) return get_single_element.get_single_element( dataset.map(reshape_fn).apply( grouping.group_by_reducer(key_fn, batch_reducer))) @tf_export("data.experimental.dense_to_sparse_batch") def dense_to_sparse_batch(batch_size, row_shape): """A transformation that batches ragged elements into `tf.SparseTensor`s. Like `Dataset.padded_batch()`, this transformation combines multiple consecutive elements of the dataset, which might have different shapes, into a single element. The resulting element has three components (`indices`, `values`, and `dense_shape`), which comprise a `tf.SparseTensor` that represents the same data. The `row_shape` represents the dense shape of each row in the resulting `tf.SparseTensor`, to which the effective batch size is prepended. For example: ```python # NOTE: The following examples use `{ ... }` to represent the # contents of a dataset. a = { ['a', 'b', 'c'], ['a', 'b'], ['a', 'b', 'c', 'd'] } a.apply(tf.data.experimental.dense_to_sparse_batch( batch_size=2, row_shape=[6])) == { ([[0, 0], [0, 1], [0, 2], [1, 0], [1, 1]], # indices ['a', 'b', 'c', 'a', 'b'], # values [2, 6]), # dense_shape ([[0, 0], [0, 1], [0, 2], [0, 3]], ['a', 'b', 'c', 'd'], [1, 6]) } ``` Args: batch_size: A `tf.int64` scalar `tf.Tensor`, representing the number of consecutive elements of this dataset to combine in a single batch. row_shape: A `tf.TensorShape` or `tf.int64` vector tensor-like object representing the equivalent dense shape of a row in the resulting `tf.SparseTensor`. Each element of this dataset must have the same rank as `row_shape`, and must have size less than or equal to `row_shape` in each dimension. Returns: A `Dataset` transformation function, which can be passed to `tf.data.Dataset.apply`. """ def _apply_fn(dataset): return _DenseToSparseBatchDataset(dataset, batch_size, row_shape) return _apply_fn def padded_batch_window(dataset, padded_shape, padding_value=None): """Batches a window of tensors with padding. Args: dataset: the input dataset. padded_shape: (Optional.) `tf.TensorShape` or `tf.int64` vector tensor-like object representing the shape to which the input elements should be padded prior to batching. Any unknown dimensions (e.g. `tf.Dimension(None)` in a `tf.TensorShape` or `-1` in a tensor-like object) will be padded to the maximum size of that dimension in each batch. padding_value: (Optional.) A scalar-shaped `tf.Tensor`, representing the padding value to use. Defaults are `0` for numeric types and the empty string for string types. If `dataset` contains `tf.SparseTensor`, this value is ignored. Returns: A `Tensor` representing the batch of the entire input dataset. Raises: ValueError: if invalid arguments are provided. """ if not issubclass(dataset.output_classes, (ops.Tensor, sparse_tensor.SparseTensor)): raise TypeError("Input dataset expected to have a single tensor component") if issubclass(dataset.output_classes, (ops.Tensor)): return _padded_batch_dense_window(dataset, padded_shape, padding_value) elif issubclass(dataset.output_classes, (sparse_tensor.SparseTensor)): if padding_value is not None: raise ValueError("Padding value not allowed for sparse tensors") return _padded_batch_sparse_window(dataset, padded_shape) else: raise TypeError("Unsupported dataset type: %s" % dataset.output_classes) def _padded_batch_dense_window(dataset, padded_shape, padding_value=None): """Batches a window of dense tensors with padding.""" padded_shape = math_ops.cast( convert.partial_shape_to_tensor(padded_shape), dtypes.int32) def key_fn(_): return np.int64(0) def max_init_fn(_): return padded_shape def max_reduce_fn(state, value): """Computes the maximum shape to pad to.""" condition = math_ops.reduce_all( math_ops.logical_or( math_ops.less_equal(array_ops.shape(value), padded_shape), math_ops.equal(padded_shape, -1))) assert_op = control_flow_ops.Assert(condition, [ "Actual shape greater than padded shape: ", array_ops.shape(value), padded_shape ]) with ops.control_dependencies([assert_op]): return math_ops.maximum(state, array_ops.shape(value)) def finalize_fn(state): return state # Compute the padded shape. max_reducer = grouping.Reducer(max_init_fn, max_reduce_fn, finalize_fn) padded_shape = get_single_element.get_single_element( dataset.apply(grouping.group_by_reducer(key_fn, max_reducer))) if padding_value is None: if dataset.output_types == dtypes.string: padding_value = "" elif dataset.output_types == dtypes.bool: padding_value = False elif dataset.output_types == dtypes.variant: raise TypeError("Unable to create padding for field of type 'variant'") else: padding_value = 0 def batch_init_fn(_): batch_shape = array_ops.concat( [np.array([0], dtype=np.int32), padded_shape], 0) return gen_array_ops.empty(batch_shape, dtype=dataset.output_types) def batch_reduce_fn(state, value): return array_ops.concat([state, [value]], 0) def pad_fn(value): shape = array_ops.shape(value) left = array_ops.zeros_like(shape) right = padded_shape - shape return array_ops.pad( value, array_ops.stack([left, right], 1), constant_values=padding_value) batch_reducer = grouping.Reducer(batch_init_fn, batch_reduce_fn, finalize_fn) return get_single_element.get_single_element( dataset.map(pad_fn).apply( grouping.group_by_reducer(key_fn, batch_reducer))) def _padded_batch_sparse_window(dataset, padded_shape): """Batches a window of sparse tensors with padding.""" def key_fn(_): return np.int64(0) def max_init_fn(_): return convert.partial_shape_to_tensor(padded_shape) def max_reduce_fn(state, value): """Computes the maximum shape to pad to.""" condition = math_ops.reduce_all( math_ops.logical_or( math_ops.less_equal(value.dense_shape, padded_shape), math_ops.equal(padded_shape, -1))) assert_op = control_flow_ops.Assert(condition, [ "Actual shape greater than padded shape: ", value.dense_shape, padded_shape ]) with ops.control_dependencies([assert_op]): return math_ops.maximum(state, value.dense_shape) def finalize_fn(state): return state # Compute the padded shape. max_reducer = grouping.Reducer(max_init_fn, max_reduce_fn, finalize_fn) padded_shape = get_single_element.get_single_element( dataset.apply(grouping.group_by_reducer(key_fn, max_reducer))) def batch_init_fn(_): indices_shape = array_ops.concat([[0], [array_ops.size(padded_shape) + 1]], 0) return sparse_tensor.SparseTensor( indices=gen_array_ops.empty(indices_shape, dtype=dtypes.int64), values=constant_op.constant([], shape=[0], dtype=dataset.output_types), dense_shape=array_ops.concat( [np.array([0], dtype=np.int64), padded_shape], 0)) def batch_reduce_fn(state, value): padded_value = sparse_tensor.SparseTensor( indices=value.indices, values=value.values, dense_shape=padded_shape) reshaped_value = sparse_ops.sparse_reshape( padded_value, array_ops.concat( [np.array([1], dtype=np.int64), padded_value.dense_shape], 0)) return sparse_ops.sparse_concat(0, [state, reshaped_value]) reducer = grouping.Reducer(batch_init_fn, batch_reduce_fn, finalize_fn) return get_single_element.get_single_element( dataset.apply(grouping.group_by_reducer(key_fn, reducer))) class _UnbatchDataset(dataset_ops.UnaryDataset): """A dataset that splits the elements of its input into multiple elements.""" def __init__(self, input_dataset): """See `unbatch()` for more details.""" super(_UnbatchDataset, self).__init__(input_dataset) flat_shapes = nest.flatten(input_dataset.output_shapes) if any(s.ndims == 0 for s in flat_shapes): raise ValueError("Cannot unbatch an input with scalar components.") known_batch_dim = tensor_shape.Dimension(None) for s in flat_shapes: try: known_batch_dim = known_batch_dim.merge_with(s[0]) except ValueError: raise ValueError("Cannot unbatch an input whose components have " "different batch sizes.") self._input_dataset = input_dataset self._structure = structure.convert_legacy_structure( input_dataset.output_types, nest.map_structure(lambda s: s[1:], input_dataset.output_shapes), input_dataset.output_classes) def _as_variant_tensor(self): return ged_ops.experimental_unbatch_dataset( self._input_dataset._as_variant_tensor(), # pylint: disable=protected-access **dataset_ops.flat_structure(self)) @property def _element_structure(self): return self._structure @tf_export("data.experimental.unbatch") def unbatch(): """Splits elements of a dataset into multiple elements on the batch dimension. For example, if elements of the dataset are shaped `[B, a0, a1, ...]`, where `B` may vary for each input element, then for each element in the dataset, the unbatched dataset will contain `B` consecutive elements of shape `[a0, a1, ...]`. ```python # NOTE: The following example uses `{ ... }` to represent the contents # of a dataset. a = { ['a', 'b', 'c'], ['a', 'b'], ['a', 'b', 'c', 'd'] } a.apply(tf.data.experimental.unbatch()) == { 'a', 'b', 'c', 'a', 'b', 'a', 'b', 'c', 'd'} ``` Returns: A `Dataset` transformation function, which can be passed to `tf.data.Dataset.apply`. """ def _apply_fn(dataset): """Function from `Dataset` to `Dataset` that applies the transformation.""" if not sparse.any_sparse(dataset.output_classes): return _UnbatchDataset(dataset) # NOTE(mrry): We must ensure that any SparseTensors in `dataset` # are normalized to the rank-1 dense representation, so that the # sparse-oblivious unbatching logic will slice them # appropriately. This leads to a somewhat inefficient re-encoding step # for all SparseTensor components. # TODO(mrry): Consider optimizing this in future # if it turns out to be a bottleneck. def normalize(arg, *rest): if rest: return sparse.serialize_many_sparse_tensors((arg,) + rest) else: return sparse.serialize_many_sparse_tensors(arg) normalized_dataset = dataset.map(normalize) # NOTE(mrry): Our `map()` has lost information about the sparseness # of any SparseTensor components, so re-apply the structure of the # original dataset. restructured_dataset = _RestructuredDataset( normalized_dataset, dataset.output_types, dataset.output_shapes, dataset.output_classes, allow_unsafe_cast=True) return _UnbatchDataset(restructured_dataset) return _apply_fn class _DenseToSparseBatchDataset(dataset_ops.UnaryDataset): """A `Dataset` that batches ragged dense elements into `tf.SparseTensor`s.""" def __init__(self, input_dataset, batch_size, row_shape): """See `Dataset.dense_to_sparse_batch()` for more details.""" super(_DenseToSparseBatchDataset, self).__init__(input_dataset) if not isinstance(input_dataset.output_types, dtypes.DType): raise TypeError("DenseToSparseDataset requires an input whose elements " "have a single component, whereas the input has %r." % input_dataset.output_types) self._input_dataset = input_dataset self._batch_size = batch_size self._row_shape = row_shape self._structure = structure.SparseTensorStructure( input_dataset.output_types, tensor_shape.vector(None).concatenate(self._row_shape)) def _as_variant_tensor(self): return ged_ops.experimental_dense_to_sparse_batch_dataset( self._input_dataset._as_variant_tensor(), # pylint: disable=protected-access self._batch_size, row_shape=convert.partial_shape_to_tensor(self._row_shape), **dataset_ops.flat_structure(self)) @property def _element_structure(self): return self._structure class _RestructuredDataset(dataset_ops.UnaryDataset): """An internal helper for changing the structure and shape of a dataset.""" def __init__(self, dataset, output_types, output_shapes=None, output_classes=None, allow_unsafe_cast=False): """Creates a new dataset with the given output types and shapes. The given `dataset` must have a structure that is convertible: * `dataset.output_types` must be the same as `output_types` module nesting. * Each shape in `dataset.output_shapes` must be compatible with each shape in `output_shapes` (if given). Note: This helper permits "unsafe casts" for shapes, equivalent to using `tf.Tensor.set_shape()` where domain-specific knowledge is available. Args: dataset: A `Dataset` object. output_types: A nested structure of `tf.DType` objects. output_shapes: (Optional.) A nested structure of `tf.TensorShape` objects. If omitted, the shapes will be inherited from `dataset`. output_classes: (Optional.) A nested structure of class types. If omitted, the class types will be inherited from `dataset`. allow_unsafe_cast: (Optional.) If `True`, the caller may switch the reported output types and shapes of the restructured dataset, e.g. to switch a sparse tensor represented as `tf.variant` to its user-visible type and shape. Raises: ValueError: If either `output_types` or `output_shapes` is not compatible with the structure of `dataset`. """ super(_RestructuredDataset, self).__init__(dataset) self._input_dataset = dataset if not allow_unsafe_cast: # Validate that the types are compatible. output_types = nest.map_structure(dtypes.as_dtype, output_types) flat_original_types = nest.flatten(dataset.output_types) flat_new_types = nest.flatten(output_types) if flat_original_types != flat_new_types: raise ValueError( "Dataset with output types %r cannot be restructured to have " "output types %r" % (dataset.output_types, output_types)) if output_shapes is None: # Inherit shapes from the original `dataset`. output_shapes = nest.pack_sequence_as( output_types, nest.flatten(dataset.output_shapes)) else: if not allow_unsafe_cast: # Validate that the shapes are compatible. nest.assert_same_structure(output_types, output_shapes) flat_original_shapes = nest.flatten(dataset.output_shapes) flat_new_shapes = nest.flatten_up_to(output_types, output_shapes) for original_shape, new_shape in zip(flat_original_shapes, flat_new_shapes): if not original_shape.is_compatible_with(new_shape): raise ValueError( "Dataset with output shapes %r cannot be restructured to have " "incompatible output shapes %r" % (dataset.output_shapes, output_shapes)) output_shapes = nest.map_structure_up_to( output_types, tensor_shape.as_shape, output_shapes) if output_classes is None: # Inherit class types from the original `dataset`. output_classes = nest.pack_sequence_as( output_types, nest.flatten(dataset.output_classes)) self._structure = structure.convert_legacy_structure( output_types, output_shapes, output_classes) def _as_variant_tensor(self): return self._input_dataset._as_variant_tensor() # pylint: disable=protected-access @property def _element_structure(self): return self._structure class _MapAndBatchDataset(dataset_ops.UnaryDataset): """A `Dataset` that maps a function over a batch of elements.""" def __init__(self, input_dataset, map_func, batch_size, num_parallel_calls, drop_remainder): """See `Dataset.map()` for details.""" super(_MapAndBatchDataset, self).__init__(input_dataset) self._input_dataset = input_dataset self._map_func = dataset_ops.StructuredFunctionWrapper( map_func, "tf.data.experimental.map_and_batch()", dataset=input_dataset) self._batch_size_t = ops.convert_to_tensor( batch_size, dtype=dtypes.int64, name="batch_size") self._num_parallel_calls_t = ops.convert_to_tensor( num_parallel_calls, dtype=dtypes.int64, name="num_parallel_calls") self._drop_remainder_t = ops.convert_to_tensor( drop_remainder, dtype=dtypes.bool, name="drop_remainder") constant_drop_remainder = tensor_util.constant_value(self._drop_remainder_t) if constant_drop_remainder: # NOTE(mrry): `constant_drop_remainder` may be `None` (unknown statically) # or `False` (explicitly retaining the remainder). self._structure = self._map_func.output_structure._batch( # pylint: disable=protected-access tensor_util.constant_value(self._batch_size_t)) else: self._structure = self._map_func.output_structure._batch(None) # pylint: disable=protected-access def _functions(self): return [self._map_func] def _as_variant_tensor(self): # pylint: disable=protected-access return ged_ops.experimental_map_and_batch_dataset( self._input_dataset._as_variant_tensor(), self._map_func.function.captured_inputs, f=self._map_func.function, batch_size=self._batch_size_t, num_parallel_calls=self._num_parallel_calls_t, drop_remainder=self._drop_remainder_t, preserve_cardinality=True, **dataset_ops.flat_structure(self)) @property def _element_structure(self): return self._structure @tf_export("data.experimental.map_and_batch") def map_and_batch(map_func, batch_size, num_parallel_batches=None, drop_remainder=False, num_parallel_calls=None): """Fused implementation of `map` and `batch`. Maps `map_func` across `batch_size` consecutive elements of this dataset and then combines them into a batch. Functionally, it is equivalent to `map` followed by `batch`. However, by fusing the two transformations together, the implementation can be more efficient. Surfacing this transformation in the API is temporary. Once automatic input pipeline optimization is implemented, the fusing of `map` and `batch` will happen automatically and this API will be deprecated. Args: map_func: A function mapping a nested structure of tensors to another nested structure of tensors. batch_size: A `tf.int64` scalar `tf.Tensor`, representing the number of consecutive elements of this dataset to combine in a single batch. num_parallel_batches: (Optional.) A `tf.int64` scalar `tf.Tensor`, representing the number of batches to create in parallel. On one hand, higher values can help mitigate the effect of stragglers. On the other hand, higher values can increase contention if CPU is scarce. drop_remainder: (Optional.) A `tf.bool` scalar `tf.Tensor`, representing whether the last batch should be dropped in case its size is smaller than desired; the default behavior is not to drop the smaller batch. num_parallel_calls: (Optional.) A `tf.int32` scalar `tf.Tensor`, representing the number of elements to process in parallel. If not specified, `batch_size * num_parallel_batches` elements will be processed in parallel. If the value `tf.data.experimental.AUTOTUNE` is used, then the number of parallel calls is set dynamically based on available CPU. Returns: A `Dataset` transformation function, which can be passed to `tf.data.Dataset.apply`. Raises: ValueError: If both `num_parallel_batches` and `num_parallel_calls` are specified. """ if num_parallel_batches is None and num_parallel_calls is None: num_parallel_calls = batch_size elif num_parallel_batches is not None and num_parallel_calls is None: num_parallel_calls = batch_size * num_parallel_batches elif num_parallel_batches is not None and num_parallel_calls is not None: raise ValueError("The `num_parallel_batches` and `num_parallel_calls` " "arguments are mutually exclusive.") def _apply_fn(dataset): return _MapAndBatchDataset(dataset, map_func, batch_size, num_parallel_calls, drop_remainder) return _apply_fn
from __future__ import print_function from __future__ import absolute_import from __future__ import division from compas.utilities import flatten import compas_rhino from compas_rv2.rhino import get_scene from compas_rv2.rhino import rv2_undo from compas_rv2.rhino import rv2_error # from compas_rv2.rhino import ModifyAttributesForm __commandname__ = "RV2force_modify_vertices" @rv2_error() @rv2_undo def RunCommand(is_interactive): scene = get_scene() if not scene: return force = scene.get("force")[0] if not force: print("There is no ForceDiagram in the scene.") return thrust = scene.get("thrust")[0] options = ["All", "ByContinuousEdges", "Manual"] option = compas_rhino.rs.GetString("Selection Type.", strings=options) if not option: return if option == "All": keys = list(force.datastructure.vertices()) elif option == "ByContinuousEdges": temp = force.select_edges() keys = list(set(flatten([force.datastructure.vertices_on_edge_loop(key) for key in temp]))) elif option == "Manual": keys = force.select_vertices() if keys: # current = scene.settings['RV2']['show.angles'] # scene.settings['RV2']['show.angles'] = False # scene.update() # ModifyAttributesForm.from_sceneNode(force, 'vertices', keys) # scene.settings['RV2']['show.angles'] = current # if thrust: # thrust.settings['_is.valid'] = False # scene.update() public = [name for name in force.datastructure.default_vertex_attributes.keys() if not name.startswith('_')] if force.update_vertices_attributes(keys, names=public): if thrust: thrust.settings['_is.valid'] = False scene.update() # ============================================================================== # Main # ============================================================================== if __name__ == "__main__": RunCommand(True)
from terminalbeat import BaseTest import os class Test(BaseTest): def test_base(self): """ Basic test with exiting Terminalbeat normally """ self.render_config_template( path=os.path.abspath(self.working_dir) + "/log/*" ) terminalbeat_proc = self.start_beat() self.wait_until(lambda: self.log_contains("terminalbeat is running")) exit_code = terminalbeat_proc.kill_and_wait() assert exit_code == 0
from __future__ import unicode_literals from decimal import Decimal from django.conf import settings from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models from django.db.models import Sum from django.utils.encoding import python_2_unicode_compatible from django.utils.timezone import now from django.utils.translation import pgettext_lazy from django_prices.models import PriceField from django.utils import timezone from datetime import datetime, timedelta from ..userprofile.models import Address from ..customer.models import Customer from ..site.models import SiteSettings from ..sale.models import Terminal, PaymentOption from . import OrderStatus class CreditManager(models.Manager): def due_credits(self): return self.get_queryset().filter(due_date__lte=timezone.now()) def customer_credits(self, customer): return self.get_queryset().filter(customer=customer).aggregate(Sum('debt'))['debt__sum'] def expired_credit(self): max_credit_date = SiteSettings.objects.get(pk=1).max_credit_date days = timezone.now()-timedelta(days=max_credit_date) return self.get_queryset().filter(created__lte=timezone.now()-timedelta(days=max_credit_date)) class Credit(models.Model): status = models.CharField( pgettext_lazy('Credit field', 'Credit status'), max_length=32, choices=OrderStatus.CHOICES, default=OrderStatus.NEW) created = models.DateTimeField( pgettext_lazy('Credit field', 'created'), default=now, editable=False) last_status_change = models.DateTimeField( pgettext_lazy('Credit field', 'last status change'), default=now, editable=False) customer = models.ForeignKey( Customer, blank=True, null=True, related_name='credit_customers', verbose_name=pgettext_lazy('Credit field', 'customer')) mobile = models.CharField(max_length=20, blank=True, null=True) customer_name = models.CharField(max_length=100, null=True, blank=True) user = models.ForeignKey( settings.AUTH_USER_MODEL, blank=True, null=True, related_name='creditor', verbose_name=pgettext_lazy('Credit field', 'user')) language_code = models.CharField(max_length=35, default=settings.LANGUAGE_CODE) billing_address = models.ForeignKey( Address, related_name='+', editable=False,blank=True, null=True, verbose_name=pgettext_lazy('Credit field', 'billing address')) user_email = models.EmailField( pgettext_lazy('Credit field', 'user email'), blank=True, default='', editable=False) terminal = models.ForeignKey( Terminal, related_name='terminal_credit',blank=True, default='', verbose_name=pgettext_lazy('Credit field', 'order')) invoice_number = models.CharField( pgettext_lazy('Credit field', 'invoice_number'), unique=True, null=True, max_length=36,) total_net = models.DecimalField( pgettext_lazy('Credit field', 'total net'), default=Decimal(0), max_digits=100, decimal_places=2) sub_total = models.DecimalField( pgettext_lazy('Credit field', 'sub total'), default=Decimal(0), max_digits=100, decimal_places=2) total_tax = models.DecimalField( pgettext_lazy('Credit field', 'total tax'), default=Decimal(0), max_digits=100, decimal_places=2) amount_paid = models.DecimalField( pgettext_lazy('Credit field', 'amount paid'), default=Decimal(0), max_digits=100, decimal_places=2) balance = models.DecimalField( pgettext_lazy('Credit field', 'balance'), default=Decimal(0), max_digits=100, decimal_places=2) debt = models.DecimalField( pgettext_lazy('Credit field', 'debt'), default=Decimal(0), max_digits=100, decimal_places=2) discount_amount = PriceField( verbose_name=pgettext_lazy('Credit field', 'discount amount'), currency=settings.DEFAULT_CURRENCY, max_digits=12, decimal_places=2, blank=True, null=True) discount_name = models.CharField( verbose_name=pgettext_lazy('Credit field', 'discount name'), max_length=255, default='', blank=True) payment_options = models.ManyToManyField( PaymentOption, related_name='credit_payment_option', blank=True, verbose_name=pgettext_lazy('Sales field', 'sales options')) notified = models.BooleanField(default=False, blank=False) due_date = models.DateTimeField( pgettext_lazy('Credit field', 'due date'), null=False, default=now) car_registration = models.CharField(max_length=100, null=True, blank=True) objects = CreditManager() class Meta: ordering = ('-last_status_change',) verbose_name = pgettext_lazy('Credit model', 'Credit') verbose_name_plural = pgettext_lazy('Credit model', 'Credits') def __str__(self): return self.invoice_number def __unicode__(self): return unicode(self.invoice_number) def total_items(self): return len(self.credititems.all()) def items(self): return self.credititems.all() def is_fully_paid(self): if self.status == 'fully-paid': return True else: return False def is_due(self): if self.due_date <= timezone.now(): return True return False def is_expired(self): difference = datetime.now() - self.created.replace(tzinfo=None) max_credit_date = SiteSettings.objects.get(pk=1).max_credit_date if difference.days > max_credit_date: return True return False def total_amount(self): return len(self.credit_history.all()) def total_balance(self): return self.credit_history.aggregate(Sum('balance'))['balance__sum'] class CreditedItem(models.Model): credit = models.ForeignKey(Credit,related_name='credititems',on_delete=models.CASCADE) order = models.IntegerField(default=Decimal(1)) sku = models.CharField( pgettext_lazy('CreditedItem field', 'SKU'), max_length=32) quantity = models.IntegerField( pgettext_lazy('CreditedItem field', 'quantity'), validators=[MinValueValidator(0)], default=Decimal(1)) product_name = models.CharField( pgettext_lazy('CreditedItem field', 'product name'), max_length=128) total_cost = models.DecimalField( pgettext_lazy('CreditedItem field', 'total cost'), default=Decimal(0), max_digits=100, decimal_places=2) unit_cost = models.DecimalField( pgettext_lazy('CreditedItem field', 'unit cost'), default=Decimal(0), max_digits=100, decimal_places=2) product_category = models.CharField( pgettext_lazy('CreditedItem field', 'product_category'), max_length=128, null=True) discount = models.DecimalField( pgettext_lazy('SoldItem field', 'discount'), default=Decimal(0), max_digits=100, decimal_places=2) tax = models.IntegerField(default=Decimal(0)) class Meta: #unique_together = ('sales') ordering = ['order'] def __unicode__(self): return '%d: %s' % (self.order,self.product_name) def __str__(self): return self.product_name @python_2_unicode_compatible class CreditHistoryEntry(models.Model): date = models.DateTimeField( pgettext_lazy('Credit history entry field', 'last history change'), default=now, editable=False) created = models.DateTimeField( pgettext_lazy('Credit history entry field', 'created'), default=now, editable=False) credit = models.ForeignKey( Credit, related_name='credit_history', verbose_name=pgettext_lazy('Credit history entry field', 'order')) amount = models.DecimalField( pgettext_lazy('Credit history entry field', 'amount cost'), default=Decimal(0), max_digits=100, decimal_places=2) balance = models.DecimalField( pgettext_lazy('Credit history entry field', 'balance'), default=Decimal(0), max_digits=100, decimal_places=2) comment = models.CharField( pgettext_lazy('Credit history entry field', 'comment'), max_length=100, default='', blank=True) crud = models.CharField( pgettext_lazy('Credit history entry field', 'crud'), max_length=30, default='', blank=True) user = models.ForeignKey( settings.AUTH_USER_MODEL, blank=True, null=True, verbose_name=pgettext_lazy('Credit history entry field', 'user')) class Meta: ordering = ('date',) verbose_name = pgettext_lazy( 'Credit history entry model', 'Credit history entry') verbose_name_plural = pgettext_lazy( 'Credit history entry model', 'Credit history entries') def __str__(self): return pgettext_lazy( 'Credit history entry str', 'CreditHistoryEntry for terminal #%s') % self.credit.invoice_number
for j in range(y_bus_size - 1, -1, -1): f=[] f += [0] * j h=f.copy() f += [1] for i in range(j + 1, y_bus_size): f += [0] for k in range(j, i): # print(j,i,k) # 临时变量temp,存储l f 的乘积 f[i] -= facter_table[k, i] * f[k] # print(f) for i in range(j, y_bus_size): h += [f[i] * facter_table[i, i]] # print(h) # print(f,j) for i in range(y_bus_size - 1, -1, -1): z_bus[i, j]=h[i] # print(i,j) for k in range(i + 1, y_bus_size): # print('in!') z_bus[i, j] -= facter_table[i, k] * z_bus[k, j]
import _plotly_utils.basevalidators class TickprefixValidator(_plotly_utils.basevalidators.StringValidator): def __init__( self, plotly_name="tickprefix", parent_name="scattergl.marker.colorbar", **kwargs ): super(TickprefixValidator, self).__init__( plotly_name=plotly_name, parent_name=parent_name, edit_type=kwargs.pop("edit_type", "calc"), **kwargs )
# -*- coding: UTF-8 -*- # # Copyright 2019-2022 Flávio Gonçalves Garcia # # 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. from behave import given, when, then from taskio.process import TaskioLoader from behave.api.async_step import async_run_until_complete from tests import PROJECT_ROOT import sys @when("{command} is called from {program} program") def step_is_called_from_program(context, command, program): program_attribute = "%s_program" % program current_program: TaskioLoader = getattr(context, program_attribute) current_program.program.args = [command] current_category = current_program.program.what_category() context.what_to_run = current_program.program.what_to_run( current_category) @then("program will resolve command") def set_program_will_resolve_command(context): context.tester.assertTrue(isinstance(context.what_to_run, TaskioCommand))
from bokeh.charts import Histogram, output_file, show from bokeh.sampledata.autompg import autompg as df p = Histogram(df, 'hp', title="HP Distribution") output_file("histogram.html",) show(p)
from pytezos import PyTezosClient class Token(object): def __init__(self, client: PyTezosClient): self.client = client def set_admin(self, contract_id, new_admin): print(f"Setting fa2 admin on {contract_id} to {new_admin}") call = self.set_admin_call(contract_id, new_admin) res = call.autofill().sign().inject(_async=False) print(f"Done {res[0]['hash']}") def set_admin_call(self, contract_id, new_admin): contract = self.client.contract(contract_id) op = contract \ .set_admin(new_admin) return op def set_minter_call(self, contract_id, new_admin): contract = self.client.contract(contract_id) op = contract \ .set_minter(new_admin) return op
''' Parse the FST of the current disk and list the files Example: MountIso c:/isos/ac.gcm (mount existing GCM) % DvdListFiles ''' def do_command(dolwin, args): # Check if any DVD is mounted (real GCM image or DolphinSDK virtual disk) mounted = False res = dolwin.ExecuteWithResult ("DvdInfo 1") # Silent mode #print (res) for i in res["result"]: if type(i) == str: mounted = i != "" if not mounted: print ("DVD is not mounted") return # Get FST offset on disk and its size DVD_BB2_OFFSET = 0x0420 DVD_APPLDR_OFFSET = 0x2440 BB2_FSTPosition = 4 BB2_FSTLength = 8 fstEntrySize = 12; fstOffset = __DvdReadUInt32 (dolwin, DVD_BB2_OFFSET + BB2_FSTPosition) fstLength = __DvdReadUInt32 (dolwin, DVD_BB2_OFFSET + BB2_FSTLength) # Including name table print ( "FST offset: 0x%0.8X, length: 0x%0.8X" % (fstOffset, fstLength)) if fstOffset <= DVD_APPLDR_OFFSET: print ("Suspicious FST offset") return if fstLength > 16*1024*1024 or fstLength < fstEntrySize: print ("Invalid FST size") return # Get the number of entries in FST if __DvdReadUInt8(dolwin, fstOffset) != 1: print ("Invalid FST format. The first entry must be of type isDir = 1") return numEntries = __DvdReadUInt32(dolwin, fstOffset + 8) if numEntries * fstEntrySize > fstLength: print ("The number of records exceeds the specified FST size (including nametable)") return nameTableLength = fstLength - numEntries * fstEntrySize if nameTableLength <= 0: print ("Suspicious nametable size") return print ("FST entries count: " + str(numEntries)) print ("Nametable size: " + str(nameTableLength) + " bytes") # Load nametable nametable = __DvdReadLargeChunk(dolwin, fstOffset + numEntries * fstEntrySize, nameTableLength) #print ("nametable: " + str(nametable)) # Collect all FST entries into a common collection for easy display entryOffset = fstOffset # Offset of the current entry entries = [] # Save all entries to this collection while numEntries != 0: entry = FSTEntry() entry.id = len(entries) entry.isDir = __DvdReadUInt8(dolwin, entryOffset) != 0 entry.nameOffset = (__DvdReadUInt8(dolwin, entryOffset + 1) << 16) | __DvdReadUInt16(dolwin, entryOffset + 2) if entry.isDir: entry.parentOffset = __DvdReadUInt32(dolwin, entryOffset + 4) entry.nextOffset = __DvdReadUInt32(dolwin, entryOffset + 8) else: entry.fileOffset = __DvdReadUInt32(dolwin, entryOffset + 4) entry.fileLength = __DvdReadUInt32(dolwin, entryOffset + 8) entries.append(entry) numEntries -= 1 entryOffset += fstEntrySize # Consecutively display the contents of FST entries (each entry is either a directory or a file) print ("category [entry_id]: path (nameOffset), ... directory/file specific info") for e in entries: __DumpFstEntry (e, entries, nametable) ''' Display FST entry contents ''' def __DumpFstEntry (entry, entries, nametable): if entry.isDir: if entry.id == 0: print ("dir [0]: (root)") else: print ("dir [%d]: %s (%d), parent: %d, next: %d" % (entry.id, __DvdGetName(nametable, entry.nameOffset), entry.nameOffset, entry.parentOffset, entry.nextOffset)) else: fullPath = __DvdGetName(nametable, entry.nameOffset) # To understand how the FST hierarchical structure works, see the bottom of this file. # Get parent directory by iterating over FST entries backward until isDir = 1 is encountered. # The `next` value for the directory must be greater file ID parentDirId = 0 currentId = entry.id while currentId != 0: if entries[currentId].isDir and entries[currentId].nextOffset > entry.id: parentDirId = currentId break currentId -= 1 # Recursively climb up directories until a directory with parent = 0 is encountered while parentDirId != 0: fullPath = __DvdGetName(nametable, entries[parentDirId].nameOffset) + "/" + fullPath parentDirId = entries[parentDirId].parentOffset fullPath = "/" + fullPath print ("file [%d]: %s (%d), offset: 0x%0.8X, len: 0x%0.8X" % (entry.id, fullPath, entry.nameOffset, entry.fileOffset, entry.fileLength)) ''' Read uint8_t from disk ''' def __DvdReadUInt8(dolwin, offset): dolwin.Execute ("DvdSeek " + str(offset)) res = dolwin.ExecuteWithResult ( "DvdRead 1 1") return res["result"][0] ''' Read uint16_t from disk (already swapped to little-endian) ''' def __DvdReadUInt16(dolwin, offset): dolwin.Execute ("DvdSeek " + str(offset)) res = dolwin.ExecuteWithResult ( "DvdRead 2 1") return (res["result"][0] << 8) | (res["result"][1]) ''' Read uint32_t from disk (already swapped to little-endian) ''' def __DvdReadUInt32(dolwin, offset): dolwin.Execute ("DvdSeek " + str(offset)) res = dolwin.ExecuteWithResult ( "DvdRead 4 1") return (res["result"][0] << 24) | (res["result"][1] << 16) | (res["result"][2] << 8) | (res["result"][3]) ''' Load large block of data. Loading is performed in chunks no larger than a sector. ''' def __DvdReadLargeChunk(dolwin, offset, size): result = [] DVD_SECTOR_SIZE = 2048 while size != 0: actualSize = min (size, DVD_SECTOR_SIZE) dolwin.Execute ("DvdSeek " + str(offset)) res = dolwin.ExecuteWithResult ( "DvdRead " + str(actualSize) + " 1") result += res["result"] offset += actualSize size -= actualSize return result ''' Get zero-terminated ANSI byte string from nametable ''' def __DvdGetName(nametable, offset): len = 0 while nametable[offset + len] != 0: len += 1 return bytearray(nametable[offset:offset+len]).decode() ''' struct DVDFileEntry { uint8_t isDir; // 1, if directory uint8_t nameOffsetHi; // Relative to Name Table start uint16_t nameOffsetLo; union { struct // file { uint32_t fileOffset; // Relative to disk start (0) uint32_t fileLength; // In bytes }; struct // directory { uint32_t parentOffset; // parent directory FST index uint32_t nextOffset; // next directory FST index }; }; }; ''' class FSTEntry (object): pass ''' An example of a directory structure in FST: / AudioRes Banks LuiSe2_0.aw LuiSec0_0.aw LuiSec1_0.aw LuiSec2_0.aw JaiInit.aaf -- file Seqs JaiArcS.arc Stream TMansion.afc TMOpen.afc CVS ... dir [84]: AudioRes (981), parent: 0, next: 96 dir [85]: Banks (990), parent: 84, next: 90 file [86]: /AudioRes/Banks/LuiSe2_0.aw (996), offset: 0x4D5785F0, len: 0x0003EA60 file [87]: /AudioRes/Banks/LuiSec0_0.aw (1008), offset: 0x4D5B7050, len: 0x002325C0 file [88]: /AudioRes/Banks/LuiSec1_0.aw (1021), offset: 0x4D7E9610, len: 0x00637200 file [89]: /AudioRes/Banks/LuiSec2_0.aw (1034), offset: 0x4DE20810, len: 0x005E1CE0 file [90]: /AudioRes/JaiInit.aaf (1047), offset: 0x56D96820, len: 0x0003B900 dir [91]: Seqs (1059), parent: 84, next: 93 file [92]: /AudioRes/Seqs/JaiArcS.arc (1064), offset: 0x4E4024F0, len: 0x0008DEA0 dir [93]: Stream (1076), parent: 84, next: 96 file [94]: /AudioRes/Stream/TMansion.afc (1083), offset: 0x4E490390, len: 0x000DE040 file [95]: /AudioRes/Stream/TMOpen.afc (1096), offset: 0x4E56E3D0, len: 0x0024FC00 dir [96]: CVS (1107), parent: 0, next: 100 As you can see, the `next` field in the `Banks` directory points to the `JaiInit.aaf` file, where the current level of the `Banks` folder hierarchy ends. '''
# The objective of this program is to multiply two input numbers def multiply(*args): a = args res = 1 for ele in a: res *= ele return res a1=int(input()) a2=int(input()) print(multiply(a1,a2))
from pyramid_layout.layout import layout_config @layout_config(template='h:templates/base.pt') class BaseLayout(object): csp = None inline_webfont = True requirements = (('app', None),) def __init__(self, context, request): self.context = context self.request = request self.forms = {} def add_form(self, form): if form.formid in self.forms: raise ValueError('duplicate form id "%s"' % form.formid) self.forms[form.formid] = form def get_widget_requirements(self): requirements = [] requirements.extend(self.requirements) for form in self.forms.values(): requirements.extend(form.get_widget_requirements()) return requirements def get_widget_resources(self): requirements = self.get_widget_requirements() return self.request.registry.resources(requirements) @property def css_links(self): return self.get_widget_resources()['css'] @property def js_links(self): return self.get_widget_resources()['js'] @layout_config(name='sidebar', template='h:templates/base.pt') class SidebarLayout(BaseLayout): requirements = (('app', None), ('sidebar', None)) def includeme(config): config.include('pyramid_layout') config.scan(__name__)
#!/usr/bin/env python # coding=utf-8 # Created by max on 17-5-4. import os import sys import numpy as np import pandas as pd import matplotlib.pyplot as plt from fbprophet import Prophet from pandas import Series, DataFrame DATA_FILE = "dataset/data0.csv" def main(args): data = pd.read_csv(DATA_FILE, parse_dates=True, index_col='timestamp') # Re-group data to fit for Prophet data format data['ds'] = data.index data = data.reindex(columns=['ds', 'v0', 'v1', 'result']) data = data.rename(columns={"v0": 'y'}) model = Prophet() model.fit(data.ix[data.index[0:500]]) future = model.make_future_dataframe(120, 'H') forecast = model.predict(future) model.plot(forecast) model.plot_components(forecast) plt.show() if __name__ == "__main__": main(sys.argv)
def mergeSort(arr): n= len(arr) if n > 1: mid = int(n/2) left = arr[0:mid] right = arr[mid:n] mergeSort(left) mergeSort(right) Merge(left, right, arr) def Merge(left, right, arr): i = 0 j = 0 k = 0 while i < len(left) and j < len(right): if left[i] <= right[j]: arr[k] = left[i] i += 1 else: arr[k] = right[j] j += 1 k =k + 1 while i < len(left): arr[k] = left[i] i += 1 k += 1 while j < len(right): arr[k] = right[j] j += 1 k += 1 if __name__ == "__main__": arr = [8,4,23,42,16,15] print('Array => '+f'{arr}') mergeSort(arr) print('Sorted array => '+f'{arr}')
# -*- coding: utf-8 -*- """ Translate docutils node important formatting. each important start will processed with visit() and finished with depart() """ from docutils.nodes import Node from sphinxpapyrus.docxbuilder.translator import DocxTranslator node_name = "important" def visit(visitor: DocxTranslator, node: Node): """Start processing important node""" assert isinstance(visitor, DocxTranslator) assert isinstance(node, Node) def depart(visitor: DocxTranslator, node: Node): """Finish processing important node""" assert isinstance(visitor, DocxTranslator) assert isinstance(node, Node)
# Always prefer setuptools over distutils from setuptools import setup, find_packages # To use a consistent encoding from codecs import open from os import path here = path.abspath(path.dirname(__file__)) # Get the long description from the relevant file with open(path.join(here, 'README.markdown'), encoding='utf-8') as f: long_description = f.read() setup( name='prpg', # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html version='0.4.1', description='A pseudorandom password generator / password manager.', long_description=long_description, # The project's main homepage. url='https://github.com/speezepearson/prpg', # Author details author='speezepearson', author_email='speeze.pearson+prpg@gmail.com', # Choose your license # license='MIT', # See https://pypi.python.org/pypi?%3Aaction=list_classifiers classifiers=[ # How mature is this project? Common values are # 3 - Alpha # 4 - Beta # 5 - Production/Stable 'Development Status :: 4 - Beta', # Indicate who your project is intended for 'Intended Audience :: Developers', 'Topic :: Security', # Pick your license as you wish (should match "license" above) # 'License :: OSI Approved :: MIT License', # Specify the Python versions you support here. In particular, ensure # that you indicate whether you support Python 2, Python 3 or both. 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', ], # What does your project relate to? keywords='password password-management password-generation', # You can just specify the packages manually here if your project is # simple. Or you can use find_packages(). packages=find_packages(exclude=['test', 'doc', 'wiki']), # List run-time dependencies here. These will be installed by pip when # your project is installed. For an analysis of "install_requires" vs pip's # requirements files see: # https://packaging.python.org/en/latest/requirements.html install_requires=[], # List additional groups of dependencies here (e.g. development # dependencies). You can install these using the following syntax, # for example: # $ pip install -e .[dev,test] extras_require={ 'dev': [], 'test': ['pytest', 'pexpect'], }, # If there are data files included in your packages that need to be # installed, specify them here. If using Python 2.6 or less, then these # have to be included in MANIFEST.in as well. # package_data={ # 'browsergui': ['_server/*.html', '_server/*.js', 'examples/*.png'], # }, # Although 'package_data' is the preferred approach, in some case you may # need to place data files outside of your packages. See: # http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files # noqa # In this case, 'data_file' will be installed into '<sys.prefix>/my_data' # data_files=[('my_data', ['data/data_file'])], # To provide executable scripts, use entry points in preference to the # "scripts" keyword. Entry points provide cross-platform support and allow # pip to create the appropriate form of executable for the target platform. entry_points={ 'console_scripts': [ 'prpg=prpg:main', ], }, )
from django import template from django.contrib.auth.models import Group register = template.Library() @register.filter(name='has_group') def has_group(user, group_name): try: group = Group.objects.get(name=group_name) except: return False # group doesn't exist, so for sure the user isn't part of the group # for superuser , always return True if user.is_superuser: return True return user.groups.filter(name=group_name).exists() # The first argument *must* be called "context" here. def breadcrumb_tag(context): request = context['request'] address = request.path return { 'link':address, 'title': address, } # Register the custom tag as an inclusion tag with takes_context=True. register.inclusion_tag('tags/breadcrumb.html', takes_context=True)(breadcrumb_tag)
# -*- coding: utf-8 -*- from __future__ import unicode_literals from frappe import _ def get_data(): return [ { "module_name": "Demo App", "color": "grey", "icon": "octicon octicon-file-directory", "type": "module", "label": _("Demo App") } ]
from django import forms from django.urls import reverse from django.utils.translation import pgettext_lazy, ugettext_lazy as _ from i18nfield.forms import I18nFormField, I18nTextarea, I18nTextInput from pretix.base.email import get_available_placeholders from pretix.base.forms import PlaceholderValidator from pretix.base.models import Item, Order, SubEvent from pretix.control.forms.widgets import Select2 class MailForm(forms.Form): recipients = forms.ChoiceField( label=_('Send email to'), widget=forms.RadioSelect, initial='orders', choices=[] ) sendto = forms.MultipleChoiceField() # overridden later subject = forms.CharField(label=_("Subject")) message = forms.CharField(label=_("Message")) items = forms.ModelMultipleChoiceField( widget=forms.CheckboxSelectMultiple( attrs={'class': 'scrolling-multiple-choice'} ), label=_('Only send to people who bought'), required=True, queryset=Item.objects.none() ) subevent = forms.ModelChoiceField( SubEvent.objects.none(), label=_('Only send to customers of'), required=False, empty_label=pgettext_lazy('subevent', 'All dates') ) def _set_field_placeholders(self, fn, base_parameters): phs = [ '{%s}' % p for p in sorted(get_available_placeholders(self.event, base_parameters).keys()) ] ht = _('Available placeholders: {list}').format( list=', '.join(phs) ) if self.fields[fn].help_text: self.fields[fn].help_text += ' ' + str(ht) else: self.fields[fn].help_text = ht self.fields[fn].validators.append( PlaceholderValidator(phs) ) def __init__(self, *args, **kwargs): event = self.event = kwargs.pop('event') super().__init__(*args, **kwargs) recp_choices = [ ('orders', _('Everyone who created a ticket order')) ] if event.settings.attendee_emails_asked: recp_choices += [ ('attendees', _('Every attendee (falling back to the order contact when no attendee email address is ' 'given)')), ('both', _('Both (all order contact addresses and all attendee email addresses)')) ] self.fields['recipients'].choices = recp_choices self.fields['subject'] = I18nFormField( label=_('Subject'), widget=I18nTextInput, required=True, locales=event.settings.get('locales'), ) self.fields['message'] = I18nFormField( label=_('Message'), widget=I18nTextarea, required=True, locales=event.settings.get('locales'), ) self._set_field_placeholders('subject', ['event', 'order', 'position_or_address']) self._set_field_placeholders('message', ['event', 'order', 'position_or_address']) choices = list(Order.STATUS_CHOICE) if not event.settings.get('payment_term_expire_automatically', as_type=bool): choices.append( ('overdue', _('pending with payment overdue')) ) self.fields['sendto'] = forms.MultipleChoiceField( label=_("Send to customers with order status"), widget=forms.CheckboxSelectMultiple( attrs={'class': 'scrolling-multiple-choice'} ), choices=choices ) if not self.initial.get('sendto'): self.initial['sendto'] = ['p', 'n'] self.fields['items'].queryset = event.items.all() if not self.initial.get('items'): self.initial['items'] = event.items.all() if event.has_subevents: self.fields['subevent'].queryset = event.subevents.all() self.fields['subevent'].widget = Select2( attrs={ 'data-model-select2': 'event', 'data-select2-url': reverse('control:event.subevents.select2', kwargs={ 'event': event.slug, 'organizer': event.organizer.slug, }), 'data-placeholder': pgettext_lazy('subevent', 'Date') } ) self.fields['subevent'].widget.choices = self.fields['subevent'].choices else: del self.fields['subevent']
from parserT28.models.instructions.Expression.type_enum import DATA_TYPE from parserT28.controllers.three_address_code import ThreeAddressCode from parserT28.controllers.error_controller import ErrorController from parserT28.models.instructions.Expression.expression import Expression, Identifiers, PrimitiveData from parserT28.models.instructions.shared import ObjectReference from math import * class ExpressionsTrigonometric(Expression): ''' ExpressionsTrigonometric ''' def __init__(self, type_trigonometric, expression1, optional_expression2, line, column): self.type_trigonometric = type_trigonometric self.expression1 = expression1 self.optional_expression2 = optional_expression2 self.line = line self.column = column self.alias = f'{self.type_trigonometric}({self.expression1.alias})' self._tac = "" def __repr__(self): return str(vars(self)) def process(self, expression): type_trigo = self.type_trigonometric exp1 = None exp2 = None result = 0 lista1 = [] try: if isinstance(self.expression1, Identifiers): if isinstance(self.optional_expression2, PrimitiveData): exp2 = self.optional_expression2.process(expression) exp1 = self.expression1.process(expression) if type_trigo.lower() == "acos": result = [acos(columns) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'acosd': result = [degrees(acos(columns)) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'asin': result = [asin(columns) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'asind': result = [degrees(asin(columns)) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'atan': result = [atan(columns) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'atand': result = [degrees(atan(columns)) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'atan2': result = [atan2(columns, exp2.value) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'atan2d': result = [degrees(atan2(columns, exp2.value)) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'cos': result = [cos(columns) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'cosd': result = [degrees(cos(columns)) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'cot': result = [(1)/(tan(columns)) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'cotd': result = [degrees((1)/(tan(columns))) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'sin': result = [sin(columns) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'sind': result = [degrees(sin(columns)) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'tan': result = [tan(columns) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'tand': result = [degrees(tan(columns)) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'cosh': result = [cosh(columns) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'sinh': result = [sinh(columns) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'tanh': result = [tanh(columns) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'acosh': result = [acosh(columns) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'asinh': result = [asinh(columns) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 elif type_trigo.lower() == 'atanh': result = [atanh(columns) for columns in exp1[0]] lista1.append(result) lista1.append(self.alias) return lista1 else: if isinstance(self.expression1, PrimitiveData): exp1 = self.expression1.process(expression) if isinstance(self.optional_expression2, PrimitiveData): exp2 = self.optional_expression2.process(expression) if type_trigo.lower() == "acos": result = round(acos(float(exp1.value)), 4) elif type_trigo.lower() == 'acosd': result = round(degrees(acos(float(exp1.value))), 4) elif type_trigo.lower() == 'asin': result = round(asin(float(exp1.value)), 4) elif type_trigo.lower() == 'asind': result = round(degrees(asin(float(exp1.value))), 4) elif type_trigo.lower() == 'atan': result = round(atan(float(exp1.value)), 4) elif type_trigo.lower() == 'atand': result = round(degrees(atan(float(exp1.value))), 4) elif type_trigo.lower() == 'atan2': result = round( atan2(float(exp1.value), float(exp2.value)), 4) elif type_trigo.lower() == 'atan2d': result = round( degrees(atan2(float(exp1.value), float(exp2.value))), 4) elif type_trigo.lower() == 'cos': result = round(cos(float(exp1.value)), 4) elif type_trigo.lower() == 'cosd': result = round(degrees(cos(float(exp1.value))), 4) elif type_trigo.lower() == 'cot': result = round(1/(tan(float(exp1.value))), 4) elif type_trigo.lower() == 'cotd': result = round(degrees(1/(tan(float(exp1.value)))), 4) elif type_trigo.lower() == 'sin': result = round(sin(float(exp1.value)), 4) elif type_trigo.lower() == 'sind': result = round(degrees(sin(float(exp1.value))), 4) elif type_trigo.lower() == 'tan': result = round(tan(float(exp1.value)), 4) elif type_trigo.lower() == 'tand': result = round(degrees(tan(float(exp1.value))), 4) elif type_trigo.lower() == 'cosh': result = round(cosh(float(exp1.value)), 4) elif type_trigo.lower() == 'sinh': result = round(sinh(float(exp1.value)), 4) elif type_trigo.lower() == 'tanh': result = round(tanh(float(exp1.value)), 4) elif type_trigo.lower() == 'acosh': result = round(acosh(float(exp1.value)), 4) elif type_trigo.lower() == 'asinh': result = round(asinh(float(exp1.value)), 4) elif type_trigo.lower() == 'atanh': result = round(atanh(float(exp1.value)), 4) return PrimitiveData(DATA_TYPE.NUMBER, result, self.line, self.column) except: desc = "FATAL ERROR --- ExpressionsTrigonometric" ErrorController().add(34, 'Execution', desc, self.line, self.column) def compile(self, expression): type_trigo = self.type_trigonometric temporal = ThreeAddressCode().newTemp() temp1 = self.expression1.compile(expression) temp2 = None if self.optional_expression2: temp2 = self.optional_expression2.compile(expression) if type_trigo.lower() == "acos": ThreeAddressCode().addCode(f"{temporal} = acos({temp1.value})") elif type_trigo.lower() == 'acosd': temporal1 = ThreeAddressCode().newTemp() ThreeAddressCode().addCode(f"{temporal1} = acos({temp1.value})") ThreeAddressCode().addCode(f"{temporal} = degrees({temporal1})") elif type_trigo.lower() == 'asin': ThreeAddressCode().addCode(f"{temporal} = asin({temp1.value})") elif type_trigo.lower() == 'asind': temporal1 = ThreeAddressCode().newTemp() ThreeAddressCode().addCode(f"{temporal1} = asin({temp1.value})") ThreeAddressCode().addCode(f"{temporal} = degrees({temporal1})") elif type_trigo.lower() == 'atan': ThreeAddressCode().addCode(f"{temporal} = atan({temp1.value})") elif type_trigo.lower() == 'atand': temporal1 = ThreeAddressCode().newTemp() ThreeAddressCode().addCode(f"{temporal1} = atan({temp1.value})") ThreeAddressCode().addCode(f"{temporal} = degrees({temporal1})") elif type_trigo.lower() == 'atan2': ThreeAddressCode().addCode( f"{temporal} = atan2({temp1.value}, {temp2.value})") elif type_trigo.lower() == 'atan2d': temporal1 = ThreeAddressCode().newTemp() ThreeAddressCode().addCode( f"{temporal1} = atan2({temp1.value}, {temp2.value})") ThreeAddressCode().addCode(f"{temporal} = degrees({temporal1})") elif type_trigo.lower() == 'cos': ThreeAddressCode().addCode(f"{temporal} = cos({temp1.value})") elif type_trigo.lower() == 'cosd': temporal1 = ThreeAddressCode().newTemp() ThreeAddressCode().addCode(f"{temporal1} = cos({temp1.value})") ThreeAddressCode().addCode(f"{temporal} = degrees({temporal1})") elif type_trigo.lower() == 'cot': temporal1 = ThreeAddressCode().newTemp() ThreeAddressCode().addCode(f"{temporal1} = tan({temp1.value})") ThreeAddressCode().addCode(f"{temporal} = 1 / {temporal1}") elif type_trigo.lower() == 'cotd': temporal1 = ThreeAddressCode().newTemp() ThreeAddressCode().addCode(f"{temporal1} = tan({temp1.value})") temporal2 = ThreeAddressCode().newTemp() ThreeAddressCode().addCode(f"{temporal2} = 1 / {temporal1}") ThreeAddressCode().addCode(f"{temporal} = degrees({temporal2})") elif type_trigo.lower() == 'sin': ThreeAddressCode().addCode(f"{temporal} = sin({temp1.value})") elif type_trigo.lower() == 'sind': temporal1 = ThreeAddressCode().newTemp() ThreeAddressCode().addCode(f"{temporal1} = sin({temp1.value})") ThreeAddressCode().addCode(f"{temporal} = degrees({temporal1})") elif type_trigo.lower() == 'tan': ThreeAddressCode().addCode(f"{temporal} = tan({temp1.value})") elif type_trigo.lower() == 'tand': temporal1 = ThreeAddressCode().newTemp() ThreeAddressCode().addCode(f"{temporal1} = tan({temp1.value})") ThreeAddressCode().addCode(f"{temporal} = degrees({temporal1})") elif type_trigo.lower() == 'cosh': ThreeAddressCode().addCode(f"{temporal} = cosh({temp1.value})") elif type_trigo.lower() == 'sinh': ThreeAddressCode().addCode(f"{temporal} = sinh({temp1.value})") elif type_trigo.lower() == 'tanh': ThreeAddressCode().addCode(f"{temporal} = tanh({temp1.value})") elif type_trigo.lower() == 'acosh': ThreeAddressCode().addCode(f"{temporal} = acosh({temp1.value})") elif type_trigo.lower() == 'asinh': ThreeAddressCode().addCode(f"{temporal} = asinh({temp1.value})") elif type_trigo.lower() == 'atanh': ThreeAddressCode().addCode(f"{temporal} = atanh({temp1.value})") return PrimitiveData(DATA_TYPE.NUMBER, temporal, self.line, self.column)
# -*- coding: utf-8 -*- import os import sys sys.path.insert(0, os.path.abspath('..')) # -- General configuration ------------------------------------------------ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.napoleon', 'sphinx.ext.todo', ] # TODO: Please Read! # Uncomment the below if you use native CircuitPython modules such as # digitalio, micropython and busio. List the modules you use. Without it, the # autodoc module docs will fail to generate with a warning. # autodoc_mock_imports = ["digitalio", "busio"] # autodoc_mock_imports = ["digitalio"] intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'Register': ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)} # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General information about the project. project = u'Adafruit MatrixKeypad Library' copyright = u'2018 ladyada' author = u'ladyada' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = u'1.0' # The full version, including alpha/beta/rc tags. release = u'1.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = None # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md'] # The reST default role (used for this markup: `text`) to use for all # documents. # default_role = "any" # If true, '()' will be appended to :func: etc. cross-reference text. # add_function_parentheses = True # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False # If this is True, todo emits a warning for each TODO entries. The default is False. todo_emit_warnings = True napoleon_numpy_docstring = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if not on_rtd: # only import and set the theme if we're building docs locally try: import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.'] except: html_theme = 'default' html_theme_path = ['.'] else: html_theme_path = ['.'] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # The name of an image file (relative to this directory) to use as a favicon of # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. # html_favicon = '_static/favicon.ico' # Output file base name for HTML help builder. htmlhelp_basename = 'AdafruitMatrixkeypadLibrarydoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'AdafruitMatrixKeypadLibrary.tex', u'AdafruitMatrixKeypad Library Documentation', author, 'manual'), ] # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ (master_doc, 'AdafruitMatrixKeypadlibrary', u'Adafruit MatrixKeypad Library Documentation', [author], 1) ] # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'AdafruitMatrixKeypadLibrary', u'Adafruit MatrixKeypad Library Documentation', author, 'AdafruitMatrixKeypadLibrary', 'One line description of project.', 'Miscellaneous'), ]
import genanki import glob from pathlib import Path import random def generateAnki(): random.seed(42) title = 'Deutschland - Stadt, Land, Fluss' aDeck = genanki.Deck( 2059400110, title) # location to name aModel = genanki.Model( 1607392319, title, fields=[ {'name': 'Question'}, {'name': 'MapStyleQ'}, {'name': 'Answer'}, {'name': 'MapStyleA'}, ], templates=[ { 'name': 'Card Number', 'qfmt': '{{Question}}<br><br>{{MapStyleQ}}<div id="inline-svg"></div><script src="https://rawcdn.githack.com/SoerenSofke/Anki/release/v1.0.0/DeutschlandStadtLandFluss/inline-svg.js"></script>', 'afmt': '{{Question}}<br><br>{{MapStyleA}}<div id="inline-svg"></div><script src="https://rawcdn.githack.com/SoerenSofke/Anki/release/v1.0.0/DeutschlandStadtLandFluss/inline-svg.js"></script><hr id=answer><u>{{Answer}}</u>', }, ], css=''' .card { font-family: arial; font-size: 20px; text-align: center; color: black; background-color: white; } hr#answer { visibility: hidden; } ''' ) states = [ "Niedersachsen", "Hamburg", "Brandenburg", "Berlin", "Saarland", "Hessen", "Bremen", "Nordrhein-Westfalen", "Rheinland-Pfalz", "Sachsen", "Schleswig-Holstein", "Thüringen", "Mecklenburg-Vorpommern", "Bayern", "Baden-Württemberg", "Sachsen-Anhalt", ] random.shuffle(states) for state in states: question = 'Wie heißt das rot markierte <u>Bundesland</u>?' mapStyle = '<style>#State_' + state + ' {fill: crimson;}</style>' answer = state aDeck.add_note( genanki.Note( model=aModel, fields=[ question, mapStyle, answer, mapStyle, ] )) for state in states: question = 'Wo liegt das Bundesland <u>' + state +'</u>?' mapStyleQ = '<style></style>' answer = '' mapStyleA = '<style>#State_' + state + ' {fill: crimson;}</style>' aDeck.add_note( genanki.Note( model=aModel, fields=[ question, mapStyleQ, answer, mapStyleA, ] )) cities = [ 'Bremen', 'Berlin', 'Hamburg', 'Dresden', 'Düsseldorf', 'Erfurt', 'Hannover', 'Kiel', 'Magdeburg', 'Mainz', 'München', 'Saarbrücken', 'Schwerin', 'Stuttgart', 'Wiesbaden', 'Potsdam', ] random.shuffle(cities) for city in cities: question = 'Wie heißt die rot markierte <u>Stadt</u>?' mapStyle = '<style>#City_' + city + ' {fill: crimson;} #Cities {visibility: visible;}</style>' answer = city aDeck.add_note( genanki.Note( model=aModel, fields=[ question, mapStyle, answer, mapStyle ] )) for city in cities: question = 'Wo liegt die Stadt <u>' + city +'</u>?' mapStyleQ = '<style>#Cities {visibility: visible;}</style>' answer = '' mapStyleA = '<style>#City_' + city + ' {fill: crimson;} #Cities {visibility: visible;}</style>' aDeck.add_note( genanki.Note( model=aModel, fields=[ question, mapStyleQ, answer, mapStyleA ] )) mountains = [ 'Teutoburger_Wald', 'Rothaargebirge', 'Westerwald', 'Eifel', 'Taunus', 'Odenwald', 'Hunsrück', 'Vogelsberg', 'Rhön', 'Thüringer_Wald', 'Erzgebirge', 'Fichtelgebirge', 'Oberpfälzer_Wald', 'Fränkische_Alb', 'Bayerischer_Wald', 'Schwäbische_Alb', 'Schwarzwald', 'Alpenvorland', 'Spessart', 'Harz', ] random.shuffle(mountains) for mountain in mountains: question = 'Wie heißt das rot markierte <u>Gebirge</u>?' mapStyle = '<style>#Mountain_' + mountain + ' {fill: crimson;} #Mountains {visibility: visible;}</style>' answer = mountain.replace('_', ' ') aDeck.add_note( genanki.Note( model=aModel, fields=[ question, mapStyle, answer, mapStyle ] )) for mountain in mountains: question = 'Wo liegt das Gebirge <u>' + mountain.replace('_', ' ') +'</u>?' mapStyleQ = '<style>#Mountains {visibility: visible;}</style>' answer = '' mapStyleA = '<style>#Mountain_' + mountain + ' {fill: crimson;} #Mountains {visibility: visible;}</style>' aDeck.add_note( genanki.Note( model=aModel, fields=[ question, mapStyleQ, answer, mapStyleA ] )) rivers = [ 'Donau', 'Lech', 'Isar', 'Inn', 'Rhein', 'Neckar', 'Main', 'Ems', 'Weser', 'Werra', 'Ruhr', 'Oder', 'Saale', 'Mosel', 'Spree', 'Neisse', 'Lippe', 'Havel', 'Elbe', 'Fulda', 'Aller', 'Mulde', 'Unstrut', 'Peene', 'Naab', 'Lahn', 'Leine', 'Regnitz', 'Salzach', ] random.shuffle(rivers) for river in rivers: question = 'Wie heißt der rot markierte <u>Fluss</u>?' mapStyle = '<style>#River_' + river + ' {stroke: crimson; stroke-width: 5} #Rivers {visibility: visible;}</style>' answer = river aDeck.add_note( genanki.Note( model=aModel, fields=[ question, mapStyle, answer, mapStyle ] )) for river in rivers: question = 'Wo liegt der Fluss <u>' + river +'</u>?' mapStyleQ = '<style>#Rivers {visibility: visible;}</style>' answer = '' mapStyleA = '<style>#River_' + river + ' {stroke: crimson; stroke-width: 5} #Rivers {visibility: visible;}</style>' aDeck.add_note( genanki.Note( model=aModel, fields=[ question, mapStyleQ, answer, mapStyleA ] )) nations = [ 'Tschechien', 'Österreich', 'Frankreich', 'Schweiz', 'Polen', 'Belgien', 'Luxemburg', 'Niederlande', 'Dänemark', ] random.shuffle(nations) for nation in nations: question = 'Wie heißt das rot markierte <u>Land</u>?' mapStyle = '<style>#Nation_' + nation + ' {fill: crimson;} </style>' answer = nation aDeck.add_note( genanki.Note( model=aModel, fields=[ question, mapStyle, answer, mapStyle ] )) for nation in nations: question = 'Wo liegt der Land <u>' + nation +'</u>?' mapStyleQ = '<style></style>' answer = '' mapStyleA = '<style>#Nation_' + nation + ' {fill: crimson;} </style>' aDeck.add_note( genanki.Note( model=aModel, fields=[ question, mapStyleQ, answer, mapStyleA ] )) aPackage = genanki.Package(aDeck) aPackage.write_to_file(title + '.apkg') def main(): generateAnki() if __name__ == "__main__": main()
# coding: utf-8 # Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. # This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. from oci.util import formatted_flat_dict, NONE_SENTINEL, value_allowed_none_or_none_sentinel # noqa: F401 from oci.decorators import init_model_state_from_kwargs @init_model_state_from_kwargs class CreateUnifiedAgentConfigurationDetails(object): """ Unified Agent configuration creation object. """ def __init__(self, **kwargs): """ Initializes a new CreateUnifiedAgentConfigurationDetails object with values from keyword arguments. The following keyword arguments are supported (corresponding to the getters/setters of this class): :param display_name: The value to assign to the display_name property of this CreateUnifiedAgentConfigurationDetails. :type display_name: str :param is_enabled: The value to assign to the is_enabled property of this CreateUnifiedAgentConfigurationDetails. :type is_enabled: bool :param service_configuration: The value to assign to the service_configuration property of this CreateUnifiedAgentConfigurationDetails. :type service_configuration: oci.logging.models.UnifiedAgentServiceConfigurationDetails :param defined_tags: The value to assign to the defined_tags property of this CreateUnifiedAgentConfigurationDetails. :type defined_tags: dict(str, dict(str, object)) :param freeform_tags: The value to assign to the freeform_tags property of this CreateUnifiedAgentConfigurationDetails. :type freeform_tags: dict(str, str) :param compartment_id: The value to assign to the compartment_id property of this CreateUnifiedAgentConfigurationDetails. :type compartment_id: str :param description: The value to assign to the description property of this CreateUnifiedAgentConfigurationDetails. :type description: str :param group_association: The value to assign to the group_association property of this CreateUnifiedAgentConfigurationDetails. :type group_association: oci.logging.models.GroupAssociationDetails """ self.swagger_types = { 'display_name': 'str', 'is_enabled': 'bool', 'service_configuration': 'UnifiedAgentServiceConfigurationDetails', 'defined_tags': 'dict(str, dict(str, object))', 'freeform_tags': 'dict(str, str)', 'compartment_id': 'str', 'description': 'str', 'group_association': 'GroupAssociationDetails' } self.attribute_map = { 'display_name': 'displayName', 'is_enabled': 'isEnabled', 'service_configuration': 'serviceConfiguration', 'defined_tags': 'definedTags', 'freeform_tags': 'freeformTags', 'compartment_id': 'compartmentId', 'description': 'description', 'group_association': 'groupAssociation' } self._display_name = None self._is_enabled = None self._service_configuration = None self._defined_tags = None self._freeform_tags = None self._compartment_id = None self._description = None self._group_association = None @property def display_name(self): """ Gets the display_name of this CreateUnifiedAgentConfigurationDetails. The user-friendly display name. This must be unique within the enclosing resource, and it's changeable. Avoid entering confidential information. :return: The display_name of this CreateUnifiedAgentConfigurationDetails. :rtype: str """ return self._display_name @display_name.setter def display_name(self, display_name): """ Sets the display_name of this CreateUnifiedAgentConfigurationDetails. The user-friendly display name. This must be unique within the enclosing resource, and it's changeable. Avoid entering confidential information. :param display_name: The display_name of this CreateUnifiedAgentConfigurationDetails. :type: str """ self._display_name = display_name @property def is_enabled(self): """ **[Required]** Gets the is_enabled of this CreateUnifiedAgentConfigurationDetails. Whether or not this resource is currently enabled. :return: The is_enabled of this CreateUnifiedAgentConfigurationDetails. :rtype: bool """ return self._is_enabled @is_enabled.setter def is_enabled(self, is_enabled): """ Sets the is_enabled of this CreateUnifiedAgentConfigurationDetails. Whether or not this resource is currently enabled. :param is_enabled: The is_enabled of this CreateUnifiedAgentConfigurationDetails. :type: bool """ self._is_enabled = is_enabled @property def service_configuration(self): """ **[Required]** Gets the service_configuration of this CreateUnifiedAgentConfigurationDetails. :return: The service_configuration of this CreateUnifiedAgentConfigurationDetails. :rtype: oci.logging.models.UnifiedAgentServiceConfigurationDetails """ return self._service_configuration @service_configuration.setter def service_configuration(self, service_configuration): """ Sets the service_configuration of this CreateUnifiedAgentConfigurationDetails. :param service_configuration: The service_configuration of this CreateUnifiedAgentConfigurationDetails. :type: oci.logging.models.UnifiedAgentServiceConfigurationDetails """ self._service_configuration = service_configuration @property def defined_tags(self): """ Gets the defined_tags of this CreateUnifiedAgentConfigurationDetails. Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see `Resource Tags`__. Example: `{\"Operations\": {\"CostCenter\": \"42\"}}` __ https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm :return: The defined_tags of this CreateUnifiedAgentConfigurationDetails. :rtype: dict(str, dict(str, object)) """ return self._defined_tags @defined_tags.setter def defined_tags(self, defined_tags): """ Sets the defined_tags of this CreateUnifiedAgentConfigurationDetails. Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see `Resource Tags`__. Example: `{\"Operations\": {\"CostCenter\": \"42\"}}` __ https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm :param defined_tags: The defined_tags of this CreateUnifiedAgentConfigurationDetails. :type: dict(str, dict(str, object)) """ self._defined_tags = defined_tags @property def freeform_tags(self): """ Gets the freeform_tags of this CreateUnifiedAgentConfigurationDetails. Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see `Resource Tags`__. Example: `{\"Department\": \"Finance\"}` __ https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm :return: The freeform_tags of this CreateUnifiedAgentConfigurationDetails. :rtype: dict(str, str) """ return self._freeform_tags @freeform_tags.setter def freeform_tags(self, freeform_tags): """ Sets the freeform_tags of this CreateUnifiedAgentConfigurationDetails. Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see `Resource Tags`__. Example: `{\"Department\": \"Finance\"}` __ https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm :param freeform_tags: The freeform_tags of this CreateUnifiedAgentConfigurationDetails. :type: dict(str, str) """ self._freeform_tags = freeform_tags @property def compartment_id(self): """ **[Required]** Gets the compartment_id of this CreateUnifiedAgentConfigurationDetails. The OCID of the compartment that the resource belongs to. :return: The compartment_id of this CreateUnifiedAgentConfigurationDetails. :rtype: str """ return self._compartment_id @compartment_id.setter def compartment_id(self, compartment_id): """ Sets the compartment_id of this CreateUnifiedAgentConfigurationDetails. The OCID of the compartment that the resource belongs to. :param compartment_id: The compartment_id of this CreateUnifiedAgentConfigurationDetails. :type: str """ self._compartment_id = compartment_id @property def description(self): """ Gets the description of this CreateUnifiedAgentConfigurationDetails. Description for this resource. :return: The description of this CreateUnifiedAgentConfigurationDetails. :rtype: str """ return self._description @description.setter def description(self, description): """ Sets the description of this CreateUnifiedAgentConfigurationDetails. Description for this resource. :param description: The description of this CreateUnifiedAgentConfigurationDetails. :type: str """ self._description = description @property def group_association(self): """ Gets the group_association of this CreateUnifiedAgentConfigurationDetails. :return: The group_association of this CreateUnifiedAgentConfigurationDetails. :rtype: oci.logging.models.GroupAssociationDetails """ return self._group_association @group_association.setter def group_association(self, group_association): """ Sets the group_association of this CreateUnifiedAgentConfigurationDetails. :param group_association: The group_association of this CreateUnifiedAgentConfigurationDetails. :type: oci.logging.models.GroupAssociationDetails """ self._group_association = group_association def __repr__(self): return formatted_flat_dict(self) def __eq__(self, other): if other is None: return False return self.__dict__ == other.__dict__ def __ne__(self, other): return not self == other
import datetime import json from twilio.base import values def iso8601_date(d): """ Return a string representation of a date that the Twilio API understands Format is YYYY-MM-DD. Returns None if d is not a string, datetime, or date """ if d == values.unset: return d elif isinstance(d, datetime.datetime): return str(d.date()) elif isinstance(d, datetime.date): return str(d) elif isinstance(d, str): return d def iso8601_datetime(d): """ Return a string representation of a date that the Twilio API understands Format is YYYY-MM-DD. Returns None if d is not a string, datetime, or date """ if d == values.unset: return d elif isinstance(d, datetime.datetime) or isinstance(d, datetime.date): return d.strftime('%Y-%m-%dT%H:%M:%SZ') elif isinstance(d, str): return d def prefixed_collapsible_map(m, prefix): """ Return a dict of params corresponding to those in m with the added prefix """ if m == values.unset: return {} def flatten_dict(d, result=None, prv_keys=None): if result is None: result = {} if prv_keys is None: prv_keys = [] for k, v in d.items(): if isinstance(v, dict): flatten_dict(v, result, prv_keys + [k]) else: result['.'.join(prv_keys + [k])] = v return result if isinstance(m, dict): flattened = flatten_dict(m) return {'{}.{}'.format(prefix, k): v for k, v in flattened.items()} return {} def object(obj): """ Return a jsonified string represenation of obj if obj is jsonifiable else return obj untouched """ if isinstance(obj, dict) or isinstance(obj, list): return json.dumps(obj) return obj def map(lst, serialize_func): """ Applies serialize_func to every element in lst """ if not isinstance(lst, list): return lst return [serialize_func(e) for e in lst]
import unittest from sqlglot import transpile from sqlglot.errors import ErrorLevel, UnsupportedError class TestDialects(unittest.TestCase): def test_mysql(self): sql = transpile('SELECT CAST(`a`.`b` AS INT) FROM foo', read='mysql', write='mysql')[0] self.assertEqual(sql, 'SELECT CAST(`a`.`b` AS INT) FROM foo') def test_postgres(self): sql = transpile('SELECT CAST(`a`.`b` AS DOUBLE) FROM foo', read='postgres', write='postgres')[0] self.assertEqual(sql, 'SELECT CAST(`a`.`b` AS DOUBLE PRECISION) FROM foo') def test_presto(self): sql = transpile('SELECT "a"."b" FROM foo', read='presto', write='presto', identify=True)[0] self.assertEqual(sql, 'SELECT "a"."b" FROM "foo"') sql = transpile('SELECT a.b FROM foo', read='presto', write='spark')[0] self.assertEqual(sql, 'SELECT a.b FROM foo') sql = transpile('SELECT "a"."b" FROM foo', read='presto', write='spark', identify=True)[0] self.assertEqual(sql, 'SELECT `a`.`b` FROM `foo`') sql = transpile('SELECT a.b FROM foo', read='presto', write='spark', identify=True)[0] self.assertEqual(sql, 'SELECT `a`.`b` FROM `foo`') sql = transpile('SELECT APPROX_DISTINCT(a) FROM foo', read='presto', write='spark')[0] self.assertEqual(sql, 'SELECT APPROX_COUNT_DISTINCT(a) FROM foo') sql = transpile( 'SELECT APPROX_DISTINCT(a, 0.1) FROM foo', read='presto', write='spark', unsupported_level=ErrorLevel.IGNORE )[0] self.assertEqual(sql, 'SELECT APPROX_COUNT_DISTINCT(a) FROM foo') ctas = "CREATE TABLE test WITH (FORMAT = 'PARQUET') AS SELECT 1" self.assertEqual(transpile(ctas, read='presto', write='presto')[0], ctas) sql = transpile(ctas, read='presto', write='spark')[0] self.assertEqual(sql, "CREATE TABLE test STORED AS PARQUET AS SELECT 1") sql = transpile("SELECT JSON_EXTRACT(x, '$.name')", read='presto', write='spark')[0] self.assertEqual(sql, "SELECT GET_JSON_OBJECT(x, '$.name')") with self.assertRaises(UnsupportedError): transpile( 'SELECT APPROX_DISTINCT(a, 0.1) FROM foo', read='presto', write='spark', unsupported_level=ErrorLevel.RAISE, ) def test_hive(self): sql = transpile('SELECT "a"."b" FROM "foo"', write='hive')[0] self.assertEqual(sql, "SELECT `a`.`b` FROM `foo`") sql = transpile('SELECT CAST(`a`.`b` AS SMALLINT) FROM foo', read='hive', write='hive')[0] self.assertEqual(sql, 'SELECT CAST(`a`.`b` AS SMALLINT) FROM foo') sql = transpile('SELECT "a"."b" FROM foo', write='hive', identify=True)[0] self.assertEqual(sql, 'SELECT `a`.`b` FROM `foo`') sql = transpile('SELECT APPROX_COUNT_DISTINCT(a) FROM foo', read='hive', write='presto')[0] self.assertEqual(sql, 'SELECT APPROX_DISTINCT(a) FROM foo') sql = transpile('CREATE TABLE test STORED AS PARQUET AS SELECT 1', read='hive', write='presto')[0] self.assertEqual(sql, "CREATE TABLE test WITH (FORMAT = 'PARQUET') AS SELECT 1") sql = transpile("SELECT GET_JSON_OBJECT(x, '$.name')", read='hive', write='presto')[0] self.assertEqual(sql, "SELECT JSON_EXTRACT(x, '$.name')") def test_spark(self): sql = transpile('SELECT "a"."b" FROM "foo"', write='spark')[0] self.assertEqual(sql, "SELECT `a`.`b` FROM `foo`") sql = transpile('SELECT CAST(`a`.`b` AS SMALLINT) FROM foo', read='spark')[0] self.assertEqual(sql, 'SELECT CAST(`a`.`b` AS SHORT) FROM foo') sql = transpile('SELECT "a"."b" FROM foo', write='spark', identify=True)[0] self.assertEqual(sql, 'SELECT `a`.`b` FROM `foo`') sql = transpile('SELECT APPROX_COUNT_DISTINCT(a) FROM foo', read='spark', write='presto')[0] self.assertEqual(sql, 'SELECT APPROX_DISTINCT(a) FROM foo') sql = transpile('CREATE TABLE test STORED AS PARQUET AS SELECT 1', read='spark', write='presto')[0] self.assertEqual(sql, "CREATE TABLE test WITH (FORMAT = 'PARQUET') AS SELECT 1") sql = transpile('SELECT /*+ COALESCE(3) */ * FROM x', read='spark')[0] self.assertEqual(sql, 'SELECT /*+ COALESCE(3) */ * FROM x') def test_sqlite(self): sql = transpile('SELECT CAST(`a`.`b` AS SMALLINT) FROM foo', read='sqlite', write='sqlite')[0] self.assertEqual(sql, 'SELECT CAST(`a`.`b` AS INTEGER) FROM foo') def test_msaccess(self): sql = transpile('SELECT [a].[b] FROM [foo]', read='msacess', write='msacess')[0] self.assertEqual(sql, 'SELECT [a].[b] FROM [foo]')
from pathlib import Path import sys import os def add_application_path(): app_path = Path(__file__).resolve().parents[1] sys.path.append(str(app_path)) os.chdir(str(app_path))
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Business Applications # Copyright (c) 2013-TODAY OpenERP S.A. <http://www.openerp.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.addons.hr_holidays.tests import test_holidays_flow checks = [ test_holidays_flow, ] # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
""" importing public methods """ from .plex_auth import connect_to_plex from .plex_movies import return_movies from .plex_tv import return_tv from .plex_users import get_emails from .plex_users import unsub_emails from .plex_email import send_mail
""" @brief test log(time=2s) """ import unittest import warnings from pyquickhelper.loghelper import fLOG class TestLONGScriptInstall(unittest.TestCase): def test_pypi(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") import xmlrpc.client as xmlrpc_client module_name = "version_information" url = 'https://pypi.org/pypi/pip/json' functions = [] with xmlrpc_client.ServerProxy(url) as pypi: try: for f in pypi.system.listMethods(): fLOG(f) sig = pypi.system.methodSignature(f) fLOG(" ", sig) h = pypi.system.methodHelp(f) fLOG(" ", h) functions.append(f) if len(functions) > 1: break available = pypi.package_releases(module_name, True) fLOG(available) except xmlrpc_client.ProtocolError as e: warnings.warn("PyPI protocal has changed {0}".format(e)) functions = [None, None] assert len(functions) > 1 if __name__ == "__main__": unittest.main()
from django.shortcuts import render from rest_framework.views import APIView from rest_framework.response import Response from rest_framework import exceptions from common.serializers import UserSerializer from core.models import User,Product,Link,OrderItem,Order from common.authentication import JWTAuthentication from rest_framework.permissions import IsAuthenticated from .serializers import ProductSerializer from django.core.cache import cache import time # Create your views here. class ProductFrontendAPIView(APIView): # authentication_classes =[JWTAuthentication] # permission_classes=[IsAuthenticated] def get(self, request): products = Product.objects.all() serializer = ProductSerializer(products, many=True) return Response(serializer.data) class ProductBackendAPIView(APIView): def get(self, request): products = cache.get('products_backend') if not products: time.sleep(2) products = list(Product.objects.all()) cache.set(products, 'products_backend',timeout=60*30) products = Product.objects.all() serializer = ProductSerializer(products, many=True) return Response(serializer.data)
from pyglet.libs.darwin.objc_runtime import * # This class is a wrapper around NSCursor which prevents us from # sending too many hide or unhide messages in a row. Apparently # NSCursor treats them like retain/release messages, which can be # problematic when we are e.g. switching between window & fullscreen. class SystemCursor: cursor_is_hidden = False @classmethod def hide(cls): if not cls.cursor_is_hidden: send_message('NSCursor', 'hide') cls.cursor_is_hidden = True @classmethod def unhide(cls): if cls.cursor_is_hidden: send_message('NSCursor', 'unhide') cls.cursor_is_hidden = False
# read version from installed package from importlib.metadata import version __version__ = version("pycounts_polluxtroy3758") from pycounts_polluxtroy3758.plotting import plot_words # noqa: F401 from pycounts_polluxtroy3758.pycounts import count_words # noqa: F401
#!/usr/bin/env python # # Copyright 2018 Confluent Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # # Example Admin clients. # from confluent_kafka.admin import AdminClient, NewTopic, NewPartitions, ConfigResource, ConfigEntry from confluent_kafka import KafkaException import sys import threading import logging logging.basicConfig() def example_create_topics(a, topics): """ Create topics """ new_topics = [NewTopic(topic, num_partitions=3, replication_factor=1) for topic in topics] # Call create_topics to asynchronously create topics, a dict # of <topic,future> is returned. fs = a.create_topics(new_topics) # Wait for operation to finish. # Timeouts are preferably controlled by passing request_timeout=15.0 # to the create_topics() call. # All futures will finish at the same time. for topic, f in fs.items(): try: f.result() # The result itself is None print("Topic {} created".format(topic)) except Exception as e: print("Failed to create topic {}: {}".format(topic, e)) def example_delete_topics(a, topics): """ delete topics """ # Call delete_topics to asynchronously delete topics, a future is returned. # By default this operation on the broker returns immediately while # topics are deleted in the background. But here we give it some time (30s) # to propagate in the cluster before returning. # # Returns a dict of <topic,future>. fs = a.delete_topics(topics, operation_timeout=30) # Wait for operation to finish. for topic, f in fs.items(): try: f.result() # The result itself is None print("Topic {} deleted".format(topic)) except Exception as e: print("Failed to delete topic {}: {}".format(topic, e)) def example_create_partitions(a, topics): """ create partitions """ new_parts = [NewPartitions(topic, int(new_total_count)) for topic, new_total_count in zip(topics[0::2], topics[1::2])] # Try switching validate_only to True to only validate the operation # on the broker but not actually perform it. fs = a.create_partitions(new_parts, validate_only=False) # Wait for operation to finish. for topic, f in fs.items(): try: f.result() # The result itself is None print("Additional partitions created for topic {}".format(topic)) except Exception as e: print("Failed to add partitions to topic {}: {}".format(topic, e)) def print_config(config, depth): print('%40s = %-50s [%s,is:read-only=%r,default=%r,sensitive=%r,synonym=%r,synonyms=%s]' % ((' ' * depth) + config.name, config.value, ConfigEntry.config_source_to_str(config.source), config.is_read_only, config.is_default, config.is_sensitive, config.is_synonym, ["%s:%s" % (x.name, ConfigEntry.config_source_to_str(x.source)) for x in iter(config.synonyms.values())])) def example_describe_configs(a, args): """ describe configs """ resources = [ConfigResource(restype, resname) for restype, resname in zip(args[0::2], args[1::2])] fs = a.describe_configs(resources) # Wait for operation to finish. for res, f in fs.items(): try: configs = f.result() for config in iter(configs.values()): print_config(config, 1) except KafkaException as e: print("Failed to describe {}: {}".format(res, e)) except Exception as e: raise def example_alter_configs(a, args): """ Alter configs atomically, replacing non-specified configuration properties with their default values. """ resources = [] for restype, resname, configs in zip(args[0::3], args[1::3], args[2::3]): resource = ConfigResource(restype, resname) resources.append(resource) for k, v in [conf.split('=') for conf in configs.split(',')]: resource.set_config(k, v) fs = a.alter_configs(resources) # Wait for operation to finish. for res, f in fs.items(): try: f.result() # empty, but raises exception on failure print("{} configuration successfully altered".format(res)) except Exception: raise def example_delta_alter_configs(a, args): """ The AlterConfigs Kafka API requires all configuration to be passed, any left out configuration properties will revert to their default settings. This example shows how to just modify the supplied configuration entries by first reading the configuration from the broker, updating the supplied configuration with the broker configuration (without overwriting), and then writing it all back. The async nature of futures is also show-cased, which makes this example a bit more complex than it needs to be in the synchronous case. """ # Convert supplied config to resources. # We can reuse the same resources both for describe_configs and # alter_configs. resources = [] for restype, resname, configs in zip(args[0::3], args[1::3], args[2::3]): resource = ConfigResource(restype, resname) resources.append(resource) for k, v in [conf.split('=') for conf in configs.split(',')]: resource.set_config(k, v) # Set up a locked counter and an Event (for signaling) to track when the # second level of futures are done. This is a bit of contrived example # due to no other asynchronous mechanism being used, so we'll need # to wait on something to signal completion. class WaitZero(object): def __init__(self, waitcnt): self.cnt = waitcnt self.lock = threading.Lock() self.event = threading.Event() def decr(self): """ Decrement cnt by 1""" with self.lock: assert self.cnt > 0 self.cnt -= 1 self.event.set() def wait(self): """ Wait until cnt reaches 0 """ self.lock.acquire() while self.cnt > 0: self.lock.release() self.event.wait() self.event.clear() self.lock.acquire() self.lock.release() def __len__(self): with self.lock: return self.cnt wait_zero = WaitZero(len(resources)) # Read existing configuration from cluster fs = a.describe_configs(resources) def delta_alter_configs_done(fut, resource): e = fut.exception() if e is not None: print("Config update for {} failed: {}".format(resource, e)) else: print("Config for {} updated".format(resource)) wait_zero.decr() def delta_alter_configs(resource, remote_config): print("Updating {} supplied config entries {} with {} config entries read from cluster".format( len(resource), resource, len(remote_config))) # Only set configuration that is not default for k, entry in [(k, v) for k, v in remote_config.items() if not v.is_default]: resource.set_config(k, entry.value, overwrite=False) fs = a.alter_configs([resource]) fs[resource].add_done_callback(lambda fut: delta_alter_configs_done(fut, resource)) # For each resource's future set up a completion callback # that in turn calls alter_configs() on that single resource. # This is ineffective since the resources can usually go in # one single alter_configs() call, but we're also show-casing # the futures here. for res, f in fs.items(): f.add_done_callback(lambda fut, resource=res: delta_alter_configs(resource, fut.result())) # Wait for done callbacks to be triggered and operations to complete. print("Waiting for {} resource updates to finish".format(len(wait_zero))) wait_zero.wait() def example_list(a, args): """ list topics and cluster metadata """ if len(args) == 0: what = "all" else: what = args[0] md = a.list_topics(timeout=10) print("Cluster {} metadata (response from broker {}):".format(md.cluster_id, md.orig_broker_name)) if what in ("all", "brokers"): print(" {} brokers:".format(len(md.brokers))) for b in iter(md.brokers.values()): if b.id == md.controller_id: print(" {} (controller)".format(b)) else: print(" {}".format(b)) if what not in ("all", "topics"): return print(" {} topics:".format(len(md.topics))) for t in iter(md.topics.values()): if t.error is not None: errstr = ": {}".format(t.error) else: errstr = "" print(" \"{}\" with {} partition(s){}".format(t, len(t.partitions), errstr)) for p in iter(t.partitions.values()): if p.error is not None: errstr = ": {}".format(p.error) else: errstr = "" print(" partition {} leader: {}, replicas: {}, isrs: {}".format( p.id, p.leader, p.replicas, p.isrs, errstr)) if __name__ == '__main__': if len(sys.argv) < 3: sys.stderr.write('Usage: %s <bootstrap-brokers> <operation> <args..>\n\n' % sys.argv[0]) sys.stderr.write('operations:\n') sys.stderr.write(' create_topics <topic1> <topic2> ..\n') sys.stderr.write(' delete_topics <topic1> <topic2> ..\n') sys.stderr.write(' create_partitions <topic1> <new_total_count1> <topic2> <new_total_count2> ..\n') sys.stderr.write(' describe_configs <resource_type1> <resource_name1> <resource2> <resource_name2> ..\n') sys.stderr.write(' alter_configs <resource_type1> <resource_name1> ' + '<config=val,config2=val2> <resource_type2> <resource_name2> <config..> ..\n') sys.stderr.write(' delta_alter_configs <resource_type1> <resource_name1> ' + '<config=val,config2=val2> <resource_type2> <resource_name2> <config..> ..\n') sys.stderr.write(' list [<all|topics|brokers>]\n') sys.exit(1) broker = sys.argv[1] operation = sys.argv[2] args = sys.argv[3:] # Create Admin client a = AdminClient({'bootstrap.servers': broker}) opsmap = {'create_topics': example_create_topics, 'delete_topics': example_delete_topics, 'create_partitions': example_create_partitions, 'describe_configs': example_describe_configs, 'alter_configs': example_alter_configs, 'delta_alter_configs': example_delta_alter_configs, 'list': example_list} if operation not in opsmap: sys.stderr.write('Unknown operation: %s\n' % operation) sys.exit(1) opsmap[operation](a, args)
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # Usage: # # $ python -m fixit.cli.run_rules --help # $ python -m fixit.cli.run_rules # $ python -m fixit.cli.run_rules --rules AvoidOrInExceptRule # $ python -m fixit.cli.run_rules . --rules AvoidOrInExceptRule NoUnnecessaryListComprehensionRule # $ python -m fixit.cli.run_rules . --rules AvoidOrInExceptRule my.custom.rules.package # $ python -m fixit.cli.run_rules . --rules fixit.rules import argparse import itertools import shutil import sys import time from dataclasses import dataclass from pathlib import Path from typing import TYPE_CHECKING, Iterable, Mapping, Optional, Sequence from libcst import ParserSyntaxError, parse_module from libcst.metadata import MetadataWrapper from fixit.cli import find_files, map_paths from fixit.cli.args import ( get_compact_parser, get_multiprocessing_parser, get_paths_parser, get_rules_parser, get_skip_ignore_byte_marker_parser, get_use_ignore_comments_parser, ) from fixit.cli.formatter import LintRuleReportFormatter from fixit.cli.full_repo_metadata import ( get_metadata_caches, rules_require_metadata_cache, ) from fixit.cli.utils import print_red from fixit.common.utils import LintRuleCollectionT from fixit.rule_lint_engine import lint_file if TYPE_CHECKING: from libcst.metadata.base_provider import ProviderT @dataclass(frozen=True) class LintOpts: rules: LintRuleCollectionT use_ignore_byte_markers: bool use_ignore_comments: bool formatter: LintRuleReportFormatter def get_formatted_reports_for_path( path: Path, opts: LintOpts, metadata_cache: Optional[Mapping["ProviderT", object]] = None, ) -> Iterable[str]: with open(path, "rb") as f: source = f.read() try: cst_wrapper = None if metadata_cache is not None: cst_wrapper = MetadataWrapper(parse_module(source), True, metadata_cache) raw_reports = lint_file( path, source, rules=opts.rules, use_ignore_byte_markers=opts.use_ignore_byte_markers, use_ignore_comments=opts.use_ignore_comments, cst_wrapper=cst_wrapper, ) except (SyntaxError, ParserSyntaxError) as e: print_red( f"Encountered the following error while parsing source code in file {path}:" ) print(e) return [] # linter completed successfully return [opts.formatter.format(rr) for rr in raw_reports] def main(raw_args: Sequence[str]) -> int: parser = argparse.ArgumentParser( description=( "Validates your lint rules by running them against the specified, " + "directory or file(s). This is not a substitute for unit tests, " + "but it can provide additional confidence in your lint rules.\n" + "If no lint rules or packages are specified, runs all lint rules " + "found in the packages specified in `fixit.config.yaml`." ), parents=[ get_paths_parser(), get_rules_parser(), get_use_ignore_comments_parser(), get_skip_ignore_byte_marker_parser(), get_compact_parser(), get_multiprocessing_parser(), ], ) parser.add_argument( "--cache-timeout", type=int, help="Timeout (seconds) for metadata cache fetching. Default is 2 seconds.", default=2, ) args = parser.parse_args(raw_args) width = shutil.get_terminal_size(fallback=(80, 24)).columns # expand path if it's a directory file_paths = tuple(find_files(args.paths)) all_rules = args.rules if not args.compact: print(f"Scanning {len(file_paths)} files") print(f"Testing {len(all_rules)} rules") print() start_time = time.time() metadata_caches: Optional[Mapping[str, Mapping["ProviderT", object]]] = None if rules_require_metadata_cache(all_rules): metadata_caches = get_metadata_caches(args.cache_timeout, file_paths) # opts is a more type-safe version of args that we pass around opts = LintOpts( rules=all_rules, use_ignore_byte_markers=args.use_ignore_byte_markers, use_ignore_comments=args.use_ignore_comments, formatter=LintRuleReportFormatter(width, args.compact), ) formatted_reports_iter = itertools.chain.from_iterable( map_paths( get_formatted_reports_for_path, file_paths, opts, workers=args.workers, metadata_caches=metadata_caches, ) ) formatted_reports = [] for formatted_report in formatted_reports_iter: # Reports are yielded as soon as they're available. Stream the output to the # terminal. print(formatted_report) # save the report from the iterator for later use formatted_reports.append(formatted_report) if not args.compact: print() print( f"Found {len(formatted_reports)} reports in {len(file_paths)} files in " + f"{time.time() - start_time :.2f} seconds." ) # Return with an exit code of 1 if there are any violations found. return int(bool(formatted_reports)) if __name__ == "__main__": sys.exit(main(sys.argv[1:]))
from gym.envs.registration import registry, register, make, spec # Algorithmic # ---------------------------------------- register( id='Copy-v0', entry_point='gym.envs.algorithmic:CopyEnv', max_episode_steps=200, reward_threshold=25.0, ) register( id='RepeatCopy-v0', entry_point='gym.envs.algorithmic:RepeatCopyEnv', max_episode_steps=200, reward_threshold=75.0, ) register( id='ReversedAddition-v0', entry_point='gym.envs.algorithmic:ReversedAdditionEnv', kwargs={'rows' : 2}, max_episode_steps=200, reward_threshold=25.0, ) register( id='ReversedAddition3-v0', entry_point='gym.envs.algorithmic:ReversedAdditionEnv', kwargs={'rows' : 3}, max_episode_steps=200, reward_threshold=25.0, ) register( id='DuplicatedInput-v0', entry_point='gym.envs.algorithmic:DuplicatedInputEnv', max_episode_steps=200, reward_threshold=9.0, ) register( id='Reverse-v0', entry_point='gym.envs.algorithmic:ReverseEnv', max_episode_steps=200, reward_threshold=25.0, ) # Classic # ---------------------------------------- register( id='CartPole-v0', entry_point='gym.envs.classic_control:CartPoleEnv', max_episode_steps=200, reward_threshold=195.0, ) register( id='CartPole-v1', entry_point='gym.envs.classic_control:CartPoleEnv', max_episode_steps=500, reward_threshold=475.0, ) register( id='MountainCar-v0', entry_point='gym.envs.classic_control:MountainCarEnv', max_episode_steps=200, reward_threshold=-110.0, ) register( id='MountainCarContinuous-v0', entry_point='gym.envs.classic_control:Continuous_MountainCarEnv', max_episode_steps=999, reward_threshold=90.0, ) register( id='Pendulum-v0', entry_point='gym.envs.classic_control:PendulumEnv', max_episode_steps=200, ) register( id='Acrobot-v1', entry_point='gym.envs.classic_control:AcrobotEnv', max_episode_steps=500, ) # Box2d # ---------------------------------------- register( id='LunarLander-v2', entry_point='gym.envs.box2d:LunarLander', max_episode_steps=1000, reward_threshold=200, ) register( id='LunarLanderContinuous-v2', entry_point='gym.envs.box2d:LunarLanderContinuous', max_episode_steps=1000, reward_threshold=200, ) register( id='BipedalWalker-v2', entry_point='gym.envs.box2d:BipedalWalker', max_episode_steps=1600, reward_threshold=300, ) register( id='BipedalWalkerHardcore-v2', entry_point='gym.envs.box2d:BipedalWalkerHardcore', max_episode_steps=2000, reward_threshold=300, ) register( id='CarRacing-v0', entry_point='gym.envs.box2d:CarRacing', max_episode_steps=1000, reward_threshold=900, ) # Toy Text # ---------------------------------------- register( id='Blackjack-v0', entry_point='gym.envs.toy_text:BlackjackEnv', ) register( id='KellyCoinflip-v0', entry_point='gym.envs.toy_text:KellyCoinflipEnv', reward_threshold=246.61, ) register( id='KellyCoinflipGeneralized-v0', entry_point='gym.envs.toy_text:KellyCoinflipGeneralizedEnv', ) register( id='FrozenLake-v0', entry_point='gym.envs.toy_text:FrozenLakeEnv', kwargs={'map_name' : '4x4'}, max_episode_steps=100, reward_threshold=0.78, # optimum = .8196 ) register( id='FrozenLake8x8-v0', entry_point='gym.envs.toy_text:FrozenLakeEnv', kwargs={'map_name' : '8x8'}, max_episode_steps=200, reward_threshold=0.99, # optimum = 1 ) register( id='CliffWalking-v0', entry_point='gym.envs.toy_text:CliffWalkingEnv', ) register( id='NChain-v0', entry_point='gym.envs.toy_text:NChainEnv', max_episode_steps=1000, ) register( id='Roulette-v0', entry_point='gym.envs.toy_text:RouletteEnv', max_episode_steps=100, ) register( id='Taxi-v2', entry_point='gym.envs.toy_text:TaxiEnv', reward_threshold=8, # optimum = 8.46 max_episode_steps=200, ) register( id='GuessingGame-v0', entry_point='gym.envs.toy_text:GuessingGame', max_episode_steps=200, ) register( id='HotterColder-v0', entry_point='gym.envs.toy_text:HotterColder', max_episode_steps=200, ) # Mujoco # ---------------------------------------- # 2D register( id='Reacher-v2', entry_point='gym.envs.mujoco:ReacherEnv', max_episode_steps=50, reward_threshold=-3.75, ) register( id='Pusher-v2', entry_point='gym.envs.mujoco:PusherEnv', max_episode_steps=100, reward_threshold=0.0, ) register( id='Thrower-v2', entry_point='gym.envs.mujoco:ThrowerEnv', max_episode_steps=100, reward_threshold=0.0, ) register( id='Striker-v2', entry_point='gym.envs.mujoco:StrikerEnv', max_episode_steps=100, reward_threshold=0.0, ) register( id='InvertedPendulum-v2', entry_point='gym.envs.mujoco:InvertedPendulumEnv', max_episode_steps=1000, reward_threshold=950.0, ) register( id='InvertedDoublePendulum-v2', entry_point='gym.envs.mujoco:InvertedDoublePendulumEnv', max_episode_steps=1000, reward_threshold=9100.0, ) register( id='HalfCheetah-v2', entry_point='gym.envs.mujoco:HalfCheetahEnv', max_episode_steps=1000, reward_threshold=4800.0, ) register( id='Hopper-v2', entry_point='gym.envs.mujoco:HopperEnv', max_episode_steps=1000, reward_threshold=3800.0, ) register( id='Swimmer-v2', entry_point='gym.envs.mujoco:SwimmerEnv', max_episode_steps=1000, reward_threshold=360.0, ) register( id='Walker2d-v2', max_episode_steps=1000, entry_point='gym.envs.mujoco:Walker2dEnv', ) register( id='Ant-v2', entry_point='gym.envs.mujoco:AntEnv', max_episode_steps=1000, reward_threshold=6000.0, ) register( id='Humanoid-v2', entry_point='gym.envs.mujoco:HumanoidEnv', max_episode_steps=1000, ) register( id='HumanoidStandup-v2', entry_point='gym.envs.mujoco:HumanoidStandupEnv', max_episode_steps=1000, ) # Robotics # ---------------------------------------- def _merge(a, b): a.update(b) return a for reward_type in ['sparse', 'dense']: suffix = 'Dense' if reward_type == 'dense' else '' kwargs = { 'reward_type': reward_type, } # Fetch register( id='FetchSlide{}-v1'.format(suffix), entry_point='gym.envs.robotics:FetchSlideEnv', kwargs=kwargs, max_episode_steps=50, ) register( id='CamSlide{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamSlideEnv', kwargs=kwargs, max_episode_steps=50, ) register( id='CamSlideJoint{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamSlideJointEnv', kwargs=kwargs, max_episode_steps=500, ) register( id='FetchPickAndPlace{}-v1'.format(suffix), entry_point='gym.envs.robotics:FetchPickAndPlaceEnv', kwargs=kwargs, max_episode_steps=50, ) register( id='CamPickAndPlace{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamPickAndPlaceEnv', kwargs=kwargs, max_episode_steps=50, ) register( id='CamPickAndPlaceJoint{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamPickAndPlaceJointEnv', kwargs=kwargs, max_episode_steps=500, ) register( id='FetchReach{}-v1'.format(suffix), entry_point='gym.envs.robotics:FetchReachEnv', kwargs=kwargs, max_episode_steps=50, ) register( id='CamReach{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamReachEnv', kwargs=kwargs, max_episode_steps=50, ) register( id='CamReachJoint{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamReachJointEnv', kwargs=kwargs, max_episode_steps=500, ) register( id='FetchPush{}-v1'.format(suffix), entry_point='gym.envs.robotics:FetchPushEnv', kwargs=kwargs, max_episode_steps=50, ) register( id='CamPush{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamPushEnv', kwargs=kwargs, max_episode_steps=50, ) register( id='CamPushJoint{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamPushJointEnv', kwargs=kwargs, max_episode_steps=500, ) # grasp register( id='Grasp{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamGraspEnv', kwargs=kwargs, max_episode_steps=2, ) # grasp open to close register( id='GraspOpenToClose{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamGraspOpenToCloseEnv', kwargs=kwargs, max_episode_steps=3, ) # grasp rotation register( id='GraspRot{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamGraspRotationEnv', kwargs=kwargs, max_episode_steps=2, ) # push register( id='Push{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamPushEnv', kwargs=kwargs, max_episode_steps=3, ) # Peg Insertion register( id='PegInsert{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamPegInsertEnv', kwargs=kwargs, max_episode_steps=2, ) # peg rotation register( id='PegInsertRot{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamPegInsertRotationEnv', kwargs=kwargs, max_episode_steps=2, ) # peg open to close register( id='PegInsertOpenToClose{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamPegInsertOpenToCloseEnv', kwargs=kwargs, max_episode_steps=3, ) # slide register( id='Slide{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamSlideEnv', kwargs=kwargs, max_episode_steps=2, ) # slide rotation register( id='SlideRot{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamSlideRotationEnv', kwargs=kwargs, max_episode_steps=2, ) # slide open to close register( id='SlideOpenToClose{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamSlideOpenToCloseEnv', kwargs=kwargs, max_episode_steps=3, ) # Drawer open register( id='Drawer{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamDrawerOpenEnv', kwargs=kwargs, max_episode_steps=2, ) # Drawer open to close register( id='DrawerOpenToClose{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamDrawerOpenToCloseEnv', kwargs=kwargs, max_episode_steps=3, ) # inverse peg insertion register( id='InversePegInsert{}-v0'.format(suffix), entry_point='gym.envs.robotics:CamInversePegInsertEnv', kwargs=kwargs, max_episode_steps=2, ) # Hand register( id='HandReach{}-v0'.format(suffix), entry_point='gym.envs.robotics:HandReachEnv', kwargs=kwargs, max_episode_steps=50, ) register( id='HandManipulateBlockRotateZ{}-v0'.format(suffix), entry_point='gym.envs.robotics:HandBlockEnv', kwargs=_merge({'target_position': 'ignore', 'target_rotation': 'z'}, kwargs), max_episode_steps=100, ) register( id='HandManipulateBlockRotateParallel{}-v0'.format(suffix), entry_point='gym.envs.robotics:HandBlockEnv', kwargs=_merge({'target_position': 'ignore', 'target_rotation': 'parallel'}, kwargs), max_episode_steps=100, ) register( id='HandManipulateBlockRotateXYZ{}-v0'.format(suffix), entry_point='gym.envs.robotics:HandBlockEnv', kwargs=_merge({'target_position': 'ignore', 'target_rotation': 'xyz'}, kwargs), max_episode_steps=100, ) register( id='HandManipulateBlockFull{}-v0'.format(suffix), entry_point='gym.envs.robotics:HandBlockEnv', kwargs=_merge({'target_position': 'random', 'target_rotation': 'xyz'}, kwargs), max_episode_steps=100, ) # Alias for "Full" register( id='HandManipulateBlock{}-v0'.format(suffix), entry_point='gym.envs.robotics:HandBlockEnv', kwargs=_merge({'target_position': 'random', 'target_rotation': 'xyz'}, kwargs), max_episode_steps=100, ) register( id='HandManipulateBlockTouchSensors{}-v0'.format(suffix), entry_point='gym.envs.robotics:HandBlockTouchSensorsEnv', kwargs=_merge({'target_position': 'random', 'target_rotation': 'xyz'}, kwargs), max_episode_steps=100, ) register( id='HandManipulateEggRotate{}-v0'.format(suffix), entry_point='gym.envs.robotics:HandEggEnv', kwargs=_merge({'target_position': 'ignore', 'target_rotation': 'xyz'}, kwargs), max_episode_steps=100, ) register( id='HandManipulateEggFull{}-v0'.format(suffix), entry_point='gym.envs.robotics:HandEggEnv', kwargs=_merge({'target_position': 'random', 'target_rotation': 'xyz'}, kwargs), max_episode_steps=100, ) # Alias for "Full" register( id='HandManipulateEgg{}-v0'.format(suffix), entry_point='gym.envs.robotics:HandEggEnv', kwargs=_merge({'target_position': 'random', 'target_rotation': 'xyz'}, kwargs), max_episode_steps=100, ) register( id='HandManipulateEggTouchSensors{}-v0'.format(suffix), entry_point='gym.envs.robotics:HandEggTouchSensorsEnv', kwargs=_merge({'target_position': 'random', 'target_rotation': 'xyz'}, kwargs), max_episode_steps=100, ) register( id='HandManipulatePenRotate{}-v0'.format(suffix), entry_point='gym.envs.robotics:HandPenEnv', kwargs=_merge({'target_position': 'ignore', 'target_rotation': 'xyz'}, kwargs), max_episode_steps=100, ) register( id='HandManipulatePenFull{}-v0'.format(suffix), entry_point='gym.envs.robotics:HandPenEnv', kwargs=_merge({'target_position': 'random', 'target_rotation': 'xyz'}, kwargs), max_episode_steps=100, ) # Alias for "Full" register( id='HandManipulatePen{}-v0'.format(suffix), entry_point='gym.envs.robotics:HandPenEnv', kwargs=_merge({'target_position': 'random', 'target_rotation': 'xyz'}, kwargs), max_episode_steps=100, ) register( id='HandManipulatePenTouchSensors{}-v0'.format(suffix), entry_point='gym.envs.robotics:HandPenTouchSensorsEnv', kwargs=_merge({'target_position': 'random', 'target_rotation': 'xyz'}, kwargs), max_episode_steps=100, ) # Atari # ---------------------------------------- # # print ', '.join(["'{}'".format(name.split('.')[0]) for name in atari_py.list_games()]) for game in ['air_raid', 'alien', 'amidar', 'assault', 'asterix', 'asteroids', 'atlantis', 'bank_heist', 'battle_zone', 'beam_rider', 'berzerk', 'bowling', 'boxing', 'breakout', 'carnival', 'centipede', 'chopper_command', 'crazy_climber', 'defender', 'demon_attack', 'double_dunk', 'elevator_action', 'enduro', 'fishing_derby', 'freeway', 'frostbite', 'gopher', 'gravitar', 'hero', 'ice_hockey', 'jamesbond', 'journey_escape', 'kangaroo', 'krull', 'kung_fu_master', 'montezuma_revenge', 'ms_pacman', 'name_this_game', 'phoenix', 'pitfall', 'pong', 'pooyan', 'private_eye', 'qbert', 'riverraid', 'road_runner', 'robotank', 'seaquest', 'skiing', 'solaris', 'space_invaders', 'star_gunner', 'tennis', 'time_pilot', 'tutankham', 'up_n_down', 'venture', 'video_pinball', 'wizard_of_wor', 'yars_revenge', 'zaxxon']: for obs_type in ['image', 'ram']: # space_invaders should yield SpaceInvaders-v0 and SpaceInvaders-ram-v0 name = ''.join([g.capitalize() for g in game.split('_')]) if obs_type == 'ram': name = '{}-ram'.format(name) nondeterministic = False if game == 'elevator_action' and obs_type == 'ram': # ElevatorAction-ram-v0 seems to yield slightly # non-deterministic observations about 10% of the time. We # should track this down eventually, but for now we just # mark it as nondeterministic. nondeterministic = True register( id='{}-v0'.format(name), entry_point='gym.envs.atari:AtariEnv', kwargs={'game': game, 'obs_type': obs_type, 'repeat_action_probability': 0.25}, max_episode_steps=10000, nondeterministic=nondeterministic, ) register( id='{}-v4'.format(name), entry_point='gym.envs.atari:AtariEnv', kwargs={'game': game, 'obs_type': obs_type}, max_episode_steps=100000, nondeterministic=nondeterministic, ) # Standard Deterministic (as in the original DeepMind paper) if game == 'space_invaders': frameskip = 3 else: frameskip = 4 # Use a deterministic frame skip. register( id='{}Deterministic-v0'.format(name), entry_point='gym.envs.atari:AtariEnv', kwargs={'game': game, 'obs_type': obs_type, 'frameskip': frameskip, 'repeat_action_probability': 0.25}, max_episode_steps=100000, nondeterministic=nondeterministic, ) register( id='{}Deterministic-v4'.format(name), entry_point='gym.envs.atari:AtariEnv', kwargs={'game': game, 'obs_type': obs_type, 'frameskip': frameskip}, max_episode_steps=100000, nondeterministic=nondeterministic, ) register( id='{}NoFrameskip-v0'.format(name), entry_point='gym.envs.atari:AtariEnv', kwargs={'game': game, 'obs_type': obs_type, 'frameskip': 1, 'repeat_action_probability': 0.25}, # A frameskip of 1 means we get every frame max_episode_steps=frameskip * 100000, nondeterministic=nondeterministic, ) # No frameskip. (Atari has no entropy source, so these are # deterministic environments.) register( id='{}NoFrameskip-v4'.format(name), entry_point='gym.envs.atari:AtariEnv', kwargs={'game': game, 'obs_type': obs_type, 'frameskip': 1}, # A frameskip of 1 means we get every frame max_episode_steps=frameskip * 100000, nondeterministic=nondeterministic, ) # Unit test # --------- register( id='CubeCrash-v0', entry_point='gym.envs.unittest:CubeCrash', reward_threshold=0.9, ) register( id='CubeCrashSparse-v0', entry_point='gym.envs.unittest:CubeCrashSparse', reward_threshold=0.9, ) register( id='CubeCrashScreenBecomesBlack-v0', entry_point='gym.envs.unittest:CubeCrashScreenBecomesBlack', reward_threshold=0.9, ) register( id='MemorizeDigits-v0', entry_point='gym.envs.unittest:MemorizeDigits', reward_threshold=20, )
from .multimodal_exploratory_search_pipeline import MultimodalSearchRecipe from .artm_baseline_pipeline import BaselineRecipe from .exploratory_search_pipeline import SearchRecipe from .artm_baseline_pipeline import ARTM_baseline_template as ARTM_baseline from .exploratory_search_pipeline import exploratory_search_template as exploratory_search
#!/usr/bin/env python """Tests for grr.parsers.windows_persistence.""" from grr.lib import flags from grr.lib import rdfvalue from grr.lib import test_lib from grr.lib.rdfvalues import client as rdf_client from grr.lib.rdfvalues import paths as rdf_paths from grr.lib.rdfvalues import protodict as rdf_protodict from grr.parsers import windows_persistence class WindowsPersistenceMechanismsParserTest(test_lib.FlowTestsBaseclass): def testParse(self): parser = windows_persistence.WindowsPersistenceMechanismsParser() path = (r"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion" r"\Run\test") pathspec = rdf_paths.PathSpec( path=path, pathtype=rdf_paths.PathSpec.PathType.REGISTRY) reg_data = "C:\\blah\\some.exe /v" reg_type = rdf_client.StatEntry.RegistryType.REG_SZ stat = rdf_client.StatEntry( aff4path="aff4:/asdfasdf/", pathspec=pathspec, registry_type=reg_type, registry_data=rdf_protodict.DataBlob(string=reg_data)) persistence = [stat] image_paths = [ "system32\\drivers\\ACPI.sys", "%systemroot%\\system32\\svchost.exe -k netsvcs", "\\SystemRoot\\system32\\drivers\\acpipmi.sys" ] reg_key = rdfvalue.RDFURN("aff4:/C.1000000000000000/registry" "/HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001" "/services/AcpiPmi") for path in image_paths: serv_info = rdf_client.WindowsServiceInformation( name="blah", display_name="GRRservice", image_path=path, registry_key=reg_key) persistence.append(serv_info) knowledge_base = rdf_client.KnowledgeBase() knowledge_base.environ_systemroot = "C:\\Windows" expected = [ "C:\\blah\\some.exe", "C:\\Windows\\system32\\drivers\\ACPI.sys", "C:\\Windows\\system32\\svchost.exe", "C:\\Windows\\system32\\drivers\\acpipmi.sys" ] for index, item in enumerate(persistence): results = list( parser.Parse(item, knowledge_base, rdf_paths.PathSpec.PathType.OS)) self.assertEqual(results[0].pathspec.path, expected[index]) self.assertEqual(len(results), 1) def main(argv): test_lib.main(argv) if __name__ == "__main__": flags.StartMain(main)
""" Copyright 2015-2018 IBM 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. Licensed Materials - Property of IBM © Copyright IBM Corp. 2015-2018 """ import asyncio from confluent_kafka import Consumer class ConsumerTask(object): def __init__(self, conf, topic_name): self.consumer = Consumer(conf) self.topic_name = topic_name self.running = True def stop(self): self.running = False @asyncio.coroutine def run(self): print('The consumer has started') self.consumer.subscribe([self.topic_name]) while self.running: msg = self.consumer.poll(1) if msg is not None and msg.error() is None: print('Message consumed: topic={0}, partition={1}, offset={2}, key={3}, value={4}'.format( msg.topic(), msg.partition(), msg.offset(), msg.key().decode('utf-8'), msg.value().decode('utf-8'))) else: print('No messages consumed') yield from asyncio.sleep(2) self.consumer.unsubscribe() self.consumer.close()
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack import * class Seqan(CMakePackage): """SeqAn is an open source C++ library of efficient algorithms and data structures for the analysis of sequences with the focus on biological data. Our library applies a unique generic design that guarantees high performance, generality, extensibility, and integration with other libraries. SeqAn is easy to use and simplifies the development of new software tools with a minimal loss of performance""" homepage = "https://www.seqan.de" url = "https://github.com/seqan/seqan/archive/seqan-v2.4.0.tar.gz" version('2.4.0', sha256='d7084d17729214003e84818e0280a16f223c8f1c6a30eeef040c27e0c0047bd7') depends_on('cmake@3.4.0:', type='build') depends_on('python@2.7.0:', type='build') depends_on('py-nose', type='build') depends_on('py-sphinx', type='build') depends_on('boost', type=('build', 'link')) depends_on('zlib', type=('build', 'link')) depends_on('bzip2', type=('build', 'link')) conflicts('%intel@:16.0.4') conflicts('%gcc@:4.9.4') conflicts('%llvm@:3.5.1')
# Copyright The PyTorch Lightning team. # # 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. from unittest.mock import ANY, Mock import pytest import torch from torch.utils.data.dataloader import DataLoader from pytorch_lightning.core.mixins import DeviceDtypeModuleMixin from pytorch_lightning.lite import LightningLite from pytorch_lightning.lite.wrappers import _LiteDataLoader, _LiteModule, _LiteOptimizer from tests.helpers.runif import RunIf class EmptyLite(LightningLite): def run(self): pass def test_lite_module_wraps(): """Test that the wrapped module is accessible via the property.""" module = Mock() assert _LiteModule(module, Mock()).module is module @RunIf(min_gpus=1) @pytest.mark.parametrize( "precision, input_type, expected_type", [ (32, torch.float16, torch.float32), (32, torch.float32, torch.float32), (32, torch.float64, torch.float32), (32, torch.int, torch.int), (16, torch.float32, torch.float16), (16, torch.float64, torch.float16), (16, torch.long, torch.long), pytest.param("bf16", torch.float32, torch.bfloat16, marks=RunIf(min_torch="1.10")), pytest.param("bf16", torch.float64, torch.bfloat16, marks=RunIf(min_torch="1.10")), pytest.param("bf16", torch.bool, torch.bool, marks=RunIf(min_torch="1.10")), ], ) def test_lite_module_forward_conversion(precision, input_type, expected_type): """Test that the LiteModule performs autocasting on the input tensors and during forward().""" lite = EmptyLite(precision=precision, accelerator="gpu", devices=1) device = torch.device("cuda", 0) def check_autocast(forward_input): assert precision != 16 or torch.is_autocast_enabled() return forward_input module = Mock(wraps=torch.nn.Identity(), side_effect=check_autocast) lite_module = _LiteModule(module, lite._precision_plugin).to(device) out = lite_module(torch.tensor([1, 2, 3], dtype=input_type, device=device)) assert module.call_args[0][0].dtype == expected_type assert out.dtype == input_type or out.dtype == torch.get_default_dtype() @pytest.mark.parametrize( "device", [torch.device("cpu"), pytest.param(torch.device("cuda", 0), marks=RunIf(min_gpus=1))] ) @pytest.mark.parametrize("dtype", [torch.float32, torch.float16]) def test_lite_module_device_dtype_propagation(device, dtype): """Test that the LiteModule propagates device and dtype properties to its submodules (e.g. torchmetrics).""" class DeviceModule(DeviceDtypeModuleMixin): pass device_module = DeviceModule() lite_module = _LiteModule(device_module, Mock()) lite_module.to(device) assert device_module.device == device assert lite_module.device == device lite_module.to(dtype) assert device_module.dtype == dtype assert lite_module.dtype == dtype def test_lite_dataloader_iterator(): """Test that the iteration over a LiteDataLoader wraps the iterator of the underlying dataloader (no automatic device placement).""" dataloader = DataLoader(range(5), batch_size=2) lite_dataloader = _LiteDataLoader(dataloader) assert len(lite_dataloader) == len(dataloader) == 3 iterator = iter(dataloader) lite_iterator = iter(lite_dataloader) assert torch.equal(next(iterator), next(lite_iterator)) assert torch.equal(next(iterator), next(lite_iterator)) assert torch.equal(next(iterator), next(lite_iterator)) with pytest.raises(StopIteration): next(iterator) with pytest.raises(StopIteration): next(lite_iterator) @pytest.mark.parametrize( "src_device, dest_device", [ (torch.device("cpu"), torch.device("cpu")), pytest.param(torch.device("cpu"), torch.device("cuda", 0), marks=RunIf(min_gpus=1)), pytest.param(torch.device("cuda", 0), torch.device("cpu"), marks=RunIf(min_gpus=1)), ], ) def test_lite_dataloader_device_placement(src_device, dest_device): """Test that the LiteDataLoader moves data to the device in its iterator.""" sample0 = torch.tensor(0, device=src_device) sample1 = torch.tensor(1, device=src_device) sample2 = {"data": torch.tensor(2, device=src_device)} sample3 = {"data": torch.tensor(3, device=src_device)} dataloader = DataLoader([sample0, sample1, sample2, sample3], batch_size=2) lite_dataloader = _LiteDataLoader(dataloader=dataloader, device=dest_device) iterator = iter(lite_dataloader) batch0 = next(iterator) assert torch.equal(batch0, torch.tensor([0, 1], device=dest_device)) batch1 = next(iterator) assert torch.equal(batch1["data"], torch.tensor([2, 3], device=dest_device)) def test_lite_optimizer_wraps(): """Test that the LiteOptimizer fully wraps the optimizer.""" optimizer_cls = torch.optim.SGD optimizer = Mock(spec=optimizer_cls) lite_optimizer = _LiteOptimizer(optimizer, Mock()) assert lite_optimizer.optimizer is optimizer assert isinstance(lite_optimizer, optimizer_cls) def test_lite_optimizer_state_dict(): """Test that the LiteOptimizer calls into the strategy to collect the state.""" optimizer = Mock() strategy = Mock() lite_optimizer = _LiteOptimizer(optimizer=optimizer, strategy=strategy) lite_optimizer.state_dict() strategy.optimizer_state.assert_called_with(optimizer) def test_lite_optimizer_steps(): """Test that the LiteOptimizer forwards the step() and zero_grad() calls to the wrapped optimizer.""" optimizer = Mock() strategy = Mock() strategy.optimizer_step.return_value = 123 lite_optimizer = _LiteOptimizer(optimizer=optimizer, strategy=strategy) step_output = lite_optimizer.step() assert step_output == 123 strategy.optimizer_step.assert_called_once() strategy.optimizer_step.assert_called_with(optimizer, opt_idx=0, closure=ANY, model=strategy.model)
# Copyright (c) 2012 Mitch Garnaat http://garnaat.org/ # Copyright (c) 2012 Amazon.com, Inc. or its affiliates. # All Rights Reserved # # 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, dis- # tribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the fol- # lowing 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 MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR 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. # import boto import boto.jsonresponse from boto.compat import json from boto.regioninfo import RegionInfo from boto.connection import AWSQueryConnection class Layer1(AWSQueryConnection): APIVersion = '2010-12-01' DefaultRegionName = 'us-east-1' DefaultRegionEndpoint = 'elasticbeanstalk.us-east-1.amazonaws.com' def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, port=None, proxy=None, proxy_port=None, proxy_user=None, proxy_pass=None, debug=0, https_connection_factory=None, region=None, path='/', api_version=None, security_token=None): if not region: region = RegionInfo(self, self.DefaultRegionName, self.DefaultRegionEndpoint) self.region = region super(Layer1, self).__init__(aws_access_key_id, aws_secret_access_key, is_secure, port, proxy, proxy_port, proxy_user, proxy_pass, self.region.endpoint, debug, https_connection_factory, path, security_token) def _required_auth_capability(self): return ['hmac-v4'] def _encode_bool(self, v): v = bool(v) return {True: "true", False: "false"}[v] def _get_response(self, action, params, path='/', verb='GET'): params['ContentType'] = 'JSON' response = self.make_request(action, params, path, verb) body = response.read() boto.log.debug(body) if response.status == 200: return json.loads(body) else: raise self.ResponseError(response.status, response.reason, body) def check_dns_availability(self, cname_prefix): """Checks if the specified CNAME is available. :type cname_prefix: string :param cname_prefix: The prefix used when this CNAME is reserved. """ params = {'CNAMEPrefix': cname_prefix} return self._get_response('CheckDNSAvailability', params) def create_application(self, application_name, description=None): """ Creates an application that has one configuration template named default and no application versions. :type application_name: string :param application_name: The name of the application. Constraint: This name must be unique within your account. If the specified name already exists, the action returns an InvalidParameterValue error. :type description: string :param description: Describes the application. :raises: TooManyApplicationsException """ params = {'ApplicationName': application_name} if description: params['Description'] = description return self._get_response('CreateApplication', params) def create_application_version(self, application_name, version_label, description=None, s3_bucket=None, s3_key=None, auto_create_application=None): """Creates an application version for the specified application. :type application_name: string :param application_name: The name of the application. If no application is found with this name, and AutoCreateApplication is false, returns an InvalidParameterValue error. :type version_label: string :param version_label: A label identifying this version. Constraint: Must be unique per application. If an application version already exists with this label for the specified application, AWS Elastic Beanstalk returns an InvalidParameterValue error. :type description: string :param description: Describes this version. :type s3_bucket: string :param s3_bucket: The Amazon S3 bucket where the data is located. :type s3_key: string :param s3_key: The Amazon S3 key where the data is located. Both s3_bucket and s3_key must be specified in order to use a specific source bundle. If both of these values are not specified the sample application will be used. :type auto_create_application: boolean :param auto_create_application: Determines how the system behaves if the specified application for this version does not already exist: true: Automatically creates the specified application for this version if it does not already exist. false: Returns an InvalidParameterValue if the specified application for this version does not already exist. Default: false Valid Values: true | false :raises: TooManyApplicationsException, TooManyApplicationVersionsException, InsufficientPrivilegesException, S3LocationNotInServiceRegionException """ params = {'ApplicationName': application_name, 'VersionLabel': version_label} if description: params['Description'] = description if s3_bucket and s3_key: params['SourceBundle.S3Bucket'] = s3_bucket params['SourceBundle.S3Key'] = s3_key if auto_create_application: params['AutoCreateApplication'] = self._encode_bool( auto_create_application) return self._get_response('CreateApplicationVersion', params) def create_configuration_template(self, application_name, template_name, solution_stack_name=None, source_configuration_application_name=None, source_configuration_template_name=None, environment_id=None, description=None, option_settings=None): """Creates a configuration template. Templates are associated with a specific application and are used to deploy different versions of the application with the same configuration settings. :type application_name: string :param application_name: The name of the application to associate with this configuration template. If no application is found with this name, AWS Elastic Beanstalk returns an InvalidParameterValue error. :type template_name: string :param template_name: The name of the configuration template. Constraint: This name must be unique per application. Default: If a configuration template already exists with this name, AWS Elastic Beanstalk returns an InvalidParameterValue error. :type solution_stack_name: string :param solution_stack_name: The name of the solution stack used by this configuration. The solution stack specifies the operating system, architecture, and application server for a configuration template. It determines the set of configuration options as well as the possible and default values. Use ListAvailableSolutionStacks to obtain a list of available solution stacks. Default: If the SolutionStackName is not specified and the source configuration parameter is blank, AWS Elastic Beanstalk uses the default solution stack. If not specified and the source configuration parameter is specified, AWS Elastic Beanstalk uses the same solution stack as the source configuration template. :type source_configuration_application_name: string :param source_configuration_application_name: The name of the application associated with the configuration. :type source_configuration_template_name: string :param source_configuration_template_name: The name of the configuration template. :type environment_id: string :param environment_id: The ID of the environment used with this configuration template. :type description: string :param description: Describes this configuration. :type option_settings: list :param option_settings: If specified, AWS Elastic Beanstalk sets the specified configuration option to the requested value. The new value overrides the value obtained from the solution stack or the source configuration template. :raises: InsufficientPrivilegesException, TooManyConfigurationTemplatesException """ params = {'ApplicationName': application_name, 'TemplateName': template_name} if solution_stack_name: params['SolutionStackName'] = solution_stack_name if source_configuration_application_name: params['SourceConfiguration.ApplicationName'] = source_configuration_application_name if source_configuration_template_name: params['SourceConfiguration.TemplateName'] = source_configuration_template_name if environment_id: params['EnvironmentId'] = environment_id if description: params['Description'] = description if option_settings: self._build_list_params(params, option_settings, 'OptionSettings.member', ('Namespace', 'OptionName', 'Value')) return self._get_response('CreateConfigurationTemplate', params) def create_environment(self, application_name, environment_name, version_label=None, template_name=None, solution_stack_name=None, cname_prefix=None, description=None, option_settings=None, options_to_remove=None, tier_name=None, tier_type=None, tier_version='1.0'): """Launches an environment for the application using a configuration. :type application_name: string :param application_name: The name of the application that contains the version to be deployed. If no application is found with this name, CreateEnvironment returns an InvalidParameterValue error. :type environment_name: string :param environment_name: A unique name for the deployment environment. Used in the application URL. Constraint: Must be from 4 to 23 characters in length. The name can contain only letters, numbers, and hyphens. It cannot start or end with a hyphen. This name must be unique in your account. If the specified name already exists, AWS Elastic Beanstalk returns an InvalidParameterValue error. Default: If the CNAME parameter is not specified, the environment name becomes part of the CNAME, and therefore part of the visible URL for your application. :type version_label: string :param version_label: The name of the application version to deploy. If the specified application has no associated application versions, AWS Elastic Beanstalk UpdateEnvironment returns an InvalidParameterValue error. Default: If not specified, AWS Elastic Beanstalk attempts to launch the most recently created application version. :type template_name: string :param template_name: The name of the configuration template to use in deployment. If no configuration template is found with this name, AWS Elastic Beanstalk returns an InvalidParameterValue error. Condition: You must specify either this parameter or a SolutionStackName, but not both. If you specify both, AWS Elastic Beanstalk returns an InvalidParameterCombination error. If you do not specify either, AWS Elastic Beanstalk returns a MissingRequiredParameter error. :type solution_stack_name: string :param solution_stack_name: This is an alternative to specifying a configuration name. If specified, AWS Elastic Beanstalk sets the configuration values to the default values associated with the specified solution stack. Condition: You must specify either this or a TemplateName, but not both. If you specify both, AWS Elastic Beanstalk returns an InvalidParameterCombination error. If you do not specify either, AWS Elastic Beanstalk returns a MissingRequiredParameter error. :type cname_prefix: string :param cname_prefix: If specified, the environment attempts to use this value as the prefix for the CNAME. If not specified, the environment uses the environment name. :type description: string :param description: Describes this environment. :type option_settings: list :param option_settings: If specified, AWS Elastic Beanstalk sets the specified configuration options to the requested value in the configuration set for the new environment. These override the values obtained from the solution stack or the configuration template. Each element in the list is a tuple of (Namespace, OptionName, Value), for example:: [('aws:autoscaling:launchconfiguration', 'Ec2KeyName', 'mykeypair')] :type options_to_remove: list :param options_to_remove: A list of custom user-defined configuration options to remove from the configuration set for this new environment. :type tier_name: string :param tier_name: The name of the tier. Valid values are "WebServer" and "Worker". Defaults to "WebServer". The ``tier_name`` and a ``tier_type`` parameters are related and the values provided must be valid. The possible combinations are: * "WebServer" and "Standard" (the default) * "Worker" and "SQS/HTTP" :type tier_type: string :param tier_type: The type of the tier. Valid values are "Standard" if ``tier_name`` is "WebServer" and "SQS/HTTP" if ``tier_name`` is "Worker". Defaults to "Standard". :type tier_version: string :type tier_version: The version of the tier. Valid values currently are "1.0". Defaults to "1.0". :raises: TooManyEnvironmentsException, InsufficientPrivilegesException """ params = {'ApplicationName': application_name, 'EnvironmentName': environment_name} if version_label: params['VersionLabel'] = version_label if template_name: params['TemplateName'] = template_name if solution_stack_name: params['SolutionStackName'] = solution_stack_name if cname_prefix: params['CNAMEPrefix'] = cname_prefix if description: params['Description'] = description if option_settings: self._build_list_params(params, option_settings, 'OptionSettings.member', ('Namespace', 'OptionName', 'Value')) if options_to_remove: self.build_list_params(params, options_to_remove, 'OptionsToRemove.member') if tier_name and tier_type and tier_version: params['Tier.member.Name'] = tier_name params['Tier.member.Type'] = tier_type params['Tier.member.Version'] = tier_version return self._get_response('CreateEnvironment', params) def create_storage_location(self): """ Creates the Amazon S3 storage location for the account. This location is used to store user log files. :raises: TooManyBucketsException, S3SubscriptionRequiredException, InsufficientPrivilegesException """ return self._get_response('CreateStorageLocation', params={}) def delete_application(self, application_name, terminate_env_by_force=None): """ Deletes the specified application along with all associated versions and configurations. The application versions will not be deleted from your Amazon S3 bucket. :type application_name: string :param application_name: The name of the application to delete. :type terminate_env_by_force: boolean :param terminate_env_by_force: When set to true, running environments will be terminated before deleting the application. :raises: OperationInProgressException """ params = {'ApplicationName': application_name} if terminate_env_by_force: params['TerminateEnvByForce'] = self._encode_bool( terminate_env_by_force) return self._get_response('DeleteApplication', params) def delete_application_version(self, application_name, version_label, delete_source_bundle=None): """Deletes the specified version from the specified application. :type application_name: string :param application_name: The name of the application to delete releases from. :type version_label: string :param version_label: The label of the version to delete. :type delete_source_bundle: boolean :param delete_source_bundle: Indicates whether to delete the associated source bundle from Amazon S3. Valid Values: true | false :raises: SourceBundleDeletionException, InsufficientPrivilegesException, OperationInProgressException, S3LocationNotInServiceRegionException """ params = {'ApplicationName': application_name, 'VersionLabel': version_label} if delete_source_bundle: params['DeleteSourceBundle'] = self._encode_bool( delete_source_bundle) return self._get_response('DeleteApplicationVersion', params) def delete_configuration_template(self, application_name, template_name): """Deletes the specified configuration template. :type application_name: string :param application_name: The name of the application to delete the configuration template from. :type template_name: string :param template_name: The name of the configuration template to delete. :raises: OperationInProgressException """ params = {'ApplicationName': application_name, 'TemplateName': template_name} return self._get_response('DeleteConfigurationTemplate', params) def delete_environment_configuration(self, application_name, environment_name): """ Deletes the draft configuration associated with the running environment. Updating a running environment with any configuration changes creates a draft configuration set. You can get the draft configuration using DescribeConfigurationSettings while the update is in progress or if the update fails. The DeploymentStatus for the draft configuration indicates whether the deployment is in process or has failed. The draft configuration remains in existence until it is deleted with this action. :type application_name: string :param application_name: The name of the application the environment is associated with. :type environment_name: string :param environment_name: The name of the environment to delete the draft configuration from. """ params = {'ApplicationName': application_name, 'EnvironmentName': environment_name} return self._get_response('DeleteEnvironmentConfiguration', params) def describe_application_versions(self, application_name=None, version_labels=None): """Returns descriptions for existing application versions. :type application_name: string :param application_name: If specified, AWS Elastic Beanstalk restricts the returned descriptions to only include ones that are associated with the specified application. :type version_labels: list :param version_labels: If specified, restricts the returned descriptions to only include ones that have the specified version labels. """ params = {} if application_name: params['ApplicationName'] = application_name if version_labels: self.build_list_params(params, version_labels, 'VersionLabels.member') return self._get_response('DescribeApplicationVersions', params) def describe_applications(self, application_names=None): """Returns the descriptions of existing applications. :type application_names: list :param application_names: If specified, AWS Elastic Beanstalk restricts the returned descriptions to only include those with the specified names. """ params = {} if application_names: self.build_list_params(params, application_names, 'ApplicationNames.member') return self._get_response('DescribeApplications', params) def describe_configuration_options(self, application_name=None, template_name=None, environment_name=None, solution_stack_name=None, options=None): """Describes configuration options used in a template or environment. Describes the configuration options that are used in a particular configuration template or environment, or that a specified solution stack defines. The description includes the values the options, their default values, and an indication of the required action on a running environment if an option value is changed. :type application_name: string :param application_name: The name of the application associated with the configuration template or environment. Only needed if you want to describe the configuration options associated with either the configuration template or environment. :type template_name: string :param template_name: The name of the configuration template whose configuration options you want to describe. :type environment_name: string :param environment_name: The name of the environment whose configuration options you want to describe. :type solution_stack_name: string :param solution_stack_name: The name of the solution stack whose configuration options you want to describe. :type options: list :param options: If specified, restricts the descriptions to only the specified options. """ params = {} if application_name: params['ApplicationName'] = application_name if template_name: params['TemplateName'] = template_name if environment_name: params['EnvironmentName'] = environment_name if solution_stack_name: params['SolutionStackName'] = solution_stack_name if options: self.build_list_params(params, options, 'Options.member') return self._get_response('DescribeConfigurationOptions', params) def describe_configuration_settings(self, application_name, template_name=None, environment_name=None): """ Returns a description of the settings for the specified configuration set, that is, either a configuration template or the configuration set associated with a running environment. When describing the settings for the configuration set associated with a running environment, it is possible to receive two sets of setting descriptions. One is the deployed configuration set, and the other is a draft configuration of an environment that is either in the process of deployment or that failed to deploy. :type application_name: string :param application_name: The application for the environment or configuration template. :type template_name: string :param template_name: The name of the configuration template to describe. Conditional: You must specify either this parameter or an EnvironmentName, but not both. If you specify both, AWS Elastic Beanstalk returns an InvalidParameterCombination error. If you do not specify either, AWS Elastic Beanstalk returns a MissingRequiredParameter error. :type environment_name: string :param environment_name: The name of the environment to describe. Condition: You must specify either this or a TemplateName, but not both. If you specify both, AWS Elastic Beanstalk returns an InvalidParameterCombination error. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error. """ params = {'ApplicationName': application_name} if template_name: params['TemplateName'] = template_name if environment_name: params['EnvironmentName'] = environment_name return self._get_response('DescribeConfigurationSettings', params) def describe_environment_resources(self, environment_id=None, environment_name=None): """Returns AWS resources for this environment. :type environment_id: string :param environment_id: The ID of the environment to retrieve AWS resource usage data. Condition: You must specify either this or an EnvironmentName, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error. :type environment_name: string :param environment_name: The name of the environment to retrieve AWS resource usage data. Condition: You must specify either this or an EnvironmentId, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error. :raises: InsufficientPrivilegesException """ params = {} if environment_id: params['EnvironmentId'] = environment_id if environment_name: params['EnvironmentName'] = environment_name return self._get_response('DescribeEnvironmentResources', params) def describe_environments(self, application_name=None, version_label=None, environment_ids=None, environment_names=None, include_deleted=None, included_deleted_back_to=None): """Returns descriptions for existing environments. :type application_name: string :param application_name: If specified, AWS Elastic Beanstalk restricts the returned descriptions to include only those that are associated with this application. :type version_label: string :param version_label: If specified, AWS Elastic Beanstalk restricts the returned descriptions to include only those that are associated with this application version. :type environment_ids: list :param environment_ids: If specified, AWS Elastic Beanstalk restricts the returned descriptions to include only those that have the specified IDs. :type environment_names: list :param environment_names: If specified, AWS Elastic Beanstalk restricts the returned descriptions to include only those that have the specified names. :type include_deleted: boolean :param include_deleted: Indicates whether to include deleted environments: true: Environments that have been deleted after IncludedDeletedBackTo are displayed. false: Do not include deleted environments. :type included_deleted_back_to: timestamp :param included_deleted_back_to: If specified when IncludeDeleted is set to true, then environments deleted after this date are displayed. """ params = {} if application_name: params['ApplicationName'] = application_name if version_label: params['VersionLabel'] = version_label if environment_ids: self.build_list_params(params, environment_ids, 'EnvironmentIds.member') if environment_names: self.build_list_params(params, environment_names, 'EnvironmentNames.member') if include_deleted: params['IncludeDeleted'] = self._encode_bool(include_deleted) if included_deleted_back_to: params['IncludedDeletedBackTo'] = included_deleted_back_to return self._get_response('DescribeEnvironments', params) def describe_events(self, application_name=None, version_label=None, template_name=None, environment_id=None, environment_name=None, request_id=None, severity=None, start_time=None, end_time=None, max_records=None, next_token=None): """Returns event descriptions matching criteria up to the last 6 weeks. :type application_name: string :param application_name: If specified, AWS Elastic Beanstalk restricts the returned descriptions to include only those associated with this application. :type version_label: string :param version_label: If specified, AWS Elastic Beanstalk restricts the returned descriptions to those associated with this application version. :type template_name: string :param template_name: If specified, AWS Elastic Beanstalk restricts the returned descriptions to those that are associated with this environment configuration. :type environment_id: string :param environment_id: If specified, AWS Elastic Beanstalk restricts the returned descriptions to those associated with this environment. :type environment_name: string :param environment_name: If specified, AWS Elastic Beanstalk restricts the returned descriptions to those associated with this environment. :type request_id: string :param request_id: If specified, AWS Elastic Beanstalk restricts the described events to include only those associated with this request ID. :type severity: string :param severity: If specified, limits the events returned from this call to include only those with the specified severity or higher. :type start_time: timestamp :param start_time: If specified, AWS Elastic Beanstalk restricts the returned descriptions to those that occur on or after this time. :type end_time: timestamp :param end_time: If specified, AWS Elastic Beanstalk restricts the returned descriptions to those that occur up to, but not including, the EndTime. :type max_records: integer :param max_records: Specifies the maximum number of events that can be returned, beginning with the most recent event. :type next_token: string :param next_token: Pagination token. If specified, the events return the next batch of results. """ params = {} if application_name: params['ApplicationName'] = application_name if version_label: params['VersionLabel'] = version_label if template_name: params['TemplateName'] = template_name if environment_id: params['EnvironmentId'] = environment_id if environment_name: params['EnvironmentName'] = environment_name if request_id: params['RequestId'] = request_id if severity: params['Severity'] = severity if start_time: params['StartTime'] = start_time if end_time: params['EndTime'] = end_time if max_records: params['MaxRecords'] = max_records if next_token: params['NextToken'] = next_token return self._get_response('DescribeEvents', params) def list_available_solution_stacks(self): """Returns a list of the available solution stack names.""" return self._get_response('ListAvailableSolutionStacks', params={}) def rebuild_environment(self, environment_id=None, environment_name=None): """ Deletes and recreates all of the AWS resources (for example: the Auto Scaling group, load balancer, etc.) for a specified environment and forces a restart. :type environment_id: string :param environment_id: The ID of the environment to rebuild. Condition: You must specify either this or an EnvironmentName, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error. :type environment_name: string :param environment_name: The name of the environment to rebuild. Condition: You must specify either this or an EnvironmentId, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error. :raises: InsufficientPrivilegesException """ params = {} if environment_id: params['EnvironmentId'] = environment_id if environment_name: params['EnvironmentName'] = environment_name return self._get_response('RebuildEnvironment', params) def request_environment_info(self, info_type='tail', environment_id=None, environment_name=None): """ Initiates a request to compile the specified type of information of the deployed environment. Setting the InfoType to tail compiles the last lines from the application server log files of every Amazon EC2 instance in your environment. Use RetrieveEnvironmentInfo to access the compiled information. :type info_type: string :param info_type: The type of information to request. :type environment_id: string :param environment_id: The ID of the environment of the requested data. If no such environment is found, RequestEnvironmentInfo returns an InvalidParameterValue error. Condition: You must specify either this or an EnvironmentName, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error. :type environment_name: string :param environment_name: The name of the environment of the requested data. If no such environment is found, RequestEnvironmentInfo returns an InvalidParameterValue error. Condition: You must specify either this or an EnvironmentId, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error. """ params = {'InfoType': info_type} if environment_id: params['EnvironmentId'] = environment_id if environment_name: params['EnvironmentName'] = environment_name return self._get_response('RequestEnvironmentInfo', params) def restart_app_server(self, environment_id=None, environment_name=None): """ Causes the environment to restart the application container server running on each Amazon EC2 instance. :type environment_id: string :param environment_id: The ID of the environment to restart the server for. Condition: You must specify either this or an EnvironmentName, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error. :type environment_name: string :param environment_name: The name of the environment to restart the server for. Condition: You must specify either this or an EnvironmentId, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error. """ params = {} if environment_id: params['EnvironmentId'] = environment_id if environment_name: params['EnvironmentName'] = environment_name return self._get_response('RestartAppServer', params) def retrieve_environment_info(self, info_type='tail', environment_id=None, environment_name=None): """ Retrieves the compiled information from a RequestEnvironmentInfo request. :type info_type: string :param info_type: The type of information to retrieve. :type environment_id: string :param environment_id: The ID of the data's environment. If no such environment is found, returns an InvalidParameterValue error. Condition: You must specify either this or an EnvironmentName, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error. :type environment_name: string :param environment_name: The name of the data's environment. If no such environment is found, returns an InvalidParameterValue error. Condition: You must specify either this or an EnvironmentId, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error. """ params = {'InfoType': info_type} if environment_id: params['EnvironmentId'] = environment_id if environment_name: params['EnvironmentName'] = environment_name return self._get_response('RetrieveEnvironmentInfo', params) def swap_environment_cnames(self, source_environment_id=None, source_environment_name=None, destination_environment_id=None, destination_environment_name=None): """Swaps the CNAMEs of two environments. :type source_environment_id: string :param source_environment_id: The ID of the source environment. Condition: You must specify at least the SourceEnvironmentID or the SourceEnvironmentName. You may also specify both. If you specify the SourceEnvironmentId, you must specify the DestinationEnvironmentId. :type source_environment_name: string :param source_environment_name: The name of the source environment. Condition: You must specify at least the SourceEnvironmentID or the SourceEnvironmentName. You may also specify both. If you specify the SourceEnvironmentName, you must specify the DestinationEnvironmentName. :type destination_environment_id: string :param destination_environment_id: The ID of the destination environment. Condition: You must specify at least the DestinationEnvironmentID or the DestinationEnvironmentName. You may also specify both. You must specify the SourceEnvironmentId with the DestinationEnvironmentId. :type destination_environment_name: string :param destination_environment_name: The name of the destination environment. Condition: You must specify at least the DestinationEnvironmentID or the DestinationEnvironmentName. You may also specify both. You must specify the SourceEnvironmentName with the DestinationEnvironmentName. """ params = {} if source_environment_id: params['SourceEnvironmentId'] = source_environment_id if source_environment_name: params['SourceEnvironmentName'] = source_environment_name if destination_environment_id: params['DestinationEnvironmentId'] = destination_environment_id if destination_environment_name: params['DestinationEnvironmentName'] = destination_environment_name return self._get_response('SwapEnvironmentCNAMEs', params) def terminate_environment(self, environment_id=None, environment_name=None, terminate_resources=None): """Terminates the specified environment. :type environment_id: string :param environment_id: The ID of the environment to terminate. Condition: You must specify either this or an EnvironmentName, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error. :type environment_name: string :param environment_name: The name of the environment to terminate. Condition: You must specify either this or an EnvironmentId, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error. :type terminate_resources: boolean :param terminate_resources: Indicates whether the associated AWS resources should shut down when the environment is terminated: true: (default) The user AWS resources (for example, the Auto Scaling group, LoadBalancer, etc.) are terminated along with the environment. false: The environment is removed from the AWS Elastic Beanstalk but the AWS resources continue to operate. For more information, see the AWS Elastic Beanstalk User Guide. Default: true Valid Values: true | false :raises: InsufficientPrivilegesException """ params = {} if environment_id: params['EnvironmentId'] = environment_id if environment_name: params['EnvironmentName'] = environment_name if terminate_resources: params['TerminateResources'] = self._encode_bool( terminate_resources) return self._get_response('TerminateEnvironment', params) def update_application(self, application_name, description=None): """ Updates the specified application to have the specified properties. :type application_name: string :param application_name: The name of the application to update. If no such application is found, UpdateApplication returns an InvalidParameterValue error. :type description: string :param description: A new description for the application. Default: If not specified, AWS Elastic Beanstalk does not update the description. """ params = {'ApplicationName': application_name} if description: params['Description'] = description return self._get_response('UpdateApplication', params) def update_application_version(self, application_name, version_label, description=None): """Updates the application version to have the properties. :type application_name: string :param application_name: The name of the application associated with this version. If no application is found with this name, UpdateApplication returns an InvalidParameterValue error. :type version_label: string :param version_label: The name of the version to update. If no application version is found with this label, UpdateApplication returns an InvalidParameterValue error. :type description: string :param description: A new description for this release. """ params = {'ApplicationName': application_name, 'VersionLabel': version_label} if description: params['Description'] = description return self._get_response('UpdateApplicationVersion', params) def update_configuration_template(self, application_name, template_name, description=None, option_settings=None, options_to_remove=None): """ Updates the specified configuration template to have the specified properties or configuration option values. :type application_name: string :param application_name: The name of the application associated with the configuration template to update. If no application is found with this name, UpdateConfigurationTemplate returns an InvalidParameterValue error. :type template_name: string :param template_name: The name of the configuration template to update. If no configuration template is found with this name, UpdateConfigurationTemplate returns an InvalidParameterValue error. :type description: string :param description: A new description for the configuration. :type option_settings: list :param option_settings: A list of configuration option settings to update with the new specified option value. :type options_to_remove: list :param options_to_remove: A list of configuration options to remove from the configuration set. Constraint: You can remove only UserDefined configuration options. :raises: InsufficientPrivilegesException """ params = {'ApplicationName': application_name, 'TemplateName': template_name} if description: params['Description'] = description if option_settings: self._build_list_params(params, option_settings, 'OptionSettings.member', ('Namespace', 'OptionName', 'Value')) if options_to_remove: self.build_list_params(params, options_to_remove, 'OptionsToRemove.member') return self._get_response('UpdateConfigurationTemplate', params) def update_environment(self, environment_id=None, environment_name=None, version_label=None, template_name=None, description=None, option_settings=None, options_to_remove=None, tier_name=None, tier_type=None, tier_version='1.0'): """ Updates the environment description, deploys a new application version, updates the configuration settings to an entirely new configuration template, or updates select configuration option values in the running environment. Attempting to update both the release and configuration is not allowed and AWS Elastic Beanstalk returns an InvalidParameterCombination error. When updating the configuration settings to a new template or individual settings, a draft configuration is created and DescribeConfigurationSettings for this environment returns two setting descriptions with different DeploymentStatus values. :type environment_id: string :param environment_id: The ID of the environment to update. If no environment with this ID exists, AWS Elastic Beanstalk returns an InvalidParameterValue error. Condition: You must specify either this or an EnvironmentName, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error. :type environment_name: string :param environment_name: The name of the environment to update. If no environment with this name exists, AWS Elastic Beanstalk returns an InvalidParameterValue error. Condition: You must specify either this or an EnvironmentId, or both. If you do not specify either, AWS Elastic Beanstalk returns MissingRequiredParameter error. :type version_label: string :param version_label: If this parameter is specified, AWS Elastic Beanstalk deploys the named application version to the environment. If no such application version is found, returns an InvalidParameterValue error. :type template_name: string :param template_name: If this parameter is specified, AWS Elastic Beanstalk deploys this configuration template to the environment. If no such configuration template is found, AWS Elastic Beanstalk returns an InvalidParameterValue error. :type description: string :param description: If this parameter is specified, AWS Elastic Beanstalk updates the description of this environment. :type option_settings: list :param option_settings: If specified, AWS Elastic Beanstalk updates the configuration set associated with the running environment and sets the specified configuration options to the requested value. :type options_to_remove: list :param options_to_remove: A list of custom user-defined configuration options to remove from the configuration set for this environment. :type tier_name: string :param tier_name: The name of the tier. Valid values are "WebServer" and "Worker". Defaults to "WebServer". The ``tier_name`` and a ``tier_type`` parameters are related and the values provided must be valid. The possible combinations are: * "WebServer" and "Standard" (the default) * "Worker" and "SQS/HTTP" :type tier_type: string :param tier_type: The type of the tier. Valid values are "Standard" if ``tier_name`` is "WebServer" and "SQS/HTTP" if ``tier_name`` is "Worker". Defaults to "Standard". :type tier_version: string :type tier_version: The version of the tier. Valid values currently are "1.0". Defaults to "1.0". :raises: InsufficientPrivilegesException """ params = {} if environment_id: params['EnvironmentId'] = environment_id if environment_name: params['EnvironmentName'] = environment_name if version_label: params['VersionLabel'] = version_label if template_name: params['TemplateName'] = template_name if description: params['Description'] = description if option_settings: self._build_list_params(params, option_settings, 'OptionSettings.member', ('Namespace', 'OptionName', 'Value')) if options_to_remove: self.build_list_params(params, options_to_remove, 'OptionsToRemove.member') if tier_name and tier_type and tier_version: params['Tier.member.Name'] = tier_name params['Tier.member.Type'] = tier_type params['Tier.member.Version'] = tier_version return self._get_response('UpdateEnvironment', params) def validate_configuration_settings(self, application_name, option_settings, template_name=None, environment_name=None): """ Takes a set of configuration settings and either a configuration template or environment, and determines whether those values are valid. This action returns a list of messages indicating any errors or warnings associated with the selection of option values. :type application_name: string :param application_name: The name of the application that the configuration template or environment belongs to. :type template_name: string :param template_name: The name of the configuration template to validate the settings against. Condition: You cannot specify both this and an environment name. :type environment_name: string :param environment_name: The name of the environment to validate the settings against. Condition: You cannot specify both this and a configuration template name. :type option_settings: list :param option_settings: A list of the options and desired values to evaluate. :raises: InsufficientPrivilegesException """ params = {'ApplicationName': application_name} self._build_list_params(params, option_settings, 'OptionSettings.member', ('Namespace', 'OptionName', 'Value')) if template_name: params['TemplateName'] = template_name if environment_name: params['EnvironmentName'] = environment_name return self._get_response('ValidateConfigurationSettings', params) def _build_list_params(self, params, user_values, prefix, tuple_names): # For params such as the ConfigurationOptionSettings, # they can specify a list of tuples where each tuple maps to a specific # arg. For example: # user_values = [('foo', 'bar', 'baz'] # prefix=MyOption.member # tuple_names=('One', 'Two', 'Three') # would result in: # MyOption.member.1.One = foo # MyOption.member.1.Two = bar # MyOption.member.1.Three = baz for i, user_value in enumerate(user_values, 1): current_prefix = '%s.%s' % (prefix, i) for key, value in zip(tuple_names, user_value): full_key = '%s.%s' % (current_prefix, key) params[full_key] = value
#!/usr/bin/env python3 import requests import multiprocessing import time session = None def set_global_session(): global session if not session: session = requests.Session() def download_site(url): with session.get(url) as response: name = multiprocessing.current_process().name print(f"{name}:Read {len(response.content)} from {url}") def download_all_sites(sites): with multiprocessing.Pool(initializer=set_global_session) as pool: pool.map(download_site, sites) if __name__ == "__main__": sites = [ "https://www.jython.org", "http://olympus.realpython.org/dice", ] * 80 start_time = time.time() download_all_sites(sites) duration = time.time() - start_time print(f"Downloaded {len(sites)} in {duration} seconds")
# Copyright 2016 Capital One Services, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or 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. from __future__ import absolute_import, division, print_function, unicode_literals from dateutil import tz from datetime import datetime, timedelta import unittest from c7n import filters as base_filters from c7n.resources.ec2 import filters from c7n.utils import annotation from .common import instance, event_data, Bag class BaseFilterTest(unittest.TestCase): def assertFilter(self, f, i, v): """ f: filter data/spec i: instance v: expected value (true/false) """ try: self.assertEqual(filters.factory(f)(i), v) except AssertionError: print(f, i['LaunchTime'], i['Tags'], v) raise class TestFilter(unittest.TestCase): def test_filter_construction(self): self.assertTrue( isinstance( filters.factory({'tag:ASV': 'absent'}), base_filters.ValueFilter)) def test_filter_validation(self): self.assertRaises( base_filters.FilterValidationError, filters.factory, {'type': 'ax', 'xyz': 1}) def test_filter_call(self): filter_instance = base_filters.Filter({}) self.assertIsInstance(filter_instance, base_filters.Filter) class TestOrFilter(unittest.TestCase): def test_or(self): f = filters.factory({ 'or': [ {'Architecture': 'x86_64'}, {'Architecture': 'armv8'}]}) results = [instance(Architecture='x86_64')] self.assertEqual( f.process(results), results) self.assertEqual( f.process([instance(Architecture='amd64')]), []) class TestAndFilter(unittest.TestCase): def test_and(self): f = filters.factory({ 'and': [ {'Architecture': 'x86_64'}, {'Color': 'green'}]}) results = [instance(Architecture='x86_64', Color='green')] self.assertEqual( f.process(results), results) self.assertEqual( f.process([ instance( Architecture='x86_64', Color='blue')]), []) self.assertEqual( f.process([ instance( Architecture='x86_64')]), []) class TestNotFilter(unittest.TestCase): def test_not(self): results = [ instance(Architecture='x86_64', Color='green'), instance(Architecture='x86_64', Color='blue'), instance(Architecture='x86_64', Color='yellow'), ] f = filters.factory({ 'not': [ {'Architecture': 'x86_64'}, {'Color': 'green'}]}) self.assertEqual(len(f.process(results)), 2) """ f = filters.factory({ 'not': [ {'Architecture': 'x86'}]}) self.assertEqual(len(f.process(results)), 3) f = filters.factory({ 'not': [ {'Architecture': 'x86_64'}, {'or': [ {'Color': 'green'}, {'Color': 'blue'}, {'Color': 'yellow'}, ]}]}) self.assertEqual(len(f.process(results)), 0) """ class TestValueFilter(unittest.TestCase): # TODO test_manager needs a valid session_factory object # def test_value_match(self): # test_manager = ??? # f_data = { # 'type': 'value', # 'key': 'day', # 'value': 5, # 'value_from': { # 'url': 's3://custodian-byebye/resource.json', # }, # } # vf = filters.factory(f_data, test_manager) # vf.match({'tag:ASV': 'present'}) def test_value_type(self): sentinel = datetime.now() value = 5 resource = {'a': 1, 'Tags': [{'Key': 'xtra', 'Value': 'hello'}]} vf = filters.factory({'tag:ASV': 'absent'}) vf.vtype = 'size' res = vf.process_value_type(sentinel, value, resource) self.assertEqual(res, (sentinel, 0)) vf.vtype = 'age' res = vf.process_value_type(sentinel, value, resource) self.assertEqual(res, (0, sentinel)) vf.vtype = 'cidr' sentinel = '10.0.0.0/16' value = '10.10.10.10' res = vf.process_value_type(sentinel, value, resource) self.assertEqual( (str(res[0]), str(res[1])), (sentinel, value), ) vf.vtype = 'cidr_size' value = '10.10.10.300' res = vf.process_value_type(sentinel, value, resource) self.assertEqual(res, (sentinel, 0)) vf.vtype = 'expr' value = 'tag:xtra' sentinel = None res = vf.process_value_type(sentinel, value, resource) self.assertEqual(res, (None, 'hello')) vf.vtype = 'expr' value = 'a' sentinel = None res = vf.process_value_type(sentinel, value, resource) self.assertEqual(res, (None, 1)) class TestAgeFilter(unittest.TestCase): def test_age_filter(self): af = base_filters.AgeFilter({}) self.assertRaises(NotImplementedError, af.validate) class TestGlobValue(unittest.TestCase): def test_regex_match(self): f = filters.factory( {'type': 'value', 'key': 'Color', 'value': '*green*', 'op': 'glob'}) self.assertEqual( f(instance( Architecture='x86_64', Color='mighty green papaya')), True) self.assertEqual( f(instance( Architecture='x86_64', Color='blue')), False) def test_glob_match(self): glob_match = base_filters.core.glob_match self.assertFalse(glob_match(0, '')) class TestRegexValue(unittest.TestCase): def test_regex_validate(self): self.assertRaises( base_filters.FilterValidationError, filters.factory({ 'type': 'value', 'key': 'Color', 'value': '*green', 'op': 'regex'}).validate) def test_regex_match(self): f = filters.factory( {'type': 'value', 'key': 'Color', 'value': '.*green.*', 'op': 'regex'}) self.assertEqual( f(instance( Architecture='x86_64', Color='green papaya')), True) self.assertEqual( f(instance( Architecture='x86_64', Color='blue')), False) self.assertEqual( f(instance( Architecture='x86_64')), False) class TestValueTypes(BaseFilterTest): def test_normalize(self): fdata = { 'type': 'value', 'key': 'tag:Name', 'value_type': 'normalize', 'value': 'compilelambda' } self.assertFilter(fdata, instance(), True) def test_size(self): fdata = { 'type': 'value', 'key': 'SecurityGroups[].GroupId', 'value_type': 'size', 'value': 2 } self.assertFilter(fdata, instance(), True) def test_integer(self): fdata = { 'type': 'value', 'key': 'tag:Count', 'op': 'greater-than', 'value_type': 'integer', 'value': 0} def i(d): return instance(Tags=[{"Key": "Count", "Value": d}]) self.assertFilter(fdata, i('42'), True) self.assertFilter(fdata, i('abc'), False) fdata['op'] = 'equal' self.assertFilter(fdata, i('abc'), True) def test_swap(self): fdata = { 'type': 'value', 'key': 'SecurityGroups[].GroupId', 'value_type': 'swap', 'op': 'in', 'value': 'sg-47b76f22' } self.assertFilter(fdata, instance(), True) def test_age(self): now = datetime.now(tz=tz.tzutc()) three_months = now - timedelta(90) two_months = now - timedelta(60) one_month = now - timedelta(30) def i(d): return instance(LaunchTime=d) fdata = { 'type': 'value', 'key': 'LaunchTime', 'op': 'less-than', 'value_type': 'age', 'value': 32} self.assertFilter(fdata, i(three_months), False) self.assertFilter(fdata, i(two_months), False) self.assertFilter(fdata, i(one_month), True) self.assertFilter(fdata, i(now), True) self.assertFilter(fdata, i(now.isoformat()), True) def test_expiration(self): now = datetime.now(tz=tz.tzutc()) three_months = now + timedelta(90) two_months = now + timedelta(60) def i(d): return instance(LaunchTime=d) fdata = { 'type': 'value', 'key': 'LaunchTime', 'op': 'less-than', 'value_type': 'expiration', 'value': 61} self.assertFilter(fdata, i(three_months), False) self.assertFilter(fdata, i(two_months), True) self.assertFilter(fdata, i(now), True) self.assertFilter(fdata, i(now.isoformat()), True) def test_resource_count_filter(self): fdata = { 'type': 'value', 'value_type': 'resource_count', 'op': 'lt', 'value': 2 } self.assertFilter(fdata, instance(file='ec2-instances.json'), []) f = filters.factory({ 'type': 'value', 'value_type': 'resource_count', 'op': 'eq', 'value': 2 }) i = instance(file='ec2-instances.json') self.assertEqual(i, f(i)) def test_resource_count_filter_validation(self): # Bad `op` f = { 'type': 'value', 'value_type': 'resource_count', 'op': 'regex', 'value': 1, } self.assertRaises( base_filters.FilterValidationError, filters.factory(f, {}).validate) # Bad `value` f = { 'type': 'value', 'value_type': 'resource_count', 'op': 'eq', 'value': 'foo', } self.assertRaises( base_filters.FilterValidationError, filters.factory(f, {}).validate) # Missing `op` f = { 'type': 'value', 'value_type': 'resource_count', 'value': 1, } self.assertRaises( base_filters.FilterValidationError, filters.factory(f, {}).validate) class TestInstanceAge(BaseFilterTest): def test_filter_instance_age(self): now = datetime.now(tz=tz.tzutc()) three_months = now - timedelta(90) two_months = now - timedelta(60) one_month = now - timedelta(30) def i(d): return instance(LaunchTime=d) for ii, v in [ (i(now), False), (i(three_months), True), (i(two_months), True), (i(one_month), False) ]: self.assertFilter({'type': 'instance-uptime', 'op': 'gte', 'days': 60}, ii, v) class TestInstanceAgeMinute(BaseFilterTest): def test_filter_instance_age(self): now = datetime.now(tz=tz.tzutc()) five_minute = now - timedelta(minutes=5) def i(d): return instance(LaunchTime=d) for ii, v in [ (i(now), False), (i(five_minute), True) ]: self.assertFilter({'type': 'instance-uptime', 'op': 'gte', 'minutes': 5}, ii, v) class TestMarkedForAction(BaseFilterTest): def test_marked_for_op_with_skew(self): now = datetime.now() yesterday = datetime.now() - timedelta(7) next_week = now + timedelta(7) def i(d, action='stop'): return instance(Tags=[ {"Key": "maid_status", "Value": "not compliant: %s@%s" % ( action, d.strftime("%Y/%m/%d"))}]) for inst, skew, expected in [ (i(next_week), 7, True), (i(next_week), 3, False), (i(now), 0, True), (i(now), 5, True), (i(yesterday), 5, True), (i(now+timedelta(1)), 1, True), (i(now+timedelta(2)), 1, False), (i(now+timedelta(3)), 1, False) ]: self.assertFilter( {'type': 'marked-for-op', 'skew': skew}, inst, expected) def test_filter_action_date(self): now = datetime.now() yesterday = now - timedelta(1) tomorrow = now + timedelta(1) def i(d, action='stop'): return instance(Tags=[ {"Key": "maid_status", "Value": "not compliant: %s@%s" % ( action, d.strftime("%Y/%m/%d"))}]) for ii, v in [ (i(yesterday), True), (i(now), True), (i(tomorrow), False), (i(yesterday, 'terminate'), False) ]: self.assertFilter({'type': 'marked-for-op'}, ii, v) class EventFilterTest(BaseFilterTest): def test_event_filter(self): b = Bag(data={'mode': []}) event = event_data('event-instance-state.json') f = {'type': 'event', 'key': 'detail.state', 'value': 'pending'} ef = filters.factory(f, b) self.assertTrue(ef.process( [instance()], event)) # event is None self.assertEqual(ef.process('resources'), 'resources') # event is not None, but is not "true" either self.assertEqual(ef.process('resources', []), []) def test_event_no_mode(self): b = Bag(data={'resource': 'something'}) f = {'type': 'event', 'key': 'detail.state', 'value': 'pending'} f = filters.factory(f, b) self.assertRaises( base_filters.FilterValidationError, f.validate) class TestInstanceValue(BaseFilterTest): def test_filter_tag_count(self): tags = [] for i in range(10): tags.append({'Key': str(i), 'Value': str(i)}) i = instance(Tags=tags) self.assertFilter( {'type': 'tag-count', 'op': 'lt'}, i, False) tags.pop(0) i = instance(Tags=tags) self.assertFilter( {'type': 'tag-count', 'op': 'gte', 'count': 9}, i, True) def test_filter_tag(self): i = instance(Tags=[ {'Key': 'ASV', 'Value': 'abcd'}]) self.assertFilter( {'tag:ASV': 'def'}, i, False) self.assertEqual( annotation(i, base_filters.ANNOTATION_KEY), ()) i = instance(Tags=[ {'Key': 'CMDB', 'Value': 'abcd'}]) self.assertFilter( {'tag:ASV': 'absent'}, i, True) self.assertEqual( annotation(i, base_filters.ANNOTATION_KEY), ['tag:ASV']) def test_present(self): i = instance(Tags=[ {'Key': 'ASV', 'Value': ''}]) self.assertFilter( {'type': 'value', 'key': 'tag:ASV', 'value': 'present'}, i, True) def test_jmespath(self): self.assertFilter( {'Placement.AvailabilityZone': 'us-west-2c'}, instance(), True) self.assertFilter( {'Placement.AvailabilityZone': 'us-east-1c'}, instance(), False) def test_complex_validator(self): self.assertRaises( base_filters.FilterValidationError, filters.factory({ "key": "xyz", "type": "value"}).validate) self.assertRaises( base_filters.FilterValidationError, filters.factory({ "value": "xyz", "type": "value"}).validate) self.assertRaises( base_filters.FilterValidationError, filters.factory({ "key": "xyz", "value": "xyz", "op": "oo", "type": "value"}).validate) def test_complex_value_filter(self): self.assertFilter( {"key": ( "length(BlockDeviceMappings" "[?Ebs.DeleteOnTermination == `true`]" ".Ebs.DeleteOnTermination)"), "value": 0, "type": "value", "op": "gt"}, instance(), True) def test_not_null_filter(self): self.assertFilter( {"key": "Hypervisor", "value": "not-null", "type": "value"}, instance(), True) class TestEqualValue(unittest.TestCase): def test_eq(self): f = filters.factory( {'type': 'value', 'key': 'Color', 'value': 'green', 'op': 'eq'}) self.assertEqual( f(instance(Color='green')), True) self.assertEqual( f(instance(Color='blue')), False) def test_equal(self): f = filters.factory( {'type': 'value', 'key': 'Color', 'value': 'green', 'op': 'equal'}) self.assertEqual( f(instance(Color='green')), True) self.assertEqual( f(instance(Color='blue')), False) class TestNotEqualValue(unittest.TestCase): def test_ne(self): f = filters.factory( {'type': 'value', 'key': 'Color', 'value': 'green', 'op': 'ne'}) self.assertEqual( f(instance(Color='green')), False) self.assertEqual( f(instance(Color='blue')), True) def test_not_equal(self): f = filters.factory( {'type': 'value', 'key': 'Color', 'value': 'green', 'op': 'not-equal'}) self.assertEqual( f(instance(Color='green')), False) self.assertEqual( f(instance(Color='blue')), True) class TestGreaterThanValue(unittest.TestCase): def test_gt(self): f = filters.factory( {'type': 'value', 'key': 'Number', 'value': 10, 'op': 'gt'}) self.assertEqual( f(instance(Number=11)), True) self.assertEqual( f(instance(Number=9)), False) self.assertEqual( f(instance(Number=10)), False) def test_greater_than(self): f = filters.factory( {'type': 'value', 'key': 'Number', 'value': 10, 'op': 'greater-than'}) self.assertEqual( f(instance(Number=11)), True) self.assertEqual( f(instance(Number=9)), False) self.assertEqual( f(instance(Number=10)), False) class TestLessThanValue(unittest.TestCase): def test_lt(self): f = filters.factory( {'type': 'value', 'key': 'Number', 'value': 10, 'op': 'lt'}) self.assertEqual( f(instance(Number=9)), True) self.assertEqual( f(instance(Number=11)), False) self.assertEqual( f(instance(Number=10)), False) def test_less_than(self): f = filters.factory( {'type': 'value', 'key': 'Number', 'value': 10, 'op': 'less-than'}) self.assertEqual( f(instance(Number=9)), True) self.assertEqual( f(instance(Number=11)), False) self.assertEqual( f(instance(Number=10)), False) class TestInList(unittest.TestCase): def test_in(self): f = filters.factory( {'type': 'value', 'key': 'Thing', 'value': ['Foo', 'Bar', 'Quux'], 'op': 'in'}) self.assertEqual( f(instance(Thing='Foo')), True) self.assertEqual( f(instance(Thing='Baz')), False) class TestNotInList(unittest.TestCase): def test_ni(self): f = filters.factory( {'type': 'value', 'key': 'Thing', 'value': ['Foo', 'Bar', 'Quux'], 'op': 'ni'}) self.assertEqual( f(instance(Thing='Baz')), True) self.assertEqual( f(instance(Thing='Foo')), False) def test_not_in(self): f = filters.factory( {'type': 'value', 'key': 'Thing', 'value': ['Foo', 'Bar', 'Quux'], 'op': 'not-in'}) self.assertEqual( f(instance(Thing='Baz')), True) self.assertEqual( f(instance(Thing='Foo')), False) class TestFilterRegistry(unittest.TestCase): def test_filter_registry(self): reg = base_filters.FilterRegistry('test.filters') self.assertRaises( base_filters.FilterValidationError, reg.factory, {'type': ''}, ) if __name__ == '__main__': unittest.main()
class Solution: def longestCommonPrefix(self, strs): min_len = len(min(strs, key = len)) for q in range(len(strs)): strs[q] = list(strs[q]) lst = [] final = '' for _ in range(min_len): lst = [q.pop(0) for q in strs] if all(q == lst[0] for q in lst): final += lst[0] else: return final return final
""" Pylibui test suite. """ from pylibui.controls import Slider from tests.utils import WindowTestCase class SliderTest(WindowTestCase): def setUp(self): super().setUp() self.slider = Slider(0, 100) def test_value_initial_value(self): """Tests the sliders's `value` initial value is the first parameter passed to constructor.""" slider = Slider(10, 110) self.assertEqual(slider.value, 10) def test_value_can_be_changed(self): """Tests the slider's `value` attribute can be changed.""" value = 30 self.slider.value = value self.assertEqual(self.slider.value, value)
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # MIT License. See license.txt import json from typing import TYPE_CHECKING, Dict, List from rq import Queue, Worker import frappe from frappe import _ from frappe.utils import convert_utc_to_user_timezone, format_datetime from frappe.utils.background_jobs import get_redis_conn from frappe.utils.scheduler import is_scheduler_inactive if TYPE_CHECKING: from rq.job import Job JOB_COLORS = { 'queued': 'orange', 'failed': 'red', 'started': 'blue', 'finished': 'green' } @frappe.whitelist() def get_info(show_failed=False) -> List[Dict]: if isinstance(show_failed, str): show_failed = json.loads(show_failed) conn = get_redis_conn() queues = Queue.all(conn) workers = Worker.all(conn) jobs = [] def add_job(job: 'Job', name: str) -> None: if job.kwargs.get('site') == frappe.local.site: job_info = { 'job_name': job.kwargs.get('kwargs', {}).get('playbook_method') or job.kwargs.get('kwargs', {}).get('job_type') or str(job.kwargs.get('job_name')), 'status': job.get_status(), 'queue': name, 'creation': format_datetime(convert_utc_to_user_timezone(job.created_at)), 'color': JOB_COLORS[job.get_status()] } if job.exc_info: job_info['exc_info'] = job.exc_info jobs.append(job_info) # show worker jobs for worker in workers: job = worker.get_current_job() if job: add_job(job, worker.name) for queue in queues: # show active queued jobs if queue.name != 'failed': for job in queue.jobs: add_job(job, queue.name) # show failed jobs, if requested if show_failed: fail_registry = queue.failed_job_registry for job_id in fail_registry.get_job_ids(): job = queue.fetch_job(job_id) if job: add_job(job, queue.name) return jobs @frappe.whitelist() def remove_failed_jobs(): conn = get_redis_conn() queues = Queue.all(conn) for queue in queues: fail_registry = queue.failed_job_registry for job_id in fail_registry.get_job_ids(): job = queue.fetch_job(job_id) fail_registry.remove(job, delete_job=True) @frappe.whitelist() def get_scheduler_status(): if is_scheduler_inactive(): return [_("Inactive"), "red"] return [_("Active"), "green"]
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://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. # On-device arrays. from functools import partial, partialmethod import operator from typing import (Any, List, Optional, Union) import weakref import numpy as np from jax import core from jax._src.config import config from jax._src import abstract_arrays from jax._src import dtypes from jax._src import profiler from jax._src.lib import xla_client as xc import jax._src.util as util ### device-persistent data xe = xc._xla Device = xc.Device Buffer = xe.Buffer def _forward_method(attrname, self, fun, *args): return fun(getattr(self, attrname), *args) _forward_to_value = partial(_forward_method, "_value") # The following is used for the type xc.Buffer or _DeviceArray. DeviceArrayProtocol = Any DeviceArray = xc.DeviceArrayBase def make_device_array( aval: core.ShapedArray, device: Optional[Device], device_buffer: Buffer, ) -> Union[Buffer, "_DeviceArray"]: """Returns a DeviceArray implementation based on arguments. This is to be used only within JAX. It will return either a PythonDeviceArray or a C++ equivalent implementation. """ if isinstance(device_buffer, xc.Buffer): if device_buffer.aval == aval and device_buffer._device == device: return device_buffer device_buffer = device_buffer.clone() device_buffer._device = device device_buffer.aval = aval device_buffer.weak_type = aval.weak_type return device_buffer return _DeviceArray(aval, device, device_buffer) def type_is_device_array(x): """Returns `True` if `x` is a non-sharded DeviceArray. Use this function instead of `type(x) is Devicearray`. """ type_x = type(x) return type_x is _DeviceArray or type_x is xc.Buffer def device_array_supports_weakrefs(): try: weakref.ref(DeviceArray()) return True except TypeError: return False class _DeviceArray(DeviceArray): # type: ignore """A DeviceArray is an ndarray backed by a single device memory buffer.""" # We don't subclass ndarray because that would open up a host of issues, # but lax_numpy.py overrides isinstance behavior and attaches ndarray methods. __slots__ = [ "aval", "device_buffer", "_npy_value", "_device", "__weakref__" ] __array_priority__ = 100 # DeviceArray has methods that are dynamically populated in lax_numpy.py, # and this annotation is needed to make pytype happy. _HAS_DYNAMIC_ATTRIBUTES = True def __init__(self, aval: core.ShapedArray, device: Optional[Device], device_buffer: Buffer): """Initializer. Args: aval: The abstract value associated to this array (shape+dtype+weak_type). device: The optional sticky device. See https://jax.readthedocs.io/en/latest/faq.html#controlling-data-and-computation-placement-on-devices device_buffer: The underlying buffer owning the on-device data. """ DeviceArray.__init__(self) self.aval = aval self.device_buffer = device_buffer self._device = device self._npy_value = None if config.jax_enable_checks: assert type(aval) is core.ShapedArray npy_value = self._value assert npy_value.dtype == aval.dtype and npy_value.shape == aval.shape, ( aval, npy_value.shape, npy_value.dtype) assert (device is None) or device is device_buffer.device() def _check_if_deleted(self): if self.device_buffer is deleted_buffer: raise RuntimeError("DeviceArray has been deleted.") @profiler.annotate_function def block_until_ready(self): """Blocks the caller until the buffer's value has been computed on device. This method is mostly useful for timing microbenchmarks that wish to time how long a computation takes, without transferring the result back to the host. Returns the buffer object (`self`). """ self._check_if_deleted() self.device_buffer.block_host_until_ready() # pytype: disable=attribute-error return self @property def _value(self): self._check_if_deleted() if self._npy_value is None: self._npy_value = self.device_buffer.to_py() # pytype: disable=attribute-error # bind-properties self._npy_value.flags.writeable = False return self._npy_value @property def shape(self): return self.aval.shape @property def dtype(self): return self.aval.dtype @property def size(self): return util.prod(self.aval.shape) @property def ndim(self): return len(self.aval.shape) def device(self): self._check_if_deleted() return self.device_buffer.device() # pytype: disable=attribute-error def copy_to_host_async(self): """Requests a copy of the buffer to the host.""" self._check_if_deleted() if self._npy_value is None: self.device_buffer.copy_to_host_async() # pytype: disable=attribute-error def delete(self): """Deletes the device array and any cached copy on the host. It is an error to access the contents of a `DeviceArray` after it has been deleted. Use of this method is optional; device buffers will be reclaimed automatically by Python when a DeviceArray object is garbage collected. However, it is sometimes useful to have more explicit control over the time of deletion. """ self.device_buffer.delete() # pytype: disable=attribute-error self.device_buffer = deleted_buffer self._npy_value = None @property def __cuda_array_interface__(self): return self.device_buffer.__cuda_array_interface__ # pytype: disable=attribute-error # bind-properties # Adding methods dynamically to both _DeviceArray and xc.Buffer # pylint: disable=protected-access for device_array in [DeviceArray]: def copy(self): """Returns an ndarray (backed by host memory, not device memory).""" return np.asarray(self) setattr(device_array, "copy", copy) def __repr__(self): line_width = np.get_printoptions()["linewidth"] prefix = '{}('.format(self.__class__.__name__.lstrip('_')) s = np.array2string(self._value, prefix=prefix, suffix=',', separator=', ', max_line_width=line_width) if self.aval is not None and self.aval.weak_type: dtype_str = f'dtype={self.dtype.name}, weak_type=True)' else: dtype_str = f'dtype={self.dtype.name})' last_line_len = len(s) - s.rfind('\n') + 1 sep = ' ' if last_line_len + len(dtype_str) + 1 > line_width: sep = ' ' * len(prefix) return "{}{},{}{}".format(prefix, s, sep, dtype_str) setattr(device_array, "__repr__", __repr__) def item(self): if dtypes.issubdtype(self.dtype, np.complexfloating): return complex(self) elif dtypes.issubdtype(self.dtype, np.floating): return float(self) elif dtypes.issubdtype(self.dtype, np.integer): return int(self) elif dtypes.issubdtype(self.dtype, np.bool_): return bool(self) else: raise TypeError(self.dtype) setattr(device_array, "item", item) def __len__(self): try: return self.aval.shape[0] except IndexError as err: raise TypeError("len() of unsized object") from err # same as numpy error setattr(device_array, "__len__", __len__) def __iter__(self): if self.ndim == 0: raise TypeError("iteration over a 0-d array") # same as numpy error else: return (sl for chunk in self._chunk_iter(100) for sl in chunk._unstack()) setattr(device_array, "__iter__", __iter__) def __reversed__(self): return iter(self[::-1]) setattr(device_array, "__reversed__", __reversed__) def __format__(self, format_spec): # Simulates behavior of https://github.com/numpy/numpy/pull/9883 if self.ndim == 0: return format(self._value[()], format_spec) else: return format(self._value, format_spec) setattr(device_array, "__format__", __format__) def __array__(self, dtype=None, context=None): return np.asarray(self._value, dtype=dtype) setattr(device_array, "__array__", __array__) setattr(device_array, "__str__", partialmethod(_forward_to_value, str)) setattr(device_array, "__bool__", partialmethod(_forward_to_value, bool)) setattr(device_array, "__nonzero__", partialmethod(_forward_to_value, bool)) setattr(device_array, "__float__", lambda self: self._value.__float__()) setattr(device_array, "__int__", lambda self: self._value.__int__()) setattr(device_array, "__complex__", lambda self: self._value.__complex__()) setattr(device_array, "__hex__", partialmethod(_forward_to_value, hex)) setattr(device_array, "__oct__", partialmethod(_forward_to_value, oct)) setattr(device_array, "__index__", partialmethod(_forward_to_value, operator.index)) to_bytes = lambda self, order="C": self._value.tobytes(order) setattr(device_array, "tobytes", to_bytes) del to_bytes setattr(device_array, "tolist", lambda self: self._value.tolist()) # pickle saves and loads just like an ndarray setattr(device_array, "__reduce__", partialmethod(_forward_to_value, operator.methodcaller("__reduce__"))) # explicitly set to be unhashable. setattr(device_array, "__hash__", None) # clobbered when jax.numpy is imported, but useful in tests setattr(device_array, "__eq__", lambda self, other: self._value == other) # The following methods are dynamically overridden in lax_numpy.py. def raise_not_implemented(): raise NotImplementedError setattr(device_array, "__getitem__", lambda self, i: raise_not_implemented()) # pylint: enable=protected-access class DeletedBuffer(object): pass deleted_buffer = DeletedBuffer() device_array_types: List[type] = [xc.Buffer, _DeviceArray] for _device_array in device_array_types: core.literalable_types.add(_device_array) core.pytype_aval_mappings[device_array] = abstract_arrays.canonical_concrete_aval
"""GUI support for the IPython ZeroMQ kernel - GTK toolkit support. """ #----------------------------------------------------------------------------- # Copyright (C) 2010-2011 The IPython Development Team # # Distributed under the terms of the BSD License. The full license is in # the file COPYING.txt, distributed as part of this software. #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Imports #----------------------------------------------------------------------------- # stdlib import sys # Third-party from gi.repository import GObject, Gtk #----------------------------------------------------------------------------- # Classes and functions #----------------------------------------------------------------------------- class GTKEmbed(object): """A class to embed a kernel into the GTK main event loop. """ def __init__(self, kernel): self.kernel = kernel # These two will later store the real gtk functions when we hijack them self.gtk_main = None self.gtk_main_quit = None def start(self): """Starts the GTK main event loop and sets our kernel startup routine. """ # Register our function to initiate the kernel and start gtk GObject.idle_add(self._wire_kernel) Gtk.main() def _wire_kernel(self): """Initializes the kernel inside GTK. This is meant to run only once at startup, so it does its job and returns False to ensure it doesn't get run again by GTK. """ self.gtk_main, self.gtk_main_quit = self._hijack_gtk() GObject.timeout_add(int(1000*self.kernel._poll_interval), self.iterate_kernel) return False def iterate_kernel(self): """Run one iteration of the kernel and return True. GTK timer functions must return True to be called again, so we make the call to :meth:`do_one_iteration` and then return True for GTK. """ self.kernel.do_one_iteration() return True def stop(self): # FIXME: this one isn't getting called because we have no reliable # kernel shutdown. We need to fix that: once the kernel has a # shutdown mechanism, it can call this. self.gtk_main_quit() sys.exit() def _hijack_gtk(self): """Hijack a few key functions in GTK for IPython integration. Modifies pyGTK's main and main_quit with a dummy so user code does not block IPython. This allows us to use %run to run arbitrary pygtk scripts from a long-lived IPython session, and when they attempt to start or stop Returns ------- The original functions that have been hijacked: - Gtk.main - Gtk.main_quit """ def dummy(*args, **kw): pass # save and trap main and main_quit from gtk orig_main, Gtk.main = Gtk.main, dummy orig_main_quit, Gtk.main_quit = Gtk.main_quit, dummy return orig_main, orig_main_quit
#GUI classes for the application from kivy.app import App from kivy.lang import Builder from kivy.core.window import Window from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition from kivy.uix.popup import Popup from kivy.uix.button import Button from kivy.uix.label import Label from kivy.uix.spinner import Spinner from kivy.uix.textinput import TextInput from kivy.properties import ObjectProperty, BooleanProperty from kivy.uix.recycleview import RecycleView from kivy.uix.recycleboxlayout import RecycleBoxLayout from kivy.uix.recycleview.views import RecycleDataViewBehavior from kivy.uix.behaviors import FocusBehavior from kivy.uix.recycleview.layout import LayoutSelectionBehavior #Window.size = (1200, 800) #FUNCTION classes for the application from app_functions import AmpFunctions, RoomDesign from app_constants import AppConstants class SelectableLabel(RecycleDataViewBehavior, Label): index = None selected = BooleanProperty(False) selectable = BooleanProperty(True) def refresh_view_attrs(self, rv, index, data): self.index = index self.selected = True ''' Catch and handle the view changes ''' return super(SelectableLabel, self).refresh_view_attrs( rv, index, data) def on_touch_down(self, touch): ''' Add selection on touch down ''' if super(SelectableLabel, self).on_touch_down(touch): return True if self.collide_point(*touch.pos) and self.selectable: return self.parent.select_with_touch(self.index, touch) def apply_selection(self, rv, index, is_selected): action = CAESD() ''' Respond to the selection of items in the view. ''' self.selected = is_selected if is_selected: machine_data = """ Machine Section: %s Machine Name: %s Machine Load: %s Machine Current: %sA Machine Current(fx): %sA Machine Cable Size: %smm2 Machine Breaker Size: %sA Machine Cable Type: Armoured PVC Insulated Single Core Cable Machine Breaker Type: %s """ % (str(rv.data[index]['machine_section']), str(rv.data[index]['machine_name']), str(rv.data[index]['machine_load']), str(rv.data[index]['machine_amp']), str(rv.data[index]['machine_amp_gd']), str(rv.data[index]['cable_size']), str(rv.data[index]['breaker_size']), str(rv.data[index]['breaker_type'])) action.popDisplays('Machine Details', machine_data) class SelectableRecycleBoxLayout(FocusBehavior, LayoutSelectionBehavior, RecycleBoxLayout): ''' Adds selection and focus behaviour to the view. ''' #Screens class LaunchPage(Screen): pass class CctvPage(Screen): dropManufacturer = ObjectProperty() dropModel = ObjectProperty() dropSensor = ObjectProperty() distFromCamera = ObjectProperty() sceneWidth = ObjectProperty() sceneHeight = ObjectProperty() sceneArea = ObjectProperty() focalLength = ObjectProperty() datastore = { 'Manu_Model_pairs': [], 'Manufacturer': '', 'Model': '', 'Sensor': '', 'Distance': '', 'Width': '', 'Height': '', 'Focal': '', 'Area': '' } def selectedManufacturer(self): self.datastore['Manufacturer'] = self.dropManufacturer.text self.datastore['Manu_Model_pairs'] = AppConstants().manufacturerModels(self.dropManufacturer.text) self.dropModel.values = [i for i in self.datastore['Manu_Model_pairs'].keys()] pass def selectedModel(self): if self.dropModel.text != 'Model': self.datastore['Model'] = self.dropModel.text self.datastore['Sensor'] = self.datastore['Manu_Model_pairs'][self.dropModel.text] self.dropSensor.text = 'Sensor format: '+ self.datastore['Sensor']+'"' self.sensor_values = AppConstants().sensorsValues(self.datastore['Sensor']) def checkManufacturerModelSelected(self): if self.dropManufacturer.text != "" and self.dropModel.text != 'Model': return True def clearValues(self): if self.sceneWidth.text == '': self.sceneHeight.text = '' self.focalLength.text = '' self.sceneArea.text = '' elif self.sceneHeight.text == '': self.sceneWidth.text = '' self.focalLength.text = '' self.sceneArea.text = '' def calculateSceneDimensions(self, dimension, value): app = CAESD() if value != '': if self.checkManufacturerModelSelected(): if self.distFromCamera.focus: self.datastore['Distance'] = self.distFromCamera.text if self.sceneWidth.text == '' or self.sceneHeight.text == '': pass else: self.focalLength.text = str(round((float(self.sensor_values[0])*float(self.distFromCamera.text))/float(self.sceneWidth.text), 1)) self.sceneArea.text = str(round(float(self.sceneWidth.text)*float(self.sceneHeight.text), 2)) elif self.sceneWidth.focus: self.datastore['Height'] = '' self.datastore['Width'] = self.sceneWidth.text self.sceneHeight.text = str(round((float(self.sceneWidth.text)*float(self.sensor_values[1]))/float(self.sensor_values[0]), 1)) if self.distFromCamera.text != '': self.focalLength.text = str(round((float(self.sensor_values[0])*float(self.distFromCamera.text))/float(self.sceneWidth.text), 1)) self.sceneArea.text = str(round(float(self.sceneWidth.text)*float(self.sceneHeight.text), 2)) elif self.sceneHeight.focus: self.datastore['Width'] = '' self.datastore['Height'] = self.sceneHeight.text self.sceneWidth.text = str(round((float(self.sceneHeight.text)*float(self.sensor_values[0]))/float(self.sensor_values[1]), 1)) if self.distFromCamera.text != '': self.focalLength.text = str(round((float(self.sensor_values[1])*float(self.distFromCamera.text))/float(self.sceneHeight.text), 1)) self.sceneArea.text = str(round(float(self.sceneHeight.text)*float(self.sceneWidth.text), 2)) else: pass else: errorMessage = 'Please select the Model' app.popDisplays('Application Error', errorMessage) else: if self.distFromCamera.text == '': self.focalLength.text = '' self.clearValues() else: self.clearValues() class EarthingPage(Screen): pass class PowerPage_one(Screen): numMachines = ObjectProperty() numSections = ObjectProperty() normalVoltage: ObjectProperty() utilityVoltage: ObjectProperty growthFactor: ObjectProperty() deratingFactor: ObjectProperty() loadingFactor: ObjectProperty() dispPowerOneError: ObjectProperty() buttAddMachines: ObjectProperty() def calculatePowerInputs(self, machines, sections): if machines: if sections: self.buttAddMachines.disabled = False PowerPage_two().powerdataApp(machines, sections, self.normalVoltage.text, self.utilityVoltage.text, self.growthFactor.text, self.deratingFactor.text) else: CAESD().displayInLabelMessage(self.dispPowerOneError, t='Please Indicate Number of Sections', i=True) else: CAESD().displayInLabelMessage(self.dispPowerOneError, t='Please Indicate Number of Machines', i=True) class PowerPage_two(Screen): machineOutOfNum = ObjectProperty() machineNameName = ObjectProperty() machineNameInput = ObjectProperty() machineLoad = ObjectProperty machineFactor = ObjectProperty() dropSelectMachineSection = ObjectProperty() dispPowerTwoScreen = ObjectProperty() buttAddMachines = ObjectProperty() buttAllMachines = ObjectProperty() dropViewMachineSection = ObjectProperty() dispMachineListHeader = ObjectProperty() dispMachineScreen = ObjectProperty() num_of_machines_and_sections = [] storageMachineData = [] def addMachineParameters(self, machine_name, load, section_selected): if machine_name: if load: if section_selected != 'Select Machine Section': CAESD().displayInLabelMessage(self.dispPowerTwoScreen, t='', i=True) self.buttAllMachines.disabled = False self.dropViewMachineSection.disabled = False self.dispMachineListHeader.disabled = False if int(self.getCurMachineNumber()) == int(self.num_of_machines_and_sections[0]): self.machineListLabels() self. displayPowerViewboard() self.buttAddMachines.disabled = True self.dropSelectMachineSection.disabled = True out_message = "Complete!!! "+str(int(self.getCurMachineNumber()))+" out of "+str(self.num_of_machines_and_sections[0])+" machines added!" CAESD().displayInLabelMessage(self.machineOutOfNum, t=out_message) else: self.machineListLabels() self. displayPowerViewboard() self.machineNameName.text = "Name for Machine "+str(int(self.getCurMachineNumber())+1) self.machineNameInput.text = "Machine "+str(int(self.getCurMachineNumber())) out_message =str(int(self.getCurMachineNumber())-1)+" out of "+str(self.num_of_machines_and_sections[0])+" machines added!" CAESD().displayInLabelMessage(self.machineOutOfNum, t=out_message, c=[0,0,0,1]) self.machineLoad.text = '' self.dropSelectMachineSection.text = 'Select Machine Section' else: CAESD().displayInLabelMessage(self.dispPowerTwoScreen, t='Please Select A Machine Section', i=True) else: CAESD().displayInLabelMessage(self.dispPowerTwoScreen, t='Please Indicate Machine Load', i=True) else: CAESD().displayInLabelMessage(self.dispPowerTwoScreen, t='Please Indicate Machine Name', i=True) def powerdataApp(self, machines, sections, a, b, c, d): self.num_of_machines_and_sections.append(machines) self.num_of_machines_and_sections.append(sections) self.num_of_machines_and_sections.append([a,b,c,d]) def getCurMachineNumber(self): return self.machineNameName.text.split(' ')[3] def selectMachineSection(self): values = [] section_alt = [chr(i) for i in range(65,91)] for i in range(1, int(self.num_of_machines_and_sections[1])+1): values.append('Section '+str(section_alt[i-1])) self.dropSelectMachineSection.values = values self.dropViewMachineSection.values = values #self.buttMachineSection.values = values def machineListLabels(self): ampCal = AmpFunctions(float(self.machineLoad.text), float(self.num_of_machines_and_sections[2][0]), float(self.num_of_machines_and_sections[2][2]), float(self.num_of_machines_and_sections[2][3])) appCons = AppConstants() self.storageMachineData.insert(0, { 'machine_section': str(self.dropSelectMachineSection.text), 'machine_name': str(self.machineNameInput.text), 'machine_load': str(self.machineLoad.text), 'machine_amp': str(ampCal.ampWithoutFutureExpansion()), 'machine_amp_gd': str(ampCal.ampWithFutureExpansion()), 'breaker_size': str(appCons.breakerSize(ampCal.ampWithFutureExpansion())), 'cable_size': str(appCons.cableSize(ampCal.ampWithoutFutureExpansion())), 'breaker_type': str(appCons.breakerType(appCons.breakerSize(ampCal.ampWithFutureExpansion())))}) self.dispMachineScreen.data = self.storageMachineData def machineSectionLabels(self, sections, data): self.dispMachineSection.data = [] values = [] section_alt = [chr(i) for i in range(65,91)] for i in range(1, int(sections)+1): values.append('Section '+str(section_alt[i-1])) values.reverse() for sect in values: section_data = [] for row in data: if row['machine_section'] == sect: section_data.append(row) formatted_data = ['Machine | Load | Amp |\n']+[i['machine_name']+' | '+i['machine_load']+'kVa | '+i['machine_amp']+'A | \n' for i in section_data] #section_header = 'Machine Name | Machine Load |\n' #formatted_data(section_header) self.dispMachineSection.data.insert(0, {'machine_section_name': str(sect), 'machine_section_data': str(''.join(formatted_data))}) def displayPowerViewboard(self): ampCal = AmpFunctions(float(self.machineLoad.text), float(self.num_of_machines_and_sections[2][0]), float(self.num_of_machines_and_sections[2][2]), float(self.num_of_machines_and_sections[2][3])) #Determine the total current all_currents = [] for i in self.dispMachineScreen.data: all_currents.append(float(i['machine_amp'])) t_current = round(sum(all_currents), 2) #Determine the transformer capacity p_current = (float(self.num_of_machines_and_sections[2][0]) * t_current)/float(self.num_of_machines_and_sections[2][1]) t_capacity = round((ampCal.phaseRoot() * float(self.num_of_machines_and_sections[2][1]) * p_current * 1)/1000, 2) power_viewboard_message = """ POWER VIEWBOARD Total Current from Machines: %sA Change Over Switch Capacity: 2500A Transformer Capacity: %skVA Generator Capacity: %skVA """ % (t_current, t_capacity, t_capacity) self.dispPowerTwoScreen.text = power_viewboard_message def displayPanelBoard(self, data_key): if data_key == 'All Machines': self.dispMachineScreen.data = self.storageMachineData #self.sectionViewboard.text = '' else: section_data = [] self.dispMachineScreen.data = [] for row in self.storageMachineData: if row['machine_section'] == data_key: section_data.append(row) else: self.dispMachineScreen.data = [] self.dispMachineScreen.data = section_data if self.dispMachineScreen.data == []: out_message = 'NO MACHINE ADDED YET FOR '+data_key.upper() CAESD().displayInLabelMessage(self.dispPowerTwoScreen, t=out_message, c=[0,0,0,1]) else: tot_load = 0 tot_amp = 0 tot_amp_gd = 0 tot_breaker_size = 0 #tot_cable_size = 0 for i in self.dispMachineScreen.data: tot_load += float(i['machine_load']) tot_amp += float(i['machine_amp']) tot_amp_gd += float(i['machine_amp_gd']) tot_breaker_size += float(i['breaker_size']) #tot_cable_size += float(i['cable_size']) data_summary = """ SUMMARY FOR %s Number of Machines: %s Total Load: %skVA Total Current: %sA Total Current(fx): %sA Total Breaker Size: %sA """ % (data_key.upper(), len(self.dispMachineScreen.data), tot_load, round(tot_amp, 2), round(tot_amp_gd, 2), round(tot_breaker_size, 2)) self.dispPowerTwoScreen.text = data_summary class IlluminationPage(Screen): lengthOfRoom = ObjectProperty() breadthOfRoom = ObjectProperty() workingHeight = ObjectProperty() wattMSq = ObjectProperty() lampL = ObjectProperty() numL = ObjectProperty() mainFac = ObjectProperty() dispIllumination = ObjectProperty() dispLampDistributions = ObjectProperty() def calculateLampsNeeded(self, length, breadth, w_height, watt_m_sq, lamp_l, no_lumin, main_fac): app = CAESD() if length and breadth and watt_m_sq and lamp_l: if lamp_l != 'Lamp lumen': if main_fac != 'Maintenance factor': Ll = AppConstants().lampLumen(str(self.lampL.text)) room = RoomDesign(float(self.lengthOfRoom.text), float(self.breadthOfRoom.text), float(self.workingHeight.text), float(self.wattMSq.text), float(Ll), float(self.numL.text), float(self.mainFac.text)) message_illumination = """ Room Index Calculated at: %s \r Total Number of lamps needed: %s """ % (str(room.roomIndex()), str(room.roomLamps())) lamp_dis = """ POSSIBLE COMBINATIONS OF LAMPS\r %s """ % str(room.possibleLampConfigurations()) app.displayInLabelMessage(self.dispIllumination, t=message_illumination, c=[0,0,0,1]) app.displayInLabelMessage(self.dispLampDistributions, t=lamp_dis, c=[0,0,0,1]) else: app.displayInLabelMessage(self.dispIllumination, t='Please select the maintenance factor', i=True) else: app.displayInLabelMessage(self.dispIllumination, t='Please choose the lamp lumen', i=True) else: app.displayInLabelMessage(self.dispIllumination, t='Missing Parameter/Input', i=True) #Main Screen Manager class CAESDApp(ScreenManager): pass main_kv = Builder.load_file("main.kv") class CAESD(App): def build(self): self.title = 'Computer Aided Electrical Services Design' self.background_color = 0,0,0,1 return main_kv def displayInLabelMessage(self, obj, **kwargs): obj.color = 1, 0, 0, 1 obj.italic = False if kwargs == {}: #Default error message obj.text = 'Attention: Application Message' else: for i in kwargs.keys(): if i == 'text' or i == 't': obj.text = kwargs[i] elif i == 'color' or i == 'c': obj.color = kwargs[i] elif i == 'italic' or i == 'i': obj.italic = kwargs[i] def popDisplays(self, title, message, hint=(.7, .45)): Popup(title=title, title_color=[1,1,1,1], content=Label(text=message), size_hint=hint, separator_color=[1,1,0,.6]).open() if __name__ == '__main__': CAESD().run()
import os, sys, inspect # realpath() will make your script run, even if you symlink it :) cmd_folder = os.path.realpath(os.path.abspath(os.path.split(inspect.getfile(inspect.currentframe()))[0])) if cmd_folder not in sys.path: sys.path.insert(0, cmd_folder) # # Use this if you want to include modules from a subfolder cmd_subfolder = os.path.realpath( os.path.abspath(os.path.join(os.path.split(inspect.getfile(inspect.currentframe()))[0], ".."))) if cmd_subfolder not in sys.path: sys.path.insert(0, cmd_subfolder) sys.path.append('../') sys.path.append('../utils/') sys.path.append('../vizualization/')
# Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs") # and others. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from glanceclient.exc import HTTPBadRequest try: from urllib.request import URLError except ImportError: from urllib2 import URLError import logging import shutil import unittest import uuid import os from snaps import file_utils from snaps.openstack import create_image from snaps.openstack.create_image import (ImageSettings, ImageCreationError, ImageSettingsError) from snaps.openstack.tests import openstack_tests from snaps.openstack.tests.os_source_file_test import OSIntegrationTestCase from snaps.openstack.utils import glance_utils __author__ = 'spisarski' logger = logging.getLogger('create_image_tests') class ImageSettingsUnitTests(unittest.TestCase): """ Tests the construction of the ImageSettings class """ def test_no_params(self): with self.assertRaises(ImageSettingsError): ImageSettings() def test_empty_config(self): with self.assertRaises(ImageSettingsError): ImageSettings(**dict()) def test_name_only(self): with self.assertRaises(ImageSettingsError): ImageSettings(name='foo') def test_config_with_name_only(self): with self.assertRaises(ImageSettingsError): ImageSettings(**{'name': 'foo'}) def test_name_user_only(self): with self.assertRaises(ImageSettingsError): ImageSettings(name='foo', image_user='bar') def test_config_with_name_user_only(self): with self.assertRaises(ImageSettingsError): ImageSettings(**{'name': 'foo', 'image_user': 'bar'}) def test_name_user_format_only(self): with self.assertRaises(ImageSettingsError): ImageSettings(name='foo', image_user='bar', img_format='qcow2') def test_config_with_name_user_format_only(self): with self.assertRaises(ImageSettingsError): ImageSettings( **{'name': 'foo', 'image_user': 'bar', 'format': 'qcow2'}) def test_name_user_format_url_only(self): settings = ImageSettings(name='foo', image_user='bar', img_format='qcow2', url='http://foo.com') self.assertEqual('foo', settings.name) self.assertEqual('bar', settings.image_user) self.assertEqual('qcow2', settings.format) self.assertEqual('http://foo.com', settings.url) self.assertIsNone(settings.image_file) self.assertFalse(settings.exists) self.assertFalse(settings.public) self.assertIsNone(settings.nic_config_pb_loc) def test_name_user_format_url_only_properties(self): properties = {'hw_video_model': 'vga'} settings = ImageSettings(name='foo', image_user='bar', img_format='qcow2', url='http://foo.com', extra_properties=properties) self.assertEqual('foo', settings.name) self.assertEqual('bar', settings.image_user) self.assertEqual('qcow2', settings.format) self.assertEqual('http://foo.com', settings.url) self.assertEqual(properties, settings.extra_properties) self.assertIsNone(settings.image_file) self.assertFalse(settings.exists) self.assertFalse(settings.public) self.assertIsNone(settings.nic_config_pb_loc) def test_config_with_name_user_format_url_only(self): settings = ImageSettings( **{'name': 'foo', 'image_user': 'bar', 'format': 'qcow2', 'download_url': 'http://foo.com'}) self.assertEqual('foo', settings.name) self.assertEqual('bar', settings.image_user) self.assertEqual('qcow2', settings.format) self.assertEqual('http://foo.com', settings.url) self.assertIsNone(settings.image_file) self.assertFalse(settings.exists) self.assertFalse(settings.public) self.assertIsNone(settings.nic_config_pb_loc) def test_name_user_format_file_only(self): settings = ImageSettings(name='foo', image_user='bar', img_format='qcow2', image_file='/foo/bar.qcow') self.assertEqual('foo', settings.name) self.assertEqual('bar', settings.image_user) self.assertEqual('qcow2', settings.format) self.assertIsNone(settings.url) self.assertEqual('/foo/bar.qcow', settings.image_file) self.assertFalse(settings.exists) self.assertFalse(settings.public) self.assertIsNone(settings.nic_config_pb_loc) def test_config_with_name_user_format_file_only(self): settings = ImageSettings( **{'name': 'foo', 'image_user': 'bar', 'format': 'qcow2', 'image_file': '/foo/bar.qcow'}) self.assertEqual('foo', settings.name) self.assertEqual('bar', settings.image_user) self.assertEqual('qcow2', settings.format) self.assertIsNone(settings.url) self.assertEqual('/foo/bar.qcow', settings.image_file) self.assertFalse(settings.exists) self.assertFalse(settings.public) self.assertIsNone(settings.nic_config_pb_loc) def test_all_url(self): properties = {'hw_video_model': 'vga'} kernel_settings = ImageSettings(name='kernel', url='http://kernel.com', image_user='bar', img_format='qcow2') ramdisk_settings = ImageSettings(name='ramdisk', url='http://ramdisk.com', image_user='bar', img_format='qcow2') settings = ImageSettings(name='foo', image_user='bar', img_format='qcow2', url='http://foo.com', extra_properties=properties, nic_config_pb_loc='/foo/bar', kernel_image_settings=kernel_settings, ramdisk_image_settings=ramdisk_settings, exists=True, public=True) self.assertEqual('foo', settings.name) self.assertEqual('bar', settings.image_user) self.assertEqual('qcow2', settings.format) self.assertEqual('http://foo.com', settings.url) self.assertEqual(properties, settings.extra_properties) self.assertIsNone(settings.image_file) self.assertEqual('/foo/bar', settings.nic_config_pb_loc) self.assertEqual('kernel', settings.kernel_image_settings.name) self.assertEqual('http://kernel.com', settings.kernel_image_settings.url) self.assertEqual('bar', settings.kernel_image_settings.image_user) self.assertEqual('qcow2', settings.kernel_image_settings.format) self.assertEqual('ramdisk', settings.ramdisk_image_settings.name) self.assertEqual('http://ramdisk.com', settings.ramdisk_image_settings.url) self.assertEqual('bar', settings.ramdisk_image_settings.image_user) self.assertEqual('qcow2', settings.ramdisk_image_settings.format) self.assertTrue(settings.exists) self.assertTrue(settings.public) def test_config_all_url(self): settings = ImageSettings( **{'name': 'foo', 'image_user': 'bar', 'format': 'qcow2', 'download_url': 'http://foo.com', 'extra_properties': '{\'hw_video_model\': \'vga\'}', 'nic_config_pb_loc': '/foo/bar', 'kernel_image_settings': { 'name': 'kernel', 'download_url': 'http://kernel.com', 'image_user': 'bar', 'format': 'qcow2'}, 'ramdisk_image_settings': { 'name': 'ramdisk', 'download_url': 'http://ramdisk.com', 'image_user': 'bar', 'format': 'qcow2'}, 'exists': True, 'public': True}) self.assertEqual('foo', settings.name) self.assertEqual('bar', settings.image_user) self.assertEqual('qcow2', settings.format) self.assertEqual('http://foo.com', settings.url) self.assertEqual('{\'hw_video_model\': \'vga\'}', settings.extra_properties) self.assertIsNone(settings.image_file) self.assertEqual('/foo/bar', settings.nic_config_pb_loc) self.assertEqual('kernel', settings.kernel_image_settings.name) self.assertEqual('http://kernel.com', settings.kernel_image_settings.url) self.assertEqual('ramdisk', settings.ramdisk_image_settings.name) self.assertEqual('http://ramdisk.com', settings.ramdisk_image_settings.url) self.assertTrue(settings.exists) self.assertTrue(settings.public) def test_all_file(self): properties = {'hw_video_model': 'vga'} settings = ImageSettings(name='foo', image_user='bar', img_format='qcow2', image_file='/foo/bar.qcow', extra_properties=properties, nic_config_pb_loc='/foo/bar', exists=True, public=True) self.assertEqual('foo', settings.name) self.assertEqual('bar', settings.image_user) self.assertEqual('qcow2', settings.format) self.assertIsNone(settings.url) self.assertEqual('/foo/bar.qcow', settings.image_file) self.assertEqual(properties, settings.extra_properties) self.assertEqual('/foo/bar', settings.nic_config_pb_loc) self.assertTrue(settings.exists) self.assertTrue(settings.public) def test_config_all_file(self): settings = ImageSettings( **{'name': 'foo', 'image_user': 'bar', 'format': 'qcow2', 'image_file': '/foo/bar.qcow', 'extra_properties': '{\'hw_video_model\' : \'vga\'}', 'nic_config_pb_loc': '/foo/bar', 'exists': True, 'public': True}) self.assertEqual('foo', settings.name) self.assertEqual('bar', settings.image_user) self.assertEqual('qcow2', settings.format) self.assertIsNone(settings.url) self.assertEqual('/foo/bar.qcow', settings.image_file) self.assertEqual('{\'hw_video_model\' : \'vga\'}', settings.extra_properties) self.assertEqual('/foo/bar', settings.nic_config_pb_loc) self.assertTrue(settings.exists) self.assertTrue(settings.public) class CreateImageSuccessTests(OSIntegrationTestCase): """ Test for the CreateImage class defined in create_image.py """ def setUp(self): """ Instantiates the CreateImage object that is responsible for downloading and creating an OS image file within OpenStack """ super(self.__class__, self).__start__() guid = uuid.uuid4() self.image_name = self.__class__.__name__ + '-' + str(guid) self.glance = glance_utils.glance_client(self.os_creds) self.image_creator = None if self.image_metadata and 'glance_tests' in self.image_metadata: glance_test_meta = self.image_metadata['glance_tests'] else: glance_test_meta = None self.tmp_dir = 'tmp/' + str(guid) if not os.path.exists(self.tmp_dir): os.makedirs(self.tmp_dir) self.image_settings = openstack_tests.cirros_image_settings( name=self.image_name, image_metadata=glance_test_meta) def tearDown(self): """ Cleans the image and downloaded image file """ if self.image_creator: self.image_creator.clean() if os.path.exists(self.tmp_dir) and os.path.isdir(self.tmp_dir): shutil.rmtree(self.tmp_dir) super(self.__class__, self).__clean__() def test_create_image_clean_url(self): """ Tests the creation of an OpenStack image from a URL. """ # Create Image # Set the default image settings, then set any custom parameters sent # from the app self.image_creator = create_image.OpenStackImage(self.os_creds, self.image_settings) created_image = self.image_creator.create() self.assertIsNotNone(created_image) retrieved_image = glance_utils.get_image( self.glance, image_settings=self.image_settings) self.assertIsNotNone(retrieved_image) self.assertEqual(created_image.size, retrieved_image.size) self.assertEqual(get_image_size(self.image_settings), retrieved_image.size) self.assertEqual(created_image.name, retrieved_image.name) self.assertEqual(created_image.id, retrieved_image.id) def test_create_image_clean_url_properties(self): """ Tests the creation of an OpenStack image from a URL and set properties. """ # Create Image # Set the default image settings, then set any custom parameters sent # from the app self.image_creator = create_image.OpenStackImage(self.os_creds, self.image_settings) created_image = self.image_creator.create() self.assertIsNotNone(created_image) retrieved_image = glance_utils.get_image( self.glance, image_settings=self.image_settings) self.assertIsNotNone(retrieved_image) self.assertEqual(self.image_creator.get_image().size, retrieved_image.size) self.assertEqual(get_image_size(self.image_settings), retrieved_image.size) self.assertEqual(created_image.name, retrieved_image.name) self.assertEqual(created_image.id, retrieved_image.id) self.assertEqual(created_image.properties, retrieved_image.properties) def test_create_image_clean_file(self): """ Tests the creation of an OpenStack image from a file. """ if not self.image_settings.image_file and self.image_settings.url: # Download the file of the image image_file_name = file_utils.download(self.image_settings.url, self.tmp_dir).name else: image_file_name = self.image_settings.image_file if image_file_name: file_image_settings = openstack_tests.file_image_test_settings( name=self.image_name, file_path=image_file_name) self.image_creator = create_image.OpenStackImage( self.os_creds, file_image_settings) created_image = self.image_creator.create() self.assertIsNotNone(created_image) self.assertEqual(self.image_name, created_image.name) retrieved_image = glance_utils.get_image( self.glance, image_settings=file_image_settings) self.assertIsNotNone(retrieved_image) self.assertEqual(self.image_creator.get_image().size, retrieved_image.size) self.assertEqual(get_image_size(file_image_settings), retrieved_image.size) self.assertEqual(created_image.name, retrieved_image.name) self.assertEqual(created_image.id, retrieved_image.id) else: logger.warn( 'Test not executed as the image metadata requires image files') def test_create_delete_image(self): """ Tests the creation then deletion of an OpenStack image to ensure clean() does not raise an Exception. """ # Create Image self.image_creator = create_image.OpenStackImage(self.os_creds, self.image_settings) created_image = self.image_creator.create() self.assertIsNotNone(created_image) retrieved_image = glance_utils.get_image( self.glance, image_settings=self.image_settings) self.assertIsNotNone(retrieved_image) self.assertEqual(self.image_creator.get_image().size, retrieved_image.size) self.assertEqual(get_image_size(self.image_settings), retrieved_image.size) # Delete Image manually glance_utils.delete_image(self.glance, created_image) self.assertIsNone(glance_utils.get_image( self.glance, image_settings=self.image_creator.image_settings)) # Must not throw an exception when attempting to cleanup non-existent # image self.image_creator.clean() self.assertIsNone(self.image_creator.get_image()) def test_create_same_image(self): """ Tests the creation of an OpenStack image when the image already exists. """ # Create Image self.image_creator = create_image.OpenStackImage(self.os_creds, self.image_settings) image1 = self.image_creator.create() retrieved_image = glance_utils.get_image( self.glance, image_settings=self.image_settings) self.assertIsNotNone(retrieved_image) self.assertEqual(self.image_creator.get_image().size, retrieved_image.size) self.assertEqual(get_image_size(self.image_settings), retrieved_image.size) self.assertEqual(image1.name, retrieved_image.name) self.assertEqual(image1.id, retrieved_image.id) self.assertEqual(image1.properties, retrieved_image.properties) # Should be retrieving the instance data os_image_2 = create_image.OpenStackImage(self.os_creds, self.image_settings) image2 = os_image_2.create() self.assertEqual(image1.id, image2.id) def test_create_same_image_new_settings(self): """ Tests the creation of an OpenStack image when the image already exists and the configuration only contains the name. """ # Create Image self.image_creator = create_image.OpenStackImage(self.os_creds, self.image_settings) image1 = self.image_creator.create() retrieved_image = glance_utils.get_image( self.glance, image_settings=self.image_settings) self.assertIsNotNone(retrieved_image) self.assertEqual(self.image_creator.get_image().size, retrieved_image.size) self.assertEqual(get_image_size(self.image_settings), retrieved_image.size) self.assertEqual(image1.name, retrieved_image.name) self.assertEqual(image1.id, retrieved_image.id) self.assertEqual(image1.properties, retrieved_image.properties) # Should be retrieving the instance data image_2_settings = ImageSettings(name=self.image_settings.name, image_user='foo', exists=True) os_image_2 = create_image.OpenStackImage(self.os_creds, image_2_settings) image2 = os_image_2.create() self.assertEqual(image1.id, image2.id) class CreateImageNegativeTests(OSIntegrationTestCase): """ Negative test cases for the CreateImage class """ def setUp(self): super(self.__class__, self).__start__() self.image_name = self.__class__.__name__ + '-' + str(uuid.uuid4()) self.image_creator = None def tearDown(self): if self.image_creator: self.image_creator.clean() super(self.__class__, self).__clean__() def test_bad_image_name(self): """ Expect an ImageCreationError when the image name does not exist when a file or URL has not been configured """ os_image_settings = ImageSettings(name='foo', image_user='bar', exists=True) self.image_creator = create_image.OpenStackImage(self.os_creds, os_image_settings) with self.assertRaises(ImageCreationError): self.image_creator.create() self.fail('ImageCreationError should have been raised prior to' 'this line') def test_bad_image_url(self): """ Expect an ImageCreationError when the image download url is bad """ os_image_settings = openstack_tests.cirros_image_settings( name=self.image_name) self.image_creator = create_image.OpenStackImage( self.os_creds, create_image.ImageSettings(name=os_image_settings.name, image_user=os_image_settings.image_user, img_format=os_image_settings.format, url="http://foo.bar")) try: self.image_creator.create() except HTTPBadRequest: pass except URLError: pass except Exception as e: self.fail('Invalid Exception ' + str(e)) def test_bad_image_image_type(self): """ Expect an ImageCreationError when the image type bad """ os_image_settings = openstack_tests.cirros_image_settings( name=self.image_name) self.image_creator = create_image.OpenStackImage( self.os_creds, create_image.ImageSettings(name=os_image_settings.name, image_user=os_image_settings.image_user, img_format='foo', url=os_image_settings.url)) with self.assertRaises(Exception): self.image_creator.create() def test_bad_image_file(self): """ Expect an ImageCreationError when the image file does not exist """ os_image_settings = openstack_tests.cirros_image_settings( name=self.image_name) self.image_creator = create_image.OpenStackImage( self.os_creds, create_image.ImageSettings(name=os_image_settings.name, image_user=os_image_settings.image_user, img_format=os_image_settings.format, image_file="/foo/bar.qcow")) with self.assertRaises(IOError): self.image_creator.create() class CreateMultiPartImageTests(OSIntegrationTestCase): """ Test different means for creating a 3-part images """ def setUp(self): """ Instantiates the CreateImage object that is responsible for downloading and creating an OS image file within OpenStack """ super(self.__class__, self).__start__() guid = uuid.uuid4() self.image_creators = list() self.image_name = self.__class__.__name__ + '-' + str(guid) self.glance = glance_utils.glance_client(self.os_creds) self.tmp_dir = 'tmp/' + str(guid) if not os.path.exists(self.tmp_dir): os.makedirs(self.tmp_dir) if self.image_metadata and 'glance_tests' in self.image_metadata: self.glance_test_meta = self.image_metadata['glance_tests'] else: self.glance_test_meta = dict() def tearDown(self): """ Cleans the images and downloaded image file """ for image_creator in self.image_creators: image_creator.clean() if os.path.exists(self.tmp_dir) and os.path.isdir(self.tmp_dir): shutil.rmtree(self.tmp_dir) super(self.__class__, self).__clean__() def test_create_three_part_image_from_url(self): """ Tests the creation of a 3-part OpenStack image from a URL. """ # Create the kernel image if 'disk_file' not in self.glance_test_meta: image_settings = openstack_tests.cirros_image_settings( name=self.image_name, image_metadata={ 'disk_url': openstack_tests.CIRROS_DEFAULT_IMAGE_URL, 'kernel_url': openstack_tests.CIRROS_DEFAULT_KERNEL_IMAGE_URL, 'ramdisk_url': openstack_tests.CIRROS_DEFAULT_RAMDISK_IMAGE_URL}) image_creator = create_image.OpenStackImage(self.os_creds, image_settings) self.image_creators.append(image_creator) image_creator.create() main_image = glance_utils.get_image(self.glance, image_settings=image_settings) self.assertIsNotNone(main_image) self.assertIsNotNone(image_creator.get_image()) self.assertEqual(image_creator.get_image().id, main_image.id) kernel_image = glance_utils.get_image( self.glance, image_settings=image_settings.kernel_image_settings) self.assertIsNotNone(kernel_image) self.assertIsNotNone(image_creator.get_kernel_image()) self.assertEqual(kernel_image.id, image_creator.get_kernel_image().id) ramdisk_image = glance_utils.get_image( self.glance, image_settings=image_settings.ramdisk_image_settings) self.assertIsNotNone(ramdisk_image) self.assertIsNotNone(image_creator.get_ramdisk_image()) self.assertEqual(ramdisk_image.id, image_creator.get_ramdisk_image().id) else: logger.warn( 'Test not executed as the image metadata requires image files') def test_create_three_part_image_from_file_3_creators(self): """ Tests the creation of a 3-part OpenStack image from files. """ file_only = False # Set properties properties = {} if self.glance_test_meta: if 'extra_properties' in self.glance_test_meta: properties = self.glance_test_meta['extra_properties'] if 'disk_file' in self.glance_test_meta: file_only = True # Create the kernel image kernel_file_name = None kernel_url = openstack_tests.CIRROS_DEFAULT_KERNEL_IMAGE_URL if 'kernel_file' in self.glance_test_meta: kernel_file_name = self.glance_test_meta['kernel_file'] elif 'kernel_url' in self.glance_test_meta: kernel_url = self.glance_test_meta['kernel_url'] else: kernel_url = openstack_tests.CIRROS_DEFAULT_KERNEL_IMAGE_URL if not kernel_file_name and not file_only: kernel_file_name = file_utils.download(kernel_url, self.tmp_dir).name else: logger.warn('Will not download the kernel image.' ' Cannot execute test') return kernel_file_image_settings = openstack_tests.file_image_test_settings( name=self.image_name + '_kernel', file_path=kernel_file_name) self.image_creators.append(create_image.OpenStackImage( self.os_creds, kernel_file_image_settings)) kernel_image = self.image_creators[-1].create() self.assertIsNotNone(kernel_image) self.assertEqual(get_image_size(kernel_file_image_settings), kernel_image.size) # Create the ramdisk image ramdisk_file_name = None ramdisk_url = openstack_tests.CIRROS_DEFAULT_RAMDISK_IMAGE_URL if 'ramdisk_file' in self.glance_test_meta: ramdisk_file_name = self.glance_test_meta['ramdisk_file'] elif 'ramdisk_url' in self.glance_test_meta: ramdisk_url = self.glance_test_meta['ramdisk_url'] if not ramdisk_file_name and not file_only: ramdisk_file_name = file_utils.download(ramdisk_url, self.tmp_dir).name else: logger.warn('Will not download the ramdisk image.' ' Cannot execute test') return ramdisk_file_image_settings = openstack_tests.file_image_test_settings( name=self.image_name + '_ramdisk', file_path=ramdisk_file_name) self.image_creators.append(create_image.OpenStackImage( self.os_creds, ramdisk_file_image_settings)) ramdisk_image = self.image_creators[-1].create() self.assertIsNotNone(ramdisk_image) self.assertEqual(get_image_size(ramdisk_file_image_settings), ramdisk_image.size) # Create the main disk image disk_file_name = None disk_url = openstack_tests.CIRROS_DEFAULT_IMAGE_URL if 'disk_file' in self.glance_test_meta: disk_file_name = self.glance_test_meta['disk_file'] elif 'disk_url' in self.glance_test_meta: disk_url = self.glance_test_meta['disk_url'] if not disk_file_name and not file_only: disk_file_name = file_utils.download(disk_url, self.tmp_dir).name else: logger.warn('Will not download the disk file image.' ' Cannot execute test') return file_image_settings = openstack_tests.file_image_test_settings( name=self.image_name, file_path=disk_file_name) properties['kernel_id'] = kernel_image.id properties['ramdisk_id'] = ramdisk_image.id file_image_settings.extra_properties = properties self.image_creators.append( create_image.OpenStackImage(self.os_creds, file_image_settings)) created_image = self.image_creators[-1].create() self.assertIsNotNone(created_image) self.assertEqual(self.image_name, created_image.name) retrieved_image = glance_utils.get_image( self.glance, image_settings=file_image_settings) self.assertIsNotNone(retrieved_image) self.assertEqual(self.image_creators[-1].get_image().size, retrieved_image.size) self.assertEqual(get_image_size(file_image_settings), retrieved_image.size) self.assertEqual(created_image.name, retrieved_image.name) self.assertEqual(created_image.id, retrieved_image.id) self.assertEqual(created_image.properties, retrieved_image.properties) def test_create_three_part_image_from_url_3_creators(self): """ Tests the creation of a 3-part OpenStack image from a URL. """ if 'disk_file' not in self.glance_test_meta: # Set properties properties = {} if self.glance_test_meta and \ 'extra_properties' in self.glance_test_meta: properties = self.glance_test_meta['extra_properties'] # Create the kernel image kernel_image_settings = openstack_tests.cirros_image_settings( name=self.image_name + '_kernel', url=openstack_tests.CIRROS_DEFAULT_KERNEL_IMAGE_URL) if self.glance_test_meta: if 'kernel_url' in self.glance_test_meta: kernel_image_settings.url = self.glance_test_meta[ 'kernel_url'] self.image_creators.append( create_image.OpenStackImage(self.os_creds, kernel_image_settings)) kernel_image = self.image_creators[-1].create() self.assertIsNotNone(kernel_image) self.assertEqual(get_image_size(kernel_image_settings), kernel_image.size) # Create the ramdisk image ramdisk_image_settings = openstack_tests.cirros_image_settings( name=self.image_name + '_ramdisk', url=openstack_tests.CIRROS_DEFAULT_RAMDISK_IMAGE_URL) if self.glance_test_meta: if 'ramdisk_url' in self.glance_test_meta: ramdisk_image_settings.url = self.glance_test_meta[ 'ramdisk_url'] self.image_creators.append( create_image.OpenStackImage(self.os_creds, ramdisk_image_settings)) ramdisk_image = self.image_creators[-1].create() self.assertIsNotNone(ramdisk_image) self.assertEqual(get_image_size(ramdisk_image_settings), ramdisk_image.size) # Create the main image os_image_settings = openstack_tests.cirros_image_settings( name=self.image_name, url=openstack_tests.CIRROS_DEFAULT_IMAGE_URL) if self.glance_test_meta: if 'disk_url' in self.glance_test_meta: os_image_settings.url = self.glance_test_meta['disk_url'] properties['kernel_id'] = kernel_image.id properties['ramdisk_id'] = ramdisk_image.id os_image_settings.extra_properties = properties self.image_creators.append( create_image.OpenStackImage(self.os_creds, os_image_settings)) created_image = self.image_creators[-1].create() self.assertIsNotNone(created_image) self.assertEqual(self.image_name, created_image.name) retrieved_image = glance_utils.get_image( self.glance, image_settings=os_image_settings) self.assertIsNotNone(retrieved_image) self.assertEqual(self.image_creators[-1].get_image().size, retrieved_image.size) self.assertEqual(get_image_size(os_image_settings), retrieved_image.size) self.assertEqual(created_image.name, retrieved_image.name) self.assertEqual(created_image.id, retrieved_image.id) self.assertEqual(created_image.properties, retrieved_image.properties) else: logger.warn( 'Test not executed as the image metadata requires image files') def get_image_size(image_settings): """ Returns the expected image size :return: """ if image_settings.image_file: return os.path.getsize(image_settings.image_file) elif image_settings.url: return int(file_utils.get_content_length(image_settings.url)) else: raise Exception( 'Cannot retrieve expected image size. Image filename or URL has ' 'not been configured')
from typing import FrozenSet, Tuple import pysmt.typing as types from pysmt.environment import Environment as PysmtEnv from pysmt.fnode import FNode from utils import symb_to_next from hint import Hint, Location def transition_system(env: PysmtEnv) -> Tuple[FrozenSet[FNode], FNode, FNode, FNode]: assert isinstance(env, PysmtEnv) mgr = env.formula_manager pc = mgr.Symbol("pc", types.INT) x = mgr.Symbol("x", types.INT) y = mgr.Symbol("y", types.INT) z = mgr.Symbol("z", types.INT) x_pc = symb_to_next(mgr, pc) x_x = symb_to_next(mgr, x) x_y = symb_to_next(mgr, y) x_z = symb_to_next(mgr, z) symbols = frozenset([pc, x, y, z]) n_locs = 5 int_bound = n_locs pcs = [] x_pcs = [] ints = [mgr.Int(i) for i in range(int_bound)] for l in range(n_locs): n = ints[l] pcs.append(mgr.Equals(pc, n)) x_pcs.append(mgr.Equals(x_pc, n)) m_1 = mgr.Int(-1) pcend = mgr.Equals(pc, m_1) x_pcend = mgr.Equals(x_pc, m_1) # initial location. init = pcs[0] # control flow graph. cfg = mgr.And( # pc = -1 : -1, mgr.Implies(pcend, x_pcend), # pc = 0 & !(y >= 1) : -1, mgr.Implies(mgr.And(pcs[0], mgr.Not(mgr.GE(y, ints[1]))), x_pcend), # pc = 0 & y >= 1 : 1, mgr.Implies(mgr.And(pcs[0], mgr.GE(y, ints[1])), x_pcs[1]), # pc = 1 & !(z >= 1) : -1, mgr.Implies(mgr.And(pcs[1], mgr.Not(mgr.GE(z, ints[1]))), x_pcend), # pc = 1 & z >= 1 : 2, mgr.Implies(mgr.And(pcs[1], mgr.GE(z, ints[1])), x_pcs[2]), # pc = 2 & !(x >= 0) : -1, mgr.Implies(mgr.And(pcs[2], mgr.Not(mgr.GE(x, ints[0]))), x_pcend), # pc = 2 & x >= 0 : 3, mgr.Implies(mgr.And(pcs[2], mgr.GE(x, ints[0])), x_pcs[3]), # pc = 3 : 4, mgr.Implies(pcs[3], x_pcs[4]), # pc = 4 : 2, mgr.Implies(pcs[4], x_pcs[2])) # transition labels. labels = mgr.And( # (pc = -1 & pc' = -1) -> (x' = x & y' = y & z' = z), mgr.Implies( mgr.And(pcend, x_pcend), mgr.And(mgr.Equals(x_x, x), mgr.Equals(x_y, y), mgr.Equals(x_z, z))), # (pc = 0 & pc' = -1) -> (x' = x & y' = y & z' = z), mgr.Implies( mgr.And(pcs[0], x_pcend), mgr.And(mgr.Equals(x_x, x), mgr.Equals(x_y, y), mgr.Equals(x_z, z))), # (pc = 0 & pc' = 1) -> (x' = x & y' = y & z' = z), mgr.Implies( mgr.And(pcs[0], x_pcs[1]), mgr.And(mgr.Equals(x_x, x), mgr.Equals(x_y, y), mgr.Equals(x_z, z))), # (pc = 1 & pc' = -1) -> (x' = x & y' = y & z' = z), mgr.Implies( mgr.And(pcs[1], x_pcend), mgr.And(mgr.Equals(x_x, x), mgr.Equals(x_y, y), mgr.Equals(x_z, z))), # (pc = 1 & pc' = 2) -> (x' = x & y' = y & z' = z), mgr.Implies( mgr.And(pcs[1], x_pcs[2]), mgr.And(mgr.Equals(x_x, x), mgr.Equals(x_y, y), mgr.Equals(x_z, z))), # (pc = 2 & pc' = -1) -> (x' = x & y' = y & z' = z), mgr.Implies( mgr.And(pcs[2], x_pcend), mgr.And(mgr.Equals(x_x, x), mgr.Equals(x_y, y), mgr.Equals(x_z, z))), # (pc = 2 & pc' = 3) -> (x' = x & y' = y & z' = z), mgr.Implies( mgr.And(pcs[2], x_pcs[3]), mgr.And(mgr.Equals(x_x, x), mgr.Equals(x_y, y), mgr.Equals(x_z, z))), # (pc = 3 & pc' = 4) -> (x' = y*z - 1 & y' = y & z' = z), mgr.Implies( mgr.And(pcs[3], x_pcs[4]), mgr.And(mgr.Equals(x_x, mgr.Minus(mgr.Times(y, z), ints[1])), mgr.Equals(x_y, y), mgr.Equals(x_z, z))), # (pc = 4 & pc' = 2) -> (x' = x & y' = y+1 & z' = z), mgr.Implies( mgr.And(pcs[4], x_pcs[2]), mgr.And(mgr.Equals(x_x, x), mgr.Equals(x_y, mgr.Plus(y, ints[1])), mgr.Equals(x_z, z)))) # transition relation. trans = mgr.And(cfg, labels) # fairness. fairness = mgr.Not(pcend) return symbols, init, trans, fairness def hints(env: PysmtEnv) -> FrozenSet[Hint]: assert isinstance(env, PysmtEnv) mgr = env.formula_manager pc = mgr.Symbol("pc", types.INT) x = mgr.Symbol("x", types.INT) y = mgr.Symbol("y", types.INT) z = mgr.Symbol("z", types.INT) symbs = frozenset([pc, x, y, z]) x_pc = symb_to_next(mgr, pc) x_x = symb_to_next(mgr, x) x_y = symb_to_next(mgr, y) x_z = symb_to_next(mgr, z) res = [] i_0 = mgr.Int(0) i_1 = mgr.Int(1) i_2 = mgr.Int(2) i_3 = mgr.Int(3) loc0 = Location(env, mgr.Equals(pc, i_2)) loc0.set_progress(1, mgr.GT(x_pc, i_2)) loc1 = Location(env, mgr.GE(pc, i_3)) loc1.set_progress(0, mgr.Equals(x_pc, i_2)) h_pc = Hint("h_pc3", env, frozenset([pc]), symbs) h_pc.set_locs([loc0, loc1]) res.append(h_pc) stutter = mgr.Equals(x_x, x) loc0 = Location(env, mgr.GT(x, i_0), mgr.And(mgr.GT(y, i_1), mgr.GT(z, i_1))) loc0.set_progress(1, mgr.GE(x_x, mgr.Minus(mgr.Times(y, z), i_1))) loc1 = Location(env, mgr.GT(x, i_0)) loc1.set_progress(0, mgr.Equals(x_x, mgr.Plus(x, i_1))) h_x = Hint("h_x2", env, frozenset([x]), symbs) h_x.set_locs([loc0, loc1]) res.append(h_x) loc0 = Location(env, mgr.GE(z, i_3), mgr.GE(y, i_0)) loc0.set_progress(1, mgr.Equals(x_z, y)) loc1 = Location(env, mgr.GE(z, i_0), mgr.GE(x, i_3)) loc1.set_progress(0, mgr.GE(x_z, mgr.Plus(z, x))) h_z = Hint("h_z3", env, frozenset([z]), symbs) h_z.set_locs([loc0, loc1]) res.append(h_z) loc0 = Location(env, mgr.GE(y, i_3)) loc0.set_progress(1, mgr.Equals(x_y, mgr.Plus(y, i_1))) loc1 = Location(env, mgr.GE(y, i_3), mgr.GE(x, i_2)) loc1.set_progress(0, mgr.Equals(x_y, mgr.Plus(y, x))) h_y = Hint("h_y3", env, frozenset([y]), symbs) h_y.set_locs([loc0, loc1]) res.append(h_y) loc0 = Location(env, mgr.GT(x, i_3), mgr.And(mgr.GT(y, i_1), mgr.GT(z, i_1))) loc0.set_progress(1, mgr.GE(x_x, mgr.Minus(mgr.Times(y, z), i_1))) loc1 = Location(env, mgr.GT(x, i_0), mgr.GE(y, i_1)) loc1.set_progress(0, mgr.Equals(x_x, mgr.Plus(x, y))) h_x = Hint("h_x3", env, frozenset([x]), symbs) h_x.set_locs([loc0, loc1]) res.append(h_x) loc0 = Location(env, mgr.GE(z, i_3)) loc0.set_progress(0, mgr.GT(x_z, z)) h_z = Hint("h_z1", env, frozenset([z]), symbs) h_z.set_locs([loc0]) res.append(h_z) loc0 = Location(env, mgr.GE(y, i_3)) loc0.set_progress(1, mgr.Equals(x_y, mgr.Plus(y, i_1))) loc1 = Location(env, mgr.GE(y, i_3)) loc1.set_progress(2, mgr.Equals(x_y, y)) loc2 = Location(env, mgr.GE(y, i_3)) loc2.set_progress(2, mgr.Equals(x_y, mgr.Plus(y, i_1))) h_y = Hint("h_y4", env, frozenset([y]), symbs) h_y.set_locs([loc0, loc1, loc2]) res.append(h_y) loc = Location(env, mgr.LE(z, i_0)) loc.set_progress(0, mgr.Equals(x_z, z)) h_z = Hint("h_z0", env, frozenset([z]), symbs) h_z.set_locs([loc]) res.append(h_z) loc0 = Location(env, mgr.GE(z, i_0)) loc0.set_progress(1, mgr.Equals(x_z, z)) loc1 = Location(env, mgr.GE(z, i_0)) loc1.set_progress(0, mgr.Equals(x_z, mgr.Plus(z, i_3))) h_z = Hint("h_z4", env, frozenset([z]), symbs) h_z.set_locs([loc0, loc1]) res.append(h_z) stutter = mgr.Equals(x_y, y) loc0 = Location(env, mgr.GE(y, i_3)) loc0.set_progress(1, mgr.Equals(x_y, mgr.Plus(y, i_1))) loc1 = Location(env, mgr.GE(y, i_3), mgr.GE(z, i_2)) loc1.set_progress(0, mgr.Equals(x_y, mgr.Plus(y, z))) h_y = Hint("h_y2", env, frozenset([y]), symbs) h_y.set_locs([loc0, loc1]) res.append(h_y) return frozenset(res)
#!/usr/bin/env python # (c) Crown Owned Copyright, 2016. Dstl. import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lighthouse.settings") from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)
from extensions import db from models.item_data_type import ItemDataType from models.label import Label from models.task import Task class Project(db.Model): id = db.Column(db.String(80), primary_key=True, nullable=False) # 1(Project)-to-1(organisation) org_id = db.Column(db.String(80), db.ForeignKey('organisation.id'), nullable=False) project_name = db.Column(db.String(80), nullable=False) item_data_type = db.Column(db.Enum(ItemDataType), nullable=False) layout = db.Column(db.JSON, nullable=False) outsource_labelling = db.Column(db.Boolean, nullable=False) created_at = db.Column(db.DateTime(), nullable=False) # parent 1-to-many w Task tasks = db.relationship('Task', backref='task', lazy=True) # parent 1-to-many w ProjectManager project_managers = db.relationship('ProjectManager', backref='project', lazy=True) def __repr__(self): return f"<Project {self.id} | {self.project_name} | Organisation : {self.org_id}>" def to_response(self): return { "id": self.id, "orgId": self.org_id, "projectName": self.project_name, "itemDataType": self.item_data_type.name, "layout": self.layout, "outsourceLabelling": self.outsource_labelling, "tasks": [t.to_response_without_item_data() for t in self.tasks], "projectManagers": [pm.to_response() for pm in self.project_managers], "created_at": self.created_at } def to_project_for_user_response(self, user_id): return { "id": self.id, "orgId": self.org_id, "projectName": self.project_name, "itemDataType": self.item_data_type.name, "layout": self.layout, "outsourceLabelling": self.outsource_labelling, "tasksLabelled": [t.to_response_with_labels_from_user(user_id) for t in self.tasks_and_labels_from_user(user_id)], "projectManagers": [pm.to_response() for pm in self.project_managers], "created_at": self.created_at } def to_created_project_response(self): return { "id": self.id, "orgId": self.org_id, "projectName": self.project_name, "itemDataType": self.item_data_type.name, "layout": self.layout, "outsourceLabelling": self.outsource_labelling, "tasks": [t.to_response_without_item_data() for t in self.tasks], "projectManagers": [pm.to_response() for pm in self.project_managers], "tasksCount": self.calculate_number_of_tasks(), "overallPercentage": self.calculate_tasks_labelled_percentage(), "created_at": self.created_at } def to_contributed_project_response(self, user_id): return { "id": self.id, "orgId": self.org_id, "projectName": self.project_name, "itemDataType": self.item_data_type.name, "layout": self.layout, "outsourceLabelling": self.outsource_labelling, "tasks": [t.to_response_without_item_data() for t in self.tasks], "projectManagers": [pm.to_response() for pm in self.project_managers], "tasksCount": self.calculate_number_of_tasks(), "overallPercentage": self.calculate_tasks_labelled_percentage(), "contributionCount": self.calculate_tasks_labelled_by_user(user_id), "contributionPercentage": self.calculate_tasks_labelled_percentage_by_user(user_id), "created_at": self.created_at } def tasks_and_labels_from_user(self, user_id): resulting_tasks = [] for task in self.tasks: for label in task.labels: if label.user_id == user_id: resulting_tasks.append(task) break return resulting_tasks def calculate_number_of_tasks(self): return len(self.tasks) def calculate_tasks_labelled_percentage(self): """ Count % of tasks that have >= 1 label """ number_of_tasks = self.calculate_number_of_tasks() if not number_of_tasks: # When there are no tasks return 0 num_labelled = len([task for task in self.tasks if len(task.labels) > 0]) return round(float((num_labelled / number_of_tasks * 100)), 1) def calculate_tasks_labelled_percentage_by_user(self, user_id): """ Count % of tasks that a user has labelled """ number_of_tasks = self.calculate_number_of_tasks() if not number_of_tasks: # When there are no tasks return 0 num_labelled_by_user = self.calculate_tasks_labelled_by_user(user_id) return round(float((num_labelled_by_user / number_of_tasks) * 100), 1) def calculate_tasks_labelled_by_user(self, user_id): """ Count number of tasks that a user has labelled """ tasks_by_user = db.session.query(Task).filter_by(project_id=self.id).join(Label).filter_by( user_id=user_id).all() num_labelled = len(tasks_by_user) return num_labelled
# -*- coding: utf-8 -* import numpy as np from loguru import logger import torch import torch.nn as nn import torch.nn.functional as F from videoanalyst.model.common_opr.common_block import (conv_bn_relu, xcorr_depthwise) from videoanalyst.model.module_base import ModuleBase from videoanalyst.model.task_model.taskmodel_base import (TRACK_TASKMODELS, VOS_TASKMODELS) torch.set_printoptions(precision=8) @TRACK_TASKMODELS.register @VOS_TASKMODELS.register class SiamTrack(ModuleBase): r""" SiamTrack model for tracking Hyper-Parameters ---------------- pretrain_model_path: string path to parameter to be loaded into module head_width: int feature width in head structure """ default_hyper_params = dict(pretrain_model_path="", head_width=256, conv_weight_std=0.01, neck_conv_bias=[True, True, True, True], corr_fea_output=False, trt_mode=False, trt_fea_model_path="", trt_track_model_path="") support_phases = ["train", "feature", "track", "freeze_track_fea"] def __init__(self, backbone, head, loss=None): super(SiamTrack, self).__init__() self.basemodel = backbone self.head = head self.loss = loss self.trt_fea_model = None self.trt_track_model = None self._phase = "train" @property def phase(self): return self._phase @phase.setter def phase(self, p): assert p in self.support_phases self._phase = p def forward(self, *args, phase=None): r""" Perform tracking process for different phases (e.g. train / init / track) Arguments --------- target_img: torch.Tensor target template image patch search_img: torch.Tensor search region image patch Returns ------- fcos_score_final: torch.Tensor predicted score for bboxes, shape=(B, HW, 1) fcos_bbox_final: torch.Tensor predicted bbox in the crop, shape=(B, HW, 4) fcos_cls_prob_final: torch.Tensor classification score, shape=(B, HW, 1) fcos_ctr_prob_final: torch.Tensor center-ness score, shape=(B, HW, 1) """ if phase is None: phase = self._phase # used during training if phase == 'train': # resolve training data training_data = args[0] target_img = training_data["im_z"] search_img = training_data["im_x"] # backbone feature f_z = self.basemodel(target_img) f_x = self.basemodel(search_img) # feature adjustment c_z_k = self.c_z_k(f_z) r_z_k = self.r_z_k(f_z) c_x = self.c_x(f_x) r_x = self.r_x(f_x) # feature matching r_out = xcorr_depthwise(r_x, r_z_k) c_out = xcorr_depthwise(c_x, c_z_k) # head fcos_cls_score_final, fcos_ctr_score_final, fcos_bbox_final, corr_fea = self.head( c_out, r_out) predict_data = dict( cls_pred=fcos_cls_score_final, ctr_pred=fcos_ctr_score_final, box_pred=fcos_bbox_final, ) if self._hyper_params["corr_fea_output"]: predict_data["corr_fea"] = corr_fea return predict_data # used for template feature extraction (normal mode) elif phase == 'feature': target_img, = args if self._hyper_params["trt_mode"]: # extract feature with trt model out_list = self.trt_fea_model(target_img) else: # backbone feature f_z = self.basemodel(target_img) # template as kernel c_z_k = self.c_z_k(f_z) r_z_k = self.r_z_k(f_z) # output out_list = [c_z_k, r_z_k] # used for template feature extraction (trt mode) elif phase == "freeze_track_fea": search_img, = args # backbone feature f_x = self.basemodel(search_img) # feature adjustment c_x = self.c_x(f_x) r_x = self.r_x(f_x) # head return [c_x, r_x] # [Broken] used for template feature extraction (trt mode) # currently broken due to following issue of "torch2trt" package # c.f. https://github.com/NVIDIA-AI-IOT/torch2trt/issues/251 elif phase == "freeze_track_head": c_out, r_out = args # head outputs = self.head(c_out, r_out, 0, True) return outputs # used for tracking one frame during test elif phase == 'track': if len(args) == 3: search_img, c_z_k, r_z_k = args if self._hyper_params["trt_mode"]: c_x, r_x = self.trt_track_model(search_img) else: # backbone feature f_x = self.basemodel(search_img) # feature adjustment c_x = self.c_x(f_x) r_x = self.r_x(f_x) elif len(args) == 4: # c_x, r_x already computed c_z_k, r_z_k, c_x, r_x = args else: raise ValueError("Illegal args length: %d" % len(args)) # feature matching r_out = xcorr_depthwise(r_x, r_z_k) c_out = xcorr_depthwise(c_x, c_z_k) # head fcos_cls_score_final, fcos_ctr_score_final, fcos_bbox_final, corr_fea = self.head( c_out, r_out, search_img.size(-1)) # apply sigmoid fcos_cls_prob_final = torch.sigmoid(fcos_cls_score_final) fcos_ctr_prob_final = torch.sigmoid(fcos_ctr_score_final) # apply centerness correction fcos_score_final = fcos_cls_prob_final * fcos_ctr_prob_final # register extra output extra = dict(c_x=c_x, r_x=r_x, corr_fea=corr_fea) # output out_list = fcos_score_final, fcos_bbox_final, fcos_cls_prob_final, fcos_ctr_prob_final, extra else: raise ValueError("Phase non-implemented.") return out_list def update_params(self): r""" Load model parameters """ self._make_convs() self._initialize_conv() super().update_params() if self._hyper_params["trt_mode"]: logger.info("trt mode enable") from torch2trt import TRTModule self.trt_fea_model = TRTModule() self.trt_fea_model.load_state_dict( torch.load(self._hyper_params["trt_fea_model_path"])) self.trt_track_model = TRTModule() self.trt_track_model.load_state_dict( torch.load(self._hyper_params["trt_track_model_path"])) logger.info("loading trt model succefully") def _make_convs(self): head_width = self._hyper_params['head_width'] # feature adjustment self.r_z_k = conv_bn_relu(head_width, head_width, 1, 3, 0, has_relu=False) self.c_z_k = conv_bn_relu(head_width, head_width, 1, 3, 0, has_relu=False) self.r_x = conv_bn_relu(head_width, head_width, 1, 3, 0, has_relu=False) self.c_x = conv_bn_relu(head_width, head_width, 1, 3, 0, has_relu=False) def _initialize_conv(self, ): conv_weight_std = self._hyper_params['conv_weight_std'] conv_list = [ self.r_z_k.conv, self.c_z_k.conv, self.r_x.conv, self.c_x.conv ] for ith in range(len(conv_list)): conv = conv_list[ith] torch.nn.init.normal_(conv.weight, std=conv_weight_std) # conv_weight_std=0.01 def set_device(self, dev): if not isinstance(dev, torch.device): dev = torch.device(dev) self.to(dev) if self.loss is not None: for loss_name in self.loss: self.loss[loss_name].to(dev)
from __future__ import unicode_literals import re from .common import InfoExtractor from ..compat import compat_str from ..utils import ( ExtractorError, int_or_none, str_to_int, unified_strdate, ) class RedTubeIE(InfoExtractor): _VALID_URL = r'https?://(?:(?:www\.)?redtube\.com/|embed\.redtube\.com/\?.*?\bid=)(?P<id>[0-9]+)' _TESTS = [{ 'url': 'http://www.redtube.com/66418', 'md5': '7b8c22b5e7098a3e1c09709df1126d2d', 'info_dict': { 'id': '66418', 'ext': 'mp4', 'title': 'Sucked on a toilet', 'upload_date': '20120831', 'duration': 596, 'view_count': int, 'age_limit': 18, } }, { 'url': 'http://embed.redtube.com/?bgcolor=000000&id=1443286', 'only_matching': True, }] @staticmethod def _extract_urls(webpage): return re.findall( r'<iframe[^>]+?src=["\'](?P<url>(?:https?:)?//embed\.redtube\.com/\?.*?\bid=\d+)', webpage) def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage( 'http://www.redtube.com/%s' % video_id, video_id) if any(s in webpage for s in ['video-deleted-info', '>This video has been removed']): raise ExtractorError('Video %s has been removed' % video_id, expected=True) title = self._html_search_regex( (r'<h1 class="videoTitle[^"]*">(?P<title>.+?)</h1>', r'videoTitle\s*:\s*(["\'])(?P<title>)\1'), webpage, 'title', group='title') formats = [] sources = self._parse_json( self._search_regex( r'sources\s*:\s*({.+?})', webpage, 'source', default='{}'), video_id, fatal=False) if sources and isinstance(sources, dict): for format_id, format_url in sources.items(): if format_url: formats.append({ 'url': format_url, 'format_id': format_id, 'height': int_or_none(format_id), }) medias = self._parse_json( self._search_regex( r'mediaDefinition\s*:\s*(\[.+?\])', webpage, 'media definitions', default='{}'), video_id, fatal=False) if medias and isinstance(medias, list): for media in medias: format_url = media.get('videoUrl') if not format_url or not isinstance(format_url, compat_str): continue format_id = media.get('quality') formats.append({ 'url': format_url, 'format_id': format_id, 'height': int_or_none(format_id), }) if not formats: video_url = self._html_search_regex( r'<source src="(.+?)" type="video/mp4">', webpage, 'video URL') formats.append({'url': video_url}) self._sort_formats(formats) thumbnail = self._og_search_thumbnail(webpage) upload_date = unified_strdate(self._search_regex( r'<span[^>]+class="added-time"[^>]*>ADDED ([^<]+)<', webpage, 'upload date', fatal=False)) duration = int_or_none(self._search_regex( r'videoDuration\s*:\s*(\d+)', webpage, 'duration', default=None)) view_count = str_to_int(self._search_regex( r'<span[^>]*>VIEWS</span></td>\s*<td>([\d,.]+)', webpage, 'view count', fatal=False)) # No self-labeling, but they describe themselves as # "Home of Videos Porno" age_limit = 18 return { 'id': video_id, 'ext': 'mp4', 'title': title, 'thumbnail': thumbnail, 'upload_date': upload_date, 'duration': duration, 'view_count': view_count, 'age_limit': age_limit, 'formats': formats, }
from Cython.Build import cythonize import numpy as np from distutils.core import setup setup(ext_modules=cythonize(["bbox.pyx","cython_nms.pyx"],include_path=[np.get_include()] ))
# -*- coding: utf-8 -*- # ***************************************************************************** # NICOS, the Networked Instrument Control System of the MLZ # Copyright (c) 2009-2021 by the NICOS contributors (see AUTHORS) # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Module authors: # Georg Brandl <g.brandl@fz-juelich.de> # Christian Felder <c.felder@fz-juelich.de> # # ***************************************************************************** """Support for "auxiliary" windows containing panels.""" from time import time as currenttime from nicos.clients.gui.config import panel from nicos.clients.gui.utils import DlgUtils, SettingGroup from nicos.guisupport.qt import QDialog, QHBoxLayout, QObject, QPainter, \ QPalette, QStyle, QStyleOption, QWidget, pyqtSignal from nicos.utils import checkSetupSpec from nicos.utils.loggers import NicosLogger class SetupDepWindowMixin: def __init__(self, client): if 'session/mastersetup' not in client._reg_keys: return values = client.ask('getcachekeys', 'session/mastersetup', quiet=True, default=[]) for key, value in values: if key == 'session/mastersetup': currtime = currenttime() for widget in client._reg_keys[key]: if widget(): widget().on_keyChange(key, value, currtime, False) class PanelDialog(SetupDepWindowMixin, QDialog): def __init__(self, parent, client, panelcfg, title, **options): from nicos.clients.gui.panels.utils import createWindowItem QDialog.__init__(self, parent) self.panels = [] self.mainwindow = parent.mainwindow self.log = NicosLogger('PanelDialog') self.log.parent = self.mainwindow.log self.client = client self.user_color = self.palette().color(QPalette.Base) self.user_font = self.font() if isinstance(panelcfg, type) and issubclass(panelcfg, Panel): panelcfg = panel('%s.%s' % (panelcfg.__module__, panelcfg.__name__), **options) elif isinstance(panelcfg, str): panelcfg = panel(panelcfg, **options) hbox = QHBoxLayout() hbox.setContentsMargins(0, 0, 0, 0) pnl = createWindowItem(panelcfg, self, self, self.mainwindow, self.log) if pnl: hbox.addWidget(pnl) self.setLayout(hbox) self.setWindowTitle(title) SetupDepWindowMixin.__init__(self, self.client) self.setProperty('type', 'PanelDialog') def addPanel(self, panel, always=True): if always or panel not in self.panels: self.panels.append(panel) class SetupDepPanelMixin(QObject): """Mixin to handle setup-dependent visibility. Note: You must explicity add the following class attribute in all classes using this mixin (A PyQt resctriction, see https://riverbankcomputing.com/pipermail/pyqt/2013-September/033199.html): `setWidgetVisible = SetupDepPanelMixin.setWidgetVisible` """ setupSpec = () setWidgetVisible = pyqtSignal(QWidget, bool, name='setWidgetVisible') def __init__(self, client, options): # pylint: disable=super-init-not-called setups = options.get('setups', '') self.setSetups(setups) client.register(self, 'session/mastersetup') def setSetups(self, setupSpec): self.setupSpec = setupSpec self.log.debug('setups are: %r', self.setupSpec) checkSetupSpec(self.setupSpec, '', log=self.log) def on_keyChange(self, key, value, time, expired): if key == 'session/mastersetup' and self.setupSpec: if hasattr(self, 'setWidgetVisible'): enabled = checkSetupSpec(self.setupSpec, value, log=self.log) self.setWidgetVisible.emit(self, enabled) class Panel(DlgUtils, QWidget, SetupDepPanelMixin): panelName = '' setWidgetVisible = SetupDepPanelMixin.setWidgetVisible def __init__(self, parent, client, options): QWidget.__init__(self, parent) self.log = NicosLogger(self.panelName) self.log.parent = parent.mainwindow.log SetupDepPanelMixin.__init__(self, client, options) DlgUtils.__init__(self, self.panelName) self.parentwindow = parent self.client = client self.mainwindow = parent.mainwindow self.actions = set() self.sgroup = SettingGroup(self.panelName) with self.sgroup as settings: self.loadSettings(settings) self.setProperty('type', 'Panel') self.setProperty('panel', self.__class__.__name__) def closeWindow(self): """Try to close the window containing this panel. If the window is the main window, nothing will be done. """ from nicos.clients.gui.panels.tabwidget import DetachedWindow from nicos.clients.gui.panels.auxwindows import AuxiliaryWindow obj = self while hasattr(obj, 'parent'): obj = obj.parent() if isinstance(obj, (DetachedWindow, AuxiliaryWindow, PanelDialog)): obj.close() return def postInit(self): """This method can be implemented to perform actions after **all** panels have been created. This can be useful e.g. for accessing other panels using their unique ``panelName``. """ def setExpertMode(self, expert): pass def setViewOnly(self, viewonly): pass def loadSettings(self, settings): pass def saveSettings(self, settings): pass def setCustomStyle(self, font, back): pass def getToolbars(self): return [] def getMenus(self): return [] def hideTitle(self): """Called when the panel is shown in a dock or tab widget, which provides its own place for the panel title. If the panel has a title widget, it should hide it in this method. """ def requestClose(self): return True def updateStatus(self, status, exception=False): pass def paintEvent(self, event): opt = QStyleOption() opt.initFrom(self) painter = QPainter(self) self.style().drawPrimitive(QStyle.PE_Widget, opt, painter, self)