.. only:: html
.. note::
:class: sphx-glr-download-link-note
Click :ref:`here ` to download the full example code
.. rst-class:: sphx-glr-example-title
.. _sphx_glr_examples_imaging_hello_world.py:
Hello World!
============
Learn the basics with Hello World!
At it's core ImagePypelines is just a way to string functions and algorithms
together.
.. code-block:: default
import imagepypelines as ip
@ip.blockify(void=True)
def print_msg(msg):
print(msg)
.. code-block:: default
tasks = {'msg':ip.Input(),
'null':(print_msg, 'msg')}
msg_printer = ip.Pipeline(tasks)
We can do this by calling process directly...
.. code-block:: default
processed = msg_printer.process(["Hello World!"])
# Or we can do this more naturally!
processed = msg_printer(["Hello World... but callable!"])
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
Hello World!
Hello World... but callable!
We can pass in any data we want! In this example, we call this function
once for every datum passed in
.. code-block:: default
processed = msg_printer.process(['we','can','print','anything','individually!'])
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
we
can
print
anything
individually!
We can also print everything at once with the `batch_type` variable
-------------------------------------------------------------------
.. code-block:: default
@ip.blockify(batch_type="all", void=True)
def print_all(msg):
print(msg)
tasks = {'msg':ip.Input(),
'null':(print_all, 'msg')}
print_all_pipeline = ip.Pipeline(tasks)
processed = print_all_pipeline.process(['we','can','print','everything','at','once!'])
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
['we', 'can', 'print', 'everything', 'at', 'once!']
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 0.005 seconds)
.. _sphx_glr_download_examples_imaging_hello_world.py:
.. only :: html
.. container:: sphx-glr-footer
:class: sphx-glr-footer-example
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download Python source code: hello_world.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: hello_world.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_