update asserts

This commit is contained in:
fenix-hub 2022-01-10 18:08:47 +01:00
parent 514f42d29f
commit 0d44e72b7c
2 changed files with 5 additions and 6 deletions

View File

@ -315,6 +315,8 @@ func _slice():
y_data.pop_front()
func update_functions(new_x, new_y : Array, param_dic : = {}) :
assert(new_y.size() == y_labels.size(),
"new values array size (%s) must match Labels size (%s)"%[new_y.size(), y_labels.size()])
_slice()
x_values.append(new_x)
@ -328,16 +330,13 @@ func update_functions(new_x, new_y : Array, param_dic : = {}) :
func update_function(id: String, new_x, new_y, param_dic := {}) -> void:
_slice()
if only_disp_values.x < x_values[0].size():
x_values.pop_front()
x_values.append(new_x)
var function = y_labels.find(id)
if function == -1: #Not found
ECUtilities._print_message("The identifier %s does not exist." % id,1)
return
_slice()
for y_data_i in range(0, y_datas.size()):
if y_data_i == function: y_datas[y_data_i].append(new_y)
else: y_datas[y_data_i].append(y_datas[y_data_i][y_datas[y_data_i].size()-1])

View File

@ -31,13 +31,13 @@ func build_dataset(data : Array, headers : PoolStringArray, labels : PoolStringA
return dataset
func insert_column(column : Array, header : String = "", index : int = dataset[0].size() - 1) -> void:
assert(column.size() == datamatrix.rows() if not datamatrix.empty() else labels.size(), "error: the column size must match the dataset column size")
assert(column.size() == (datamatrix.rows() if not datamatrix.empty() else labels.size()), "error: the column size must match the dataset column size")
headers.insert(index, header if header != "" else MatrixGenerator.get_letter_index(index))
datamatrix.insert_column(column, index)
dataset = build_dataset_from_matrix(datamatrix, headers, labels)
func insert_row(row : Array, label : String = "", index : int = dataset.size() - 1) -> PoolStringArray:
assert(row.size() == datamatrix.columns() if not datamatrix.empty() else headers.size(), "error: the row size must match the dataset row size")
assert(row.size() == (datamatrix.columns() if not datamatrix.empty() else headers.size()), "error: the row size must match the dataset row size")
labels.insert(index, label if label != "" else str(index))
datamatrix.insert_row(row, index)
dataset = build_dataset_from_matrix(datamatrix, headers, labels)