No project description provided
Project description
Custom WKT
Tooling to render WKT values based on specific, custom data layouts.
Given two series of 2-D data, grouped by classes, render into a list of WKT LINESTRINGs.
import custom_wkt
import numpy as np
custom_wkt.linestring(np.linspace(0, 5, 6), np.linspace(0, 5, 6) / 2.0, np.array([0, 0, 0, 0, 1, 1]), 1)
# ['LINESTRING (0.0 0.0, 1.0 0.5, 2.0 1.0, 3.0 1.5)', 'LINESTRING (4.0 2.0, 5.0 2.5)']
Operation
| x | y | c |
|---|---|---|
| 0.0 | 0.0 | 0 |
| 1.0 | 0.5 | 0 |
| 2.0 | 1.0 | 0 |
| 3.0 | 1.5 | 0 |
| 4.0 | 2.0 | 1 |
| 5.0 | 2.5 | 1 |
Where x, y are the elements are np.float64 values for the points and c are the classes for the points as np.int64.
Note that classes must already be consecutive and returned LINESTRINGs will match the classes' order.
LINESTRING (0.0 0.0, 1.0 0.5, 2.0 1.0, 3.0 1.5) for class 0 and LINESTRING (4.0 2.0, 5.0 2.5) for class 1.
Function Signature
Note that this package is type strict - point values must be np.float64, classes must be np.int64, and precision must be an int.
The underlying code is written in Rust and offers a function signature equivalent to:
def linestring(x: np.ndarray, y: np.ndarray, classes: np.ndarray, precision: int) -> List[str]:
"""
Parameters
----------
x : np.ndarray
First Point Value - float64
y : np.ndarray
Second Point Values - float64
classes : np.ndarray
Classes - int64
precision : int
Number of places for rendering in string, >= 0
Returns
-------
List[str]
List of LineStrings
"""
Example Usage
import pandas as pd
import numpy as np
import custom_wkt
df = (
pd.DataFrame({"x": np.arange(6).astype(np.float64)})
.assign(y=lambda idf: idf["x"] / 2, c=lambda idf: (idf["x"] > 3).astype(np.int64))
.sort_index("c")
)
result = custom_wkt.linestring(df["x"].values, df["y"].values, df["c"].values, 1)
# ['LINESTRING (0.0 0.0, 1.0 0.5, 2.0 1.0, 3.0 1.5)', 'LINESTRING (4.0 2.0, 5.0 2.5)']
If classes are available as Pandas series as strings or another type,
str_series = df["c"].astype(str)
int_classes = str_series.astype("category").cat.codes.astype(np.int64).values
# NOTE: Cast to int64. Pandas will return the smallest int dtype to fit number of categories
# but custom_wkt requires strict types
result = custom_wkt.linestring(df["x"].values, df["y"].values, int_classes, 1)
# ['LINESTRING (0.0 0.0, 1.0 0.5, 2.0 1.0, 3.0 1.5)', 'LINESTRING (4.0 2.0, 5.0 2.5)']
Performance
Performance varies greatly depending on size of inputs, size of the groups, and relative precision.
Rough estimates measure 2-3x speedup and decreased memory usage over normal python logic.
Similar Pandas operations are much less efficient computation. The nature of the solution includes groupbys and python function calls, which have richer functionality but negatively impact performance for this operation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file custom_wkt-0.1.0-cp39-none-win_amd64.whl.
File metadata
- Download URL: custom_wkt-0.1.0-cp39-none-win_amd64.whl
- Upload date:
- Size: 129.9 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd056faf925f86aa9892f2e45e82ca9c44989cfa7f4df353c37292845115eeb3
|
|
| MD5 |
3dc3c02556ec74a8b475b9940b2779d9
|
|
| BLAKE2b-256 |
1639596c8317737325baba840d4a0a01afa9e7a1e37e057d7111037d85a8d4ed
|
File details
Details for the file custom_wkt-0.1.0-cp39-cp39-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: custom_wkt-0.1.0-cp39-cp39-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 187.1 kB
- Tags: CPython 3.9, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87f32b043a931f47bbf8186c553dc461dd53616dfbfe576ff145699de1d078b2
|
|
| MD5 |
ccb8beb49f213f7e746232e2238882a5
|
|
| BLAKE2b-256 |
55527d12011d417f09d3bdd4cc149804d3821ee60572ff251f4e9d8175eff653
|
File details
Details for the file custom_wkt-0.1.0-cp39-cp39-macosx_10_7_x86_64.whl.
File metadata
- Download URL: custom_wkt-0.1.0-cp39-cp39-macosx_10_7_x86_64.whl
- Upload date:
- Size: 178.3 kB
- Tags: CPython 3.9, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
817920c865a9491aee146d5a35cbdfde978734a8957174d018f732dbbc3fc15e
|
|
| MD5 |
fdd2e5d07ba064c12897893292220796
|
|
| BLAKE2b-256 |
89e411c2aa952ab81bc562757504b41fa919070e1754cd769e2a763ad2c62dac
|
File details
Details for the file custom_wkt-0.1.0-cp38-none-win_amd64.whl.
File metadata
- Download URL: custom_wkt-0.1.0-cp38-none-win_amd64.whl
- Upload date:
- Size: 129.7 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2aceae19b281a649f87278cc940b16113b94ddadadecdd11f138ac58d8fdb6f
|
|
| MD5 |
4a1b055a8e6a0c57dc8589f1db885098
|
|
| BLAKE2b-256 |
f6ef79ef5c2c0c3aa652bef209bc7f825750229a6ce2bef15f3b1ee44010bed9
|
File details
Details for the file custom_wkt-0.1.0-cp38-cp38-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: custom_wkt-0.1.0-cp38-cp38-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 187.1 kB
- Tags: CPython 3.8, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16f88bc1f3f2605a992a0f73a4bdb6e3fde0b5034fbb174d4607396078f83caf
|
|
| MD5 |
65883dacf4309fd154005003f8a2fabb
|
|
| BLAKE2b-256 |
2a74cf09dbc6f59bf22d2083aefa1d67ec4f0f57512651e7109b4380d34d391d
|
File details
Details for the file custom_wkt-0.1.0-cp38-cp38-macosx_10_7_x86_64.whl.
File metadata
- Download URL: custom_wkt-0.1.0-cp38-cp38-macosx_10_7_x86_64.whl
- Upload date:
- Size: 178.3 kB
- Tags: CPython 3.8, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f81e60d3acf26cc7a69ba945c8032fa4c4a2a3c367f02ede9cc75be58de383b7
|
|
| MD5 |
e62ae7b601e5eb6cf41eb9f767b4d864
|
|
| BLAKE2b-256 |
99f2c1ae65de50fb173515899e33bff7b3dc3572a12929635f3b0a9c641bce77
|
File details
Details for the file custom_wkt-0.1.0-cp37-none-win_amd64.whl.
File metadata
- Download URL: custom_wkt-0.1.0-cp37-none-win_amd64.whl
- Upload date:
- Size: 129.9 kB
- Tags: CPython 3.7, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbc67d59918c9545831496d036ccb32dbbe097d52e074334413583b347b4b91e
|
|
| MD5 |
0c9f022bdc3a2fa9af0304f15b0069ec
|
|
| BLAKE2b-256 |
678fa2109cc97089e93b210b3b4f514759683e6fe58664e9f36862037011c10b
|
File details
Details for the file custom_wkt-0.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: custom_wkt-0.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 187.1 kB
- Tags: CPython 3.7m, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
129153f2ec339c31ed4d19e8c9661c4e4c8619d02719b27183ebb9ce81cce35f
|
|
| MD5 |
55f9ea516f4d6ee3c36e63f155bdcb3d
|
|
| BLAKE2b-256 |
2adf6fdac72485786593ebff27bcaac6d34b6f3cfd2f54a61ec9e380f6e4c4b0
|
File details
Details for the file custom_wkt-0.1.0-cp37-cp37m-macosx_10_7_x86_64.whl.
File metadata
- Download URL: custom_wkt-0.1.0-cp37-cp37m-macosx_10_7_x86_64.whl
- Upload date:
- Size: 178.5 kB
- Tags: CPython 3.7m, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d95c812b1d524ab222d992fbd73e7f4666aade72875d9bd97a916d0a1f93e93
|
|
| MD5 |
b277069b9e8061ae408756ef1c2880e6
|
|
| BLAKE2b-256 |
3acd81beba46fcfd8f2daf7ecb34b9375a473b1d705d93d41b2458d2e4d769ec
|
File details
Details for the file custom_wkt-0.1.0-cp36-none-win_amd64.whl.
File metadata
- Download URL: custom_wkt-0.1.0-cp36-none-win_amd64.whl
- Upload date:
- Size: 129.9 kB
- Tags: CPython 3.6, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6da43fb346a71c94b9682c34df33ffa094ed43ef0ab18033c5c135a3cf30bf88
|
|
| MD5 |
bc1d5e2630503f86f23136d0c0baf481
|
|
| BLAKE2b-256 |
66f529f0005a0af52bbd98b5e03d9d7a783b7c1a04d00536830aabf457493791
|
File details
Details for the file custom_wkt-0.1.0-cp36-cp36m-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: custom_wkt-0.1.0-cp36-cp36m-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 187.2 kB
- Tags: CPython 3.6m, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fd90929c1d7dcca0116433c2411c76676c6f4a3591e8703643183dc211ba413
|
|
| MD5 |
85c6e9b76ec7a1a4dd4a778613cd8288
|
|
| BLAKE2b-256 |
2ca25c07db2dfe9d3a85da8aeaee382c89eedc3fbf3a2fd35c812c8d2ddded1c
|
File details
Details for the file custom_wkt-0.1.0-cp36-cp36m-macosx_10_7_x86_64.whl.
File metadata
- Download URL: custom_wkt-0.1.0-cp36-cp36m-macosx_10_7_x86_64.whl
- Upload date:
- Size: 178.5 kB
- Tags: CPython 3.6m, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
455566721624353cadf6d870806e49dc47561ad006946616bd44c3aa77970266
|
|
| MD5 |
03a3cd4287efcabe6f419d01ca888e40
|
|
| BLAKE2b-256 |
fd4dfaffd0066a43f3dd17882ac1ee771b807e01378ee9ded6d8e5d04327aef6
|