spatstat-interface
Simple Python interface with the spatial statistics R package spatstat using rpy2.
Dependencies
- R (programming language)
spatstatpackage, which has recently been split into multiple sub-packages and extensions. Warning: potential new splits may break your code!
- Python >= 3.7, with dependencies listed in the
pyproject.tomlfile. Note that they mostly correspond to the latest version.
Installation
You may consider using poetry to manage your whole project as described here https://github.com/guilgautier/template-python-project.
Install the project as a dependency
-
Install the latest version published on
# activate your virtual environment an run poetry add spatstat-interface # pip install spatstat-interface
-
Install from source (this may be broken)
# activate your virtual environment an run poetry add git+https://github.com/For-a-few-DPPs-more/spatstat-interface.git # pip install git+https://github.com/For-a-few-DPPs-more/spatstat-interface.git
Install in editable mode and potentially contribute to the project
You may consider forking the repository.
In any case, your can clone the repository
-
if you have forked the repository
git clone https://github.com/your_user_name/spatstat-interface.git
-
if you have not forked the repository
git clone https://github.com/For-a-few-DPPs-more/spatstat-interface.git
Editable install with poetry
The package can be installed in editable mode along with
- main (non-optional) dependencies, see
[tool.poetry.dependencies]inpyproject.toml - development dependencies,
[tool.poetry.group.dev.dependencies]inpyproject.toml
cd spatstat-interface
# poetry shell # to create/activate local .venv (see poetry.toml)
poetry install
# poetry install --with dev
# poetry install --with dev --extras "notebook"
Editable install with pip
Consider using pip>=21.3.1, when installing packages defined by a pyproject.toml file.
cd spatstat-interface
# activate your virtual environment and run
pip install --editable .
# pip install --editable ".[notebook]" to install notebook dependencies
See also the pip install optional commands.
Documentation
Main resources
notebooksshowcase detailed examplesrpy2documentationspatstatdocumentation
Notes about spatstat
The spatstat package has recently been split into multiple sub-packages and extensions.
Warning: potential new splits may break your code!
Using spatstat-interface, sub-packages and extensions are accessible in the following way
from spatstat_interface.interface import SpatstatInterface
spatstat = SpatstatInterface()
# spatstat.spatstat is None
# spatstat.model is None
# spatstat.explore is None
# spatstat.geom is None
# load/import sub-packages or extensions
spatstat.import_package("model", "explore", "geom", update=True)
spatstat.model
spatstat.explore
spatstat.geom
Calling functions
Calling function.variant
To call the R function.variant
# R code pcf.ppp
spatstat.explore::pcf.ppp(X)
Replace . by _ to call function_variant in Python
# Python code pcf_ppp
spatstat.explore.pcf_ppp(X)
Keyword arguments
Consider using Python dictionaries to pass keyword arguments. Below are a few examples.
-
dot keywords, for example passing
var.approxkeyword argument won't work in Python# R code spatstat.explore::pcf.ppp(X, kernel="epanechnikov", var.approx=False)
# Python code params = {"kernel": "epanechnikov", "var.approx": False} spatstat.explore.pcf_ppp(X, **params)
-
reserved keywords, for example
lambdais a reserved Python keyword; it can't be used as a keyword argument# R code spatstat.model::dppGauss(lambda=rho, alpha=alpha, d=d)
# Python code params = {"lambda": rho, "alpha": alpha, "d": d} spatstat.model.dppGauss(**params)
Metadata
Release files for spatstat-interface 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| spatstat_interface-1.0.1.tar.gz | 6.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| spatstat_interface-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.6 kB
Release files / spatstat_interface-1.0.1.tar.gz
| Download URL | spatstat_interface-1.0.1.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b89374c45a15829a5a9296c9a781ba339fb1cdbd02781b7a576daf715429b141
|
|
BLAKE2b-256 checksum How to use checksums |
0f19b44fe4e9502e465b39c4d24db16d396d6a31cee242c4ec8d52b75edb5d2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.8.5 Darwin/20.6.0
|
Release files / spatstat_interface-1.0.1-py3-none-any.whl
| Download URL | spatstat_interface-1.0.1-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd56a688ba191ea3937ea7976aa20ab29edf1752d62cb40a0588bf70845f15fa
|
|
BLAKE2b-256 checksum How to use checksums |
bf98034d2646d7860a74bb4649e40c0313c06488837f28282d6285ae6973b4ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.8.5 Darwin/20.6.0
|
Security for spatstat-interface 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.