Get the single-detector SNRs for each row in the table.
420006
def get_sngl_snrs(self, instruments=None):
		
		if len(self) and instruments is None:
			instruments = map(str, \
			                instrument_set_from_ifos(self[0].ifos))
		elif instruments is None:
			instruments = []
		return dict((ifo, self.get_sngl_snr(ifo))\
		            for ifo in instruments)
964776
def getcellslice(self, rownr, blc, trc, inc=[]):
        """"""
        return self._table.getcellslice(self._column, rownr, blc, trc, inc)
74806
def _read_as_table(self):
        
        rows = list()

        for row in self._rows:
            rows.append([row[i].get() for i in range(self.num_of_columns)])

        return rows
940624
def _calculate_std_res(self, counts, total, colsum, rowsum):
        
        if set(self.dim_types) & DT.ARRAY_TYPES:  # ---has-mr-or-ca---
            return self._array_type_std_res(counts, total, colsum, rowsum)
        return self._scalar_type_std_res(counts, total, colsum, rowsum)
50851
def rows(self, cell_mode=CellMode.cooked):
    
    for row_index in range(self.nrows):
      yield self.parse_row(self.get_row(row_index), row_index, cell_mode)
1208482
def _get_table_rows(parent_table, table_name, row_name):
        
        if parent_table is None:
            return []
        _table = parent_table.get(table_name)
        _table_rows = []
        if isinstance(_table, list):
            _table_rows = [_table_row.get(row_name) for _table_row in _table]
        elif isinstance(_table, dict):
            _table_rows = _table.get(row_name)
        if not isinstance(_table_rows, list):
            _table_rows = [_table_rows]
        return _table_rows
588505
def table_repr(columns, rows, data, padding=2):
    """"""
    padding = ' ' * padding
    column_lengths = [len(column) for column in columns]
    for row in rows:
        for i, column in enumerate(columns):
            item = str(data[row][column])
            column_lengths[i] = max(len(item), column_lengths[i])
    max_row_length = max(len(row) for row in rows) if len(rows) else 0
    table_row = ' ' * max_row_length
    for i, column in enumerate(columns):
        table_row += padding + column.rjust(column_lengths[i])
    table_rows = [table_row]
    for row in rows:
        table_row = row.rjust(max_row_length)
        for i, column in enumerate(columns):
            item = str(data[row][column])
            table_row += padding + item.rjust(column_lengths[i])
        table_rows.append(table_row)
    return '\n'.join(table_rows)
544133
def iter_rows(self):
        
        fileobj = self._fileobj
        cls_row = self.cls_row
        fields = self.fields

        for idx in range(self.prolog.records_count):
            data = fileobj.read(1)

            marker = struct.unpack('<1s', data)[0]
            is_deleted = marker == b'*'

            if is_deleted:
                continue

            row_values = []
            for field in fields:
                val = field.cast(fileobj.read(field.len))
                row_values.append(val)

            yield cls_row(*row_values)
720742
def filter_positive_detections(detections):
        
        class_idx = 0
        assert(isinstance(detections, mx.nd.NDArray) or isinstance(detections, np.ndarray))
        detections_per_image = []
        # for each image
        for i in range(detections.shape[0]):
            result = []
            det = detections[i, :, :]
            for obj in det:
                if obj[class_idx] >= 0:
                    result.append(obj)
            detections_per_image.append(result)
        logging.info("%d positive detections", len(result))
        return detections_per_image
909816
def rsr(self):
        """"""
        arr = np.array([self.wave.value, self.throughput]).swapaxes(0, 1)

        return arr
248671
def _set_SNR_grids(self):
        
        if self.SNR_prior == 'unif':
            SNR_grids = np.linspace(0, 1, self.SNR_bins)
            SNR_weights = np.ones(self.SNR_bins) / (self.SNR_bins - 1)
            SNR_weights[0] = SNR_weights[0] / 2.0
            SNR_weights[-1] = SNR_weights[-1] / 2.0
        elif self.SNR_prior == 'lognorm':
            dist = scipy.stats.lognorm
            alphas = np.arange(np.mod(self.SNR_bins, 2),
                               self.SNR_bins + 2, 2) / self.SNR_bins
            # The goal here is to divide the area under the pdf curve
            # to segments representing equal probabilities.
            bounds = dist.interval(alphas, (self.logS_range,))
            bounds = np.unique(bounds)
            # bounds contain the boundaries which equally separate
            # the probability mass of the distribution
            SNR_grids = np.zeros(self.SNR_bins)
            for i in np.arange(self.SNR_bins):
                SNR_grids[i] = dist.expect(
                    lambda x: x, args=(self.logS_range,),
                    lb=bounds[i], ub=bounds[i + 1]) * self.SNR_bins
            # Center of mass of each segment between consecutive
            # bounds are set as the grids for SNR.
            SNR_weights = np.ones(self.SNR_bins) / self.SNR_bins
        elif self.SNR_prior == 'exp':
            SNR_grids = self._bin_exp(self.SNR_bins)
            SNR_weights = np.ones(self.SNR_bins) / self.SNR_bins
        else:
            SNR_grids = np.ones(1)
            SNR_weights = np.ones(1)
        SNR_weights = SNR_weights / np.sum(SNR_weights)
        return SNR_grids, SNR_weights
813405
def _get_rows(self, table):
        """"""

        childnodes = table.childNodes
        qname_childnodes = [(s.qname[1], s) for s in childnodes]
        return [node for name, node in qname_childnodes
                if name == u'table-row']
1183621
def get_null_snr(self):
		
		null_snr_sq = self.get_coinc_snr()**2 - self.get_column('snr')**2
		null_snr_sq[null_snr_sq < 0] = 0.
		return null_snr_sq**(1./2.)
68052
def toSparse(self):
        """"""
        if self.isTransposed:
            values = np.ravel(self.toArray(), order='F')
        else:
            values = self.values
        indices = np.nonzero(values)[0]
        colCounts = np.bincount(indices // self.numRows)
        colPtrs = np.cumsum(np.hstack(
            (0, colCounts, np.zeros(self.numCols - colCounts.size))))
        values = values[indices]
        rowIndices = indices % self.numRows

        return SparseMatrix(self.numRows, self.numCols, colPtrs, rowIndices, values)
431469
def sample(self, num):
        
        if num > len(self):
            return self.copy()
        elif num < 0:
            raise IndexError("Cannot sample a negative number of rows "
                             "from a DataTable")

        random_row_mask = ([True] * num) + ([False] * (len(self) - num))
        shuffle(random_row_mask)

        sampled_table = self.mask(random_row_mask)
        random_col_name = 'random_sorting_column'
        while random_col_name in sampled_table:
            random_col_name = '%030x' % randrange(16**30)
        sampled_table[random_col_name] = [random()
                                          for _ in xrange(len(sampled_table))]
        sampled_table.sort(random_col_name, inplace=True)
        del sampled_table[random_col_name]
        return sampled_table
380294
def table_mask(self):
        """"""
        margin = compress_pruned(
            self._slice.margin(
                axis=None,
                weighted=False,
                include_transforms_for_dims=self._hs_dims,
                prune=self._prune,
            )
        )
        mask = margin < self._size

        if margin.shape == self._shape:
            return mask

        if self._slice.dim_types[0] == DT.MR:
            # If the margin is a column vector - broadcast it's mask to the array shape
            return np.logical_or(np.zeros(self._shape, dtype=bool), mask[:, None])

        return np.logical_or(np.zeros(self._shape, dtype=bool), mask)
949625
def table2matrix(table):
    """"""

    if not is_simpletable(table):
        raise NotSimpleTable("Not able read a cell in the table as a string")
    rows = []
    for tr in table('tr'):
        row = []
        for td in tr('td'):
            td = tdbr2EOL(td) # convert any '<br>' in the td to line ending
            try:
                row.append(td.contents[0])
            except IndexError:
                row.append('')
        rows.append(row)
    return rows