kajihs_utils


Namekajihs_utils JSON
Version 0.8.0 PyPI version JSON
download
home_pageNone
SummaryFully typed, plausibly practical, and remarkably random utilities for me—and maybe for you too.
upload_time2025-04-20 21:57:55
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseNone
keywords jax loguru matplotlib numpy pyplot python tools utils whenever
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Build][github-ci-image]][github-ci-link]
[![Coverage Status][codecov-image]][codecov-link]
[![PyPI Version][pypi-image]][pypi-link]
[![PyPI - Python Version][python-image]][pypi-link]
![License][license-image]

# Kajihs Utils

Fully typed, plausibly practical, and remarkably random utilities for me—and maybe for you too.

## ⬇️ Installation

You can install **kajihs_utils** via pip:

```bash
pip install kajihs-utils
```

## 🏃 Getting Started

```python:dev/readme_snippets/formatted/features_demo.py
from kajihs_utils import get_first, is_sorted

# Useful protocols for structural subtyping
from kajihs_utils.protocols import SupportsAllComparisons, SupportsDunderLT

# Get first key existing in a dict
d = {"a": 1, "b": 2, "c": 3}
print(get_first(d, ["x", "a", "b"]))  # Output: 1

# Check if an iterable is sorted
print(is_sorted([1, 2, 2, 3]))  # Output: True
print(is_sorted("cba", reverse=True))  # Output: True
print(is_sorted([0, 1, 0]))  # Output: False

# === Loguru features ===
from kajihs_utils.loguru import prompt, setup_logging

# Better logged and formatted prompts
prompt("Enter a number")  

# Simply setup well formatted logging in files and console
setup_logging(prefix="app", log_dir="logs")

# === Numpy features ===
import numpy as np

from kajihs_utils.numpy_utils import Vec2d, find_closest

x = np.array([[0, 0], [10, 10], [20, 20]])
print(find_closest(x, [[-1, 2], [15, 12]]))  # Output: [0 1]

# Vec2d class
v = Vec2d(3.0, 4.0)
print(v)  # Output: [3. 4.]
print(tuple(v))  # Output: (np.float64(3.0), np.float64(4.0))
print(v.x)  # Output: 3.0
print(v.y)  # Output: 4.0
print(v.magnitude())  # Output: 5.0
print(v.normalized())  # Output: [0.6 0.8]
print(v.angle())  # Output: 53.13010235415598
print(v.rotate(90, center=(1, 1)))  # Output: [-2.  3.]

# === Whenever features ===
from datetime import datetime

from kajihs_utils.whenever import AllDateTime, ExactDateTime, dt_to_system_datetime  # Useful types

print(dt_to_system_datetime(datetime.now()))  # Output: 2025-04-20T21:57:31.460653+00:00
```

## 🧾 License

[MIT license](LICENSE)

<!-- Links -->
[github-ci-image]: https://github.com/Kajiih/kajihs_utils/actions/workflows/build.yml/badge.svg?branch=main
[github-ci-link]: https://github.com/Kajiih/kajihs_utils/actions?query=workflow%3Abuild+branch%3Amain

[codecov-image]: https://img.shields.io/codecov/c/github/Kajiih/kajihs_utils/main.svg?logo=codecov&logoColor=aaaaaa&labelColor=333333
[codecov-link]: https://codecov.io/github/Kajiih/kajihs_utils

[pypi-image]: https://img.shields.io/pypi/v/kajihs-utils.svg?logo=pypi&logoColor=aaaaaa&labelColor=333333
[pypi-link]: https://pypi.python.org/pypi/kajihs-utils

[python-image]: https://img.shields.io/pypi/pyversions/kajihs-utils?logo=python&logoColor=aaaaaa&labelColor=333333
[license-image]: https://img.shields.io/badge/license-MIT_license-blue.svg?labelColor=333333

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "kajihs_utils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "jax, loguru, matplotlib, numpy, pyplot, python, tools, utils, whenever",
    "author": null,
    "author_email": "Kajih <itskajih@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/cd/c9/a395ec04041afa65d3e6682248346b96a5a9f49d0c4b12a2f89fc24ce557/kajihs_utils-0.8.0.tar.gz",
    "platform": null,
    "description": "[![Build][github-ci-image]][github-ci-link]\n[![Coverage Status][codecov-image]][codecov-link]\n[![PyPI Version][pypi-image]][pypi-link]\n[![PyPI - Python Version][python-image]][pypi-link]\n![License][license-image]\n\n# Kajihs Utils\n\nFully typed, plausibly practical, and remarkably random utilities for me\u2014and maybe for you too.\n\n## \u2b07\ufe0f Installation\n\nYou can install **kajihs_utils** via pip:\n\n```bash\npip install kajihs-utils\n```\n\n## \ud83c\udfc3 Getting Started\n\n```python:dev/readme_snippets/formatted/features_demo.py\nfrom kajihs_utils import get_first, is_sorted\n\n# Useful protocols for structural subtyping\nfrom kajihs_utils.protocols import SupportsAllComparisons, SupportsDunderLT\n\n# Get first key existing in a dict\nd = {\"a\": 1, \"b\": 2, \"c\": 3}\nprint(get_first(d, [\"x\", \"a\", \"b\"]))  # Output: 1\n\n# Check if an iterable is sorted\nprint(is_sorted([1, 2, 2, 3]))  # Output: True\nprint(is_sorted(\"cba\", reverse=True))  # Output: True\nprint(is_sorted([0, 1, 0]))  # Output: False\n\n# === Loguru features ===\nfrom kajihs_utils.loguru import prompt, setup_logging\n\n# Better logged and formatted prompts\nprompt(\"Enter a number\")  \n\n# Simply setup well formatted logging in files and console\nsetup_logging(prefix=\"app\", log_dir=\"logs\")\n\n# === Numpy features ===\nimport numpy as np\n\nfrom kajihs_utils.numpy_utils import Vec2d, find_closest\n\nx = np.array([[0, 0], [10, 10], [20, 20]])\nprint(find_closest(x, [[-1, 2], [15, 12]]))  # Output: [0 1]\n\n# Vec2d class\nv = Vec2d(3.0, 4.0)\nprint(v)  # Output: [3. 4.]\nprint(tuple(v))  # Output: (np.float64(3.0), np.float64(4.0))\nprint(v.x)  # Output: 3.0\nprint(v.y)  # Output: 4.0\nprint(v.magnitude())  # Output: 5.0\nprint(v.normalized())  # Output: [0.6 0.8]\nprint(v.angle())  # Output: 53.13010235415598\nprint(v.rotate(90, center=(1, 1)))  # Output: [-2.  3.]\n\n# === Whenever features ===\nfrom datetime import datetime\n\nfrom kajihs_utils.whenever import AllDateTime, ExactDateTime, dt_to_system_datetime  # Useful types\n\nprint(dt_to_system_datetime(datetime.now()))  # Output: 2025-04-20T21:57:31.460653+00:00\n```\n\n## \ud83e\uddfe License\n\n[MIT license](LICENSE)\n\n<!-- Links -->\n[github-ci-image]: https://github.com/Kajiih/kajihs_utils/actions/workflows/build.yml/badge.svg?branch=main\n[github-ci-link]: https://github.com/Kajiih/kajihs_utils/actions?query=workflow%3Abuild+branch%3Amain\n\n[codecov-image]: https://img.shields.io/codecov/c/github/Kajiih/kajihs_utils/main.svg?logo=codecov&logoColor=aaaaaa&labelColor=333333\n[codecov-link]: https://codecov.io/github/Kajiih/kajihs_utils\n\n[pypi-image]: https://img.shields.io/pypi/v/kajihs-utils.svg?logo=pypi&logoColor=aaaaaa&labelColor=333333\n[pypi-link]: https://pypi.python.org/pypi/kajihs-utils\n\n[python-image]: https://img.shields.io/pypi/pyversions/kajihs-utils?logo=python&logoColor=aaaaaa&labelColor=333333\n[license-image]: https://img.shields.io/badge/license-MIT_license-blue.svg?labelColor=333333\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Fully typed, plausibly practical, and remarkably random utilities for me\u2014and maybe for you too.",
    "version": "0.8.0",
    "project_urls": {
        "Issues": "https://github.com/Kajiih/kajihs_utils/issues",
        "Repository": "https://github.com/Kajiih/kajihs_utils"
    },
    "split_keywords": [
        "jax",
        " loguru",
        " matplotlib",
        " numpy",
        " pyplot",
        " python",
        " tools",
        " utils",
        " whenever"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "898e1674b7f90ed6f5a124292ab2a092a6248ea280eb198f254b70144d37f1bd",
                "md5": "2ec714eca4552027ac912bbe1bdf9d7b",
                "sha256": "3e72be2d12b91d263a766b51d4af6b45e93b2cbf77990bdec1b62a2b359fa3d9"
            },
            "downloads": -1,
            "filename": "kajihs_utils-0.8.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2ec714eca4552027ac912bbe1bdf9d7b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 14174,
            "upload_time": "2025-04-20T21:57:56",
            "upload_time_iso_8601": "2025-04-20T21:57:56.534669Z",
            "url": "https://files.pythonhosted.org/packages/89/8e/1674b7f90ed6f5a124292ab2a092a6248ea280eb198f254b70144d37f1bd/kajihs_utils-0.8.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "cdc9a395ec04041afa65d3e6682248346b96a5a9f49d0c4b12a2f89fc24ce557",
                "md5": "64d66f72333140984e2233874278a961",
                "sha256": "9c0455af68c2a83f1dd4ba202f3eeac97509826f14906d9b80c5fb5fb242d41f"
            },
            "downloads": -1,
            "filename": "kajihs_utils-0.8.0.tar.gz",
            "has_sig": false,
            "md5_digest": "64d66f72333140984e2233874278a961",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 104580,
            "upload_time": "2025-04-20T21:57:55",
            "upload_time_iso_8601": "2025-04-20T21:57:55.179022Z",
            "url": "https://files.pythonhosted.org/packages/cd/c9/a395ec04041afa65d3e6682248346b96a5a9f49d0c4b12a2f89fc24ce557/kajihs_utils-0.8.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-04-20 21:57:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Kajiih",
    "github_project": "kajihs_utils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "kajihs_utils"
}
        
Elapsed time: 0.40638s