Пример #1
0
    def generate_dataset(self):
        """Generate the test dataset and store it to disk."""
        sets = {
            "train": 10,
            "test": 5,
        }

        fields = {
            "strings_list":
            lambda x: str_to_ascii(self.generate_string_list(x)),
            "data": lambda x: np.random.randint(0, 10, (x, 10)),
            "number": lambda x: np.array(range(x)),
            "field_with_a_long_name_for_printing":
            lambda x: np.array(range(x)),
        }

        lists = {
            "list_dummy_data": np.array(range(10)),
            "list_dummy_number": np.array(range(10), dtype=np.uint8),
        }

        dataset = {}
        data_fields = {}
        for set_name in sets:
            dataset[set_name] = self.populate_set(sets[set_name], fields,
                                                  lists)
            data_fields[set_name] = sorted(dataset[set_name].keys())

        return dataset, data_fields
Пример #2
0
    def populate_set(self, size, fields, lists):
        dataset = {}

        for field in fields:
            dataset[field] = fields[field](size)

        for field in lists:
            dataset[field] = lists[field]

        obj_fields = sorted(fields.keys())
        dataset['object_fields'] = str_to_ascii(obj_fields)
        dataset['object_ids'] = np.array([[i] * len(obj_fields) for i in range(size)])

        return dataset
Пример #3
0
def test_str_to_ascii(sample, output):
    res = str_to_ascii(sample)
    assert(output == res.tolist())