https://github.com/axil/ndfind
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.8%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: axil
- Language: Cython
- Default Branch: master
- Size: 1.15 MB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
ndfind
A collection of three cython-optimized search functions for NumPy. When the required value is found,
they return immediately, without scanning the whole array. It can result in 1000x or larger speedups for
huge arrays if the value is located close to the the beginning of the array. It is at least as fast as
np.where() if the value is close to the end of the array.
find(a, v)finds v in a, returns index of the first match or -1 if not foundfirst_above(a, v)finds first element in a that is strictly greater thanv, returns its index or -1 if not foundfirst_nonzero(a)finds the first nonzero element in a, returns its index or -1 if not found
Installation:
pip install ndfind
Writen in Cython. Binary wheels built for Python 3.8-3.11 on Windows, Linux, and Mac OS.
Documentation
find(a, v, rtol=1e-05, atol=1e-08, sorted=False, missing=-1, raises=False)Returns the index of the first element in
aequal tov. If either a or v (or both) is of floating type, the parametersatol(absolute tolerance) andrtol(relative tolerance) are used for comparison (seenp.isclose()for details).For 1D returns the index as an integer scalar; for 2D and above, returns a tuple of indices.
In 2D and above the the values in
aare always tested and returned in row-major, C-style order.If
vis not ina, returns themissingvalue (-1 by default) or raises aValueErrorifraises=True.For example,
python
>>> find([3, 1, 4, 1, 5], 4)
2
>>> find([1, 2, 3], 7)
-1
>>> find([1.1, 1.2, 1.3], 1.2)
1
>>> find(np.arange(0, 1, 0.1), 0.3)
3
>>> find([[3, 8, 4], [5, 2, 7]], 7)
(1, 2)
>>> find([[3, 8, 4], [5, 2, 7]], 9)
-1
>>> find([999980., 999990., 1e6], 1e6)
1
>>> find([999980., 999990., 1e6], 1e6, rtol=1e-9)
2
first_above(a, v, sorted=False, missing=-1, raises=False)Returns the index of the first element in
astrictly greater thanv. If either a or v (or both) is of floating type, the parametersatol(absolute tolerance) andrtol(relative tolerance) are used for comparison (seenp.isclose()for details).If there is no value in
agreater thanv, returns thedefaultvalue (-1 by default) or raises aValueErrorifraises=True.sorted, use binary search to speed things up (works only if the array is sorted)amust be 1-dimensional.For example,
python
>>> first_above([4, 5, 8, 2, 7], 6)
2
>>> first_above([[4, 5, 8], [2, 7, 3]], 6)
(0, 2)
>>> first_above([5, 6, 7], 9)
3
first_nonzero(a, missing=-1, raises=False)Returns the index of the first nonzero element in
a.In 2D and above the the values in
aare always tested and returned in row-major, C-style order.For example,
python
>>> first_nonzero([0, 0, 7, 0, 5])
2
>>> first_nonzero([False, True, False, False, True])
1
>>> first_nonzero([[0, 0, 0, 0], [0, 0, 5, 3]])
(1, 2)
Testing
Run pytest in the project root.
Owner
- Name: Lev Maximov
- Login: axil
- Kind: user
- Repositories: 119
- Profile: https://github.com/axil
GitHub Events
Total
Last Year
Committers
Last synced: over 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Lev Maximov | l****v@g****m | 42 |
| Lev Maximov | a****b@g****m | 11 |
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 194 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 4
- Total maintainers: 1
pypi.org: ndfind
A collection of cython-optimized search functions for NumPy
- Homepage: https://github.com/axil/ndfind
- Documentation: https://ndfind.readthedocs.io/
- License: MIT License
-
Latest release: 0.4.1
published about 3 years ago