Skip to main content

Dictionary utilities (DotDict, safe_merge) for the SciTeX ecosystem

Project description

scitex-dict

SciTeX

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

Full Documentation · uv pip install scitex-dict[all]

PyPI Python Tests Coverage Docs License: AGPL v3


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

Architecture

scitex-dict/
├── src/scitex_dict/
│   ├── _DotDict.py        # attribute-access dict subclass
│   ├── _safe_merge.py     # raises on duplicate keys
│   ├── _flatten.py        # nested → dotted-key
│   └── _listed_dict.py    # default-list dict factory
└── tests/

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})

Demo

flowchart LR
    YAML[YAML config] --> DD[DotDict]
    DD -->|cfg.model.lr| Code[Your code]
    A[dict A] --> SM[safe_merge]
    B[dict B] --> SM
    SM --> Merged[merged 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})

Part of SciTeX

scitex-dict is part of SciTeX. Install via the umbrella with pip install scitex[dict] to use as scitex.dict (Python) or scitex dict ... (CLI).

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.8.tar.gz (8.6 MB 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.8-py3-none-any.whl (8.3 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scitex_dict-0.1.8.tar.gz
  • Upload date:
  • Size: 8.6 MB
  • 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.8.tar.gz
Algorithm Hash digest
SHA256 8070007beb108bcff20c729172c8812fd9e989d978e1908181975fd307f48db2
MD5 a051aa27225d16d78f903c5d12bc9625
BLAKE2b-256 5840b38db0c0395e802b23d44b1789b29ca074f474e454b4344e5fa0efa4cafe

See more details on using hashes here.

Provenance

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

Publisher: pypi-publish-and-github-release-on-tag.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.8-py3-none-any.whl.

File metadata

  • Download URL: scitex_dict-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 8.3 MB
  • 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 3768cedb11f4b5ce809de152fce96b1a56caa8cb4a41441b5760ee0ec8b782c3
MD5 5c7f96be6921cc724756bb61b87a48be
BLAKE2b-256 6bb4bd56a1020561b1e8f2ad0f543a4d7c547a5b437bc88284fb3798d7aedbd8

See more details on using hashes here.

Provenance

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

Publisher: pypi-publish-and-github-release-on-tag.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