From c018cd607151f5285648f3a8cf6592975e561935 Mon Sep 17 00:00:00 2001 From: Milne Date: Fri, 28 Jun 2024 10:58:58 +0100 Subject: [PATCH 1/4] Casts columns to string before checking for special characters --- gptables/core/wrappers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gptables/core/wrappers.py b/gptables/core/wrappers.py index 86ca122..da470de 100644 --- a/gptables/core/wrappers.py +++ b/gptables/core/wrappers.py @@ -505,7 +505,7 @@ def _write_table_elements(self, pos, gptable, auto_width): warnings.warn(msg) # Raise error if any table element is only special characters - if gptable.table.stack().str.contains('^[^a-zA-Z0-9]*$').any(): + if gptable.table.astype("string").stack().str.contains('^[^a-zA-Z0-9]*$').any(): msg = (f""" Cell found in {gptable.table_name} containing only special characters, replace with alphanumeric characters before inputting to GPTable. From eb2dea85d35c59cb3647f13bfa4da8920ff71c58 Mon Sep 17 00:00:00 2001 From: Milne Date: Fri, 28 Jun 2024 11:50:40 +0100 Subject: [PATCH 2/4] Adds unit test for integer tables --- gptables/test/test_wrappers.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gptables/test/test_wrappers.py b/gptables/test/test_wrappers.py index 1f2f746..f116aea 100644 --- a/gptables/test/test_wrappers.py +++ b/gptables/test/test_wrappers.py @@ -243,6 +243,14 @@ def test__write_empty_table(self, testbook, create_gptable_with_kwargs): with pytest.raises(ValueError): testbook.ws._write_table_elements([0,0], gptable, auto_width=True) + def test__write_integer_table(self, testbook, create_gptable_with_kwargs): + gptable = create_gptable_with_kwargs({ + "table": pd.DataFrame({"a": [0], "b": [1]}) + }) + + #Testing that this function executes with no errors + testbook.ws._write_table_elements([0,0], gptable, auto_width=True) + @pytest.mark.parametrize("cell_value1,cell_value2,expectation", [ (None, "valid text", pytest.warns(UserWarning)), From 87c4af76d39771d1d030d86618a25032e99c972a Mon Sep 17 00:00:00 2001 From: Milne Date: Fri, 28 Jun 2024 13:47:14 +0100 Subject: [PATCH 3/4] Stops testing python 3.6 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e186181..0382b04 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9, '3.10'] + python-version: [3.7, 3.8, 3.9, '3.10'] steps: - uses: actions/checkout@v2 @@ -71,7 +71,7 @@ jobs: runs-on: windows-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9, '3.10'] + python-version: [3.7, 3.8, 3.9, '3.10'] steps: - uses: actions/checkout@v2 From 476faaaf618135b55fdabf034449b3ea829ffe2e Mon Sep 17 00:00:00 2001 From: Milne Date: Fri, 28 Jun 2024 15:30:17 +0100 Subject: [PATCH 4/4] Removes testing for python 3.12 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08b664b..0daf28d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] steps: @@ -72,7 +72,7 @@ jobs: runs-on: windows-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] steps: