Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ 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
pip install .[dev]
- 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
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ nav:
- Reference: reference.md
- Development: dev.md

copyright: Copyright &copy; 2023 Maintained by <a href="https://github.com/bdfsaraiva">Bruno D. Ferreira-Saraiva</a>.
copyright: Copyright &copy; 2023-2025 Maintained by <a href="https://github.com/bdfsaraiva">Bruno D. Ferreira-Saraiva</a>.
14 changes: 8 additions & 6 deletions parshift/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
),
}
)

Expand Down
3 changes: 2 additions & 1 deletion parshift/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Empty file added parshift/py.typed
Empty file.
48 changes: 30 additions & 18 deletions parshift/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
}

Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ packages = ["parshift"]

[project]
name = "parshift"
version = "1.0.1"
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.8"
requires-python = ">=3.9"
keywords = [
"python",
"conversation-analysis",
Expand Down Expand Up @@ -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"]
Expand Down
5 changes: 3 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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
Expand Down Expand Up @@ -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"),
}
Expand Down
Loading