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

fix for data #4580

Merged
merged 1 commit into from
Jul 19, 2022
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
12 changes: 8 additions & 4 deletions nodes/list_struct/item_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,24 @@ def set_items(self, data, new_items, indexes):
data_out = data.copy() if isinstance(data, list) else list(data)
params = list_match_func[self.list_match_local]([indexes, new_items])
for ind, i in zip(*params):
if self.replace and len(data_out) > ind:
data_out.pop(ind)
data_out.insert(ind, i)
idx = ind % len(data) # translate to positive idx
if self.replace and len(data_out) > idx:
data_out.pop(idx)
data_out.insert(idx, i)
return data_out

elif type(data) == np.ndarray:
out_data = np.array(data)
ind, items = list_match_func[self.list_match_local]([indexes, new_items])

if self.replace:
out_data[ind] = items

else:
for i, item in zip(ind, items):
out_data = np.concatenate([data[:i], [item], data[i:]])

return out_data

elif type(data) == str:
ind, items = list_match_func[self.list_match_local]([indexes, new_items])

Expand All @@ -128,6 +131,7 @@ def set_items(self, data, new_items, indexes):
for i, item in zip(ind, items):
out_data = out_data[:i]+ str(item) + out_data[i+add_one:]
return out_data

return None

def get_(self, data, new_items, level, items, f):
Expand Down