Skip to main content

Tools for reading, writing and manipulating data stored in the human-friendly structured data (HSD) format

Project description

Utilities to read and write files in the Human-friendly Structured Data (HSD) format.

The HSD-format is very similar to both JSON and YAML, but tries to minimize the effort for humans to read and write it. It ommits special characters as much as possible (in contrast to JSON) and is not indentation dependent (in contrast to YAML). It was developed originally as the input format for the scientific simulation tool (DFTB+), but is of general purpose. Data stored in HSD can be easily mapped to a subset of JSON or XML and vica versa.

Detailed documentation can be found on Read the Docs.

Installation

The package can be installed via conda-forge:

conda install --channel "conda-forge" hsd-python

Alternatively, the package can be downloaded and installed via pip into the active Python interpreter (preferably using a virtual python environment) by

pip install hsd

or into the user space issueing

pip install --user hsd

Quick tutorial

A typical, self-explaining input written in HSD looks like

driver {
  conjugate_gradients {
    moved_atoms = 1 2 "7:19"
    max_steps = 100
  }
}

hamiltonian {
  dftb {
    scc = yes
    scc_tolerance = 1e-10
    mixer {
      broyden {}
    }
    filling {
      fermi {
        # This is comment which will be ignored
        # Note the attribute (unit) of the field below
        temperature [kelvin] = 100
      }
    }
    k_points_and_weights {
      supercell_folding {
        2   0   0
        0   2   0
        0   0   2
        0.5 0.5 0.5
      }
    }
  }
}

The above input can be parsed into a Python dictionary with:

import hsd
hsdinput = hsd.load("test.hsd")

The dictionary hsdinput will then look as:

{
    "driver": {
        "conjugate_gradients" {
            "moved_atoms": [1, 2, "7:19"],
            "max_steps": 100
        }
    },
    "hamiltonian": {
        "dftb": {
            "scc": True,
            "scc_tolerance": 1e-10,
            "mixer": {
                "broyden": {}
            },
            "filling": {
                "fermi": {
                    "temperature": 100,
                    "temperature.attrib": "kelvin"
                }
            }
            "k_points_and_weights": {
                "supercell_folding": [
                    [2, 0, 0],
                    [0, 2, 0],
                    [0, 0, 2],
                    [0.5, 0.5, 0.5]
                ]
            }
        }
    }
}

Being a simple Python dictionary, it can be easily queried and manipulated in Python

hsdinput["driver"]["conjugate_gradients"]["max_steps"] = 200

and then stored again in HSD format

hsd.dump(hsdinput, "test2.hsd")

License

The hsd-python package is licensed under the BSD 2-clause license.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

hsd-0.1.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

hsd-0.1-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file hsd-0.1.tar.gz.

File metadata

  • Download URL: hsd-0.1.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for hsd-0.1.tar.gz
Algorithm Hash digest
SHA256 95861b9ff8ddb7e0e10d4afe44630058178902b6690e8e376ce418415c82184e
MD5 37b245f8d3dc87918b149e12d455b39a
BLAKE2b-256 62d256f61a461789f4e6ffc4a63d3420ebc9f93ab18c1c7fc0f7a9cee51ccd3d

See more details on using hashes here.

File details

Details for the file hsd-0.1-py3-none-any.whl.

File metadata

  • Download URL: hsd-0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for hsd-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1f67e5ea0348776a2355c8e8c003d5dd632a7cea7c3062fc45e423ddbc4297e8
MD5 0bf0f66299f37d93688fdf3bd8a6c983
BLAKE2b-256 4803e46d7b901cdc5ee561bae5bc244435f268ee2f379322379d0d2777fd5879

See more details on using hashes here.

Supported by

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