ouch


Nameouch JSON
Version 0.0.15 PyPI version JSON
download
home_pagehttps://github.com/thyeem/ouch
SummaryOdd Utility Collection Hub
upload_time2025-01-15 11:30:38
maintainerNone
docs_urlNone
authorFrancis Lim
requires_python>=3.6
licenseMIT
keywords utilities functional
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center"> <img src="https://raw.githubusercontent.com/thyeem/ouch/main/ouch.png" height="250"/></p>

[![ouch](https://img.shields.io/pypi/v/ouch)](https://pypi.org/project/ouch)

# ouch

_Odd Utiltiy Collection Hub_.

[`ouch`](https://github.com/thyeem/ouch) is a collection of utilities that are based on and aligned with [`foc`](https://github.com/thyeem/foc).

```bash
$ pip install -U ouch
```

```python
from ouch import *

# soft flatten
>>> flatten([1, [2, 3, (4, 5)]])
[1, 2, 3, (4, 5)]
# hard flatten
>>> [1, [(2,), [[{3}, (x for x in range(3))]]]] | flat | collect
[1, 2, 3, 0, 1, 2]

# 'shell' command
>>> shell(f"du -hs ouch/__init__.py 2>/dev/null") | fst | ob(_.split)()
['40K', 'ouch/__init__.py']

# 'ls' command
>>> ls(".", r=True, grep="^(ouch).*py$")
['ouch/__init__.py']

# poor man's dot-accessible dict, 'dmap' and pretty-printer 'pp'
>>> d = dmap(name="yunchan lim", age=19)
>>> d.cliburn.semifinal.concerto = "Mozart Piano Concerto No.22, K.482"
>>> d.cliburn.semifinal.recital = "Liszt 12 Transcendental Etudes"
>>> d.cliburn.final = "Rachmaninov Piano Concerto No.3, Op.30"
>>> d | pp
  cliburn |     final | Rachmaninov Piano Concerto No.3, Op.30
            semifinal | concerto | Mozart Piano Concerto No.22, K.482
                         recital | Liszt 12 Transcendental Etudes
     name | yunchan lim

# poor man's 'tabulate'
>>> data = [['Name', 'Age'], ['Sofia', 9], ['Maria', 7]]
>>> print(tabulate(data, style='grid'))    # style={'org', 'markdown', ...}
+-------+-----+
| Name  | Age |
+=======+=====+
| Sofia | 9   |
+-------+-----+
| Maria | 7   |
+-------+-----+

# poor man's progress bar, 'tracker'
>>> for batch in tracker(dataloader, "training"):  # single progress bar
...     model(batch)

>>> for i in tracker(range(10), "outer"):  # nested progress bars
...     ...             
...     for j in tracker(range(20), "inner"):
...         ...              

>>> g = (x for x in range(100))
>>> for item in tracker(g, "task", total=100):  # generator with known length
...     process(item)


# and see more poor man's things in 'ouch'
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/thyeem/ouch",
    "name": "ouch",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "utilities functional",
    "author": "Francis Lim",
    "author_email": "thyeem@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c0/29/57fa179d3398fee27f6c823a0be03c112b7838d4197e90bc5b57a05d6e91/ouch-0.0.15.tar.gz",
    "platform": null,
    "description": "<p align=\"center\"> <img src=\"https://raw.githubusercontent.com/thyeem/ouch/main/ouch.png\" height=\"250\"/></p>\n\n[![ouch](https://img.shields.io/pypi/v/ouch)](https://pypi.org/project/ouch)\n\n# ouch\n\n_Odd Utiltiy Collection Hub_.\n\n[`ouch`](https://github.com/thyeem/ouch) is a collection of utilities that are based on and aligned with [`foc`](https://github.com/thyeem/foc).\n\n```bash\n$ pip install -U ouch\n```\n\n```python\nfrom ouch import *\n\n# soft flatten\n>>> flatten([1, [2, 3, (4, 5)]])\n[1, 2, 3, (4, 5)]\n# hard flatten\n>>> [1, [(2,), [[{3}, (x for x in range(3))]]]] | flat | collect\n[1, 2, 3, 0, 1, 2]\n\n# 'shell' command\n>>> shell(f\"du -hs ouch/__init__.py 2>/dev/null\") | fst | ob(_.split)()\n['40K', 'ouch/__init__.py']\n\n# 'ls' command\n>>> ls(\".\", r=True, grep=\"^(ouch).*py$\")\n['ouch/__init__.py']\n\n# poor man's dot-accessible dict, 'dmap' and pretty-printer 'pp'\n>>> d = dmap(name=\"yunchan lim\", age=19)\n>>> d.cliburn.semifinal.concerto = \"Mozart Piano Concerto No.22, K.482\"\n>>> d.cliburn.semifinal.recital = \"Liszt 12 Transcendental Etudes\"\n>>> d.cliburn.final = \"Rachmaninov Piano Concerto No.3, Op.30\"\n>>> d | pp\n  cliburn |     final | Rachmaninov Piano Concerto No.3, Op.30\n            semifinal | concerto | Mozart Piano Concerto No.22, K.482\n                         recital | Liszt 12 Transcendental Etudes\n     name | yunchan lim\n\n# poor man's 'tabulate'\n>>> data = [['Name', 'Age'], ['Sofia', 9], ['Maria', 7]]\n>>> print(tabulate(data, style='grid'))    # style={'org', 'markdown', ...}\n+-------+-----+\n| Name  | Age |\n+=======+=====+\n| Sofia | 9   |\n+-------+-----+\n| Maria | 7   |\n+-------+-----+\n\n# poor man's progress bar, 'tracker'\n>>> for batch in tracker(dataloader, \"training\"):  # single progress bar\n...     model(batch)\n\n>>> for i in tracker(range(10), \"outer\"):  # nested progress bars\n...     ...             \n...     for j in tracker(range(20), \"inner\"):\n...         ...              \n\n>>> g = (x for x in range(100))\n>>> for item in tracker(g, \"task\", total=100):  # generator with known length\n...     process(item)\n\n\n# and see more poor man's things in 'ouch'\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Odd Utility Collection Hub",
    "version": "0.0.15",
    "project_urls": {
        "Homepage": "https://github.com/thyeem/ouch"
    },
    "split_keywords": [
        "utilities",
        "functional"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a094d8faacc6f663b7c5ec1c4a350116c9e7a53336ae3263fa703662590af502",
                "md5": "496862fa130186ef193f0df0bb288515",
                "sha256": "3e610c834813585006351498ba4ff814e98bbe2080992ce362552bd0a6607cb9"
            },
            "downloads": -1,
            "filename": "ouch-0.0.15-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "496862fa130186ef193f0df0bb288515",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 15117,
            "upload_time": "2025-01-15T11:30:36",
            "upload_time_iso_8601": "2025-01-15T11:30:36.708189Z",
            "url": "https://files.pythonhosted.org/packages/a0/94/d8faacc6f663b7c5ec1c4a350116c9e7a53336ae3263fa703662590af502/ouch-0.0.15-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c02957fa179d3398fee27f6c823a0be03c112b7838d4197e90bc5b57a05d6e91",
                "md5": "235eeeba3becf7b12d5125242d00070c",
                "sha256": "5be1cf18c1a3adcfaf37baa0f2794abbd7109ec324590b015b2a40c19b622364"
            },
            "downloads": -1,
            "filename": "ouch-0.0.15.tar.gz",
            "has_sig": false,
            "md5_digest": "235eeeba3becf7b12d5125242d00070c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 16474,
            "upload_time": "2025-01-15T11:30:38",
            "upload_time_iso_8601": "2025-01-15T11:30:38.302337Z",
            "url": "https://files.pythonhosted.org/packages/c0/29/57fa179d3398fee27f6c823a0be03c112b7838d4197e90bc5b57a05d6e91/ouch-0.0.15.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-15 11:30:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "thyeem",
    "github_project": "ouch",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ouch"
}
        
Elapsed time: 0.41835s