Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

conceptual_dictionary-0.1.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

conceptual_dictionary-0.1.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file conceptual_dictionary-0.1.2.tar.gz.

File metadata

  • Download URL: conceptual_dictionary-0.1.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for conceptual_dictionary-0.1.2.tar.gz
Algorithm Hash digest
SHA256 68d41b35596bbf14750205e6c94389e5b2f618ded9314d45289b60aae0730d1c
MD5 cd348ab1d1be4204c47a3e69a69dbd57
BLAKE2b-256 c4d2350200d0d153ea6ff38353e038a1414f0eb63f3e2c3b727b48ff720e20c1

See more details on using hashes here.

File details

Details for the file conceptual_dictionary-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for conceptual_dictionary-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e6d8ef5739d249f3c68b32c3dfdf349300d61651e25a782990cf16810ed5569b
MD5 a579a8ea35ad7c8da16f681bfc0ea315
BLAKE2b-256 60137649897c00b717076ad5ea6c0a33911e399923dc75bbded8d846725afe7f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page