From 9131bdfdcc5401a69f77349bb54241365cfaa508 Mon Sep 17 00:00:00 2001 From: CAOShurong <170531907+CAOShurong@users.noreply.github.com> Date: Wed, 14 Oct 2026 15:01:59 +0800 Subject: [PATCH] Fix column-major ordering of multidimensional text waves --- CHANGELOG | 2 ++ igor2/binarywave.py | 2 +- tests/data/README | 5 +++++ tests/data/text3.ibw | Bin 0 -> 456 bytes tests/test_ibw.py | 12 ++++++++++++ 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/data/text3.ibw diff --git a/CHANGELOG b/CHANGELOG index 5752791..69669c9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +Unreleased + - fix: preserve column-major ordering of multidimensional text waves (#25) 0.5.13 - fix: thread safety issues and add better concurrent tests (#27) 0.5.12 diff --git a/igor2/binarywave.py b/igor2/binarywave.py index 4e831e8..373cba1 100644 --- a/igor2/binarywave.py +++ b/igor2/binarywave.py @@ -602,7 +602,7 @@ def post_unpack(self, parents, data): wdata = _numpy.array(strings) shape = [n for n in wave_header['nDim'] if n > 0] or (0,) try: - wdata = wdata.reshape(shape) + wdata = wdata.reshape(shape, order='F') except ValueError: logger.error( 'could not reshape strings from %s to %s', diff --git a/tests/data/README b/tests/data/README index 7ec9646..e206810 100644 --- a/tests/data/README +++ b/tests/data/README @@ -2,3 +2,8 @@ polar-graphs-demo.pxp was distributed with IGOR Pro 5.04 as Examples/Graphing Techniques/Obsolete/Polar Graphs Demo.pxp + +text3.ibw was provided by jbemis99 in issue #25: +https://github.com/AFM-analysis/igor2/issues/25 +The 3-by-2 text wave contains columns (cat, dog, fish) and +(tiger, wolf, shark), as shown by the reporter in Igor Pro. diff --git a/tests/data/text3.ibw b/tests/data/text3.ibw new file mode 100644 index 0000000000000000000000000000000000000000..aeb7d65d60bafbc3f27a71f4fa636dc8236b2427 GIT binary patch literal 456 zcmZQ&Q2!Od$N&Zs5Q-p)tS%!;oX1+E{0RuNA#^e`Gcz)jq*jy|BgC+>5_WU(Fau?n zFl0a2LxgbA7#au&JY^xE0IT$gXmK7U24)6m5MfnAND!nOroY~RfdS@_6+p9-6H8L^ z)6+7GGfFbkQ;W*;bJB`45{t4yVW*IiSdyraS*(y+mYS!Klb;7v017KmICB9pKM)H8 HF(^I&`+Oxk literal 0 HcmV?d00001 diff --git a/tests/test_ibw.py b/tests/test_ibw.py index 6a1755f..bbdadf2 100644 --- a/tests/test_ibw.py +++ b/tests/test_ibw.py @@ -1,4 +1,5 @@ from helper import assert_equal_dump_no_whitespace_no_byte, dumpibw +from helper import data_dir, loadibw def test_ibw01(): @@ -629,3 +630,14 @@ def test_ibw_10(): 'whpad4': 0}}} """ assert_equal_dump_no_whitespace_no_byte(act, exp) + + +def test_multidimensional_text_wave(): + data = loadibw(data_dir / 'text3.ibw')['wave']['wData'] + + assert data.shape == (3, 2) + assert data.tolist() == [ + [b'cat', b'tiger'], + [b'dog', b'wolf'], + [b'fish', b'shark'], + ]