spycio


Namespycio JSON
Version 0.2.8 PyPI version JSON
download
home_pagehttps://pypi.org/project/spycio/
SummaryDistances in python
upload_time2023-04-24 21:22:08
maintainer
docs_urlNone
authorBruno Peixoto
requires_python>=3.8.1,<4.0
licenseMIT
keywords distance
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![apartogether](https://github.com/trouchet/spycio/blob/master/images/spycio_tiny.png?raw=true)

[![Version](https://img.shields.io/pypi/v/spycio.svg)](https://pypi.python.org/pypi/spycio)
[![python](https://img.shields.io/pypi/pyversions/spycio.svg)](https://pypi.org/project/spycio/)
[![downloads](https://img.shields.io/pypi/dm/spycio)](https://pypi.org/project/spycio/)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/trouchet/spycio/HEAD)

[![codecov](https://codecov.io/gh/trouchet/spycio/branch/master/graph/badge.svg?token=65OGOH51NV)](https://codecov.io/gh/trouchet/spycio)
[![Lint workflow](https://github.com/trouchet/spycio/actions/workflows/check-lint.yaml/badge.svg)](https://github.com/trouchet/spycio/actions/workflows/check-lint.yaml)

Space with a (pseudo-)metric allows us to perform distances. This library offers several functionalities in this regard; 

How to install
================

We run the command on desired installation environment:

``` {.bash}
pip install spycio
```

Minimal example
================

``` {.bash}
#!/usr/bin/env python
from numpy import pi, Inf

from spycio import distance, travelTime
from spycio.utils import spherToGeo

def format_distance_without_configuration(A, B, speed, method):
    string_template='A:{origin}, B:{target}, speed:{speed}, method:{on}, distance:{d}, eta:{eta}'
    
    dist=distance(A, B, method)
    duration=travelTime(speed, A, B, method)
    
    return string_template.format(origin=A,target=B,speed=speed, on=method,d=dist,eta=duration)

def format_distance(A, B, speed, method, config):
    string_template='A:{origin}, B:{target}, speed:{speed}, method:{on}, config:{setup}, distance:{d}, eta:{eta}'
    
    dist=distance(A, B, method, config)
    duration=travelTime(speed, A, B, method, config)
    
    return string_template.format(origin=A,target=B, speed=speed, on=method,setup=config, d=dist, eta=duration)


# Default distance calculation: Euclidean
A=[0, 0]
B=[1, 1]
C=[2, 2]
D=[pi / 2, 0]

speed=1

print('Euclidean distance: '+str(distance(A, B)))

print('\n')

configurations=[
    (B, C, speed, "manhattan"),
    (B, C, speed, "euclidean"),
    (B, C, speed, "max"),
    (B, C, speed, "chebyshev"),
    (B, C, speed, "manhattan"),
    (B, C, speed, "cityblock"),
    (B, C, speed, "cosine"),
    (B, C, speed, "braycurtis"),
    (B, C, speed, "canberra")
]

print('Format distance without configuration: ')
for origin, target, speed, method in configurations:
    print(format_distance_without_configuration(origin, target, speed, method))

print('\n')

configurations=[
    (B, C, speed, "pnorm", { "exponent": 2 }),
    (B, C, speed, "pnorm", { "exponent": 3 }),
    (B, C, speed, "pnorm", { "exponent": 4 }),
    (B, C, speed, "pnorm", { "exponent": Inf }),
    (A, D, speed, "sphere", { "radius": 1 }),
    (spherToGeo(A), spherToGeo(D), speed, "geographical", { "radius": 1 })
]

print('Format distance with configuration: ')

for origin, target, speed, method, config in configurations:
    print(format_distance(origin, target, speed, method, config))
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.org/project/spycio/",
    "name": "spycio",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.1,<4.0",
    "maintainer_email": "",
    "keywords": "distance",
    "author": "Bruno Peixoto",
    "author_email": "brunolnetto@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/4e/92/0f9e7bdd0336057b8129aef715c1e62d086f07c47f1abed53044665d9e53/spycio-0.2.8.tar.gz",
    "platform": null,
    "description": "![apartogether](https://github.com/trouchet/spycio/blob/master/images/spycio_tiny.png?raw=true)\n\n[![Version](https://img.shields.io/pypi/v/spycio.svg)](https://pypi.python.org/pypi/spycio)\n[![python](https://img.shields.io/pypi/pyversions/spycio.svg)](https://pypi.org/project/spycio/)\n[![downloads](https://img.shields.io/pypi/dm/spycio)](https://pypi.org/project/spycio/)\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/trouchet/spycio/HEAD)\n\n[![codecov](https://codecov.io/gh/trouchet/spycio/branch/master/graph/badge.svg?token=65OGOH51NV)](https://codecov.io/gh/trouchet/spycio)\n[![Lint workflow](https://github.com/trouchet/spycio/actions/workflows/check-lint.yaml/badge.svg)](https://github.com/trouchet/spycio/actions/workflows/check-lint.yaml)\n\nSpace with a (pseudo-)metric allows us to perform distances. This library offers several functionalities in this regard; \n\nHow to install\n================\n\nWe run the command on desired installation environment:\n\n``` {.bash}\npip install spycio\n```\n\nMinimal example\n================\n\n``` {.bash}\n#!/usr/bin/env python\nfrom numpy import pi, Inf\n\nfrom spycio import distance, travelTime\nfrom spycio.utils import spherToGeo\n\ndef format_distance_without_configuration(A, B, speed, method):\n    string_template='A:{origin}, B:{target}, speed:{speed}, method:{on}, distance:{d}, eta:{eta}'\n    \n    dist=distance(A, B, method)\n    duration=travelTime(speed, A, B, method)\n    \n    return string_template.format(origin=A,target=B,speed=speed, on=method,d=dist,eta=duration)\n\ndef format_distance(A, B, speed, method, config):\n    string_template='A:{origin}, B:{target}, speed:{speed}, method:{on}, config:{setup}, distance:{d}, eta:{eta}'\n    \n    dist=distance(A, B, method, config)\n    duration=travelTime(speed, A, B, method, config)\n    \n    return string_template.format(origin=A,target=B, speed=speed, on=method,setup=config, d=dist, eta=duration)\n\n\n# Default distance calculation: Euclidean\nA=[0, 0]\nB=[1, 1]\nC=[2, 2]\nD=[pi / 2, 0]\n\nspeed=1\n\nprint('Euclidean distance: '+str(distance(A, B)))\n\nprint('\\n')\n\nconfigurations=[\n    (B, C, speed, \"manhattan\"),\n    (B, C, speed, \"euclidean\"),\n    (B, C, speed, \"max\"),\n    (B, C, speed, \"chebyshev\"),\n    (B, C, speed, \"manhattan\"),\n    (B, C, speed, \"cityblock\"),\n    (B, C, speed, \"cosine\"),\n    (B, C, speed, \"braycurtis\"),\n    (B, C, speed, \"canberra\")\n]\n\nprint('Format distance without configuration: ')\nfor origin, target, speed, method in configurations:\n    print(format_distance_without_configuration(origin, target, speed, method))\n\nprint('\\n')\n\nconfigurations=[\n    (B, C, speed, \"pnorm\", { \"exponent\": 2 }),\n    (B, C, speed, \"pnorm\", { \"exponent\": 3 }),\n    (B, C, speed, \"pnorm\", { \"exponent\": 4 }),\n    (B, C, speed, \"pnorm\", { \"exponent\": Inf }),\n    (A, D, speed, \"sphere\", { \"radius\": 1 }),\n    (spherToGeo(A), spherToGeo(D), speed, \"geographical\", { \"radius\": 1 })\n]\n\nprint('Format distance with configuration: ')\n\nfor origin, target, speed, method, config in configurations:\n    print(format_distance(origin, target, speed, method, config))\n```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Distances in python",
    "version": "0.2.8",
    "split_keywords": [
        "distance"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0572115d5a43f0198b5371a8e411738b919118d2d5ef2dee1381bc779619f318",
                "md5": "4d3cecf98833cdd8c39f5cbf2fae8ac1",
                "sha256": "86b0af5638c9b708a4a01c0e2509ffac99ea523aee02c940e899a59c5c817bb4"
            },
            "downloads": -1,
            "filename": "spycio-0.2.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4d3cecf98833cdd8c39f5cbf2fae8ac1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1,<4.0",
            "size": 10137,
            "upload_time": "2023-04-24T21:22:06",
            "upload_time_iso_8601": "2023-04-24T21:22:06.542230Z",
            "url": "https://files.pythonhosted.org/packages/05/72/115d5a43f0198b5371a8e411738b919118d2d5ef2dee1381bc779619f318/spycio-0.2.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4e920f9e7bdd0336057b8129aef715c1e62d086f07c47f1abed53044665d9e53",
                "md5": "ab1f554da9cb2aa9272294f6a3f9c707",
                "sha256": "20d57aca6700c04c882999fc86939393b0fe958d608b1c35346abcd0aca1aff7"
            },
            "downloads": -1,
            "filename": "spycio-0.2.8.tar.gz",
            "has_sig": false,
            "md5_digest": "ab1f554da9cb2aa9272294f6a3f9c707",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1,<4.0",
            "size": 10258,
            "upload_time": "2023-04-24T21:22:08",
            "upload_time_iso_8601": "2023-04-24T21:22:08.667119Z",
            "url": "https://files.pythonhosted.org/packages/4e/92/0f9e7bdd0336057b8129aef715c1e62d086f07c47f1abed53044665d9e53/spycio-0.2.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-24 21:22:08",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "spycio"
}
        
Elapsed time: 0.19340s