conceptual-dictionary 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 pyscal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.4
2
+ Name: conceptual-dictionary
3
+ Version: 0.1.1
4
+ Summary: A Python dictionary template for storing serializable metadata
5
+ Author: Sarath Menon, Abril Azocar Guzman
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 pyscal
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/pyscal/conceptual_dictionary
29
+ Project-URL: Bug Tracker, https://github.com/pyscal/conceptual_dictionary/issues
30
+ Keywords: dictionary,metadata,serialization,conceptual
31
+ Classifier: Development Status :: 3 - Alpha
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Programming Language :: Python :: 3
35
+ Classifier: Programming Language :: Python :: 3.7
36
+ Classifier: Programming Language :: Python :: 3.8
37
+ Classifier: Programming Language :: Python :: 3.9
38
+ Classifier: Programming Language :: Python :: 3.10
39
+ Classifier: Programming Language :: Python :: 3.11
40
+ Classifier: Programming Language :: Python :: 3.12
41
+ Requires-Python: >=3.7
42
+ Description-Content-Type: text/markdown
43
+ License-File: LICENSE
44
+ Requires-Dist: numpy
45
+ Requires-Dist: pyyaml
46
+ Dynamic: license-file
47
+
48
+ # conceptual_dictionary
49
+
50
+ A Python dictionary template for storing serializable metadata.
51
+
52
+ ## Installation
53
+
54
+ Install from source:
55
+
56
+ ```bash
57
+ pip install -e .
58
+ ```
59
+
60
+ ## Usage
61
+
62
+ ### Using Templates
63
+
64
+ Import and use predefined dictionary templates:
65
+
66
+ ```python
67
+ from conceptual_dictionary.templates import sample_template, property_template, workflow_template
68
+
69
+ # Use a template directly
70
+ my_data = sample_template.copy()
71
+ my_data['material']['element_ratio'] = {'Fe': 0.7, 'C': 0.3}
72
+ my_data['simulation_cell']['volume']['value'] = 1000
73
+ ```
74
+
75
+ ### Using ConceptualDict Class
76
+
77
+ Work with conceptual dictionaries using the ConceptualDict class:
78
+
79
+ ```python
80
+ from conceptual_dictionary.conceptualdict import ConceptualDict
81
+
82
+ # Create a new conceptual dictionary
83
+ cd = ConceptualDict()
84
+
85
+ # Set values using dot notation
86
+ cd.set("material.element_ratio.Fe", 0.7)
87
+ cd.set("material.element_ratio.C", 0.3)
88
+ cd.set("simulation_cell.volume.value", 1000)
89
+
90
+ # Get values
91
+ fe_ratio = cd.get("material.element_ratio.Fe")
92
+ volume = cd.get("simulation_cell.volume.value")
93
+
94
+ # Convert to standard dictionary
95
+ data = cd.to_dict()
96
+
97
+ # Serialize to JSON
98
+ json_str = cd.to_json(indent=2)
99
+
100
+ # Save to file
101
+ cd.save("my_conceptual.json")
102
+
103
+ # Load from file
104
+ cd_loaded = ConceptualDict.from_json("my_conceptual.json")
105
+ ```
106
+
107
+ ## Available Templates
108
+
109
+ - **sample_template**: Standard template with metadata, content, and schema sections
110
+ - **property_template**: Template for defining properties with values and units
111
+ - **workflow_template**: Template for describing workflows, including algorithms and methods
112
+
113
+ ## License
114
+
115
+ MIT License
@@ -0,0 +1,68 @@
1
+ # conceptual_dictionary
2
+
3
+ A Python dictionary template for storing serializable metadata.
4
+
5
+ ## Installation
6
+
7
+ Install from source:
8
+
9
+ ```bash
10
+ pip install -e .
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### Using Templates
16
+
17
+ Import and use predefined dictionary templates:
18
+
19
+ ```python
20
+ from conceptual_dictionary.templates import sample_template, property_template, workflow_template
21
+
22
+ # Use a template directly
23
+ my_data = sample_template.copy()
24
+ my_data['material']['element_ratio'] = {'Fe': 0.7, 'C': 0.3}
25
+ my_data['simulation_cell']['volume']['value'] = 1000
26
+ ```
27
+
28
+ ### Using ConceptualDict Class
29
+
30
+ Work with conceptual dictionaries using the ConceptualDict class:
31
+
32
+ ```python
33
+ from conceptual_dictionary.conceptualdict import ConceptualDict
34
+
35
+ # Create a new conceptual dictionary
36
+ cd = ConceptualDict()
37
+
38
+ # Set values using dot notation
39
+ cd.set("material.element_ratio.Fe", 0.7)
40
+ cd.set("material.element_ratio.C", 0.3)
41
+ cd.set("simulation_cell.volume.value", 1000)
42
+
43
+ # Get values
44
+ fe_ratio = cd.get("material.element_ratio.Fe")
45
+ volume = cd.get("simulation_cell.volume.value")
46
+
47
+ # Convert to standard dictionary
48
+ data = cd.to_dict()
49
+
50
+ # Serialize to JSON
51
+ json_str = cd.to_json(indent=2)
52
+
53
+ # Save to file
54
+ cd.save("my_conceptual.json")
55
+
56
+ # Load from file
57
+ cd_loaded = ConceptualDict.from_json("my_conceptual.json")
58
+ ```
59
+
60
+ ## Available Templates
61
+
62
+ - **sample_template**: Standard template with metadata, content, and schema sections
63
+ - **property_template**: Template for defining properties with values and units
64
+ - **workflow_template**: Template for describing workflows, including algorithms and methods
65
+
66
+ ## License
67
+
68
+ MIT License
@@ -0,0 +1 @@
1
+ # This file marks the conceptual_dictionary module.
@@ -0,0 +1,70 @@
1
+ import yaml
2
+ import json
3
+ from typing import Any, Dict
4
+ import numpy as np
5
+ import string
6
+ import random
7
+
8
+
9
+ class ConceptualDict(dict):
10
+ def __init__(self, *args, **kwargs):
11
+ data = {"computational_sample": [], "workflow": []}
12
+ super().__init__(data, *args, **kwargs)
13
+
14
+ def generate_id(self, length=7):
15
+ """Generate a random alphanumeric ID of given length."""
16
+ chars = string.ascii_letters + string.digits
17
+ return "".join(random.choices(chars, k=length))
18
+
19
+ @staticmethod
20
+ def _clean_data(obj: Any) -> Any:
21
+ if isinstance(obj, dict):
22
+ return {k: ConceptualDict._clean_data(v) for k, v in obj.items()}
23
+ elif isinstance(obj, list):
24
+ return [ConceptualDict._clean_data(v) for v in obj]
25
+ elif isinstance(obj, np.ndarray):
26
+ return obj.tolist()
27
+ elif isinstance(obj, (np.floating, np.float32, np.float64)):
28
+ return float(obj)
29
+ elif isinstance(obj, (np.integer, np.int32, np.int64)):
30
+ return int(obj)
31
+ elif isinstance(obj, (np.bool_, bool)):
32
+ return bool(obj)
33
+ elif obj is None or isinstance(obj, (str, float, int)):
34
+ return obj
35
+ else:
36
+ return str(obj)
37
+
38
+ # --------------------
39
+ # YAML I/O
40
+ # --------------------
41
+ def to_yaml(self, filepath: str, sort_keys: bool = False) -> None:
42
+ clean_dict = ConceptualDict._clean_data(dict(self))
43
+ with open(filepath, "w") as f:
44
+ yaml.safe_dump(clean_dict, f, sort_keys=sort_keys, allow_unicode=True)
45
+
46
+ @classmethod
47
+ def from_yaml(cls, filepath: str) -> "ConceptualDict":
48
+ with open(filepath, "r") as f:
49
+ data = yaml.safe_load(f)
50
+ kg = cls()
51
+ kg.update(data)
52
+ return kg
53
+
54
+ # --------------------
55
+ # JSON I/O
56
+ # --------------------
57
+ def to_json(self, filepath: str, sort_keys: bool = False, indent: int = 2) -> None:
58
+ clean_dict = ConceptualDict._clean_data(dict(self))
59
+ with open(filepath, "w") as f:
60
+ json.dump(
61
+ clean_dict, f, sort_keys=sort_keys, indent=indent, ensure_ascii=False
62
+ )
63
+
64
+ @classmethod
65
+ def from_json(cls, filepath: str) -> "ConceptualDict":
66
+ with open(filepath, "r") as f:
67
+ data = json.load(f)
68
+ kg = cls()
69
+ kg.update(data)
70
+ return kg
@@ -0,0 +1,62 @@
1
+ sample_template = {
2
+ "id": "sample1",
3
+ "material": {
4
+ "element_ratio": {},
5
+ "crystal_structure": {
6
+ "spacegroup_symbol": None,
7
+ "spacegroup_number": None,
8
+ "unit_cell": {
9
+ "bravais_lattice": None,
10
+ "lattice_parameter": None,
11
+ "angle": [],
12
+ },
13
+ },
14
+ },
15
+ "simulation_cell": {
16
+ "volume": {"value": None},
17
+ "number_of_atoms": None,
18
+ "length": [],
19
+ "vector": [],
20
+ "angle": [],
21
+ "repetitions": [],
22
+ "grain_size": None,
23
+ "number_of_grains": 0,
24
+ },
25
+ "atom_attribute": {
26
+ "position": None,
27
+ "species": None,
28
+ },
29
+ }
30
+
31
+ property_template = {
32
+ "basename": None,
33
+ "value": None,
34
+ "unit": None,
35
+ "associate_to_sample": [],
36
+ }
37
+
38
+ workflow_template = {
39
+ "algorithm": None,
40
+ "method": None,
41
+ "xc_functional": None,
42
+ "input_parameter": [],
43
+ "input_sample": [],
44
+ "output_sample": [],
45
+ "calculated_property": [],
46
+ "degrees_of_freedom": [],
47
+ "interatomic_potential": {
48
+ "potential_type": None,
49
+ "uri": None,
50
+ },
51
+ "software": {
52
+ "uri": None,
53
+ "version": None,
54
+ "label": None,
55
+ },
56
+ "workflow_manager": {
57
+ "uri": None,
58
+ "version": None,
59
+ "label": None,
60
+ },
61
+ "thermodynamic_ensemble": None,
62
+ }
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.4
2
+ Name: conceptual-dictionary
3
+ Version: 0.1.1
4
+ Summary: A Python dictionary template for storing serializable metadata
5
+ Author: Sarath Menon, Abril Azocar Guzman
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 pyscal
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/pyscal/conceptual_dictionary
29
+ Project-URL: Bug Tracker, https://github.com/pyscal/conceptual_dictionary/issues
30
+ Keywords: dictionary,metadata,serialization,conceptual
31
+ Classifier: Development Status :: 3 - Alpha
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Programming Language :: Python :: 3
35
+ Classifier: Programming Language :: Python :: 3.7
36
+ Classifier: Programming Language :: Python :: 3.8
37
+ Classifier: Programming Language :: Python :: 3.9
38
+ Classifier: Programming Language :: Python :: 3.10
39
+ Classifier: Programming Language :: Python :: 3.11
40
+ Classifier: Programming Language :: Python :: 3.12
41
+ Requires-Python: >=3.7
42
+ Description-Content-Type: text/markdown
43
+ License-File: LICENSE
44
+ Requires-Dist: numpy
45
+ Requires-Dist: pyyaml
46
+ Dynamic: license-file
47
+
48
+ # conceptual_dictionary
49
+
50
+ A Python dictionary template for storing serializable metadata.
51
+
52
+ ## Installation
53
+
54
+ Install from source:
55
+
56
+ ```bash
57
+ pip install -e .
58
+ ```
59
+
60
+ ## Usage
61
+
62
+ ### Using Templates
63
+
64
+ Import and use predefined dictionary templates:
65
+
66
+ ```python
67
+ from conceptual_dictionary.templates import sample_template, property_template, workflow_template
68
+
69
+ # Use a template directly
70
+ my_data = sample_template.copy()
71
+ my_data['material']['element_ratio'] = {'Fe': 0.7, 'C': 0.3}
72
+ my_data['simulation_cell']['volume']['value'] = 1000
73
+ ```
74
+
75
+ ### Using ConceptualDict Class
76
+
77
+ Work with conceptual dictionaries using the ConceptualDict class:
78
+
79
+ ```python
80
+ from conceptual_dictionary.conceptualdict import ConceptualDict
81
+
82
+ # Create a new conceptual dictionary
83
+ cd = ConceptualDict()
84
+
85
+ # Set values using dot notation
86
+ cd.set("material.element_ratio.Fe", 0.7)
87
+ cd.set("material.element_ratio.C", 0.3)
88
+ cd.set("simulation_cell.volume.value", 1000)
89
+
90
+ # Get values
91
+ fe_ratio = cd.get("material.element_ratio.Fe")
92
+ volume = cd.get("simulation_cell.volume.value")
93
+
94
+ # Convert to standard dictionary
95
+ data = cd.to_dict()
96
+
97
+ # Serialize to JSON
98
+ json_str = cd.to_json(indent=2)
99
+
100
+ # Save to file
101
+ cd.save("my_conceptual.json")
102
+
103
+ # Load from file
104
+ cd_loaded = ConceptualDict.from_json("my_conceptual.json")
105
+ ```
106
+
107
+ ## Available Templates
108
+
109
+ - **sample_template**: Standard template with metadata, content, and schema sections
110
+ - **property_template**: Template for defining properties with values and units
111
+ - **workflow_template**: Template for describing workflows, including algorithms and methods
112
+
113
+ ## License
114
+
115
+ MIT License
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ conceptual_dictionary/__init__.py
5
+ conceptual_dictionary/conceptualdict.py
6
+ conceptual_dictionary/templates.py
7
+ conceptual_dictionary.egg-info/PKG-INFO
8
+ conceptual_dictionary.egg-info/SOURCES.txt
9
+ conceptual_dictionary.egg-info/dependency_links.txt
10
+ conceptual_dictionary.egg-info/requires.txt
11
+ conceptual_dictionary.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ conceptual_dictionary
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "conceptual-dictionary"
7
+ version = "0.1.1"
8
+ description = "A Python dictionary template for storing serializable metadata"
9
+ readme = "README.md"
10
+ requires-python = ">=3.7"
11
+ license = {file = "LICENSE"}
12
+ authors = [
13
+ {name = "Sarath Menon"},
14
+ {name = "Abril Azocar Guzman"},
15
+ ]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.7",
22
+ "Programming Language :: Python :: 3.8",
23
+ "Programming Language :: Python :: 3.9",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ ]
28
+ keywords = ["dictionary", "metadata", "serialization", "conceptual"]
29
+
30
+ dependencies = [
31
+ "numpy",
32
+ "pyyaml",
33
+ ]
34
+
35
+ [project.urls]
36
+ "Homepage" = "https://github.com/pyscal/conceptual_dictionary"
37
+ "Bug Tracker" = "https://github.com/pyscal/conceptual_dictionary/issues"
38
+
39
+ [tool.setuptools]
40
+ packages = ["conceptual_dictionary"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+