Example generator for cache testing. Example amplifier for marginal frequecy and temporal locality.
Project description
caxample
Lightweight utilities to amplify sequences using a temporal kernel and marginal PDF.
Install
pip install caxample
For development:
pip install -e ".[dev]"
Basic usage
There are two primary entry points:
Amplifierclass for programmatic controlamplify()convenience function
Example:
from caxample.amplify import amplify, Amplifier
from caxample.kernel.powerlaw import PowerLawKernel
from caxample.pdf.zipf import ZipPDF
# Examples can be list of `any` objects.
examples = ['a', 'b', 'c', 'd','e','f','g']
# simple one-liner using defaults
out = amplify(examples, length=100, seed=42)
# more control: use a power-law temporal kernel and a Zipf marginal
kernel = PowerLawKernel(alpha=-1.5, window_size=100)
pdf = ZipPDF(s=1.2)
amp = Amplifier(f_kernel=kernel, g_pdf=pdf, p=1.0, seed=42)
out = amp.amplify(examples, length=200)
print(out[:20])
Notes
- If
f_kernelis omitted, draws are independent from the marginalg_pdf. - If
g_pdfis omitted, a uniform PDF is used. - Supplying both
f_kernelandg_pdfmay produce temporal correlations that alter observed marginals (see code warnings).
Running tests
Run the test suite with:
pytest -q
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
caxample-0.1.0.tar.gz
(7.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file caxample-0.1.0.tar.gz.
File metadata
- Download URL: caxample-0.1.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0280a717e2ec86d6211b4bbd49756df9b8eb7dd2d09214960e26bc4725804d6c
|
|
| MD5 |
385686eb23c5c12412c20f3c3607a751
|
|
| BLAKE2b-256 |
51b48259cc66e801784bd6a5915dcb318a3e371f8dd9cf822cc5e9509f954b9a
|
File details
Details for the file caxample-0.1.0-py3-none-any.whl.
File metadata
- Download URL: caxample-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35f22cc7dfbf9476b89e9bebc05e16eefd7c7f552902bc5a76cb0ea6138a8c7d
|
|
| MD5 |
0d937d888aae9daa9da02e6aad7e3fc9
|
|
| BLAKE2b-256 |
bdeb48aa01c3be7de97009b4e2a31216c4f5c25616bf58c576c1f7e7fbc6a88c
|