Skip to content

Commit

Permalink
Add tests for ascii to float and reverse conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
jloveric committed Dec 2, 2023
1 parent 0abd22e commit d02704b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@
dataset_from_file,
SingleTextDataset,
RandomizeCharacters,
TextTransformerDataset
TextTransformerDataset,
ascii_to_float,
float_to_ascii
)
from torch.utils.data import DataLoader, Dataset
import torch

def test_ascii_to_float():
sample = torch.arange(128)
res = ascii_to_float(sample)
assert torch.all(torch.max(res)<1)
assert torch.all(torch.min(res)>-1)

reverse = float_to_ascii(res)
assert torch.all(sample==reverse)

def test_dataset_from_gutenberg():
num_features = 10
Expand Down

0 comments on commit d02704b

Please sign in to comment.