Search is not available for this dataset
text
stringlengths
75
104k
def fit(self, X, y, cost_mat): """ Build a example-dependent cost-sensitive logistic regression from the training set (X, y, cost_mat) Parameters ---------- X : array-like of shape = [n_samples, n_features] The input samples. y : array indicator matrix G...
def predict_proba(self, X): """Probability estimates. The returned estimates. Parameters ---------- X : array-like, shape = [n_samples, n_features] Returns ------- T : array-like, shape = [n_samples, 2] Returns the probability of the sample ...
def predict(self, X, cut_point=0.5): """Predicted class. Parameters ---------- X : array-like, shape = [n_samples, n_features] Returns ------- T : array-like, shape = [n_samples] Returns the prediction of the sample.. """ return np.fl...
def list_tags(userdata): """List all used macros within a UserData script. :param userdata: The UserData script. :type userdata: str """ macros = re.findall('@(.*?)@', userdata) logging.info('List of available macros:') for macro in macros: logging.in...
def handle_tags(userdata, macros): """Insert macro values or auto export variables in UserData scripts. :param userdata: The UserData script. :type userdata: str :param macros: UserData macros as key value pair. :type macros: dict :return: UserData script with the macros...
def handle_import_tags(userdata, import_root): """Handle @import(filepath)@ tags in a UserData script. :param import_root: Location for imports. :type import_root: str :param userdata: UserData script content. :type userdata: str :return: UserData script with the content...
def retry_on_ec2_error(self, func, *args, **kwargs): """ Call the given method with the given arguments, retrying if the call failed due to an EC2ResponseError. This method will wait at most 30 seconds and perform up to 6 retries. If the method still fails, it will propagate the ...
def connect(self, region, **kw_params): """Connect to a EC2. :param region: The name of the region to connect to. :type region: str :param kw_params: :type kw_params: dict """ self.ec2 = boto.ec2.connect_to_region(region, **kw_params) if not self.ec2: ...
def resolve_image_name(self, image_name): """Look up an AMI for the connected region based on an image name. :param image_name: The name of the image to resolve. :type image_name: str :return: The AMI for the given image. :rtype: str """ # look at each scope in o...
def create_on_demand(self, instance_type='default', tags=None, root_device_type='ebs', size='default', vol_type='gp2', delete_on_termination=False): """Create one...
def create_spot_requests(self, price, instance_type='default', root_device_type='ebs', size='default', vol_type='gp2', delete_on_termination=False...
def check_spot_requests(self, requests, tags=None): """Check status of one or more EC2 spot instance requests. :param requests: List of EC2 spot instance request IDs. :type requests: list :param tags: :type tags: dict :return: List of boto.ec2.instance.Instance's created...
def cancel_spot_requests(self, requests): """Cancel one or more EC2 spot instance requests. :param requests: List of EC2 spot instance request IDs. :type requests: list """ ec2_requests = self.retry_on_ec2_error(self.ec2.get_all_spot_instance_requests, request_ids=requests) ...
def create_spot(self, price, instance_type='default', tags=None, root_device_type='ebs', size='default', vol_type='gp2', delete_on_termination=False, timeout=No...
def _scale_down(self, instances, count): """Return a list of |count| last created instances by launch time. :param instances: A list of instances. :type instances: list :param count: Number of instances to scale down. :type count: integer :return: List of instances to be...
def _get_default_name_size(self, instance_type, size): """Checks if root device name/size were specified in the image definition. :param instance_type: A section name in amazon.json. :type instance_type: str :param size: :type size: int :return: Root device name and size...
def _configure_ebs_volume(self, vol_type, name, size, delete_on_termination): """Sets the desired root EBS size, otherwise the default EC2 value is used. :param vol_type: Type of EBS storage - gp2 (SSD), io1 or standard (magnetic) :type vol_type: str :param size: Desired root EBS size. ...
def stop(self, instances, count=0): """Stop each provided running instance. :param count: :param instances: A list of instances. :type instances: list """ if not instances: return if count > 0: instances = self._scale_down(instances, count...
def terminate(self, instances, count=0): """Terminate each provided running or stopped instance. :param count: :param instances: A list of instances. :type instances: list """ if not instances: return if count > 0: instances = self._scale_...
def find(self, instance_ids=None, filters=None): """Flatten list of reservations to a list of instances. :param instance_ids: A list of instance ids to filter by :type instance_ids: list :param filters: A dict of Filter.N values defined in http://goo.gl/jYNej9 :type filters: dic...
def load(self, root, module_path, pkg_name): """Load modules dynamically. """ root = os.path.join(root, module_path) import_name = os.path.join(pkg_name, module_path).replace(os.sep, '.') for (_, name, _) in pkgutil.iter_modules([root]): self.modules[name] = import_mo...
def command_line_interfaces(self): """Return the CommandLine classes from each provider. """ interfaces = [] for _, module in self.modules.items(): for entry in dir(module): if entry.endswith('CommandLine'): interfaces.append((module, entry...
def pluralize(item): """Nothing to see here. """ assert isinstance(item, (int, list)) if isinstance(item, int): return 's' if item > 1 else '' if isinstance(item, list): return 's' if len(item) > 1 else '' return ''
def validate(self): """Perform some basic configuration validation. """ if not self.conf.get('auth_token'): raise PacketManagerException('The auth token for Packet is not defined but required.') if not self.conf.get('projects'): raise PacketManagerException('Requi...
def print_projects(self, projects): """Print method for projects. """ for project in projects: print('{}: {}'.format(project.name, project.id))
def print_operating_systems(self, operating_systems): """Print method for operating systems. """ for _os in operating_systems: print('{}: {}'.format(_os.name, _os.slug))
def print_plans(self, plans): """Print method for plans. """ for plan in plans: print('Name: {} "{}" Price: {} USD'.format(plan.name, plan.slug, plan.pricing['hour'])) self.pprint(plan.specs) print('\n')
def print_facilities(self, facilities): """Print method for facilities. """ for facility in facilities: print('{} - ({}): {}'.format(facility.code, facility.name, ",".join(facility.features)))
def list_devices(self, project_id, conditions=None, params=None): """Retrieve list of devices in a project by one of more conditions. """ default_params = {'per_page': 1000} if params: default_params.update(params) data = self.api('projects/%s/devices' % project_id, p...
def print_devices(self, devices): """Print method for devices. """ for device in devices: print('ID: {} OS: {} IP: {} State: {} ({}) Tags: {}' .format(device.id, device.operating_system.slug, self.get_public_ip(dev...
def filter(criterias, devices): # pylint: disable=too-many-branches """Filter a device by criterias on the root level of the dictionary. """ if not criterias: return devices result = [] for device in devices: # pylint: disable=too-many-nested-blocks for ...
def get_public_ip(addresses, version=4): """Return either the devices public IPv4 or IPv6 address. """ for addr in addresses: if addr['public'] and addr['address_family'] == version: return addr.get('address') return None
def validate_capacity(self, servers): """Validates if a deploy can be fulfilled. """ try: return self.manager.validate_capacity(servers) except packet.baseapi.Error as msg: raise PacketManagerException(msg)
def create_volume(self, project_id, plan, size, facility, label=""): """Creates a new volume. """ try: return self.manager.create_volume(project_id, label, plan, size, facility) except packet.baseapi.Error as msg: raise PacketManagerException(msg)
def attach_volume_to_device(self, volume_id, device_id): """Attaches the created Volume to a Device. """ try: volume = self.manager.get_volume(volume_id) volume.attach(device_id) except packet.baseapi.Error as msg: raise PacketManagerException(msg) ...
def create_demand(self, project_id, facility, plan, operating_system, tags=None, userdata='', hostname=None, count=1): """Create a new o...
def stop(self, devices): """Power-Off one or more running devices. """ for device in devices: self.logger.info('Stopping: %s', device.id) try: device.power_off() except packet.baseapi.Error: raise PacketManagerException('Unable ...
def reboot(self, devices): """Reboot one or more devices. """ for device in devices: self.logger.info('Rebooting: %s', device.id) try: device.reboot() except packet.baseapi.Error: raise PacketManagerException('Unable to reboot i...
def terminate(self, devices): """Terminate one or more running or stopped instances. """ for device in devices: self.logger.info('Terminating: %s', device.id) try: device.delete() except packet.baseapi.Error: raise PacketManager...
def parse_args(cls): """Main argument parser of Laniakea. """ # Initialize configuration and userdata directories. dirs = appdirs.AppDirs(__title__, 'Mozilla Security') if not os.path.isdir(dirs.user_config_dir): shutil.copytree(os.path.join(cls.HOME, 'examples'), dir...
def main(cls): """Main entry point of Laniakea. """ args = cls.parse_args() if args.focus: Focus.init() else: Focus.disable() logging.basicConfig(format='[Laniakea] %(asctime)s %(levelname)s: %(message)s', level=args.v...
def tags(self, tags=None): """Filter by tags. :param tags: Tags to filter. :type tags: ``list`` :return: A list of Node objects. :rtype: ``list`` of :class:`Node` """ if tags is None or not tags: return self nodes = [] for node in...
def state(self, states=None): """Filter by state. :param tags: States to filter. :type tags: ``list`` :return: A list of Node objects. :rtype: ``list`` of :class:`Node` """ if states is None or not states: return self nodes = [] f...
def name(self, names=None): """Filter by node name. :param names: Node names to filter. :type names: ``list`` :return: A list of Node objects. :rtype: ``list`` of :class:`Node` """ if names is None or not names: return self nodes = [] ...
def is_preemptible(self): """Filter by preemptible scheduling. :return: A list of Node objects. :rtype: ``list`` of :class:`Node` """ nodes = [] for node in self.nodes: if Kurz.is_preemtible(node): nodes.append(node) return self
def expr(self, callback): """Filter by custom expression. :param callback: Callback for custom expression. :type name: ``function`` :return: A list of Node objects. :rtype: ``list`` of :class:`Node` """ nodes = [] for node in self.nodes: ...
def connect(self, **kwargs): """Connect to Google Compute Engine. """ try: self.gce = get_driver(Provider.GCE)( self.user_id, self.key, project=self.project, **kwargs) except: raise ComputeEngineManag...
def is_connected(self, attempts=3): """Try to reconnect if neccessary. :param attempts: The amount of tries to reconnect if neccessary. :type attempts: ``int`` """ if self.gce is None: while attempts > 0: self.logger.info("Attempting to connect ....
def create(self, size, number, meta, name=None, image=None, attempts=3): """Create container VM nodes. Uses a container declaration which is undocumented. :param size: The machine type to use. :type size: ``str`` or :class:`GCENodeSize` :param number: Amount of nodes to be spawn...
def stop(self, nodes=None): """Stop one or many nodes. :param nodes: Nodes to be stopped. :type nodes: ``list`` """ if not self.is_connected(): return None nodes = nodes or self.nodes result = [] for node in nodes: if node.s...
def start(self, nodes=None): """Start one or many nodes. :param nodes: Nodes to be started. :type nodes: ``list`` """ if not self.is_connected(): return None nodes = nodes or self.nodes result = [] for node in nodes: if node...
def reboot(self, nodes=None): """Reboot one or many nodes. :param nodes: Nodes to be rebooted. :type nodes: ``list`` """ if not self.is_connected(): return None nodes = nodes or self.nodes result = [] for node in nodes: if n...
def terminate(self, nodes=None): """Destroy one or many nodes. :param nodes: Nodes to be destroyed. :type nodes: ``list`` :return: List of nodes which failed to terminate. :rtype: ``list`` """ if not self.is_connected(): return None no...
def terminate_with_threads(self, nodes=None): """Destroy one or many nodes threaded. :param nodes: Nodes to be destroyed. :type nodes: ``list`` :return: List of nodes which failed to terminate. :rtype: ``list`` """ if not self.is_connected(): r...
def terminate_ex(self, nodes, threads=False, attempts=3): """Wrapper method for terminate. :param nodes: Nodes to be destroyed. :type nodes: ``list`` :param attempts: The amount of attempts for retrying to terminate failed instances. :type attempts: ``int`` :...
def build_bootdisk(self, image, size=10, auto_delete=True): """Buid a disk struct. :param image: Base image name. :type image: ``str`` :param size: Persistent disk size. :type size: ``int`` :param auto_delete: Wether to auto delete disk on instance termination. ...
def build_container_vm(self, container, disk, zone="us-east1-b", tags=None, preemptible=True): """Build kwargs for a container VM. :param container: Container declaration. :type container: ``dict`` :param disk: Disk definition structure. :type disk: ``dict`` ...
def filter(self, zone='all'): """Filter nodes by their attributes. :param zone: A zone containing nodes. :type zone: ``str`` :return: A chainable filter object. :rtype: ``object`` of :class:`Filter` """ if not self.is_connected(): return None ...
def add_arguments(cls, subparsers, dirs): """Argument parser of this module. """ parser = subparsers.add_parser( 'packet', help='Packet Bare Metal', formatter_class=lambda prog: argparse.ArgumentDefaultsHelpFormatter(prog, max_help_position=40, width=120)) ...
def main(cls, args, settings=None, userdata=None): # pylint: disable=too-many-branches,too-many-statements """Main entry point of this module. """ # Packet Configuration logger.info('Using Packet configuration from %s', Focus.info(args.conf.name)) try: conf = json.loa...
def main(cls, args, settings=None, userdata=None): # pylint: disable=too-many-branches,too-many-statements """Main entry point of this module. """ # The command-line client uses Service Account authentication. logger.info('Using Compute Engine credentials from %s', Focus.info(args.conf....
def anglesep_meeus(lon0: float, lat0: float, lon1: float, lat1: float, deg: bool = True) -> float: """ Parameters ---------- lon0 : float or numpy.ndarray of float longitude of first point lat0 : float or numpy.ndarray of float latitude of first point lon1 : f...
def anglesep(lon0: float, lat0: float, lon1: float, lat1: float, deg: bool = True) -> float: """ Parameters ---------- lon0 : float longitude of first point lat0 : float latitude of first point lon1 : float longitude of second point lat1 : float ...
def azel2radec(az_deg: float, el_deg: float, lat_deg: float, lon_deg: float, time: datetime, usevallado: bool = False) -> Tuple[float, float]: """ viewing angle (az, el) to sky coordinates (ra, dec) Parameters ---------- az_deg : float or numpy.ndarray of float ...
def radec2azel(ra_deg: float, dec_deg: float, lat_deg: float, lon_deg: float, time: datetime, usevallado: bool = False) -> Tuple[float, float]: """ sky coordinates (ra, dec) to viewing angle (az, el) Parameters ---------- ra_deg : float or numpy.ndarray of float ...
def lookAtSpheroid(lat0: float, lon0: float, h0: float, az: float, tilt: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ Calculates line-of-sight intersection with Earth (or other ellipsoid) surface from above surface / orbit Parameters ---------- ...
def enu2aer(e: np.ndarray, n: np.ndarray, u: np.ndarray, deg: bool = True) -> Tuple[float, float, float]: """ ENU to Azimuth, Elevation, Range Parameters ---------- e : float or np.ndarray of float ENU East coordinate (meters) n : float or np.ndarray of float ENU North coordina...
def aer2enu(az: float, el: float, srange: float, deg: bool = True) -> Tuple[float, float, float]: """ Azimuth, Elevation, Slant range to target to East, north, Up Parameters ---------- azimuth : float or np.ndarray of float azimuth clockwise from north (degrees) elevation : float or...
def enu2geodetic(e: float, n: float, u: float, lat0: float, lon0: float, h0: float, ell=None, deg: bool = True) -> Tuple[float, float, float]: """ East, North, Up to target to geodetic coordinates Parameters ---------- e : float or np.ndarray of float East ...
def geodetic2enu(lat: float, lon: float, h: float, lat0: float, lon0: float, h0: float, ell=None, deg: bool = True) -> Tuple[float, float, float]: """ Parameters ---------- lat : float or np.ndarray of float target geodetic latitude lon : float or np.ndarr...
def vdist(Lat1: float, Lon1: float, Lat2: float, Lon2: float, ell: Ellipsoid = None) -> Tuple[float, float, float]: """ Using the reference ellipsoid, compute the distance between two points within a few millimeters of accuracy, compute forward azimuth, and compute backward azimuth, all using a vectoriz...
def vreckon(Lat1: float, Lon1: float, Rng: float, Azim: float, ell: Ellipsoid = None) -> Tuple[float, float, float]: """ This is the Vincenty "forward" solution. Computes points at a specified azimuth and range in an ellipsoidal earth. Using the reference ellipsoid, travel a given distance ...
def track2(lat1: float, lon1: float, lat2: float, lon2: float, ell: Ellipsoid = None, npts: int = 100, deg: bool = True): """ computes great circle tracks starting at the point lat1, lon1 and ending at lat2, lon2 Parameters ---------- Lat1 : float or numpy.ndarray of float Geode...
def datetime2sidereal(time: datetime, lon_radians: float, usevallado: bool = True) -> float: """ Convert ``datetime`` to sidereal time from D. Vallado "Fundamentals of Astrodynamics and Applications" time : datetime.datetime time to convert lon_...
def juliandate(time: datetime) -> float: """ Python datetime to Julian time from D.Vallado Fundamentals of Astrodynamics and Applications p.187 and J. Meeus Astronomical Algorithms 1991 Eqn. 7.1 pg. 61 Parameters ---------- time : datetime.datetime time to convert Results ...
def julian2sidereal(Jdate: float) -> float: """ Convert Julian time to sidereal time D. Vallado Ed. 4 Parameters ---------- Jdate: float Julian centuries from J2000.0 Results ------- tsr : float Sidereal time """ jdate = np.atleast_1d(Jdate) assert ...
def get_radius_normal(lat_radians: float, ell: Ellipsoid = None) -> float: """ Compute normal radius of planetary body Parameters ---------- lat_radians : float latitude in radians ell : Ellipsoid, optional reference ellipsoid Returns ------- radius : float ...
def geodetic2ecef(lat: float, lon: float, alt: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ point transformation from Geodetic of specified ellipsoid (default WGS-84) to ECEF Parameters ---------- lat : float or numpy.ndarray of float ...
def ecef2geodetic(x: float, y: float, z: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ convert ECEF (meters) to geodetic coordinates Parameters ---------- x : float or numpy.ndarray of float target x ECEF coordinate (meters) y : flo...
def ecef2enuv(u: float, v: float, w: float, lat0: float, lon0: float, deg: bool = True) -> Tuple[float, float, float]: """ VECTOR from observer to target ECEF => ENU Parameters ---------- u : float or numpy.ndarray of float target x ECEF coordinate (meters) v : float or n...
def ecef2enu(x: float, y: float, z: float, lat0: float, lon0: float, h0: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ from observer to target, ECEF => ENU Parameters ---------- x : float or numpy.ndarray of float target x ECEF ...
def enu2uvw(east: float, north: float, up: float, lat0: float, lon0: float, deg: bool = True) -> Tuple[float, float, float]: """ Parameters ---------- e1 : float or numpy.ndarray of float target east ENU coordinate (meters) n1 : float or numpy.ndarray of float target nor...
def uvw2enu(u: float, v: float, w: float, lat0: float, lon0: float, deg: bool = True) -> Tuple[float, float, float]: """ Parameters ---------- u : float or numpy.ndarray of float v : float or numpy.ndarray of float w : float or numpy.ndarray of float Results ------- E...
def eci2geodetic(eci: np.ndarray, t: datetime, useastropy: bool = True) -> Tuple[float, float, float]: """ convert ECI to geodetic coordinates Parameters ---------- eci : tuple of float [meters] Nx3 target ECI location (x,y,z) t : datetime.datetime, float le...
def enu2ecef(e1: float, n1: float, u1: float, lat0: float, lon0: float, h0: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ ENU to ECEF Parameters ---------- e1 : float or numpy.ndarray of float target east ENU coordinate (meters...
def aer2ned(az: float, elev: float, slantRange: float, deg: bool = True) -> Tuple[float, float, float]: """ converts azimuth, elevation, range to target from observer to North, East, Down Parameters ----------- az : float or numpy.ndarray of float azimuth elev : float or n...
def ned2aer(n: float, e: float, d: float, deg: bool = True) -> Tuple[float, float, float]: """ converts North, East, Down to azimuth, elevation, range Parameters ---------- n : float or numpy.ndarray of float North NED coordinate (meters) e : float or numpy.ndarray of float...
def ned2geodetic(n: float, e: float, d: float, lat0: float, lon0: float, h0: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ Converts North, East, Down to target latitude, longitude, altitude Parameters ---------- n : float or nu...
def ned2ecef(n: float, e: float, d: float, lat0: float, lon0: float, h0: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ North, East, Down to target ECEF coordinates Parameters ---------- n : float or numpy.ndarray of float North...
def ecef2ned(x: float, y: float, z: float, lat0: float, lon0: float, h0: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ Convert ECEF x,y,z to North, East, Down Parameters ---------- x : float or numpy.ndarray of float ECEF x coo...
def ecef2nedv(x: float, y: float, z: float, lat0: float, lon0: float, deg: bool = True) -> Tuple[float, float, float]: """ for VECTOR between two points Parameters ---------- x : float or numpy.ndarray of float ECEF x coordinate (meters) y : float or numpy.nd...
def azel2radec(az_deg: float, el_deg: float, lat_deg: float, lon_deg: float, time: datetime) -> Tuple[float, float]: """ converts azimuth, elevation to right ascension, declination Parameters ---------- az_deg : float or numpy.ndarray of float azimuth (clockwi...
def radec2azel(ra_deg: float, dec_deg: float, lat_deg: float, lon_deg: float, time: datetime) -> Tuple[float, float]: """ converts right ascension, declination to azimuth, elevation Parameters ---------- ra_deg : float or numpy.ndarray of float right ascension...
def ecef2geodetic_old(x: float, y: float, z: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ convert ECEF (meters) to geodetic coordinates input ----- x,y,z [meters] target ECEF location [0,Infinity) ell re...
def ecef2aer(x: float, y: float, z: float, lat0: float, lon0: float, h0: float, ell=None, deg: bool = True) -> Tuple[float, float, float]: """ gives azimuth, elevation and slant range from an Observer to a Point with ECEF coordinates. ECEF input location is with units of meters ...
def geodetic2aer(lat: float, lon: float, h: float, lat0: float, lon0: float, h0: float, ell=None, deg: bool = True) -> Tuple[float, float, float]: """ gives azimuth, elevation and slant range from an Observer to a Point with geodetic coordinates. Parameters ----------...
def aer2geodetic(az: float, el: float, srange: float, lat0: float, lon0: float, h0: float, ell=None, deg: bool = True) -> Tuple[float, float, float]: """ gives geodetic coordinates of a point with az, el, range from an observer at lat0, lon0, h0 Parame...
def eci2aer(eci: Tuple[float, float, float], lat0: float, lon0: float, h0: float, t: datetime, useastropy: bool = True) -> Tuple[float, float, float]: """ takes ECI coordinates of point and gives az, el, slant range from Observer Parameters ---------- eci : tupl...
def aer2eci(az: float, el: float, srange: float, lat0: float, lon0: float, h0: float, t: datetime, ell=None, deg: bool = True, useastropy: bool = True) -> np.ndarray: """ gives ECI of a point from an observer at az, el, slant range Parameters ---------- az : floa...
def aer2ecef(az: float, el: float, srange: float, lat0: float, lon0: float, alt0: float, ell=None, deg: bool = True) -> Tuple[float, float, float]: """ converts target azimuth, elevation, range from observer at lat0,lon0,alt0 to ECEF coordinates. Parameters ---------- az :...