.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/design_space/plot_load_design_space.py" .. LINE NUMBERS ARE GIVEN BELOW. .. 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_design_space_plot_load_design_space.py: DesignSpace import and export from disk ======================================= In this example, we will see how to read, filter, and export a design space from the disk. .. GENERATED FROM PYTHON SOURCE LINES 30-38 .. code-block:: default from __future__ import division, unicode_literals from gemseo.api import configure_logger, export_design_space, read_design_space configure_logger() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 39-44 Read a design space from a file ------------------------------- The user can read a design space from a file using the :func:`.create_design_space` function. .. GENERATED FROM PYTHON SOURCE LINES 44-50 .. code-block:: default design_space = read_design_space("design_space.txt") print(design_space) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Design space: +------+-------------+-------+-------------+---------+ | name | lower_bound | value | upper_bound | type | +------+-------------+-------+-------------+---------+ | x1 | -1 | 0 | 1 | float | | x2 | 5 | 6 | 8 | float | | x | 2 | 3 | 5 | integer | +------+-------------+-------+-------------+---------+ .. GENERATED FROM PYTHON SOURCE LINES 51-56 Filtering the design space -------------------------- The user can filter the design space in order to only keep some variables. To do so, the user can use the :meth:`.DesignSpace.filter` method: .. GENERATED FROM PYTHON SOURCE LINES 56-60 .. code-block:: default design_space.filter(["x1", "x2"]) print(design_space) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Design space: +------+-------------+-------+-------------+-------+ | name | lower_bound | value | upper_bound | type | +------+-------------+-------+-------------+-------+ | x1 | -1 | 0 | 1 | float | | x2 | 5 | 6 | 8 | float | +------+-------------+-------+-------------+-------+ .. GENERATED FROM PYTHON SOURCE LINES 61-66 Export the design space ----------------------- The user can export a :class:`.DesignSpace` instance by using the :func:`.export_design_space` function. .. GENERATED FROM PYTHON SOURCE LINES 66-69 .. code-block:: default export_design_space(design_space, "new_design_space.txt") .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.005 seconds) .. _sphx_glr_download_examples_design_space_plot_load_design_space.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: plot_load_design_space.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_load_design_space.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_