Return the output of an ipynb cell.
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()
196105
def output(self):
        """"""
        if self._timeseries is None:
            self.compute()
        output = self._timeseries[:, self.system.output_vars]
        if isinstance(self.system, NetworkModel):
            return self.system._reshape_output(output)
        else:
            return output
987714
def _code_cell(self, source):
        """"""
        input, output = self._prompt.to_cell(source)
        return {'cell_type': 'code',
                'input': input,
                'output': output}
1052948
def getOutputElementCount(self, name):
    
    if name in ["activeCells", "learnableCells", "sensoryAssociatedCells"]:
      return self.cellCount * self.moduleCount
    else:
      raise Exception("Invalid output name specified: " + name)
1263191
def strip_output(nb):
    
    for cell in nb.worksheets[0].cells:
        if 'outputs' in cell:
            cell['outputs'] = []
        if 'prompt_number' in cell:
            cell['prompt_number'] = None
    return nb
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
921607
def py(self, output):
        """"""
        import pprint
        pprint.pprint(output, stream=self.outfile)
461682
def GetIpForwardTable():
    """"""
    # We get the size first
    size = ULONG()
    res = _GetIpForwardTable(None, byref(size), False)
    if res != 0x7a:  # ERROR_INSUFFICIENT_BUFFER -> populate size
        raise RuntimeError("Error getting structure length (%d)" % res)
    # Now let's build our buffer
    pointer_type = PMIB_IPFORWARDTABLE
    buffer = create_string_buffer(size.value)
    pIpForwardTable = ctypes.cast(buffer, pointer_type)
    # And call GetAdaptersAddresses
    res = _GetIpForwardTable(pIpForwardTable, byref(size), True)
    if res != NO_ERROR:
        raise RuntimeError("Error retrieving table (%d)" % res)
    results = []
    for i in range(pIpForwardTable.contents.NumEntries):
        results.append(_struct_to_dict(pIpForwardTable.contents.Table[i]))
    del(pIpForwardTable)
    return results
1069952
def _get_output(algorithm, iport=0, iconnection=0, oport=0, active_scalar=None,
                active_scalar_field='point'):
    """"""
    ido = algorithm.GetInputDataObject(iport, iconnection)
    data = wrap(algorithm.GetOutputDataObject(oport))
    data.copy_meta_from(ido)
    if active_scalar is not None:
        data.set_active_scalar(active_scalar, preference=active_scalar_field)
    return data
587299
def output(self):
        
        if (self._output is None) or (len(self._output) == 0):
            result = None
        else:
            result = self._output.pop(0)
        return result
1341376
def cell(self, row_idx, col_idx):
        
        return _Cell(self._tbl.tc(row_idx, col_idx), self)
927751
def getOutputBlocks():
    """"""
    raw=open("output.txt").read()
    d={}
    for block in raw.split("\n####### ")[1:]:
        title=block.split("\n")[0].split("(")[0]
        block=block.split("\n",1)[1].strip()
        d[title]=block.split("\nfinished in ")[0]
    return d
278868
def convert_ipynb_to_gallery(file_name):
    
    python_file = ""

    nb_dict = json.load(open(file_name))
    cells = nb_dict['cells']

    for i, cell in enumerate(cells):
        if i == 0:
            assert cell['cell_type'] == 'markdown', \
                'First cell has to be markdown'

            md_source = ''.join(cell['source'])
            rst_source = pdoc.convert_text(md_source, 'rst', 'md')
            python_file = '"""\n' + rst_source + '\n"""'
        else:
            if cell['cell_type'] == 'markdown':
                md_source = ''.join(cell['source'])
                rst_source = pdoc.convert_text(md_source, 'rst', 'md')
                commented_source = '\n'.join([
                    '# ' + x for x in rst_source.split('\n')
                ])
                python_file = python_file + '\n\n\n' + '#' * 70 + '\n' + \
                    commented_source
            elif cell['cell_type'] == 'code':
                source = ''.join(cell['source'])
                python_file = python_file + '\n' * 2 + source

    open(file_name.replace('.ipynb', '.py'), 'w').write(python_file)
1304985
def convert_ipynbs(directory):
    """"""
    # The ipython_examples dir has to be in the same dir as this script
    for root, subfolders, files in os.walk(os.path.abspath(directory)):
        for f in files:
            if ".ipynb_checkpoints" not in root:
                if f.endswith("ipynb"):
                    ipynb_to_rst(root, f)
1030313
def export_ipynb(self, pathname):
        

        if pathname == '-':
            nbf.write(self.nb, sys.__stdout__)
        else:
            with codecs.open(pathname, 'w', encoding='utf-8') as f:
                ret = nbf.write(self.nb, f)
                pass

        logging.info("Jupyter notebook exported to '{}'".format(pathname))
1024143
def preview(file):
    """"""
    body, resources = render(file)
    default_ipython_style = resources['inlining']['css'][1]
    return render_template(
        'invenio_previewer/ipynb.html',
        file=file,
        content=body,
        style=default_ipython_style
    )
1185172
def _cells(nb):
    """"""
    if nb.nbformat < 4:
        for ws in nb.worksheets:
            for cell in ws.cells:
                yield cell
    else:
        for cell in nb.cells:
            yield cell