Skip to content

Commit dc8285a

Browse files
committed
Fix #61: crash when importing multiple curve text file
1 parent 3208410 commit dc8285a

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
See DataLab [roadmap page](https://datalab-platform.com/en/contributing/roadmap.html)
44
for future and past milestones.
55

6+
## DataLab Version 0.14.2 ##
7+
8+
🛠️ Bug fixes:
9+
10+
* Fixed [Issue #61](https://github.com/DataLab-Platform/DataLab/issues/61) - Text file import wizard: application crash when importing a multiple curve text file:
11+
* This issue concerns a use case where the text file contains multiple curves
12+
* This is now fixed and an automatic test has been added to prevent regressions
13+
614
## DataLab Version 0.14.1 ##
715

816
🎉 New domain name: [datalab-platform.com](https://datalab-platform.com)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
time;PT380;TT382;2TT385;1TT385;TT383
2+
-1294.982;1254.853394;26.64377594;35.75617218;32.19374466;32.60350037
3+
-1294.884;1254.853394;26.64377594;35.75617218;32.19374466;32.60350037
4+
-1294.883;1254.853394;26.64377594;35.75617218;32.19374466;32.60350037
5+
-1294.876;1254.853394;26.64377594;35.75617218;32.19374466;32.60350037
6+
-1294.834;1254.853394;26.64377594;35.75617218;32.19374466;32.60350037
7+
-1294.805;1254.853394;26.64377594;35.75617218;32.19374466;32.60350037
8+
-1294.784;1254.853394;26.64377594;35.75617218;32.19374466;32.60350037
9+
-1294.756;1254.853394;26.64377594;35.75617218;32.19374466;32.60350037
10+
-1294.755;1254.853394;26.64033699;35.75617218;32.19374466;32.60350037
11+
-1294.684;1254.853394;26.64033699;35.75617218;32.19374466;32.60350037
12+
-1294.634;1254.853394;26.64033699;35.75617218;32.19374466;32.60350037
13+
-1294.633;1254.853394;26.63676262;35.75617218;32.19374466;32.60350037
14+
-1294.626;1254.853394;26.63676262;35.75617218;32.19374466;32.60350037
15+
-1294.584;1254.853394;26.63676262;35.74349594;32.19374466;32.60350037
16+
-1294.555;1254.853394;26.63676262;35.74349594;32.19374466;32.60350037
17+
-1294.506;1254.853394;26.63676262;35.74349594;32.19374466;32.60350037
18+
-1294.505;1254.853394;26.6340313;35.74349594;32.19374466;32.60350037
19+
-1294.484;1254.853394;26.6340313;35.74349594;32.19374466;32.60350037
20+
-1294.446;1254.853394;26.6340313;35.74349594;32.19374466;32.60350037
21+
-1294.444;1254.853394;26.6340313;35.74349594;32.19374466;32.60350037
22+
-1294.436;1254.853394;26.6340313;35.74349594;32.19374466;32.60350037
23+
-1294.432;1254.853394;26.6340313;35.74349594;32.19374466;32.60350037
24+
-1294.376;1254.853394;26.6340313;35.74349594;32.19374466;32.60350037
25+
-1294.356;1254.853394;26.6340313;35.74349594;32.19374466;32.60350037
26+
-1294.355;1254.853394;26.63006401;35.74349594;32.19374466;32.60350037
27+
-1294.331;1254.853394;26.63006401;35.74349594;32.19374466;32.60350037
28+
-1294.315;1254.853394;26.63006401;35.74349594;32.19374466;32.60350037
29+
-1294.311;1254.853394;26.63006401;35.74349594;32.19374466;32.60350037

cdl/tests/features/common/textimport_unit_test.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def test_import_wizard():
3030
with qt_app_context():
3131
for destination, fname, otype in (
3232
("image", "fiber.txt", ImageObj),
33+
("signal", "multiple_curves.csv", SignalObj),
3334
("signal", "paracetamol.txt", SignalObj),
3435
):
3536
path = get_test_fnames(fname)[0]
@@ -48,8 +49,13 @@ def test_import_wizard():
4849
srcpge.source_widget.file_edit.editingFinished.emit()
4950
wizard.go_to_next_page()
5051
datapge = wizard.data_page
52+
n_objs = 1
5153
if fname == "fiber.txt":
5254
datapge.param.delimiter_choice = " "
55+
elif fname == "multiple_curves.csv":
56+
datapge.param.delimiter_choice = ";"
57+
datapge.param.skip_rows = 1
58+
n_objs = 5
5359
else:
5460
datapge.param.skip_rows = 10
5561
datapge.param_widget.get()
@@ -59,7 +65,7 @@ def test_import_wizard():
5965
wizard.go_to_next_page()
6066
wizard.go_to_next_page()
6167
wizard.accept()
62-
assert len(wizard.get_objs()) == 1
68+
assert len(wizard.get_objs()) == n_objs
6369
assert isinstance(wizard.get_objs()[0], otype)
6470
elif exec_dialog(wizard):
6571
for obj in wizard.get_objs():

cdl/widgets/textimport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def set_preview_data(
358358
if len(data.shape) == 1:
359359
h_headers = ["Y"]
360360
elif first_col_is_x:
361-
if len(data.shape) == 2:
361+
if len(data[0]) == 2:
362362
h_headers = ["X", "Y"]
363363
else:
364364
h_headers = ["X"] + [f"Y{i+1}" for i in range(len(data[0]) - 1)]

0 commit comments

Comments
 (0)