digit-converter


Namedigit-converter JSON
Version 2.0 PyPI version JSON
download
home_pagehttps://github.com/Freakwill/digit_converter
SummaryA cool tool for digits converting. It could be applied in GA. It transforms a number to a list of digits under any base.
upload_time2023-11-28 02:43:07
maintainer
docs_urlNone
authorWilliam Song
requires_python>=3.7,<4.0
licenseMIT
keywords digit converting encoding genetic algorithm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            Introduction
=============

**Abstract**

A cool tool for digits converting.

It could be applied in Genetic Algorithm to encode the solutions.

**Keywords** Converter, Digits

## Content

### Classes

    BaseConverter: .tonumber(lst), .tolist(num, L)
    DigitConverter
    BinaryConverter: subclass of DigitConverter
    IntegerConverter: only convert integer
    IntervalConverter: subclass of IntegerConverter, converts a number in an interval to an integer what is the index of the number then applies IntegerConverter

### Objects

    colorConverter: instance of BinaryConverter, transform a number (0~255) to a 8-length list of 0-1s
    unitIntervalConverter: instance of IntervalConverter, transform a number in interval [0,1] to list of 0-1s

## Grammar

### import

`import digit_converter`



### Basic usage

#### Codes

```python
    print(f'color-converter: {colorConverter.tonumber([1,0,1,0,1,1,1,0])}<->{colorConverter.tolist(174)}')

    c = BinaryConverter(exponent=3)
    d = c.tolist(12.223, L=8)
    print(f'binary-converter: {d}<->{c.tonumber(d)}={c.pretty(d)}')

    c = IntervalConverter(lb=0, ub=10)
    d = c.tolist(2.4, L=8)
    print(f'[{c.lb},{c.ub}]-converter: {d}<->{c(d)} -> {c.pretty(d)}-th number')

    c = DigitConverter(base=16)
    d = c.tolist(2.4, L=8)
    print(f'16-converter: {d}<->{c(d)}={c.pretty(d)}')
```

 *OUTPUT:*

    color-converter: 174<->[1, 0, 1, 0, 1, 1, 1, 0]
    binary-converter: [1, 1, 0, 0, 0, 0, 1, 1]<->12.1875=2^{3} + 2^{2} + 2^{-3} + 2^{-4}
    [0,10]-converter: [0, 0, 1, 1, 1, 1, 0, 1]<->2.3828125 -> 2^{5} + 2^{4} + 2^{3} + 2^{2} + 2^{0}-th number
    16-converter: [0, 2, 6, 6, 6, 6, 6, 6]<->2.399999976158142=2*16^0 + 6*16^-1 + 6*16^-2 + 6*16^-3 + 6*16^-4 + 6*16^-5 + 6*16^-6
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Freakwill/digit_converter",
    "name": "digit-converter",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "Digit Converting,Encoding,Genetic Algorithm",
    "author": "William Song",
    "author_email": "30965609+Freakwill@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/62/ef/95a35534112d9de76f905f1e6bd237bea285b72690a9bb8a4f17947dc5d4/digit_converter-2.0.tar.gz",
    "platform": null,
    "description": "Introduction\n=============\n\n**Abstract**\n\nA cool tool for digits converting.\n\nIt could be applied in Genetic Algorithm to encode the solutions.\n\n**Keywords** Converter, Digits\n\n## Content\n\n### Classes\n\n    BaseConverter: .tonumber(lst), .tolist(num, L)\n    DigitConverter\n    BinaryConverter: subclass of DigitConverter\n    IntegerConverter: only convert integer\n    IntervalConverter: subclass of IntegerConverter, converts a number in an interval to an integer what is the index of the number then applies IntegerConverter\n\n### Objects\n\n    colorConverter: instance of BinaryConverter, transform a number (0~255) to a 8-length list of 0-1s\n    unitIntervalConverter: instance of IntervalConverter, transform a number in interval [0,1] to list of 0-1s\n\n## Grammar\n\n### import\n\n`import digit_converter`\n\n\n\n### Basic usage\n\n#### Codes\n\n```python\n    print(f'color-converter: {colorConverter.tonumber([1,0,1,0,1,1,1,0])}<->{colorConverter.tolist(174)}')\n\n    c = BinaryConverter(exponent=3)\n    d = c.tolist(12.223, L=8)\n    print(f'binary-converter: {d}<->{c.tonumber(d)}={c.pretty(d)}')\n\n    c = IntervalConverter(lb=0, ub=10)\n    d = c.tolist(2.4, L=8)\n    print(f'[{c.lb},{c.ub}]-converter: {d}<->{c(d)} -> {c.pretty(d)}-th number')\n\n    c = DigitConverter(base=16)\n    d = c.tolist(2.4, L=8)\n    print(f'16-converter: {d}<->{c(d)}={c.pretty(d)}')\n```\n\n *OUTPUT:*\n\n    color-converter: 174<->[1, 0, 1, 0, 1, 1, 1, 0]\n    binary-converter: [1, 1, 0, 0, 0, 0, 1, 1]<->12.1875=2^{3} + 2^{2} + 2^{-3} + 2^{-4}\n    [0,10]-converter: [0, 0, 1, 1, 1, 1, 0, 1]<->2.3828125 -> 2^{5} + 2^{4} + 2^{3} + 2^{2} + 2^{0}-th number\n    16-converter: [0, 2, 6, 6, 6, 6, 6, 6]<->2.399999976158142=2*16^0 + 6*16^-1 + 6*16^-2 + 6*16^-3 + 6*16^-4 + 6*16^-5 + 6*16^-6",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A cool tool for digits converting. It could be applied in GA. It transforms a number to a list of digits under any base.",
    "version": "2.0",
    "project_urls": {
        "Homepage": "https://github.com/Freakwill/digit_converter",
        "Repository": "https://github.com/Freakwill/digit_converter"
    },
    "split_keywords": [
        "digit converting",
        "encoding",
        "genetic algorithm"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1ab1dab8b120793111f9b970beaf4654a95dda51b1a664eeb34b03ee8dc6347e",
                "md5": "9c64db63c3876f3693d8b1a1bcad38aa",
                "sha256": "2a67712c87be556e2428901c39694cfa8e17384c252fdf302fc2e207df40677c"
            },
            "downloads": -1,
            "filename": "digit_converter-2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9c64db63c3876f3693d8b1a1bcad38aa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 5029,
            "upload_time": "2023-11-28T02:43:06",
            "upload_time_iso_8601": "2023-11-28T02:43:06.026538Z",
            "url": "https://files.pythonhosted.org/packages/1a/b1/dab8b120793111f9b970beaf4654a95dda51b1a664eeb34b03ee8dc6347e/digit_converter-2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "62ef95a35534112d9de76f905f1e6bd237bea285b72690a9bb8a4f17947dc5d4",
                "md5": "54e3bb59de274702914b47ffcc0b6247",
                "sha256": "840ad9810b2797ef54245b693b21b7d1cd0538b40cef888569651a42fa757320"
            },
            "downloads": -1,
            "filename": "digit_converter-2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "54e3bb59de274702914b47ffcc0b6247",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 4282,
            "upload_time": "2023-11-28T02:43:07",
            "upload_time_iso_8601": "2023-11-28T02:43:07.974553Z",
            "url": "https://files.pythonhosted.org/packages/62/ef/95a35534112d9de76f905f1e6bd237bea285b72690a9bb8a4f17947dc5d4/digit_converter-2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-28 02:43:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Freakwill",
    "github_project": "digit_converter",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "lcname": "digit-converter"
}
        
Elapsed time: 0.79020s