similar to matlab toc

    SeeAlso:
        ut.tic
193805
def toc(tt, return_msg=False, write_msg=True, verbose=None):
    
    if verbose is not None:
        write_msg = verbose
    (msg, start_time) = tt
    ellapsed = (default_timer() - start_time)
    if (not return_msg) and write_msg and msg is not None:
        sys.stdout.write('...toc(%.4fs, ' % ellapsed + '"' + str(msg) + '"' + ')\n')
    if return_msg:
        return msg
    else:
        return ellapsed
917552
def tc_at_grid_col(self, idx):
        
        grid_col = 0
        for tc in self.tc_lst:
            if grid_col == idx:
                return tc
            grid_col += tc.grid_span
            if grid_col > idx:
                raise ValueError('no cell on grid column %d' % idx)
        raise ValueError('index out of bounds')
507679
def readTableFromDelimited(f, separator="\t"):
    
    rowNames = []
    columnNames = []
    matrix = []

    first = True
    for line in f.readlines():
        line = line.rstrip()
        if len(line) == 0:
            continue

        row = line.split(separator)
        if first:
            columnNames = row[1:]
            first = False
        else:
            rowNames.append(row[0])
            matrix.append([float(c) for c in row[1:]])

    return Table(rowNames, columnNames, matrix)
826369
def aggregate_tile(cells, ti, tj, aggregate, params, metadata, layout, summary):
  
  tile = []
  keys = cells.keys()
  for i,key in enumerate(keys):
    print("cell", i+1, "/", len(keys), end='\r')
    cell_json = aggregate(cells[key], params, metadata, layout, summary)
    tile.append({"aggregate":cell_json, "i":int(key[0]), "j":int(key[1])})
  return tile
639951
function TicTacToeBoard(cells){
    this.board = [];
		for(var i=0; i<NUM_CELLS; i++) {
      if(cells){
        this.board[i] = cells[i];
      } else {
        this.board[i] = Cell.EMPTY;
      }
		}
  }
118261
def prt_tsv_dat(prt, data_nts, **kws):
    """"""
    sep = "\t" if 'sep' not in kws else kws['sep']
    fld2fmt = None if 'fld2fmt' not in kws else kws['fld2fmt']
    if 'sort_by' in kws:
        data_nts = sorted(data_nts, key=kws['sort_by'])
    prt_if = kws['prt_if'] if 'prt_if' in kws else None
    prt_flds = kws['prt_flds'] if 'prt_flds' in kws else data_nts[0]._fields
    items = 0
    for nt_data_row in data_nts:
        if prt_if is None or prt_if(nt_data_row):
            if fld2fmt is not None:
                row_fld_vals = [(fld, getattr(nt_data_row, fld)) for fld in prt_flds]
                row_vals = _fmt_fields(row_fld_vals, fld2fmt)
            else:
                row_vals = [getattr(nt_data_row, fld) for fld in prt_flds]
            prt.write("{}\n".format(sep.join(str(d) for d in row_vals)))
            items += 1
    return items
1018889
def taax(mt, x, t, m=1):
    
    return mt.Nx[x + t] / mt.Dx[x] - ((float(m - 1) / float(m * 2)) * (1 - nEx(mt, x, t)))
1201696
def find_inouts_st(voxel_grid, datapts, **kwargs):
    
    tol = kwargs.get('tol', 10e-8)
    filled = [0 for _ in range(len(voxel_grid))]
    for idx, bb in enumerate(voxel_grid):
        pts_inside = is_point_inside_voxel(bb, datapts, tol=tol)
        if pts_inside:
            filled[idx] = 1
    return filled
136002
def xistep(self, i):
        
        """

        self.YU[:] = self.Y - self.U[..., i]
        b = np.take(self.ZSf, [i], axis=self.cri.axisK) + \
            self.rho*sl.rfftn(self.YU, None, self.cri.axisN)

        self.Xf[..., i] = sl.solvedbi_sm(np.take(
            self.Zf, [i], axis=self.cri.axisK),
                                         self.rho, b, axis=self.cri.axisM)
        self.X[..., i] = sl.irfftn(self.Xf[..., i], self.cri.Nv,
                                   self.cri.axisN)
1340800
def show_plot(t_array, th_array):
    
    th_mean = gv.mean(th_array)
    th_sdev = gv.sdev(th_array)
    thp = th_mean + th_sdev
    thm = th_mean - th_sdev
    plt.fill_between(t_array, thp, thm, color='0.8')
    plt.plot(t_array, th_mean, linewidth=0.5)
    plt.xlabel('$t$')
    plt.ylabel(r'$\theta(t)$')
    plt.savefig('pendulum.pdf', bbox_inches='tight')
    plt.show()
43738
def ti(self):
        
        if self._ti is None:
            from .tcex_ti import TcExTi

            self._ti = TcExTi(self)
        return self._ti
1069386
def output(self):
        """"""
        subts = [s.output for s in self.sims]
        sub_ndim = subts[0].ndim
        if sub_ndim is 1:
            subts = [distob.expand_dims(ts, 1) for ts in subts]
            sub_ndim += 1
        nodeaxis = sub_ndim
        subts = [distob.expand_dims(ts, nodeaxis) for ts in subts]
        ts = subts[0].concatenate(subts[1:], axis=nodeaxis)
        ts.labels[nodeaxis] = self._node_labels()
        return ts
92708
def M(self, t, tips=None, gaps=None):
        """"""
        assert isinstance(t, float) and t > 0, "Invalid t: {0}".format(t)
        with scipy.errstate(under='ignore'): # don't worry if some values 0
            if ('expD', t) not in self._cached:
                self._cached[('expD', t)] = scipy.exp(self.D * self.mu * t)
            expD = self._cached[('expD', t)]
            if tips is None:
                # swap axes to broadcast multiply D as diagonal matrix
                M = broadcastMatrixMultiply((self.A.swapaxes(0, 1) *
                        expD).swapaxes(1, 0), self.Ainv)
            else:
                M = broadcastMatrixVectorMultiply((self.A.swapaxes(0, 1)
                        * expD).swapaxes(1, 0), broadcastGetCols(
                        self.Ainv, tips))
                if gaps is not None:
                    M[gaps] = scipy.ones(N_CODON, dtype='float')
        #if M.min() < -0.01:
        #    warnings.warn("Large negative value in M(t) being set to 0. "
        #            "Value is {0}, t is {1}".format(M.min(), t))
        M[M < 0] = 0.0
        return M
519073
def _cell_output(cell):
    """"""
    outputs = cell.get('outputs', [])
    # Add stdout.
    stdout = ('\n'.join(_ensure_string(output.get('text', ''))
                        for output in outputs)).rstrip()
    # Add text output.
    text_outputs = []
    for output in outputs:
        out = output.get('data', {}).get('text/plain', [])
        out = _ensure_string(out)
        # HACK: skip <matplotlib ...> outputs.
        if out.startswith('<matplotlib'):
            continue
        text_outputs.append(out)
    return stdout + '\n'.join(text_outputs).rstrip()
767665
def idf2txt(txt):
    """"""
    astr = nocomment(txt)
    objs = astr.split(';')
    objs = [obj.split(',') for obj in objs]
    objs = [[line.strip() for line in obj] for obj in objs]
    objs = [[_tofloat(line) for line in obj] for obj in objs]
    objs = [tuple(obj) for obj in objs]
    objs.sort()

    lst = []
    for obj in objs:
        for field in obj[:-1]:
            lst.append('%s,' % (field, ))
        lst.append('%s;\n' % (obj[-1], ))

    return '\n'.join(lst)
557353
def toc(message='Elapsed time : {} s'):
    
    t = time.time()
    print(message.format(t - __time_tic_toc))
    return t - __time_tic_toc
727620
def display(self,
                ret,
                indent,
                out,
                rows_key=None,
                labels_key=None):

        ''''''

        rows = []
        labels = None

        if isinstance(ret, dict):
            if not rows_key or (rows_key and rows_key in list(ret.keys())):
                # either not looking for a specific key
                # either looking and found in the current root
                for key in sorted(ret):
                    if rows_key and key != rows_key:
                        continue  # if searching specifics, ignore anything else
                    val = ret[key]
                    if not rows_key:
                        out.append(
                            self.ustring(
                                indent,
                                self.DARK_GRAY,  # pylint: disable=no-member
                                key,
                                suffix=':'
                            )
                        )
                        out.append(
                            self.ustring(
                                indent,
                                self.DARK_GRAY,  # pylint: disable=no-member
                                '----------'
                            )
                        )
                    if isinstance(val, (list, tuple)):
                        rows = val
                        if labels_key:
                            # at the same depth
                            labels = ret.get(labels_key)  # if any
                        out.extend(self.display_rows(rows, labels, indent))
                    else:
                        self.display(val, indent + 4, out, rows_key=rows_key, labels_key=labels_key)
            elif rows_key:
                # dig deeper
                for key in sorted(ret):
                    val = ret[key]
                    self.display(val, indent, out, rows_key=rows_key, labels_key=labels_key)  # same indent
        elif isinstance(ret, (list, tuple)):
            if not rows_key:
                rows = ret
                out.extend(self.display_rows(rows, labels, indent))

        return out