Skip to main content

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

 1  import pprint
 2  import dataclasses
 3 
 4  import idspy_toolkit
 5  from idspy_dictionaries import ids_gyrokinetics_local as gkids
 6 
 7  pp = pprint.PrettyPrinter(indent=2)
 8 
 9  ids_test = gkids.GyrokineticsLocal()
10  # you can directly print the class to see what it looks like  :
11  pp.pprint(ids_test)
12 
13  # if you want to see all the available classes in the current module :
14  ids_dict = idspy_toolkit.list_ids_members(gkids)
15  pp.pprint(ids_dict)
16 
17  #to fill an IDS with default values following IMAS standard
18  idspy_toolkit.fill_missing_values(ids_test)
19 
20  # you can use the . to access ids members :
21  pp.pprint(ids_test.ids_properties)
22 
23  # and to set a value :
24  ids_test.ids_properties.comment="a comment"
25 
26  # if in a script you want to reach a "deeper" value, you can use the function *get_ids_value_from_string*
27  idspy_toolkit.get_ids_value_from_string(ids_test, "ids_properties/comment")
28  # and for list element, put the element index after an #
29  idspy_toolkit.get_ids_value_from_string(ids_test, "tag#0/name")
30 
31  # same kind of function exist to set a value :
32  idspy_toolkit.set_ids_value_from_string(ids_test, "tag#0/name", "a new tag name")
33 
34  # to print the ids as a dictionary ( better with a vertical screen ;)):
35  ids_dict = dataclasses.asdict(ids_test)
36  pp.pprint(ids_dict)
37 
38  # HDF5 Operations Example
39  # Save IDS to HDF5 file (will raise IOError if file exists)
40  idspy_toolkit.ids_to_hdf5(ids_test, "my_ids.h5")
41 
42  # Save with overwrite option and array size constraints
43  idspy_toolkit.ids_to_hdf5(ids_test, "my_ids.h5",
44                           overwrite=True,          # Overwrite existing file
45                           max_array_dim=2,         # Maximum array dimensions
46                           max_array_size=100,      # Maximum size in MB
47                           max_array_elements=1000) # Maximum number of elements
48 
49  # Load IDS from HDF5 file with constraints
50  loaded_ids = idspy_toolkit.hdf5_to_ids("my_ids.h5",
51                                        ids_gyrokinetics.Gyrokinetics,
52                                        fill=True,           # Fill missing values with defaults
53                                        todict=True,         # Convert XML strings to dictionaries
54                                        max_array_dim=2,     # Maximum array dimensions to load
55                                        max_array_size=100,  # Maximum array size in MB
56                                        max_array_elements=1000) # Maximum number of elements

Metadata

Release files for idspy-toolkit 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for idspy-toolkit 1.0.1
File Size Uploaded
idspy_toolkit-1.0.1.tar.gz 38.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for idspy-toolkit 1.0.1
File Interpreter ABI Platform
idspy_toolkit-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 63.6 kB

Release files / idspy_toolkit-1.0.1.tar.gz

Download URL idspy_toolkit-1.0.1.tar.gz
Size 38.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1e65ee60319deba588c8b3d439d58b04a994e43f1c0a9f874e1f9d61fb97566d
BLAKE2b-256 checksum
How to use checksums
16c5bbb5cda691ea3d94a96d50fbfecc0c4f3bd194123a70a5b7f4fdfa0b68b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.10

Release files / idspy_toolkit-1.0.1-py3-none-any.whl

Download URL idspy_toolkit-1.0.1-py3-none-any.whl
Size 24.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2bafe1ad5797640139dbb42b18bc8acd34600765c0a8baf18bc2d93a8a5578cf
BLAKE2b-256 checksum
How to use checksums
2a829adba58271ae43aed16ca3d4437620a2cb551bbce2f8f53e1182857b9e9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.10

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

0.7.0

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

1 release file

0.4.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page