Skip to content

Commit

Permalink
Bump version to v0.5.0 for release
Browse files Browse the repository at this point in the history
  • Loading branch information
souradipp76 committed Jan 31, 2024
1 parent 1668528 commit 9d193ea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
19 changes: 15 additions & 4 deletions tests/chaos_generator_test.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
import numpy as np
""" Chaos Generator Tests"""

import random
import string
import time

import numpy as np
import pytest

from tp_chaos_generator import ChaosGenerator, utils


def test_generate_key():
cg = ChaosGenerator()
keys1 = cg.generate_key()
time.sleep(1)
keys2 = cg.generate_key()
assert len(keys1) > 0 and len(keys1) == len(keys2) \
assert (
len(keys1) > 0
and len(keys1) == len(keys2)
and not all(keys1[i] == keys2[i] for i in range(len(keys1)))
)


@pytest.fixture
def texts() -> list[str]:
lengths = [10, 20, 50, 100, 500, 1000, 2000, 5000, 10000, 100000]
return [''.join(random.choice(string.printable) for i in range(len)) for len in lengths]
return ["".join(random.choice(string.printable) for i in range(len)) for len in lengths]


@pytest.fixture
def images() -> list:
sizes = [5, 10, 20, 50, 100]
return [np.random.randint(0, 256, (3, len, len)) for len in sizes]


def test_texts(texts):
cg = ChaosGenerator()
key = cg.generate_key()
Expand All @@ -37,6 +47,7 @@ def test_texts(texts):
assert len(texts) == len(decrypted_texts)
assert all(texts[i] == decrypted_texts[i] for i in range(len(texts)))


def test_images(images):
cg = ChaosGenerator()
key = cg.generate_key()
Expand All @@ -47,4 +58,4 @@ def test_images(images):
de_image = cg.decrypt(en_image, key)
decrypted_images.append(np.array(de_image).reshape((3, h, w)))
assert len(images) == len(decrypted_images)
assert all(np.all(images[i] == decrypted_images[i]) for i in range(len(images)))
assert all(np.all(images[i] == decrypted_images[i]) for i in range(len(images)))
1 change: 0 additions & 1 deletion tp_chaos_generator/chaos_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ def fetch_key(self, path) -> list:
lines = f.readlines()
keyset_len = len(lines)
seed = int(time.time())
print(seed)
self.rng = np.random.RandomState(seed)
index = self.rng.randint(0, keyset_len)
key = decode_key(lines[index])
Expand Down
2 changes: 1 addition & 1 deletion tp_chaos_generator/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" Version """

_MAJOR = "0"
_MINOR = "4"
_MINOR = "5"
# On main and in a nightly release the patch should be one ahead of the last
# released build.
_PATCH = "0"
Expand Down

0 comments on commit 9d193ea

Please sign in to comment.