Tools to manipulate the IDSPy Dictionaries
Project description
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
1import pprint
2import dataclasses
34
import idspy_toolkit
5from idspy_dictionaries import ids_gyrokinetics
67
pp = pprint.PrettyPrinter(indent=2)
89
ids_test = ids_gyrokinetics.Gyrokinetics()
10# you can directly print the class to see what it looks like :
11pp.pprint(ids_test)
1213
# if you want to see all the available classes in the current module :
14ids_dict = idspy_toolkit.list_ids_members(gkids)
15pp.pprint(ids_dict)
1617
#to fill an IDS with default values
18idspy_toolkit.fill_missing_values(ids_test)
1920
# you can use the . to access ids members :
21pp.pprint(ids_test.ids_properties)
2223
# and to set a value :
24ids_test.ids_properties.comment="a comment"
2526
# if in a script you want to reach a "deeper" value, you can use the function *get_ids_value_from_string*
27idspy_toolkit.get_ids_value_from_string(ids_test, "ids_properties/comment")
28# and for list element, put the element index after an #
29idspy_toolkit.get_ids_value_from_string(ids_test, "tag#0/name")
3031
# same kind of function exist to set a value :
32idspy_toolkit.set_ids_value_from_string(ids_test, "tag#0/name", "a new tag name")
3334
# pour afficher la classe sous forme de dictionnaire (conseil mettez l'ecran en vertical ;)):
35ids_dict = dataclasses.asdict(ids_test)
36pp.pprint(ids_dict)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
idspy_toolkit-0.5.0.tar.gz
(27.3 kB
view details)
Built Distribution
File details
Details for the file idspy_toolkit-0.5.0.tar.gz
.
File metadata
- Download URL: idspy_toolkit-0.5.0.tar.gz
- Upload date:
- Size: 27.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9326a7d21f6a0b21f2e803293243261a60367a60930e7cfa349dcd8c71553f6 |
|
MD5 | 5c6164294dd370f70803934e4bc39475 |
|
BLAKE2b-256 | 007e892316a74a24cc07848eaedfe40e424b22640e7fd5c32832b151a914965d |
File details
Details for the file idspy_toolkit-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: idspy_toolkit-0.5.0-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f9b53121468e12c22b6ae70679d7c866edb80318458360077e837c85cb7463d |
|
MD5 | ece63b4038625b938b00763cc7924121 |
|
BLAKE2b-256 | 817cda163d7114376158360f651c159d5f0fb62ae7bd48db1b6f7b5d4f6b8649 |