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

Uploaded Python 3

File details

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

File metadata

  • Download URL: scitex_dict-0.1.7.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.7.tar.gz
Algorithm Hash digest
SHA256 ee3d3180d195cac9ebe36ceda9a92776d95c6ed655720bd4fb132159e8490747
MD5 164b3c7b2a28d69d2f93c04549f0a6d1
BLAKE2b-256 0a9bd9c84aae63d29e58b15c959485932cc64be627a4c80bc3c8f65a9624cdb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_dict-0.1.7.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.7-py3-none-any.whl.

File metadata

  • Download URL: scitex_dict-0.1.7-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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e975a3ec175c24962d440d8399fb2579bcc0891ddf44d3b47f6572073cb5efe6
MD5 0d53f1764005bf28bf5e0b212ab7d08f
BLAKE2b-256 2d3a0eff9bacbf884d298b34d9f96d243a28ab7cc4196fa00696f2a30a2427d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_dict-0.1.7-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