Shoot a knarrow to the knee
Project description
knarrow
Shoot a knarrow to the knee ;)
(The lib is better than this pun, I swear.)
Detect knee points in various scenarios using a plethora of methods
Usage
Just plug in your values in a list, tuple or an np.ndarray and watch knarrow hit the knee:
>>> from knarrow import find_knee
>>> find_knee([1, 2, 3, 4, 6]) # use a list
3
>>> find_knee((1, 2, 3, 4, 6)) # or a tuple
3
>>> import numpy as np
>>> y = np.array([1.0, 1.05, 1.15, 1.28, 1.30, 2.5, 3.6, 4.9])
>>> find_knee(y) # provide just the values
4
>>> x = np.arange(8)
>>> find_knee(x, y) # or both x and y
4
>>> A = np.vstack((x, y))
>>> A
array([[0. , 1. , 2. , 3. , 4. , 5. , 6. , 7. ],
[1. , 1.05, 1.15, 1.28, 1.3 , 2.5 , 3.6 , 4.9 ]])
>>> find_knee(A) # works with x in first row, y in the second
4
>>> A.T
array([[0. , 1. ],
[1. , 1.05],
[2. , 1.15],
[3. , 1.28],
[4. , 1.3 ],
[5. , 2.5 ],
[6. , 3.6 ],
[7. , 4.9 ]])
>>> find_knee(A.T) # also works with x in the first column, y in the second column
4
>>> find_knee(x, y, smoothing=0.01) # for better results use cubic spline smoothing
4
CLI
This library can also come with a handy CLI if you install it with the cli extra:
$ pip install "knarrow[cli]"
$ cat data.txt | knarrow -
<stdin> 11
$ cat data.txt | knarrow -o value -
<stdin> 59874.14171519781845532648
$ knarrow --sort -d ',' -o value shuf_delim.txt
shuf_delim.txt 20
(the - for stdin is, unfortunately, mandatory)
Try writing knarrow --help for more info.
Similar projects
While I've come up with most of these methods by myself, I am not the only one. Here is a (non-comprehensive) list of projects I've found that implement a similar functionality and may have been an inspiration for me:
Note: this project was bootstrapped by python-blueprint. Since then, it has been heavily modified, though.
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 Distribution
Built Distribution
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 knarrow-0.9.1.tar.gz.
File metadata
- Download URL: knarrow-0.9.1.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff87f9c6adc8bb08d7d9195f79875754ef1db73aedf95e1bc3bd4804d4952c9f
|
|
| MD5 |
e1832faeaa1a0dea072063d703e3b06c
|
|
| BLAKE2b-256 |
7694fbe3730f88bc9344d2b2abd261f9564cd3cad10d5ba304aad974c8cfae76
|
Provenance
The following attestation bundles were made for knarrow-0.9.1.tar.gz:
Publisher:
build-and-publish.yml on InCogNiTo124/knarrow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
knarrow-0.9.1.tar.gz -
Subject digest:
ff87f9c6adc8bb08d7d9195f79875754ef1db73aedf95e1bc3bd4804d4952c9f - Sigstore transparency entry: 1230058714
- Sigstore integration time:
-
Permalink:
InCogNiTo124/knarrow@bf8bc506fba584e98c8e12e46e3b097e9fcc4ef7 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/InCogNiTo124
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-and-publish.yml@bf8bc506fba584e98c8e12e46e3b097e9fcc4ef7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file knarrow-0.9.1-py3-none-any.whl.
File metadata
- Download URL: knarrow-0.9.1-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b98cca020567d514b005e04fe0d1708a3a2b2247bc53e5d83cb5a7234e4997b9
|
|
| MD5 |
27389a12d87da78643ea9538f9448713
|
|
| BLAKE2b-256 |
5df9c08c3dd5ed493b15d851356cf1b66417dcdd23e5bb18d82718cd77e15c23
|
Provenance
The following attestation bundles were made for knarrow-0.9.1-py3-none-any.whl:
Publisher:
build-and-publish.yml on InCogNiTo124/knarrow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
knarrow-0.9.1-py3-none-any.whl -
Subject digest:
b98cca020567d514b005e04fe0d1708a3a2b2247bc53e5d83cb5a7234e4997b9 - Sigstore transparency entry: 1230058777
- Sigstore integration time:
-
Permalink:
InCogNiTo124/knarrow@bf8bc506fba584e98c8e12e46e3b097e9fcc4ef7 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/InCogNiTo124
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-and-publish.yml@bf8bc506fba584e98c8e12e46e3b097e9fcc4ef7 -
Trigger Event:
push
-
Statement type: