Skip to main content

Delay Propagation in Transportation Networks

Project description

Documentation PyPI Version Python Version Anaconda Version

DOI Ruff Contributor Covenant

pipeline status coverage report

Python package to reconstruct and analyse delay functional networks from time series. It provides tools for data preparation and detrending, multiple connectivity measures (e.g. Granger causality, transfer entropy, correlations), optimal-lag network reconstruction, and network analysis.

Features

  • Connectivity measures with hypothesis testing and optimal-lag reconstruction
  • Network analysis: betweenness, eigenvector centrality, link density, transitivity, reciprocity, isolated nodes, global efficiency
  • Null-model normalisation for metrics: report z-scores vs directed G(n,m) random graphs (igraph-based; binary-only; on-the-fly generation)
  • Comprehensive documentation and examples
  • Tested across multiple Python versions with high coverage

For details on how to use this package, see the Guide or the Documentation.

Setup

This package can be installed from PyPI using pip:

pip install delaynet  # when public on PyPI

This will automatically install all the necessary dependencies as specified in the pyproject.toml file. It is recommended to use a virtual environment, e.g., using conda, mamba or micromamba (they can be used interchangeably).

micromamba create -n delay_net -c conda-forge python
micromamba activate delay_net
pip install delaynet  # or `micromamba install delaynet` when on conda-forge

Quickstart

import numpy as np
import delaynet as dn

# Generate toy data: 5 nodes, 300 time points
rng = np.random.default_rng(1520)
data = rng.standard_normal((300, 5))

# Compute a connectivity p-value and lag for one pair
pval, lag = dn.connectivity(data[:, 0], data[:, 1], metric="gc", lag_steps=10)
print(f"GC p-value={pval:.3g}, best lag={lag}")

# Reconstruct a delay network (p-value matrix and lag matrix)
weights, lags = dn.reconstruct_network(data, connectivity_measure="gc", lag_steps=5)
print(weights.shape, lags.shape)

Development Setup

For development, we recommend using uv or micromamba to create a virtual environment. After cloning the repository, navigate to the root folder and create the environment. When using uv, the environment can be created with the following command:

uv sync

Or, if you prefer to use micromamba, with the desired Python version and the dependencies.

micromamba create -n delay_net -c conda-forge -f requirements.txt
micromamba activate delay_net

Either way, using pip to install the package in editable mode will also install the development dependencies.

pip install -e ".[all]"

Or, to let micromamba handle the dependencies, use the requirements.txt file

micromamba install --file requirements.txt
pip install --no-build-isolation --no-deps -e .

Now, the package can be imported and used in the python environment, from anywhere on the system if the environment is activated.

Set up Jupyter kernel

If you want to use delaynet with its environment delay_net in Jupyter, run:

pip install --user ipykernel
python -m ipykernel install --user --name=delay_net

This allows you to run Jupyter with the kernel delay_net (Kernel > Change Kernel > im_env)

Acknowledgments

This project has received funding from the European Research Council (ERC) under the European Union's Horizon 2020 research and innovation programme (grant agreement No 851255). This work was partially supported by the María de Maeztu project CEX2021-001164-M funded by the MICIU/AEI/10.13039/501100011033 and FEDER, EU.

Copyright (c) 2024, delaynet Developers. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

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

delaynet-0.3.2.tar.gz (73.8 kB view details)

Uploaded Source

Built Distribution

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

delaynet-0.3.2-py3-none-any.whl (95.5 kB view details)

Uploaded Python 3

File details

Details for the file delaynet-0.3.2.tar.gz.

File metadata

  • Download URL: delaynet-0.3.2.tar.gz
  • Upload date:
  • Size: 73.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for delaynet-0.3.2.tar.gz
Algorithm Hash digest
SHA256 7b7c9763f056c83629557bb7f7f778226184d093e64ff41e3bc8d97a2aabb0d0
MD5 09d4752a7e1e3837eb3ea4fc643f7134
BLAKE2b-256 65ee9bea52c390335e40a8f33792a1365ff33b2d3b251a2718a79ceedadb5d92

See more details on using hashes here.

File details

Details for the file delaynet-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: delaynet-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 95.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for delaynet-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fd643797f0c5c8244201bcfac2091ec82a28f6ff7ef99d95e586144daef64467
MD5 54377a01167fdda0bfe155cf14519ff7
BLAKE2b-256 e6809c5a6eca0263c0b771ef4b817131b0c6fe7fbcb1d352be45feee05df4840

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