Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle Pair of Lists example generation #775

Merged
merged 3 commits into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ersilia/io/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def __init__(self, model_id, config_json=None):
if type(self.input_shape) is InputShapeList:
self._flatten = self._flatten_list
if type(self.input_shape) is InputShapePairOfLists:
self._flatten = self._flatten_single
self._flatten = self._flatten_pair_of_lists

@throw_ersilia_exception
def check_model_id(self, model_id):
Expand All @@ -204,10 +204,10 @@ def _get_delimiter(file_name):
return ","

def _flatten_single(self, datum):
return datum
return [datum]

def _flatten_list(self, datum):
return self._string_delimiter.join(datum)
return [self._string_delimiter.join(datum)]

def _flatten_pair_of_lists(self, datum):
return [
Expand Down Expand Up @@ -242,7 +242,7 @@ def example(self, n_samples, file_name, simple):
writer = csv.writer(f, delimiter=delimiter)
if simple:
for v in self.IO.example(n_samples):
writer.writerow([self._flatten(v["input"])])
writer.writerow(self._flatten(v["input"]))
else:
writer.writerow(["key", "input", "text"])
for v in self.IO.example(n_samples):
Expand Down
Loading