From bf5dc36d280693cf2eb266362d2d1f5d237aac4a Mon Sep 17 00:00:00 2001 From: Nuno Fachada Date: Fri, 22 Aug 2025 15:44:42 +0100 Subject: [PATCH 1/8] Add py.typed to signal client code lib uses types --- parshift/py.typed | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 parshift/py.typed diff --git a/parshift/py.typed b/parshift/py.typed new file mode 100644 index 0000000..e69de29 From 9081c886fe2f7ce699e767314f27f5cabb7b1bd6 Mon Sep 17 00:00:00 2001 From: Nuno Fachada Date: Fri, 22 Aug 2025 15:57:03 +0100 Subject: [PATCH 2/8] Set min. Python version to 3.9 --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4beacf8..8f80322 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,10 +7,10 @@ packages = ["parshift"] [project] name = "parshift" -version = "1.0.1" +version = "1.0.1.9000" description = "Python package based on Gibson's framework (2003) for turn-taking in group conversation analysis." readme = "README.md" -requires-python = ">=3.8" +requires-python = ">=3.9" keywords = [ "python", "conversation-analysis", @@ -62,7 +62,7 @@ norecursedirs = [ testpaths = ["parshift", "tests"] [tool.mypy] -python_version = 3.8 +python_version = "3.9" [[tool.mypy.overrides]] module = [ "squarify", "matplotlib", "matplotlib.pyplot"] From f26dcc4211706d320b32360d513847eba8e46822 Mon Sep 17 00:00:00 2001 From: Nuno Fachada Date: Fri, 22 Aug 2025 15:57:52 +0100 Subject: [PATCH 3/8] Fix mypy issue in conftest.py --- tests/conftest.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index f62e349..158d558 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,6 +4,7 @@ """Fixtures to be used by test functions.""" +from numpy.typing import DTypeLike from os import PathLike from pathlib import Path @@ -92,14 +93,14 @@ # Mandatory columns and types of conversation data frame -_p_shift_cols_mandatory = { +_p_shift_cols_mandatory: dict[str, DTypeLike] = { "utterance_id": np.int64, "speaker_id": np.dtype("O"), "utterance": np.dtype("O"), } # Optional columns and types of conversation data frame -_p_shift_cols_optional = { +_p_shift_cols_optional: dict[str, DTypeLike] = { "reply_to_id": np.dtype("O"), "target_id": np.dtype("O"), } From 70a8cb0d9a1bd24e696c0205584c4a430c1a386f Mon Sep 17 00:00:00 2001 From: Nuno Fachada Date: Fri, 22 Aug 2025 16:01:51 +0100 Subject: [PATCH 4/8] Fix mypy issue in annotation module --- parshift/annotation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parshift/annotation.py b/parshift/annotation.py index 8a274ed..27ccfbb 100644 --- a/parshift/annotation.py +++ b/parshift/annotation.py @@ -125,7 +125,7 @@ def conv2turns(conv_df: pd.DataFrame) -> List[Dict[str, Any]]: and conversation[turn - 1][last_col] == row[last_col] ): msg_join = ". ".join( - [conversation[turn - 1]["utterance"], row["utterance"]] + [conversation[turn - 1]["utterance"], str(row["utterance"])] ) list_id = conversation[turn - 1]["utterance_ids"] + [row["utterance_id"]] conversation[turn - 1]["utterance_ids"] = list_id From a5e1c163a519965461ed320d296e3644aef564fb Mon Sep 17 00:00:00 2001 From: Nuno Fachada Date: Fri, 22 Aug 2025 16:05:43 +0100 Subject: [PATCH 5/8] Update all CI workflows and Python to latest versions --- .github/workflows/cov.yml | 8 ++++---- .github/workflows/docs.yml | 2 +- .github/workflows/publish.yml | 2 +- .github/workflows/tests.yml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cov.yml b/.github/workflows/cov.yml index f1f0546..26c3e06 100644 --- a/.github/workflows/cov.yml +++ b/.github/workflows/cov.yml @@ -14,11 +14,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Clone repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup latest Python uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' - name: Install dependencies run: | pip install pip --upgrade @@ -26,6 +26,6 @@ jobs: - name: Test with pytest and create coverage report run: pytest --cov=parshift --cov-report=xml - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: - files: ./coverage.xml \ No newline at end of file + token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 2de668f..75ed892 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -9,7 +9,7 @@ jobs: docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: lfs: true - name: Build docs diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 25f8e34..b3a1c49 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout package - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install build and publish dependencies run: | pip3 install --upgrade build diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f08cf52..6e07434 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,11 +16,11 @@ jobs: strategy: fail-fast: false matrix: - version: ['3.8', '3.12'] + version: ['3.9', '3.13'] os: [ubuntu-latest, windows-latest, macos-latest] steps: - name: Clone repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup latest Python uses: actions/setup-python@v4 with: From 1f970031edf81d8d15ad2ca1388857662c2752eb Mon Sep 17 00:00:00 2001 From: Nuno Fachada Date: Fri, 22 Aug 2025 16:10:39 +0100 Subject: [PATCH 6/8] Reapply black and isort to code --- parshift/annotation.py | 12 ++++++----- parshift/plotting.py | 3 ++- parshift/statistics.py | 48 ++++++++++++++++++++++++++---------------- tests/conftest.py | 2 +- 4 files changed, 40 insertions(+), 25 deletions(-) diff --git a/parshift/annotation.py b/parshift/annotation.py index 27ccfbb..55c11ff 100644 --- a/parshift/annotation.py +++ b/parshift/annotation.py @@ -143,11 +143,13 @@ def conv2turns(conv_df: pd.DataFrame) -> List[Dict[str, Any]]: "utterance_ids": [id], "speaker_id": speaker_id, "utterance": utterance, - last_col: last_col_val - if last_col_val != "" - and last_col_val != None - and last_col_val != "None" - else None, + last_col: ( + last_col_val + if last_col_val != "" + and last_col_val != None + and last_col_val != "None" + else None + ), } ) diff --git a/parshift/plotting.py b/parshift/plotting.py index 88dd5af..14d519b 100644 --- a/parshift/plotting.py +++ b/parshift/plotting.py @@ -2,13 +2,14 @@ # Distributed under the MIT License (See accompanying file LICENSE or copy # at http://opensource.org/licenses/MIT) +from typing import Optional + import matplotlib import matplotlib.pyplot as plt import pandas as pd import squarify from .annotation import pshift_class -from typing import Optional def frequency_treemap( diff --git a/parshift/statistics.py b/parshift/statistics.py index c630215..f3ebb20 100644 --- a/parshift/statistics.py +++ b/parshift/statistics.py @@ -153,35 +153,47 @@ def cond_probs(pshift_codes: pd.DataFrame) -> pd.DataFrame: if key.split("-")[0] == "A0": if key not in ["A0-AY", "AB-A0", "AB-AY", "A0-A0"]: cond_prob[key] = { - "CP": round(freq_table[key] / frequency_table_and_counts[1], 2) - if frequency_table_and_counts[1] != 0 - else 0, - "CPeTC": round(freq_table[key] / frequency_table_and_counts[3], 2) - if frequency_table_and_counts[3] != 0 - else 0, + "CP": ( + round(freq_table[key] / frequency_table_and_counts[1], 2) + if frequency_table_and_counts[1] != 0 + else 0 + ), + "CPeTC": ( + round(freq_table[key] / frequency_table_and_counts[3], 2) + if frequency_table_and_counts[3] != 0 + else 0 + ), } else: cond_prob[key] = { - "CP": round(freq_table[key] / frequency_table_and_counts[1], 2) - if frequency_table_and_counts[1] != 0 - else 0, + "CP": ( + round(freq_table[key] / frequency_table_and_counts[1], 2) + if frequency_table_and_counts[1] != 0 + else 0 + ), "CPeTC": "", } else: if key not in ["A0-AY", "AB-A0", "AB-AY", "A0-A0"]: cond_prob[key] = { - "CP": round(freq_table[key] / frequency_table_and_counts[2], 2) - if frequency_table_and_counts[2] != 0 - else 0, - "CPeTC": round(freq_table[key] / frequency_table_and_counts[4], 2) - if frequency_table_and_counts[4] != 0 - else 0, + "CP": ( + round(freq_table[key] / frequency_table_and_counts[2], 2) + if frequency_table_and_counts[2] != 0 + else 0 + ), + "CPeTC": ( + round(freq_table[key] / frequency_table_and_counts[4], 2) + if frequency_table_and_counts[4] != 0 + else 0 + ), } else: cond_prob[key] = { - "CP": round(freq_table[key] / frequency_table_and_counts[2], 2) - if frequency_table_and_counts[2] != 0 - else 0, + "CP": ( + round(freq_table[key] / frequency_table_and_counts[2], 2) + if frequency_table_and_counts[2] != 0 + else 0 + ), "CPeTC": "", } diff --git a/tests/conftest.py b/tests/conftest.py index 158d558..d0a3425 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,13 +4,13 @@ """Fixtures to be used by test functions.""" -from numpy.typing import DTypeLike from os import PathLike from pathlib import Path import numpy as np import pandas as pd import pytest +from numpy.typing import DTypeLike # Files containing good conversations, optional parameters required to open them, # and CSV file containing respective conversation after annotation From 81dae0782d34466d7d64892a357275c117b9db16 Mon Sep 17 00:00:00 2001 From: Nuno Fachada Date: Fri, 22 Aug 2025 16:44:34 +0100 Subject: [PATCH 7/8] Update copyright year in docs --- docs/mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 5da66aa..46e4530 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -68,4 +68,4 @@ nav: - Reference: reference.md - Development: dev.md -copyright: Copyright © 2023 Maintained by Bruno D. Ferreira-Saraiva. +copyright: Copyright © 2023-2025 Maintained by Bruno D. Ferreira-Saraiva. From 304b879e580e95d6d1eb793b22045d1f0fc1c23b Mon Sep 17 00:00:00 2001 From: Nuno Fachada Date: Fri, 22 Aug 2025 16:44:56 +0100 Subject: [PATCH 8/8] Bump version to v1.0.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8f80322..c9d848d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ packages = ["parshift"] [project] name = "parshift" -version = "1.0.1.9000" +version = "1.0.2" description = "Python package based on Gibson's framework (2003) for turn-taking in group conversation analysis." readme = "README.md" requires-python = ">=3.9"