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:
pip install spycio
Minimal example
#!/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))
Metadata
Release files for spycio 0.2.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spycio-0.2.8.tar.gz | 10.3 kB | Without provenance | Details for spycio-0.2.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spycio-0.2.8-py3-none-any.whl | Python 3 | none | any | Details for spycio-0.2.8-py3-none-any.whl |
Total release size: 20.4 kB
Release files / spycio-0.2.8.tar.gz
| Download URL | spycio-0.2.8.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20d57aca6700c04c882999fc86939393b0fe958d608b1c35346abcd0aca1aff7
|
|
BLAKE2b-256 checksum How to use checksums |
4e920f9e7bdd0336057b8129aef715c1e62d086f07c47f1abed53044665d9e53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.8.10 Linux/5.15.0-69-generic
|
Release files / spycio-0.2.8-py3-none-any.whl
| Download URL | spycio-0.2.8-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
86b0af5638c9b708a4a01c0e2509ffac99ea523aee02c940e899a59c5c817bb4
|
|
BLAKE2b-256 checksum How to use checksums |
0572115d5a43f0198b5371a8e411738b919118d2d5ef2dee1381bc779619f318
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.8.10 Linux/5.15.0-69-generic
|
Security for spycio 0.2.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.