Skip to main content

cpstress

A comprehensive stress testing data generator for competitive programming with cryptographically secure randomness.

Version History

v0.2.0 - Bug Fixes & Improvements

  • Fixed edge cases in graph generation (weighted graph parameter handling)
  • Improved performance for large-scale random generation
  • Enhanced documentation and examples
  • Fixed import paths and module organization
  • Added better error handling for invalid parameters
  • Optimized random number generation for cryptographic security

v0.1.0 - Initial Release

  • Initial stable release with core functionality

Features

  • Arrays: Random arrays, permutations, matrices, pairs, subsets, partitions, and specialized patterns (strictly increasing/decreasing, arithmetic/geometric progressions)
  • Numbers: Random integers, floats, weighted random selection, exclusion sets
  • Strings: Random strings with case control, palindromes, alphanumeric strings, custom alphabets
  • Graphs: Trees, simple graphs, weighted graphs, directed graphs, DAGs, bipartite graphs, cycles, complete graphs, regular graphs
  • Secure Randomness: Uses secrets.SystemRandom() instead of Python's predictable MT19937 algorithm

Installation

From PyPI

pip install cpstress

From Source

git clone https://github.com/sharpsalt/cpstress.git
cd cpstress
pip install -e .

Quick Start

from cpstress.generators import gen_arrays, gen_numbers, gen_strings, gen_graphs

# Generate random array
arr = gen_arrays.random(10, 1, 100)
print(arr)

# Generate random integer
num = gen_numbers.random_int(1, 1000)
print(num)

# Generate random string
s = gen_strings.random(15, CaseType.Mixed)
print(s)

# Generate tree
tree = gen_graphs.tree(10)
print(tree)

Module Reference

Arrays (gen_arrays)

  • random(len, l, r, unique=False, sorted=False) - Random array
  • permutation(n) - Random permutation
  • matrix(rows, cols, l, r) - Random matrix
  • pairs(len, l1, r1, l2, r2, ordered=False) - Random pairs
  • subset(l, r, k, sorted=False) - Random subset
  • partition(sum, k, min_val, max_val) - Partition sum into k parts
  • strictly_increasing/decreasing() - Monotonic sequences
  • arithmetic_progression/geometric_progression() - Special sequences
  • bit_array(len, prob_one=0.5) - Binary array

Numbers (gen_numbers)

  • random_int(l, r) - Random integer
  • random_real(l, r) - Random float
  • random_range(l, r, count) - List of random numbers
  • random_exclude(l, r, exclude_set) - Random excluding values
  • random_weighted(values, weights) - Weighted random selection
  • random_real_exclude() - Random float with exclusion range

Strings (gen_strings)

  • random(len, case_type) - Random string
  • palindrome(len, case_type) - Random palindrome
  • random_alphanum(len, letters, digits, case_type) - Alphanumeric string
  • random_custom(len, alphabet) - String from custom alphabet
  • random_strings(count, len, case_type) - Multiple random strings
  • palindromes(count, len, case_type) - Multiple palindromes

Graphs (gen_graphs)

  • tree(n, zero_based=False) - Random tree
  • simple_graph(n, m) - Random undirected graph
  • weighted_graph(n, m, min_w, max_w) - Weighted graph
  • directed_graph(n, m) - Directed graph
  • dag(n, m) - Directed acyclic graph
  • bipartite(n1, n2, m) - Bipartite graph
  • cycle(n), star(n), complete(n), regular(n, d) - Special graphs

Security

All random number generation uses Python's secrets.SystemRandom(), which provides cryptographically strong randomness that cannot be easily determined or predicted, unlike the standard random.Random() module.

License

This project is licensed under the MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author

Srijan Verma - GitHub Profile

Metadata

Release files for cpstress 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cpstress 0.2.1
File Size Uploaded
cpstress-0.2.1.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cpstress 0.2.1
File Interpreter ABI Platform
cpstress-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / cpstress-0.2.1.tar.gz

Download URL cpstress-0.2.1.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cffd5b4b1f3ac17440aba418117ff44dbef2bf2ebcc22bbed9fcedb227f5c72b
BLAKE2b-256 checksum
How to use checksums
5171646a4c4ddaf7ad3a0691cd2d37d2863d818652c1adc35b2879a59ce013e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Release files / cpstress-0.2.1-py3-none-any.whl

Download URL cpstress-0.2.1-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64f23b4daed297b542a0984d94e4ac9efd258cd3e3f0b3fa3b9f0d7076a08c10
BLAKE2b-256 checksum
How to use checksums
fa112038c142e8d41f4cf877ea018d8c11aceb19893dfa196504a86ce98ae331
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page