Skip to main content

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

Project description

cpstress

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

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.

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

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

cpstress-0.1.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

cpstress-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file cpstress-0.1.0.tar.gz.

File metadata

  • Download URL: cpstress-0.1.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for cpstress-0.1.0.tar.gz
Algorithm Hash digest
SHA256 de4f9de24a90dcf1293528149f2fdb7a35ed55d331eb651d97451ade74021df2
MD5 5200b9a58101aef50d629c7307d2cb6d
BLAKE2b-256 837125191f3cdf2793123e170e667b6d5911d6ae274de1ece2d029cf085517a2

See more details on using hashes here.

File details

Details for the file cpstress-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cpstress-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for cpstress-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3e917ec9d9a734a0868df32b38986d75ce2883de871e19e55fbc9979327815e
MD5 3482e07014c6e2d96111206bb3087d6e
BLAKE2b-256 e36c3a0ab8eedbe9215b049841e54b7799e77b894979853cba2ee8133b082737

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