semvec/pypi-packages huggingface dataset:
crosci 0.1.10
Biomarkers of Critical Oscillations
Requires Python: >=3.11

# crosci: biomarkers of Critical Oscillations

Collection of biomarkers for estimating criticality of neuronal oscillations:

- detrended fluctuation analysis (DFA), as implemented in [1]
- fE/I, a non-invasive estimate of E/I ratio [2]

The spectral ranges for computation of DFA and fE/I have been optimized in [3]

To reference, please cite the following papers:

1. Hardstone, Richard, et al. "Detrended fluctuation analysis: a scale-free view on neuronal oscillations." Frontiers in physiology 3 (2012): 450.
2. Bruining, Hilgo, et al. "Measurement of excitation-inhibition ratio in autism spectrum disorder using critical brain dynamics." Scientific reports 10.1 (2020): 9195.
3. Diachenko, Marina, et al. "Functional excitation-inhibition ratio indicates near-critical oscillations across frequencies." Imaging Neuroscience 2 (2024): 1-17.

## Running

The demo script (demo.py) exemplifies how DFA and fEI are computed for randomly generated data. You can use it as a starting point for your own data.

## Building

We use uv and setuptools to build this package. As we also use Cyhton to improve performance you will need to have clang installed on your system

To build go into the source directory and do

```bash
uv build
```

This will both build a SDist and a wheel of the package for your machine.

### Note

Crosci is also dependent on openmp, with is missing on modern MacOS clang version Apple ships. For the build to be succesfull you will need to install libomp as shown below:

```zsh
brew install libomp
```
loopretry 0.1.0
Retry context manager for arbitrary code blocks
Requires Python: >=3.9

# Loopretry

Loop retry is a library which allow to retry specific code block in Python.

It is different from many other retries libraries because it allows to retry a block
of code, not just a lambda or a function.

Usage

```python

from loopretry import retries
import time

for retry in retries(10):
    with retry():
        # any code you want to retry in case of exception
        assert int(time.time()) % 10 == 0, "Not a round number!"
```

This attempts the block up to 10 times with a 1-second delay between failures. On first success it stops. If the final attempt still fails, the exception is raised.

Typical use is waiting for eventual consistency in small integration tests.

An example for use in pytest, which waits for a metric to appear in Prometheus
for up to 30 seconds:

```python

    for retry in retries(30):
        with retry():
            assert prom_query('myapp_up{server="srv1"}') == 1.0

```

# API

```python
def retries(
    max_attempts: int,
    delay_sec: float = 1.0,
    expected_exception: type[BaseException] | tuple[type[BaseException], ...] = Exception,
) -> Iterable[Callable[[], ContextManager[None]]]
```

- max_attempts: total number of attempts (>= 1).
- delay_sec: delay between failed attempts.
- expected_exception: exception class or tuple of classes to retry on. Defaults to Exception.

Returns an iterable. Each iteration yields a callable that returns a context manager. If the block raises one of expected_exception and attempts remain, the exception is swallowed, a delay is applied, and the loop continues. Otherwise, the exception is propagated.

# License

MIT.

# Contributing

Contributions are welcome.
click-compose 2025.10.27.3
Composable Click callback utilities for building flexible CLI applications.
Requires Python: >=3.10
Keywords: callbacks, cli, click, validation

click-compose
=============

Composable Click callback utilities for building flexible CLI applications.

.. contents::
   :local:

Installation
------------

.. code-block:: shell

   $ pip install click-compose

Or with ``uv``:

.. code-block:: shell

   $ uv add click-compose

Quick Start
-----------

``click-compose`` provides two main utilities for composing Click callbacks:

multi_callback
~~~~~~~~~~~~~~

Combine multiple callbacks into a single callback that applies them in sequence:

.. code-block:: python

   """Example of using multi_callback to combine validators."""

   import click

   from click_compose import multi_callback


   def validate_positive(
       _ctx: click.Context,
       _param: click.Parameter,
       value: int,
   ) -> int:
       """Validate that value is positive."""
       if value <= 0:
           msg = "Must be positive"
           raise click.BadParameter(message=msg)
       return value


   MAX_VALUE = 100


   def validate_max_100(
       _ctx: click.Context,
       _param: click.Parameter,
       value: int,
   ) -> int:
       """Validate that value is at most 100."""
       if value > MAX_VALUE:
           msg = "Must be <= 100"
           raise click.BadParameter(message=msg)
       return value


   @click.command()
   @click.option(
       "--count",
       type=int,
       callback=multi_callback(callbacks=[validate_positive, validate_max_100]),
   )
   def cmd(count: int) -> None:
       """Example command with multiple validators."""
       click.echo(message=f"Count: {count}")

sequence_validator
~~~~~~~~~~~~~~~~~~

Apply a validator to each element in a sequence (useful with ``multiple=True``):

.. code-block:: python

   """Example of using sequence_validator with multiple values."""

   import click

   from click_compose import sequence_validator


   def validate_positive(
       _ctx: click.Context | None,
       _param: click.Parameter | None,
       value: int,
   ) -> int:
       """Validate that value is positive."""
       if value <= 0:
           msg = "Must be positive"
           raise click.BadParameter(message=msg)
       return value


   @click.command()
   @click.option(
       "--numbers",
       multiple=True,
       type=int,
       callback=sequence_validator(validator=validate_positive),
   )
   def cmd(numbers: tuple[int, ...]) -> None:
       """Example command with sequence validation."""
       click.echo(message=f"Sum: {sum(numbers)}")

Documentation
-------------

See the `full documentation <https://adamtheturtle.github.io/click-compose/>`__.