Skip to main content

C++ spatial scan wrapper for Python

Project description

pyscan-stats

pyscan-stats is a Python package for spatial scan statistics, created from a fork of the original pyscan library by Michael Matheny.

User Installation

pip install pyscan-stats

Documentation

  1. Read the original documentation at https://michaelmathen.github.io/pyscan/
  2. Ready to run examples with data are available at: https://github.com/simonpedrogonzalez/pyscan-stats-resources

New Features

Faster Numpy-based Net Grid Constructor

grid = pyscan.Grid(
    unique_xs, unique_ys, # (N,) numpy arrays of sorted unique x and y coordinates
    m_arr, b_arr # (N, 3) numpy arrays (x, y, weight)
    )

Removes the burden of instantiating in Python the pyscan.WPoint for each data point, which can be slow in larger datasets.

Area-Limited Max Convex Subgrid Scan

prec = 1e-3
disc_f = pyscan.RKULLDORF
max_area = 750 # Maximum number of pixels in the subgrid
max_subgrid = pyscan.max_subgrid_convex(grid, prec, disc_f, max_area)

Allows for specifying a maximum area for the subgrid, useful when the interest is in smaller anomalies or when computational resources are limited. Usage example here. The implementation uses a sliding window version of Kadane's algorithm.

Improvements

  • Support for new Python versions (3.10+)
  • Project dependency update and organization for easier extension and maintenance.
  • Updated examples.

Dev installation

  1. git clone https://github.com/simonpedrogonzalez/pyscan.
  2. Install uv package manager if not already installed.
  3. Install CMake, Boost, GSL, CGAL if not already installed. For example, on Mac:
    brew install cmake boost gsl cgal
    
  4. Run make init to create a Python 3.12 venv in .venv and install dev dependencies.

You are all set to start developing! The following utility commands are available:

  • make cpp: compiles C++ code into the build/ directory.
  • make py: builds the Python package and installs it in the venv, with the last compiled cpp binaries.
  • make test: runs the C++ tests, only works after compiling the C++ code.
  • make clean: removes build/, dist/ and packaging artifacts.

Notes: If an error occurs executing one of the commands, try:

  • Manually activating the venv source .venv/bin/activate and running the command again.
  • Running make clean before make cpp to ensure a clean build.
  • This setup was tested both on macOS and Linux.

About pyscan

Pyscan is a python wrapper around a large number of anomaly detection algorithms written in c++. These algorithms are from several papers by Jeff M. Phillips, Michael Matheny, Dong Xie, Mingxuan Han, Raghvendra Singh, Liang Zhang, Kaiqiang Wang, Deepak Agarwal, Andrew McGregor, Suresh Venkatasubramanian and Zhengyuan Zhu:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyscan_stats-1.0.1.tar.gz (14.3 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyscan_stats-1.0.1-cp313-cp313-manylinux_2_28_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

pyscan_stats-1.0.1-cp313-cp313-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

pyscan_stats-1.0.1-cp312-cp312-manylinux_2_28_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

pyscan_stats-1.0.1-cp312-cp312-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

pyscan_stats-1.0.1-cp311-cp311-manylinux_2_28_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

pyscan_stats-1.0.1-cp311-cp311-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

pyscan_stats-1.0.1-cp310-cp310-manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

pyscan_stats-1.0.1-cp310-cp310-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

pyscan_stats-1.0.1-cp39-cp39-manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

pyscan_stats-1.0.1-cp39-cp39-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

pyscan_stats-1.0.1-cp38-cp38-manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

pyscan_stats-1.0.1-cp38-cp38-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.8macOS 14.0+ ARM64

File details

Details for the file pyscan_stats-1.0.1.tar.gz.

File metadata

  • Download URL: pyscan_stats-1.0.1.tar.gz
  • Upload date:
  • Size: 14.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyscan_stats-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ef362891326ccabe8c601ab5b910ead259784fc54a3ab9e6e24678b42151198e
MD5 bb8b764133c37a54e02bd9a9fc0b44cb
BLAKE2b-256 557e40c75b453998ebcaf253ec6fd75a6486b57a2fd574164e1b1834600abeac

See more details on using hashes here.

File details

Details for the file pyscan_stats-1.0.1-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyscan_stats-1.0.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5220c5563ed6f38a8c6a730824ac281a4d3bb94af5c1cc865b61a2ae8674c3fb
MD5 fc5f2f8ae120e1b613e04234dfcaa43d
BLAKE2b-256 d2fbeda58d2ac0a11eb0a3f50b5512a553d7db6249c007366cf72487117f5f85

See more details on using hashes here.

File details

Details for the file pyscan_stats-1.0.1-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyscan_stats-1.0.1-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 84a1ce6d0b53f287082620bcfb8b4e57288c6db6f089e23dd027629bd9dcd33c
MD5 1e582d24eae40a60da4ad913e436ab77
BLAKE2b-256 8fd2fcdf61641a08e2ac25627219fc78aece5c1ad8b7dcc03e76710399f9d09f

See more details on using hashes here.

File details

Details for the file pyscan_stats-1.0.1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyscan_stats-1.0.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f8b19f65672a1301bb7b06cd43542c259312d1a9b414385bd6868ed3d6976244
MD5 4ffec728b252f42eb8de411594ca4a99
BLAKE2b-256 eba73b54a91c4eca25970c792af6ced2de8a201b3293d56c5693d2862e23465f

See more details on using hashes here.

File details

Details for the file pyscan_stats-1.0.1-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyscan_stats-1.0.1-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 3b4b4a8e35ba1c45936f3c37688a9f222777835b2e9bb399102f531a75f8cee0
MD5 38d9db41f189dd7d8037588c055412b3
BLAKE2b-256 b41c9363732b1729d9ecccc8d7307c61db642416234eb786a70fef69b97a822c

See more details on using hashes here.

File details

Details for the file pyscan_stats-1.0.1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyscan_stats-1.0.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f7d8f7f8a2194cf6bd619f8f238a0c43e8ce40d8d8765358002e91f77ace6b69
MD5 a6ed9e79f5c9e2631379f68e6f5e63bc
BLAKE2b-256 1c68c445112677dfa9ad3f7ab81a50e1f73bd760eba6f527e1f12b660f051fcd

See more details on using hashes here.

File details

Details for the file pyscan_stats-1.0.1-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyscan_stats-1.0.1-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 9a604146385705f4bb4aa4e5d01789236c7b9c9d9e8b069fe9e3427c991d05eb
MD5 278906ff861f6a96f760f8d63cef524d
BLAKE2b-256 f34ab24c3a7676005f9830f09f5472e541ce5a99c0bfb9fd14b456ed404b1a27

See more details on using hashes here.

File details

Details for the file pyscan_stats-1.0.1-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyscan_stats-1.0.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2b877f7324f4736d7efffd77ff8eae231fb6e86accbe0d90d7c68dee201bae52
MD5 4778abb2543a8a8e1e657796282d9d8c
BLAKE2b-256 56f484eb2370e776556527b699c49e9294e75b2fdf57cc1cfa2abc6bb78d6282

See more details on using hashes here.

File details

Details for the file pyscan_stats-1.0.1-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyscan_stats-1.0.1-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 34e27f0c35379aebcefbd4f910f6b120e5f579847de027e2b6d0c68f9e4786ec
MD5 3fc53caae44f22d4ca99435d0d84e940
BLAKE2b-256 f7c548b0cf15d255ea5f7749c4046f525732d073222fd85c5c75f9eac8d6870b

See more details on using hashes here.

File details

Details for the file pyscan_stats-1.0.1-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyscan_stats-1.0.1-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2fa601c191576c47b6f794c086cd3ae4573307477e9407d90363a36ab1d2e412
MD5 780171dc003bda0ef4bdd99e72e317fa
BLAKE2b-256 aa6cc2605465cfe0ae3f3bf075114505408f1df480f6bceb6f118770ba854619

See more details on using hashes here.

File details

Details for the file pyscan_stats-1.0.1-cp39-cp39-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyscan_stats-1.0.1-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 4c906aeb11580b56e3d723cb37296539d7cf1e4483553f9b407f698f0a9006eb
MD5 b875d0facaea146f5403810adaf5bf67
BLAKE2b-256 6003d8774b95e649289b0e27a4f0c53b07b75d360709e25d74917b358c742e78

See more details on using hashes here.

File details

Details for the file pyscan_stats-1.0.1-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyscan_stats-1.0.1-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 574f5b456139740b964bb13b72b6446187ad05b53ca4475bafee75dec7b63425
MD5 e67837b36fdae598c0643bf8bc4dd95b
BLAKE2b-256 168a84041f9c8cc9164a516e5052618a2a2598c327c5f8c8bbb88d4c781ed4bc

See more details on using hashes here.

File details

Details for the file pyscan_stats-1.0.1-cp38-cp38-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyscan_stats-1.0.1-cp38-cp38-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a901ff4593ec4e24181587ae30c649a943520066dce7ccd8b4e801defe54d24e
MD5 0f5a158c422260f8ee7d04377f5e8a2d
BLAKE2b-256 64b01a3514e366b143e23211f3981e578fd22d1aa23635f241cf35cb94904367

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page