Skip to main content

Dictionary utilities (DotDict, safe_merge) for the SciTeX ecosystem

Project description

scitex-dict

PyPI Python Tests Install Test Coverage Docs License: AGPL v3

SciTeX

Dictionary utilities — DotDict, safe_merge, flatten, listed_dict, replace.

Full Documentation · pip install scitex-dict


Problem and Solution

# Problem Solution
1 YAML config access ergonomicsCONFIG["MODEL"]["hidden_size"] vs CONFIG.MODEL.hidden_size matters in a notebook DotDict — attribute-access dict subclass with recursive .x.y.z; works as a drop-in for the umpteen competing alternatives (addict, easydict, box, dotmap)
2 Merging configs silently overwrites{**a, **b} on duplicate keys loses information safe_merge — duplicate keys raise; flatten turns nested dicts into dotted-key single-level for logging/CSV

Installation

pip install scitex-dict

Quick Start

from scitex_dict import DotDict, safe_merge

cfg = DotDict({"model": {"lr": 0.001, "epochs": 100}})
print(cfg.model.lr)              # 0.001

merged = safe_merge({"a": 1}, {"b": 2})

1 Interfaces

Python API
from scitex_dict import (
    DotDict, flatten, listed_dict, pop_keys,
    replace, safe_merge, to_str,
)

cfg = DotDict({"model": {"lr": 0.001}})
cfg.model.lr                              # 0.001

safe_merge({"a": 1}, {"b": 2})

flatten({"x": {"y": 1, "z": [10, 20]}})   # {"x_y": 1, "x_z_0": 10, ...}

d = listed_dict(["a", "b"])

replace("hello world", {"hello": "hi"})   # "hi world"

to_str({"a": 1, "b": 2})

Part of SciTeX

scitex-dict is part of SciTeX.

Four Freedoms for Research

  1. The freedom to run your research anywhere — your machine, your terms.
  2. The freedom to study how every step works — from raw data to final manuscript.
  3. The freedom to redistribute your workflows, not just your papers.
  4. The freedom to modify any module and share improvements with the community.

AGPL-3.0 — because we believe research infrastructure deserves the same freedoms as the software it runs on.

License

AGPL-3.0. See LICENSE.


SciTeX

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

scitex_dict-0.1.4.tar.gz (402.0 kB view details)

Uploaded Source

Built Distribution

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

scitex_dict-0.1.4-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file scitex_dict-0.1.4.tar.gz.

File metadata

  • Download URL: scitex_dict-0.1.4.tar.gz
  • Upload date:
  • Size: 402.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scitex_dict-0.1.4.tar.gz
Algorithm Hash digest
SHA256 23db9c3286a1121cc805f5b8b9ac733d59349ff51c2898edda0c0893f21c95d2
MD5 32f29696726db4c4e39fefa020987b0e
BLAKE2b-256 bc1c83b22bdfc0f2411c7eb1ab7593b90e3f07208d314eed687246fca074fc29

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_dict-0.1.4.tar.gz:

Publisher: publish-pypi.yml on ywatanabe1989/scitex-dict

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scitex_dict-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: scitex_dict-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scitex_dict-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4482e1ff19e37256dd65d46d5d28918f62898f11476a01001a25421a24689f5a
MD5 82fc7ecc4293da1dd224996008ba4843
BLAKE2b-256 d3dac49f569596998e59451496f06c00e9440a7dfb7951fdf00ce66e62994dfc

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_dict-0.1.4-py3-none-any.whl:

Publisher: publish-pypi.yml on ywatanabe1989/scitex-dict

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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