A Python dictionary template for storing serializable metadata
Project description
conceptual_dictionary
A Python dictionary template for storing serializable metadata.
Installation
Install from source:
pip install -e .
Usage
Using Templates
Import and use predefined dictionary templates:
from conceptual_dictionary.templates import sample_template, property_template, workflow_template
# Use a template directly
my_data = sample_template.copy()
my_data['material']['element_ratio'] = {'Fe': 0.7, 'C': 0.3}
my_data['simulation_cell']['volume']['value'] = 1000
Using ConceptualDict Class
Work with conceptual dictionaries using the ConceptualDict class:
from conceptual_dictionary.conceptualdict import ConceptualDict
# Create a new conceptual dictionary
cd = ConceptualDict()
# Set values using dot notation
cd.set("material.element_ratio.Fe", 0.7)
cd.set("material.element_ratio.C", 0.3)
cd.set("simulation_cell.volume.value", 1000)
# Get values
fe_ratio = cd.get("material.element_ratio.Fe")
volume = cd.get("simulation_cell.volume.value")
# Convert to standard dictionary
data = cd.to_dict()
# Serialize to JSON
json_str = cd.to_json(indent=2)
# Save to file
cd.save("my_conceptual.json")
# Load from file
cd_loaded = ConceptualDict.from_json("my_conceptual.json")
Available Templates
- sample_template: Standard template with metadata, content, and schema sections
- property_template: Template for defining properties with values and units
- workflow_template: Template for describing workflows, including algorithms and methods
- operation_template: Unified template for all atomic-scale operations (DeleteAtom, SubstituteAtom, AddAtom, Rotate, Translate, Shear) with all possible fields
Using Operation Template
from conceptual_dictionary.templates import operation_template
# Create a rotation operation
rotation_op = operation_template.copy()
rotation_op['method'] = 'Rotate'
rotation_op['input_sample'] = 'sample1'
rotation_op['output_sample'] = 'sample2'
rotation_op['rotation_matrix'] = [[1.0, 0.0, 0.0], [0.0, 0.707, -0.707], [0.0, 0.707, 0.707]]
# Create a translation operation
translation_op = operation_template.copy()
translation_op['method'] = 'Translate'
translation_op['input_sample'] = 'sample2'
translation_op['output_sample'] = 'sample3'
translation_op['translation_vector'] = [1.5, 2.0, 0.5]
# Create a simple delete operation
delete_op = operation_template.copy()
delete_op['method'] = 'DeleteAtom'
delete_op['input_sample'] = 'sample3'
delete_op['output_sample'] = 'sample4'
# Add to ConceptualDict
cd = ConceptualDict()
cd['operation'].append(rotation_op)
cd['operation'].append(translation_op)
cd['operation'].append(delete_op)
License
MIT License
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file conceptual_dictionary-0.3.0.tar.gz.
File metadata
- Download URL: conceptual_dictionary-0.3.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc6db72462073a73b9f30a54d88d0018349e442dc08e6d04337d519902ccb322
|
|
| MD5 |
a0ab7e9eaebc9b67d51200d95a53dcef
|
|
| BLAKE2b-256 |
f98383b6a3939e28cb6a5956c205605a14bac49b4877baa29ad3f97899c2e360
|
File details
Details for the file conceptual_dictionary-0.3.0-py3-none-any.whl.
File metadata
- Download URL: conceptual_dictionary-0.3.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea9b3b4a837d16f34da33681f3aea89c15f63a0c74b8b10c14fa6083f2f0058f
|
|
| MD5 |
d36a5724fdfda33f2430eaf1db579bfa
|
|
| BLAKE2b-256 |
22b4fa0f4a63d8c529925193a43df5e8e76b7d948959fa825364047f09c0dde0
|