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

Wheels for Linux and macOS 14+ are available on PyPI. To install, run:

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 for 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 (you can use other package managers).
  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 (15.6, M2) and Linux (Ubuntu 20.04).

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:

🛠️ Need Help?

Things never go as planned! Feel free to reach out:

📧 simon.pedro.g@gmail.com
🐙 GitHub Issues

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.2.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.2-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.2-cp313-cp313-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

pyscan_stats-1.0.2-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.2-cp312-cp312-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

pyscan_stats-1.0.2-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.2-cp311-cp311-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

pyscan_stats-1.0.2-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.2-cp310-cp310-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

pyscan_stats-1.0.2-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.2-cp39-cp39-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

pyscan_stats-1.0.2-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.2-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.2.tar.gz.

File metadata

  • Download URL: pyscan_stats-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 a92ea7f25b73519538a9d511d415fecf12aae06ef23673d488f58d2f55b62d65
MD5 9009473692814ccd748f28e73ccf9fcc
BLAKE2b-256 a55f2c3917cc4b4e15d7725bda708082c477012bf42907c3cc2124ba4ed05512

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyscan_stats-1.0.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fa19b2bcd371784e0ae48468d51de966ec7c065dbc14ffbe6371bf606de3de8f
MD5 83361b327791d13852df054b817c1bea
BLAKE2b-256 7ec8502316f4bbbb299cbaebec082dd41730074d54f6d710dc32b7cadf1ae7c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyscan_stats-1.0.2-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 f56e932685ecacdeb38617087d17a5cd8c2f2d5a6c5705e3afb864d27277e8f6
MD5 7a19d8903f2b4b83e9e5527bebe216cf
BLAKE2b-256 718b4443c11df75078cbb592a8e9c608d0143a97279e453580fddb10479b2fd7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyscan_stats-1.0.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c7a3cce9916fbac44236012a5f6826dc38ff64be64b9d9aa6d2e04d5228310a1
MD5 fef53f0616b21a42e2bd4cc91b1a44bd
BLAKE2b-256 4a8c22c4b03f80ccbbab264b9334bd8670db2883aeaedf321de4c16c9d7df5ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyscan_stats-1.0.2-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b19d7e05ce9f415f982c6a663a1fe68c1a6f8cd7b11688686f9f573db45d9804
MD5 d0d29d68412b9adac383a171894d3ecb
BLAKE2b-256 3ae7da3c160dffd8dc625a3d05c584c8d440110e0d29617d0ec6296f18cc7f1b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyscan_stats-1.0.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 300c567d920437b04e130f6da854ddad2e6ecc02ee05e7cdaa4cec9437fedaf5
MD5 de719ad53c144db1975755654e18e7a9
BLAKE2b-256 3814de6f56342aae2df5b3a7f4d4e88203635b3761f725d3d2d255fed5592fc8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyscan_stats-1.0.2-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 26318162798de87c7f8d07b1083bf97c1f37328a8b4af43490f5ef9c5e8029d7
MD5 a643974a9ee283aceec6084afed0d870
BLAKE2b-256 4e5b14a2d73de5dd5e9906e165e5b629b9faab145eb88e08263dd308dee05456

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyscan_stats-1.0.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 384e3b858d344623f2dfb949dfda5c56a42ea00156da0f65e04c7c3812ed548a
MD5 89608fc72a8dd011927d04415bf62afd
BLAKE2b-256 3f320b84ac237495431b4ed440a1e30b1a4e0c87794d37f53cc737e814aaa002

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyscan_stats-1.0.2-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 41b62c0a86769270449f50eb4ca26337bc86a5ab117984b6f87d4cb2f2f1d5ea
MD5 d2286ba24e90471c2fa1ac0d10be87ff
BLAKE2b-256 62eae0e1a9f79b1568f87b7c75344eb9c4ff5dd100779a2c7bb3df4a37d29f39

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyscan_stats-1.0.2-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ab2ba92396b5e2aebbf8cb85b266148e80ea0f7cc7072209c57ce22823115a4f
MD5 04851256f9fc592f73e3043f05b64ba8
BLAKE2b-256 7b933a8c24f24ac3a988973c76ac3f612c6990b2f8816e0b0fb51426467b88cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyscan_stats-1.0.2-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 9f748f978932bdb957b028da8627c85f3ee5f955b15a4babe587445871df50bd
MD5 23374ec446ecc03c6ad4513186e086aa
BLAKE2b-256 49c2596d4197e32012ed412b7cc02cedca65f20747670271e222ac4c90e0e7ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyscan_stats-1.0.2-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 560f4f2367d1e27e3864bd32eb64bdad948a399973c55f24c7cd1bf2ec81c9cb
MD5 f3948ed2ed54aee1c7411a2a378ef39b
BLAKE2b-256 e9c72dc055e55d0c281516781b27a6c748aeffc4236eea5c18c6a6852b388d61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyscan_stats-1.0.2-cp38-cp38-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 f755b1f0ee480597d7ecd05f1b25a45e0fb9145182e27d18fbe33158aa5363bb
MD5 f0cf42b748e9d6a7ff125a3aeef3dcd0
BLAKE2b-256 81303691ab93c3176053f59974eadbcb9d3df76f2eae8e79cbe21ba04de1e320

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