Group the assets per taxonomy and compute the outputs by using the
        underlying riskmodels. Yield one output per realization.

        :param riskinput: a RiskInput instance
        :param monitor: a monitor object used to measure the performance
506325
def gen_outputs(self, riskinput, monitor, epspath=None, hazard=None):
        
        self.monitor = monitor
        hazard_getter = riskinput.hazard_getter
        if hazard is None:
            with monitor('getting hazard'):
                hazard_getter.init()
                hazard = hazard_getter.get_hazard()
        sids = hazard_getter.sids
        assert len(sids) == 1
        with monitor('computing risk', measuremem=False):
            # this approach is slow for event_based_risk since a lot of
            # small arrays are passed (one per realization) instead of
            # a long array with all realizations; ebrisk does the right
            # thing since it calls get_output directly
            assets_by_taxo = get_assets_by_taxo(riskinput.assets, epspath)
            for rlzi, haz in sorted(hazard[sids[0]].items()):
                out = self.get_output(assets_by_taxo, haz, rlzi)
                yield out
839913
@Override
    public boolean registerMonitor(Object monitor) {
        // Process the annotated object, build a configuration, and create probe
        // listeners that represent each call site of the monitor.
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "monitor = " + monitor);
        }
        long startTime = System.nanoTime();
        Set<ProbeListener> listeners = buildListenersFromAnnotated(monitor);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "buildListenersFromAnnotated time = " + TimeUnit.NANOSECONDS.toMicros(System.nanoTime() - startTime) + "usec");
        }

        // Update collections of listeners
        startTime = System.nanoTime();
        if (!addListenersForMonitor(monitor, listeners)) {
            return false;
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "addListenersForMonitorTime = " + TimeUnit.NANOSECONDS.toMicros(System.nanoTime() - startTime) + "usec");
        }

        // Process all of the listeners and determine which of the available
        // classes needs to be transformed
        startTime = System.nanoTime();
        Collection<Class<?>> effectedClasses = processNewListeners(listeners);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "processNewListeners time = " + TimeUnit.NANOSECONDS.toMicros(System.nanoTime() - startTime) + "usec");
        }

        // Update the classes with the configured probes
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "effectedClasses.size() = " + effectedClasses.size());
        }
        startTime = System.nanoTime();
        this.transformer.instrumentWithProbes(effectedClasses);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "instrumentWithProbes time = " + TimeUnit.NANOSECONDS.toMicros(System.nanoTime() - startTime) + "usec");
        }

        return true;
    }
1132813
def get_monitors():
    
    count_value = ctypes.c_int(0)
    count = ctypes.pointer(count_value)
    result = _glfw.glfwGetMonitors(count)
    monitors = [result[i] for i in range(count_value.value)]
    return monitors
968464
public void performFinish(IProgressMonitor monitor) throws CoreException, InterruptedException {
		final SubMonitor subMonitor = SubMonitor.convert(monitor, 4);
		try {
			monitor.beginTask(NewWizardMessages.NewJavaProjectWizardPageTwo_operation_create, 3);
			if (this.currProject == null) {
				updateProject(subMonitor.newChild(1));
			}

			final String newProjectCompliance = this.keepContent ? null : this.firstPage.getCompilerCompliance();
			configureJavaProject(newProjectCompliance, subMonitor.newChild(1));
		} catch (Throwable e) {
			if (this.currProject != null) {
				removeProvisonalProject();
			}
			throw e;
		} finally {
			subMonitor.done();
			this.currProject = null;
			if (this.isAutobuild != null) {
				CoreUtility.setAutoBuilding(this.isAutobuild.booleanValue());
				this.isAutobuild = null;
			}
		}
	}
850435
def _generate_provenance(self):
        """"""
        # noinspection PyTypeChecker
        exposure = definition(
            self._provenance['exposure_keywords']['exposure'])

        # noinspection PyTypeChecker
        hazard = definition(
            self._provenance['hazard_keywords']['hazard'])
        # noinspection PyTypeChecker
        hazard_category = definition(self._provenance['hazard_keywords'][
            'hazard_category'])

        # InaSAFE
        set_provenance(
            self._provenance, provenance_impact_function_name, self.name)
        set_provenance(
            self._provenance, provenance_impact_function_title, self.title)

        # Map title
        set_provenance(
            self._provenance,
            provenance_map_title,
            get_map_title(hazard, exposure, hazard_category))

        set_provenance(
            self._provenance,
            provenance_map_legend_title,
            exposure['layer_legend_title'])

        set_provenance(
            self._provenance,
            provenance_analysis_question,
            get_analysis_question(hazard, exposure))

        if self.requested_extent:
            set_provenance(
                self._provenance,
                provenance_requested_extent,
                self.requested_extent.asWktPolygon())
        else:
            set_provenance(
                self._provenance,
                provenance_requested_extent,
                None)
        set_provenance(
            self._provenance,
            provenance_analysis_extent,
            self.analysis_extent.asWkt())

        set_provenance(
            self._provenance,
            provenance_data_store_uri,
            self.datastore.uri_path)

        # Notes and Action
        set_provenance(self._provenance, provenance_notes, self.notes())
        set_provenance(
            self._provenance,
            provenance_action_checklist,
            self.action_checklist())

        # CRS
        set_provenance(
            self._provenance, provenance_crs, self._crs.authid())

        # Rounding
        set_provenance(
            self._provenance, provenance_use_rounding, self.use_rounding)

        # Debug mode
        set_provenance(
            self._provenance, provenance_debug_mode, self.debug_mode)

        self._provenance_ready = True
816485
def view_assets_by_site(token, dstore):
    
    taxonomies = dstore['assetcol/tagcol/taxonomy'].value
    assets_by_site = dstore['assetcol'].assets_by_site()
    data = ['taxonomy mean stddev min max num_sites num_assets'.split()]
    num_assets = AccumDict()
    for assets in assets_by_site:
        num_assets += {k: [len(v)] for k, v in group_array(
            assets, 'taxonomy').items()}
    for taxo in sorted(num_assets):
        val = numpy.array(num_assets[taxo])
        data.append(stats(taxonomies[taxo], val, val.sum()))
    if len(num_assets) > 1:  # more than one taxonomy, add a summary
        n_assets = numpy.array([len(assets) for assets in assets_by_site])
        data.append(stats('*ALL*', n_assets, n_assets.sum()))
    return rst_table(data)
535128
def sg_graph_input(self, value, stream_id):
        """""""

        self.sensor_graph.process_input(stream_id, value)
        return [Error.NO_ERROR]
839110
def QA_fetch_risk(message={}, params={"_id": 0, 'assets': 0, 'timeindex': 0, 'totaltimeindex': 0, 'benchmark_assets': 0, 'month_profit': 0}, db=DATABASE):
    
    collection = DATABASE.risk
    return [res for res in collection.find(message, params)]
1187237
def set_monitored_resource(series, option_resource_type):
    
    resource_type = GLOBAL_RESOURCE_TYPE

    if option_resource_type == "":
        resource = monitored_resource.get_instance()
        if resource is not None:
            resource_labels = resource.get_labels()

            if resource.get_type() == 'gke_container':
                resource_type = 'k8s_container'
                set_attribute_label(series, resource_labels, 'project_id')
                set_attribute_label(series, resource_labels, 'cluster_name')
                set_attribute_label(series, resource_labels, 'container_name')
                set_attribute_label(series, resource_labels, 'namespace_id',
                                    'namespace_name')
                set_attribute_label(series, resource_labels, 'pod_id',
                                    'pod_name')
                set_attribute_label(series, resource_labels, 'zone',
                                    'location')

            elif resource.get_type() == 'gce_instance':
                resource_type = 'gce_instance'
                set_attribute_label(series, resource_labels, 'project_id')
                set_attribute_label(series, resource_labels, 'instance_id')
                set_attribute_label(series, resource_labels, 'zone')

            elif resource.get_type() == 'aws_ec2_instance':
                resource_type = 'aws_ec2_instance'
                set_attribute_label(series, resource_labels, 'aws_account')
                set_attribute_label(series, resource_labels, 'instance_id')
                set_attribute_label(series, resource_labels, 'region',
                                    label_value_prefix='aws:')
    else:
        resource_type = option_resource_type
    series.resource.type = resource_type
1271866
def spawn(self, monitor, kind=None, **params):
        '''
        '''
        proxy = _spawn_actor(kind, monitor, **params)
        # Add to the list of managed actors if this is a remote actor
        if isinstance(proxy, Actor):
            self._register(proxy)
            return proxy
        else:
            proxy.monitor = monitor
            self.managed_actors[proxy.aid] = proxy
            future = actor_proxy_future(proxy)
            proxy.start()
            return future
502705
static void addMonitorFields(
      List<Monitor<?>> monitors, String id, TagList tags, Object obj) {
    try {
      final SortedTagList.Builder builder = SortedTagList.builder();
      builder.withTag("class", className(obj.getClass()));
      if (tags != null) {
        builder.withTags(tags);
      }
      if (id != null) {
        builder.withTag("id", id);
      }
      final TagList classTags = builder.build();

      final Set<Field> fields = Reflection.getAllFields(obj.getClass());
      for (Field field : fields) {
        if (isMonitorType(field.getType())) {
          field.setAccessible(true);
          final Monitor<?> m = (Monitor<?>) field.get(obj);
          if (m == null) {
            throw new NullPointerException("field " + field.getName()
                + " in class " + field.getDeclaringClass().getName()
                + " is null, all monitor fields must be"
                + " initialized before registering");
          }
          monitors.add(wrap(classTags, m));
        }
      }
    } catch (Exception e) {
      throw Throwables.propagate(e);
    }
  }
406789
def monitor(interests=:rw)
      @monitor ||= begin
        raise @error if @error
        monitor = @ioloop.add_io_wait(@io, interests) {callback_on_waiting}
        ObjectSpace.define_finalizer(self, self.class.finalizer(monitor))
        monitor
      end
    end
549115
def addMonitor(self, monitor):
    

    token = self.nextMonitorToken
    self.nextMonitorToken += 1

    self.monitors[token] = monitor

    return token
1028059
def start_ebrisk(rupgetter, srcfilter, param, monitor):
    
    with monitor('weighting ruptures'):
        rupgetter.set_weights(srcfilter, param['num_taxonomies'])
    if rupgetter.weights.sum() <= param['maxweight']:
        yield ebrisk(rupgetter, srcfilter, param, monitor)
    else:
        for rgetter in rupgetter.split(param['maxweight']):
            yield ebrisk, rgetter, srcfilter, param
918776
def run(self, data):
        
        if self.normalize_data:
            data = cell_normalize(data)
        M, W, ll = poisson_estimate_state(data, **self.params)
        outputs = []
        if self.return_w:
            outputs.append(W)
        if self.return_m:
            outputs.append(M)
        if self.return_mw:
            outputs.append(M.dot(W))
        if self.return_mds:
            X = dim_reduce(M, W, 2)
            outputs.append(X.T.dot(W))
        return outputs, ll
941414
def _inputs_for_term(term, workspace, graph):
        
        offsets = graph.offset
        out = []
        if term.windowed:
            # If term is windowed, then all input data should be instances of
            # AdjustedArray.
            for input_ in term.inputs:
                adjusted_array = ensure_adjusted_array(
                    workspace[input_], input_.missing_value,
                )
                out.append(
                    adjusted_array.traverse(
                        window_length=term.window_length,
                        offset=offsets[term, input_],
                    )
                )
        else:
            # If term is not windowed, input_data may be an AdjustedArray or
            # np.ndarray.  Coerce the former to the latter.
            for input_ in term.inputs:
                input_data = ensure_ndarray(workspace[input_])
                offset = offsets[term, input_]
                # OPTIMIZATION: Don't make a copy by doing input_data[0:] if
                # offset is zero.
                if offset:
                    input_data = input_data[offset:]
                out.append(input_data)
        return out
487244
def add_model(self, model):
        

        if model.model_type not in self.supported_models:
            raise ValueError('Model type not supported for Aggregate! Apologies')

        if not self.model_list:
            self.model_list.append(model)
            if model.model_type in ['EGARCH', 'EGARCHM', 'EGARCHMReg', 'GARCH', 'LMEGARCH', 'LMSEGARCH', 'SEGARCH', 'SEGARCHM']:
                self.data = np.abs(model.data)
            else:
                self.data = model.data
            self.index = model.index
        else:
            if model.model_type in ['EGARCH', 'EGARCHM', 'EGARCHMReg', 'GARCH', 'LMEGARCH', 'LMSEGARCH', 'SEGARCH', 'SEGARCHM']:
                if np.isclose(np.abs(np.abs(model.data[-self.match_window:])-self.data[-self.match_window:]).sum(),0.0) or model.model_type=='GPNARX':
                    self.model_list.append(model)
                else:
                    raise ValueError('Data entered is deemed different based on %s last values!' % (s))
            else:
                if np.isclose(np.abs(model.data[-self.match_window:]-self.data[-self.match_window:]).sum(),0.0) or model.model_type=='GPNARX':
                    self.model_list.append(model)
                else:
                    raise ValueError('Data entered is deemed different based on %s last values!' % (s))

        self.model_names = [i.model_name for i in self.model_list]