Metadata-Version: 2.1
Name: idspy_toolkit
Version: 0.7.0
Summary: Tools to manipulate the IDSPy Dictionaries
Author-email: Guillaume Fuhr <guillaume.fuhr@univ-amu.fr>
License: BSD 3-Clause License
        
        Copyright (c) 2023, CNRS, contributor: Y. Camenen
        Copyright (c) 2023, Aix-Marseille Univ., contributor: G. Fuhr
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: homepage, https://gitlab.com/gkdb/imas-gk
Project-URL: repository, https://gitlab.com/gkdb/imas-gk/-/tree/main/idspy_toolkit
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.9
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: idspy_dictionaries>=34000.2.0
Requires-Dist: numpy>=1.23
Requires-Dist: h5py>=3.6.0
Requires-Dist: defusedxml
Provides-Extra: test
Requires-Dist: pytest>=7.0.0; extra == "test"

IDSPy Toolkit
=============

This module contains a serie of function to help mange and manipulate IDSPy dataclasses

 * fill_missing_values
 * ids_to_hdf5
 * hdf5_to_ids
 * get_ids_value_from_string
 * set_ids_value_from_string
 * list_ids_members
 * copy_ids


**Please note that this work is still under progress/heavy development and as experimental status.
This means that functions arguments/signatures as long as HDF5 structure might be totally redesigned in the next updates.**

## Quick example
#################################################################################################
.. code-block:: python
   :number-lines:

    import pprint
    import dataclasses

    import idspy_toolkit
    from idspy_dictionaries import ids_gyrokinetics

    pp = pprint.PrettyPrinter(indent=2)

    ids_test = ids_gyrokinetics.Gyrokinetics()
    # you can directly print the class to see what it looks like  :
    pp.pprint(ids_test)

    # if you want to see all the available classes in the current module :
    ids_dict = idspy_toolkit.list_ids_members(gkids)
    pp.pprint(ids_dict)

    #to fill an IDS with default values
    idspy_toolkit.fill_missing_values(ids_test)

    # you can use the . to access ids members :
    pp.pprint(ids_test.ids_properties)

    # and to set a value :
    ids_test.ids_properties.comment="a comment"

    # if in a script you want to reach a "deeper" value, you can use the function *get_ids_value_from_string*
    idspy_toolkit.get_ids_value_from_string(ids_test, "ids_properties/comment")
    # and for list element, put the element index after an #
    idspy_toolkit.get_ids_value_from_string(ids_test, "tag#0/name")

    # same kind of function exist to set a value :
    idspy_toolkit.set_ids_value_from_string(ids_test, "tag#0/name", "a new tag name")

    # pour afficher la classe sous forme de dictionnaire (conseil mettez l'ecran en vertical ;)):
    ids_dict = dataclasses.asdict(ids_test)
    pp.pprint(ids_dict)
