https://github.com/axil/ndfind

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
Last synced: 10 months ago · JSON representation

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
Created about 3 years ago · Last pushed about 3 years ago
Metadata Files
Readme

README.md

ndfind

pypi python pytest Code style: black License

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 found
  • first_above(a, v) finds first element in a that is strictly greater than v, returns its index or -1 if not found
  • first_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 a equal to v. If either a or v (or both) is of floating type, the parameters atol (absolute tolerance) and rtol (relative tolerance) are used for comparison (see np.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 a are always tested and returned in row-major, C-style order.

    If v is not in a, returns the missing value (-1 by default) or raises a ValueError if raises=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 a strictly greater than v. If either a or v (or both) is of floating type, the parameters atol (absolute tolerance) and rtol (relative tolerance) are used for comparison (see np.isclose() for details).

    If there is no value in a greater than v, returns the default value (-1 by default) or raises a ValueError if raises=True.

    sorted, use binary search to speed things up (works only if the array is sorted)

    a must 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 a are 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

GitHub Events

Total
Last Year

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 53
  • Total Committers: 2
  • Avg Commits per committer: 26.5
  • Development Distribution Score (DDS): 0.208
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email 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

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 194 Last month
Rankings
Dependent packages count: 7.2%
Downloads: 15.3%
Average: 25.1%
Forks count: 30.5%
Dependent repos count: 33.4%
Stargazers count: 39.3%
Maintainers (1)
Last synced: 10 months ago