From aa73e999997a84cf68699bbf710bcdc4c065ecb8 Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 00:37:00 +0200 Subject: [PATCH 01/23] fixed compatibility with pandas, argmax/argmin to idxmax/idxmin --- .travis.yml | 3 +-- whatstk/utils/auto_header.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2cf0feb..c1662a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,8 @@ dist: xenial language: python python: -- 3.7.2 +- 3.7 - 3.8 -- 3.5 install: - pip install . #pip install -r requirements.txt diff --git a/whatstk/utils/auto_header.py b/whatstk/utils/auto_header.py index d7adbd3..9e1e2fa 100644 --- a/whatstk/utils/auto_header.py +++ b/whatstk/utils/auto_header.py @@ -205,9 +205,9 @@ def _extract_header_format_from_components(elements_list, template_list): template = template_list[0] hour_code = "%H" # day - day_pos = ((dates_df.max()>27) & (dates_df.max()<32)).argmax() + day_pos = ((dates_df.max()>27) & (dates_df.max()<32)).idxmax() # year - year_pos = dates_df.std().argmin() + year_pos = dates_df.std().idxmin() # month and hour positions = (dates_df.max() < 13) # & (dates_df.max() > 11) positions = positions.index[positions].tolist() From fc3c867c9abd6bc587b178194381dccb73fb57c2 Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 00:39:44 +0200 Subject: [PATCH 02/23] versions set in requirements --- requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 35d6621..f88b994 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -pandas -numpy -plotly \ No newline at end of file +pandas==1.0.3 +numpy==1.18.2 +plotly==4.5.0 \ No newline at end of file From 638f710fe46a5b7ad34778201f53efb20e6d93bc Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 00:40:23 +0200 Subject: [PATCH 03/23] removed 3.5 badge in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aca62de..0cb8811 100755 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![Package version](https://img.shields.io/badge/whatstk-v0.2.0-teal.svg?style=for-the-badge&color=25D366&logo=whatsapp) [![Build Status](https://travis-ci.com/lucasrodes/whatstk.svg?branch=develop)](https://travis-ci.com/lucasrodes/whatstk) -[![Python 3.6](https://img.shields.io/badge/python-3.5|3.7|3.8-blue.svg)](https://www.python.org/downloads/release/python-3/) +[![Python 3.6](https://img.shields.io/badge/python-3.7|3.8-blue.svg)](https://www.python.org/downloads/release/python-3/) [![Documentation](https://img.shields.io/badge/documentation-royalblue.svg)](docs/index.md) [![GitHub license](https://img.shields.io/github/license/lucasrodes/whatstk.svg)](https://github.com/lucasrodes/whatstk/blob/master/LICENSE) From 238fac87e625edcbd951aa7e8a980f74d2b35375 Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 00:44:04 +0200 Subject: [PATCH 04/23] version patch updated --- .bumpversion.cfg | 2 +- README.md | 2 +- setup.py | 2 +- whatstk/__init__.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index c446dd1..ae1323d 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.0 +current_version = 0.2.1 [bumpversion:file:setup.py] diff --git a/README.md b/README.md index 0cb8811..1b63260 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [whatstk](http://lucasrodes.github.io/whatstk) -![Package version](https://img.shields.io/badge/whatstk-v0.2.0-teal.svg?style=for-the-badge&color=25D366&logo=whatsapp) +![Package version](https://img.shields.io/badge/whatstk-v0.2.1-teal.svg?style=for-the-badge&color=25D366&logo=whatsapp) [![Build Status](https://travis-ci.com/lucasrodes/whatstk.svg?branch=develop)](https://travis-ci.com/lucasrodes/whatstk) [![Python 3.6](https://img.shields.io/badge/python-3.7|3.8-blue.svg)](https://www.python.org/downloads/release/python-3/) diff --git a/setup.py b/setup.py index 3347ee6..20c687f 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='whatstk', - version="0.2.0", + version="0.2.1", description="Parser and analytics tools for WhatsApp group chats", long_description=long_description, long_description_content_type='text/markdown', diff --git a/whatstk/__init__.py b/whatstk/__init__.py index 8d8b3b1..7d590a1 100755 --- a/whatstk/__init__.py +++ b/whatstk/__init__.py @@ -4,7 +4,7 @@ name = "whatstk" -__version__ = "0.2.0" +__version__ = "0.2.1" __all__ = [ 'WhatsAppChat', From 3b13a447b566ddd2cf0165617e858caa081a443a Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 01:10:43 +0200 Subject: [PATCH 05/23] changed travis token --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c1662a7..d54e65e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,16 @@ dist: xenial language: python python: -- 3.7 +- 3.7.2 - 3.8 install: - pip install . -#pip install -r requirements.txt script: - pytest deploy: provider: pypi user: lucasrodes password: - secure: fqmlRL4Cbg8p+OolNSZW84I6iiIXKvrEcH5w2WSaQ1D+qO8b0+xMgLttypQ3vf+hFFc0K6HXHg9HNONFx8yP0/GNAKEl6gwk2ld3+JTM/rKAceVsoZlq6PwnoQqiityDGZHIg8pXVbKdccGQwWh1jvsMNQG3ACFpNZKHYjjESMSDtib9DsvqwdfwbUrjaM7Ucdvmw+ABeD4yDKgG1bU9pMnE+zdQe+9EsmFYY+K5FEdY6vre76BUadTl1MUn9mnUGi7bJHY+QXFxu23X5mvo7fPyII06Ss8lFcsJI/EjZlemr+aYTOXwKgUhfC+Rf3DGcEIRFNuPrq4WMUI7ox+ehE64L3Eved4jIlI1U+hWHitWT6FX+1xdg67lVPQqhbJN4vhhjJEz1+n55BkADp+zQ2UB/IfZbNgBNFtNf+NQYi87d2zNss+FP1Pg1qI0LsqwfroiLNfh2HBCMl6G5tjlU0OBbbiVsLxHxxk9i0uuDcp6FbCPwWZ/bUlj2EP+HPpuCYlzUQjySe+1T0WoGDx9ltXCQzHxiRPlU4i4q7EguMTLBG4vmA5HtYyOqEk0s5z5nsggYAu2ZTx5r3jmsQHElls5de96z4xDhNLMiz5IDngO/9niR65NhWEJXY8kEWubh+mQHvVDGl2rFC38ZwoGbs2+5Uq+Gzgp1b+byOoEc4E= + secure: z0Phj0i34mGtRYMyTZsc/5PGC7se0U3O5E7YCOUg/14JCcRTZoqd4U4XPU0VchH3cgLax2p8xHnVJ3n1VcgBdEiuBGyU6xNacgPanONBFGk479S5wAPA6cTVvYarDZ9Oh5/f8JmP+WiqZUzLJQtoFprf1xjpOq5SECynx45+o/XJOcAL0JbNAV2C00WZG/lbRayESX+5EwIv0NzXki8aouJQMBklCvbp0I/kEc3xBsAavQdqji6/6169YZ+B0IuyjRq2SCvqNtmvxNScqn/Mvov1qSnuZ0ljxU0bG2StPyfA6cY5h9J3L9IuqrXMeJmY79aCL6xWZzv7emBMn0Q5Ly3wpiv2nnznhOVRzoDz5YptrNm45P/M0qiYtw+1pHRpHVjZ5LlSAVsIGNfjhvlsZw7ZzI70+WziW9v/+UszwURABrggE/kfAMeMjKTfRtXbPXqE0XApubdJrS9hiGHcaqkJVOasDB5zr7lkAg4bcDIyYsU9oGhcC5UKqn/jF0VcXyUoF4UFuuqNg+MjP1B96FMPdbWc1R9XEkYuqSva3fXehPw6RB/P5DGt8neBHywkuKsuUkxlOLBFdurS0O4i6dUZh4uXoDYQHM0brYo3U43yzTUR4CDQzazNVeg3kCj08eF8lvmf6H7OGSaWmQpyMvavb5vITPfS9v+UyOEjZ84= on: - tags: true \ No newline at end of file + tags: true From fc929c492b2866a0b107c93d180a110317ff9197 Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 01:56:17 +0200 Subject: [PATCH 06/23] travis issues --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d54e65e..2d2d134 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,7 @@ script: - pytest deploy: provider: pypi - user: lucasrodes - password: - secure: z0Phj0i34mGtRYMyTZsc/5PGC7se0U3O5E7YCOUg/14JCcRTZoqd4U4XPU0VchH3cgLax2p8xHnVJ3n1VcgBdEiuBGyU6xNacgPanONBFGk479S5wAPA6cTVvYarDZ9Oh5/f8JmP+WiqZUzLJQtoFprf1xjpOq5SECynx45+o/XJOcAL0JbNAV2C00WZG/lbRayESX+5EwIv0NzXki8aouJQMBklCvbp0I/kEc3xBsAavQdqji6/6169YZ+B0IuyjRq2SCvqNtmvxNScqn/Mvov1qSnuZ0ljxU0bG2StPyfA6cY5h9J3L9IuqrXMeJmY79aCL6xWZzv7emBMn0Q5Ly3wpiv2nnznhOVRzoDz5YptrNm45P/M0qiYtw+1pHRpHVjZ5LlSAVsIGNfjhvlsZw7ZzI70+WziW9v/+UszwURABrggE/kfAMeMjKTfRtXbPXqE0XApubdJrS9hiGHcaqkJVOasDB5zr7lkAg4bcDIyYsU9oGhcC5UKqn/jF0VcXyUoF4UFuuqNg+MjP1B96FMPdbWc1R9XEkYuqSva3fXehPw6RB/P5DGt8neBHywkuKsuUkxlOLBFdurS0O4i6dUZh4uXoDYQHM0brYo3U43yzTUR4CDQzazNVeg3kCj08eF8lvmf6H7OGSaWmQpyMvavb5vITPfS9v+UyOEjZ84= + user: $USER_PYPI + password: $PWD_PYPI on: tags: true From 31055b0d4b21dec4119a72691ce26cb9dc2d9fe9 Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 02:08:29 +0200 Subject: [PATCH 07/23] v0.2.2 --- .bumpversion.cfg | 2 +- README.md | 2 +- setup.py | 2 +- whatstk/__init__.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index ae1323d..55b068d 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.1 +current_version = 0.2.2 [bumpversion:file:setup.py] diff --git a/README.md b/README.md index 1b63260..4240294 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [whatstk](http://lucasrodes.github.io/whatstk) -![Package version](https://img.shields.io/badge/whatstk-v0.2.1-teal.svg?style=for-the-badge&color=25D366&logo=whatsapp) +![Package version](https://img.shields.io/badge/whatstk-v0.2.2-teal.svg?style=for-the-badge&color=25D366&logo=whatsapp) [![Build Status](https://travis-ci.com/lucasrodes/whatstk.svg?branch=develop)](https://travis-ci.com/lucasrodes/whatstk) [![Python 3.6](https://img.shields.io/badge/python-3.7|3.8-blue.svg)](https://www.python.org/downloads/release/python-3/) diff --git a/setup.py b/setup.py index 20c687f..ae0da32 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='whatstk', - version="0.2.1", + version="0.2.2", description="Parser and analytics tools for WhatsApp group chats", long_description=long_description, long_description_content_type='text/markdown', diff --git a/whatstk/__init__.py b/whatstk/__init__.py index 7d590a1..cd1dacf 100755 --- a/whatstk/__init__.py +++ b/whatstk/__init__.py @@ -4,7 +4,7 @@ name = "whatstk" -__version__ = "0.2.1" +__version__ = "0.2.2" __all__ = [ 'WhatsAppChat', From ad014828f9e61a9f3c1429a86e5bf59a867a41a8 Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 02:08:45 +0200 Subject: [PATCH 08/23] v0.2.3 --- .bumpversion.cfg | 2 +- README.md | 2 +- setup.py | 2 +- whatstk/__init__.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 55b068d..8aa8f97 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.2 +current_version = 0.2.3 [bumpversion:file:setup.py] diff --git a/README.md b/README.md index 4240294..2b9583b 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [whatstk](http://lucasrodes.github.io/whatstk) -![Package version](https://img.shields.io/badge/whatstk-v0.2.2-teal.svg?style=for-the-badge&color=25D366&logo=whatsapp) +![Package version](https://img.shields.io/badge/whatstk-v0.2.3-teal.svg?style=for-the-badge&color=25D366&logo=whatsapp) [![Build Status](https://travis-ci.com/lucasrodes/whatstk.svg?branch=develop)](https://travis-ci.com/lucasrodes/whatstk) [![Python 3.6](https://img.shields.io/badge/python-3.7|3.8-blue.svg)](https://www.python.org/downloads/release/python-3/) diff --git a/setup.py b/setup.py index ae0da32..7bc341f 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='whatstk', - version="0.2.2", + version="0.2.3", description="Parser and analytics tools for WhatsApp group chats", long_description=long_description, long_description_content_type='text/markdown', diff --git a/whatstk/__init__.py b/whatstk/__init__.py index cd1dacf..e095b91 100755 --- a/whatstk/__init__.py +++ b/whatstk/__init__.py @@ -4,7 +4,7 @@ name = "whatstk" -__version__ = "0.2.2" +__version__ = "0.2.3" __all__ = [ 'WhatsAppChat', From aa8982a1dacadc665f632e9e73af71da4ccd19f5 Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 02:09:56 +0200 Subject: [PATCH 09/23] v.0.2.4 --- .bumpversion.cfg | 2 +- README.md | 2 +- setup.py | 2 +- whatstk/__init__.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 8aa8f97..4c8be79 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.3 +current_version = 0.2.4 [bumpversion:file:setup.py] diff --git a/README.md b/README.md index 2b9583b..0a776a8 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [whatstk](http://lucasrodes.github.io/whatstk) -![Package version](https://img.shields.io/badge/whatstk-v0.2.3-teal.svg?style=for-the-badge&color=25D366&logo=whatsapp) +![Package version](https://img.shields.io/badge/whatstk-v0.2.4-teal.svg?style=for-the-badge&color=25D366&logo=whatsapp) [![Build Status](https://travis-ci.com/lucasrodes/whatstk.svg?branch=develop)](https://travis-ci.com/lucasrodes/whatstk) [![Python 3.6](https://img.shields.io/badge/python-3.7|3.8-blue.svg)](https://www.python.org/downloads/release/python-3/) diff --git a/setup.py b/setup.py index 7bc341f..eb8fec9 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='whatstk', - version="0.2.3", + version="0.2.4", description="Parser and analytics tools for WhatsApp group chats", long_description=long_description, long_description_content_type='text/markdown', diff --git a/whatstk/__init__.py b/whatstk/__init__.py index e095b91..f5fc41d 100755 --- a/whatstk/__init__.py +++ b/whatstk/__init__.py @@ -4,7 +4,7 @@ name = "whatstk" -__version__ = "0.2.3" +__version__ = "0.2.4" __all__ = [ 'WhatsAppChat', From 56a473f68d424339b28e796f65e502f1a5fc2140 Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 18:01:41 +0200 Subject: [PATCH 10/23] integrating codecov in travis --- .gitignore | 1 - .travis.yml | 14 +++++++++----- MANIFEST.in | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 7869fa7..d29a9bb 100755 --- a/.gitignore +++ b/.gitignore @@ -257,7 +257,6 @@ examples tox.ini .coveragerc requirements-flake.txt -requirements-test.txt setup.cfg testreport.html testreport.xml diff --git a/.travis.yml b/.travis.yml index 2cf0feb..3504205 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,18 @@ dist: xenial language: python python: -- 3.7.2 -- 3.8 -- 3.5 + - 3.7.2 + - 3.8 + - 3.5 +before_install: + - pip install -r requirements-test.txt install: -- pip install . + - pip install . #pip install -r requirements.txt script: -- pytest + - pytest +after_success: + - codecov # submit coverage deploy: provider: pypi user: lucasrodes diff --git a/MANIFEST.in b/MANIFEST.in index e432b3d..78d509d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,7 @@ include *.md include LICENSE include requirements.txt +include requirements-test.txt recursive-include altair *.py *.json *.ipynb *.html global-exclude *.py[co] __pycache__ \ No newline at end of file From dec6e9b84417f4c58df96d2090d9005e6ef103b8 Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 18:02:23 +0200 Subject: [PATCH 11/23] tests scripts --- tests/chats/{example.txt => example_1.txt} | 0 tests/chats/example_2.txt | 21 +++++++++++++++++++++ tests/test_analysis.py | 0 tests/test_core.py | 5 +++++ tests/test_objects.py | 13 ++++++++++--- tests/test_plot.py | 13 +++++++++++++ 6 files changed, 49 insertions(+), 3 deletions(-) rename tests/chats/{example.txt => example_1.txt} (100%) create mode 100644 tests/chats/example_2.txt create mode 100644 tests/test_analysis.py create mode 100644 tests/test_core.py create mode 100644 tests/test_plot.py diff --git a/tests/chats/example.txt b/tests/chats/example_1.txt similarity index 100% rename from tests/chats/example.txt rename to tests/chats/example_1.txt diff --git a/tests/chats/example_2.txt b/tests/chats/example_2.txt new file mode 100644 index 0000000..d11a89c --- /dev/null +++ b/tests/chats/example_2.txt @@ -0,0 +1,21 @@ +[2016/04/15 15:04] You created group “Sample Group” +[2016/08/06 13:18] Messages you send to this group are now secured with end-to-end encryption. Tap for more info. +[2016/08/06 13:23] Ash Ketchum: Hey guys! +[2016/08/06 13:25] Brock: Hey Ash, good to have a common group! +[2016/08/06 13:30] Misty: Hey guys! Long time haven't heard anything from you +[2016/08/06 13:45] Ash Ketchum: Indeed. I think having a whatsapp group nowadays is a good idea +[2016/08/06 14:30] Misty: Definetly +[2016/08/06 17:25] Brock: I totally agree +[2016/08/07 11:45] Prof. Oak: Kids, shall I design a smart poke-ball? +[2016/08/07 18:45] Ash Ketchum: I don't mind Prof. I quitted capturing pokemon. +[2016/08/07 19:30] Misty: Was a great time, but had enough also. +[2016/08/07 23:25] Brock: Guys, I am still in the first gym. No one is playing pokemon, they went crazy with pokemon Go. +[2016/08/10 09:45] Jessie & James: Hey, thanks for adding us. Wanna meet soon? Just for the old times. +[2016/08/10 11:25] Raichu: I am in! +[2016/08/10 13:23] Ash Ketchum: FFS, no way, Pikachu did you evolve? +[2016/08/10 15:23] Raichu: Yes... Weird to have a different body! +[2016/08/11 19:30] Misty: Gotta see that. +[2016/09/11 20:25] Meowth: Hey people, I was on holidays in Sinnoh. Crazy region. +[2016/10/31 11:45] Prof. Oak: Smart-pokeball is created. +[2016/10/31 12:23] Wobbuffet: Wo-bbu-ffet + diff --git a/tests/test_analysis.py b/tests/test_analysis.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_core.py b/tests/test_core.py new file mode 100644 index 0000000..5ea6e7d --- /dev/null +++ b/tests/test_core.py @@ -0,0 +1,5 @@ +from whatstk.core import WhatsAppChat +from whatstk.core import interventions + +def test(): + assert(True) \ No newline at end of file diff --git a/tests/test_objects.py b/tests/test_objects.py index 441bb03..00db51d 100644 --- a/tests/test_objects.py +++ b/tests/test_objects.py @@ -3,15 +3,22 @@ def test_object_auto(): - filename = './chats/example.txt' + filename = 'tests/chats/example_1.txt' + chat = WhatsAppChat.from_txt(filename) + assert(isinstance(chat.df, pd.DataFrame)) + + filename = 'tests/chats/example_2.txt' chat = WhatsAppChat.from_txt(filename) assert(isinstance(chat.df, pd.DataFrame)) def test_object_hformat(): - filename = './chats/example.txt' + filename = 'tests/chats/example_1.txt' hformat = '%d.%m.%y, %H:%M - %name:' chat = WhatsAppChat.from_txt(filename) assert(isinstance(chat.df, pd.DataFrame)) - + filename = 'tests/chats/example_2.txt' + hformat = '[%y/%m/%d %H:%M] %name:' + chat = WhatsAppChat.from_txt(filename) + assert(isinstance(chat.df, pd.DataFrame)) diff --git a/tests/test_plot.py b/tests/test_plot.py new file mode 100644 index 0000000..1a2c98f --- /dev/null +++ b/tests/test_plot.py @@ -0,0 +1,13 @@ +from whatstk.plot import vis +from whatstk.objects import WhatsAppChat +from whatstk.analysis import interventions + + +def test_vis(): + filename = 'tests/chats/example_1.txt' + chat = WhatsAppChat.from_txt(filename) + counts = interventions(chat=chat, date_mode='date', msg_length=False) + counts_cumsum = counts.cumsum() + fig = vis(counts_cumsum, 'cumulative number of messages sent per day') + assert isinstance(fig, dict) + assert ('data' in fig and 'layout' in fig) From bcaa00a96b1158133a4a0512c7629e25285f5618 Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 18:02:33 +0200 Subject: [PATCH 12/23] test requirements libs --- requirements-test.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 requirements-test.txt diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 0000000..a0ddaf8 --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,6 @@ +pytest +pytest-mock +pytest-cov +pytest-html +coverage +codecov From 50e581459f8e78e7edb2919e44cd85b7b8270553 Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 18:06:27 +0200 Subject: [PATCH 13/23] travis test --- .coveragerc | 6 ++++++ .gitignore | 5 +++-- .travis.yml | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..32ef275 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,6 @@ +[run] +branch = True +omit = whatstk/tests/* + +[report] +fail_under=90 \ No newline at end of file diff --git a/.gitignore b/.gitignore index d29a9bb..d5e8f01 100755 --- a/.gitignore +++ b/.gitignore @@ -255,7 +255,7 @@ examples #tox stuff tox.ini -.coveragerc +#.coveragerc requirements-flake.txt setup.cfg testreport.html @@ -268,4 +268,5 @@ py37 *.ipynb .pypirc -learn/ \ No newline at end of file +learn/ +assets/style.css \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 3504205..7b3540c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ install: - pip install . #pip install -r requirements.txt script: - - pytest + - py.test --html=testreport.html --cov-report html --cov-report term --cov=whatstk tests/ after_success: - codecov # submit coverage deploy: From 4cff313c49077e8c3c12395275b4671f60127004 Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 18:08:39 +0200 Subject: [PATCH 14/23] testing travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7b3540c..defd5ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ install: - pip install . #pip install -r requirements.txt script: - - py.test --html=testreport.html --cov-report html --cov-report term --cov=whatstk tests/ + - pytest --cov-report term --cov=whatstk tests/ after_success: - codecov # submit coverage deploy: From c56ca2c6062247514cd01714478f6ed16a431fcc Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 18:15:25 +0200 Subject: [PATCH 15/23] requirements test --- requirements-test.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/requirements-test.txt b/requirements-test.txt index 3ff9ed7..0a362a8 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,5 +1,4 @@ -pytest -pytest-mock -pytest-cov -coverage -codecov +pytest>=5.4.1 +pytest-cov>=2.8.1 +coverage>=4.5.1 +codecov>=2.0.22 From dd5a033f4d344574dea5da5890e70d3fc0039ffb Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 18:23:22 +0200 Subject: [PATCH 16/23] travis test --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 028beef..3af5df9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,13 @@ python: before_install: - pip install -r requirements-test.txt install: - - pip install . + - ECHO "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+" + - ls -l + - pip uninstall whatstk + - pip install -e . #pip install -r requirements.txt script: + - pip freeze | grep whatstk - pytest --cov-report term --cov=whatstk tests/ after_success: - codecov # submit coverage From bbd13587d4211907d563f83cd4bf91e754f3863a Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 18:25:14 +0200 Subject: [PATCH 17/23] travis test --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3af5df9..cc9c670 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,6 @@ python: before_install: - pip install -r requirements-test.txt install: - - ECHO "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+" - ls -l - pip uninstall whatstk - pip install -e . From 2b2c4b610a85796649436a3ed25ee67410ab9f21 Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 18:56:34 +0200 Subject: [PATCH 18/23] comments on pull requests --- MANIFEST.in | 1 + README.md | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 78d509d..b3098f4 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,6 +2,7 @@ include *.md include LICENSE include requirements.txt include requirements-test.txt +include .coveragerc recursive-include altair *.py *.json *.ipynb *.html global-exclude *.py[co] __pycache__ \ No newline at end of file diff --git a/README.md b/README.md index 3b0a341..2f07b7d 100755 --- a/README.md +++ b/README.md @@ -150,5 +150,15 @@ header unit. ## Contribute + We are very open to have collaborators. You can freely fork and issue a pull request with your updates! -For other issues/bugs/suggestions, please report it as an issue or [text me](mailto:lucasrg@kth.se). \ No newline at end of file +For other issues/bugs/suggestions, please report it as an issue or [text me](mailto:lucasrg@kth.se). + +###  Pull Requests +Make sure to test your code before issuing a pull request: + +``` +py.test --cov-report term --cov=whatstk tests/ +``` + +However, pull requests will trigger the Travis CI pipeline, which will run the tests as well. \ No newline at end of file From fef9b51708c80bed635b3d4c052de66f3431812c Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 19:34:03 +0200 Subject: [PATCH 19/23] interventions method now returns correct index naming for option 'hourweekday' --- whatstk/analysis/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/whatstk/analysis/base.py b/whatstk/analysis/base.py index fbfd3b3..96ae5c1 100644 --- a/whatstk/analysis/base.py +++ b/whatstk/analysis/base.py @@ -50,7 +50,10 @@ def interventions(chat, date_mode='date', msg_length=False): raise InterventionModeError("Mode {} is not implemented. Valid modes are 'date', 'hour', 'weekday', " "'hourweekday' and 'month".format(date_mode)) - n_interventions.index.name = date_mode + if date_mode == 'hourweekday': + n_interventions.index = n_interventions.index.set_names(['weekday', 'hour']) + else: + n_interventions.index.name = date_mode n_interventions.columns = n_interventions.columns.get_level_values('username') return n_interventions From 0ecb5c52c4635fbcc556a8e33c6807196ea87afc Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 20:16:22 +0200 Subject: [PATCH 20/23] travis test --- .coveragerc | 2 +- README.md | 2 + tests/test_analysis.py | 175 ++++++++++++++++++++++++++++++++++++ whatstk/analysis/base.py | 4 +- whatstk/objects.py | 1 - whatstk/utils/exceptions.py | 5 -- 6 files changed, 180 insertions(+), 9 deletions(-) diff --git a/.coveragerc b/.coveragerc index 32ef275..fb45bc5 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,4 +3,4 @@ branch = True omit = whatstk/tests/* [report] -fail_under=90 \ No newline at end of file +fail_under=80 \ No newline at end of file diff --git a/README.md b/README.md index 2f07b7d..39937bb 100755 --- a/README.md +++ b/README.md @@ -161,4 +161,6 @@ Make sure to test your code before issuing a pull request: py.test --cov-report term --cov=whatstk tests/ ``` +_Note 1: Use `--html=testreport.html --cov-report html` to generate HTML reports._ + However, pull requests will trigger the Travis CI pipeline, which will run the tests as well. \ No newline at end of file diff --git a/tests/test_analysis.py b/tests/test_analysis.py index e69de29..dbb3da9 100644 --- a/tests/test_analysis.py +++ b/tests/test_analysis.py @@ -0,0 +1,175 @@ +from whatstk.analysis import interventions +from whatstk.objects import WhatsAppChat +import pandas as pd +import pytest + + +def test_interventions_date(): + + filename = 'tests/chats/example_1.txt' + chat = WhatsAppChat.from_txt(filename) + counts = interventions(chat, date_mode='date', msg_length=False) + + assert(isinstance(counts, pd.DataFrame)) + # Asswert chat df and counts df have same users + assert(set(chat.users) == set(counts.columns)) + + # Assert chat df and counts df have same date window + assert(chat.df.index.max().date() == counts.index.max().date()) + assert(chat.df.index.min().date() == counts.index.min().date()) + + +def test_interventions_date_msg_length(): + + filename = 'tests/chats/example_1.txt' + chat = WhatsAppChat.from_txt(filename) + counts = interventions(chat, date_mode='date', msg_length=True) + + assert(isinstance(counts, pd.DataFrame)) + # Asswert chat df and counts df have same users + assert(set(chat.users) == set(counts.columns)) + + # Assert chat df and counts df have same date window + assert(chat.df.index.max().date() == counts.index.max().date()) + assert(chat.df.index.min().date() == counts.index.min().date()) + + +def test_interventions_hour(): + + filename = 'tests/chats/example_1.txt' + chat = WhatsAppChat.from_txt(filename) + counts = interventions(chat, date_mode='hour', msg_length=False) + + assert(isinstance(counts, pd.DataFrame)) + # Asswert chat df and counts df have same users + assert(set(chat.users) == set(counts.columns)) + + # Check range hours + assert(counts.index.max() == chat.df.index.hour.max()) + assert(counts.index.min() == chat.df.index.hour.min()) + + + +def test_interventions_hour_msg_length(): + + filename = 'tests/chats/example_1.txt' + chat = WhatsAppChat.from_txt(filename) + counts = interventions(chat, date_mode='hour', msg_length=True) + + assert(isinstance(counts, pd.DataFrame)) + # Asswert chat df and counts df have same users + assert(set(chat.users) == set(counts.columns)) + + # Check range hours + assert(counts.index.max() == chat.df.index.hour.max()) + assert(counts.index.min() == chat.df.index.hour.min()) + + +def test_interventions_month(): + + filename = 'tests/chats/example_1.txt' + chat = WhatsAppChat.from_txt(filename) + counts = interventions(chat, date_mode='month', msg_length=False) + + assert(isinstance(counts, pd.DataFrame)) + # Asswert chat df and counts df have same users + assert(set(chat.users) == set(counts.columns)) + + # Check range hours + assert(counts.index.max() == chat.df.index.month.max()) + assert(counts.index.min() == chat.df.index.month.min()) + + + +def test_interventions_month_msg_length(): + + filename = 'tests/chats/example_1.txt' + chat = WhatsAppChat.from_txt(filename) + counts = interventions(chat, date_mode='month', msg_length=False) + + assert(isinstance(counts, pd.DataFrame)) + # Asswert chat df and counts df have same users + assert(set(chat.users) == set(counts.columns)) + + # Check range hours + assert(counts.index.max() == chat.df.index.month.max()) + assert(counts.index.min() == chat.df.index.month.min()) + + +def test_interventions_weekday(): + + filename = 'tests/chats/example_1.txt' + chat = WhatsAppChat.from_txt(filename) + counts = interventions(chat, date_mode='weekday', msg_length=False) + + assert(isinstance(counts, pd.DataFrame)) + # Asswert chat df and counts df have same users + assert(set(chat.users) == set(counts.columns)) + + # Check range hours + assert(counts.index.max() == chat.df.index.weekday.max()) + assert(counts.index.min() == chat.df.index.weekday.min()) + + + +def test_interventions_weekday_msg_length(): + + filename = 'tests/chats/example_1.txt' + chat = WhatsAppChat.from_txt(filename) + counts = interventions(chat, date_mode='weekday', msg_length=True) + + assert(isinstance(counts, pd.DataFrame)) + # Asswert chat df and counts df have same users + assert(set(chat.users) == set(counts.columns)) + + # Check range hours + assert(counts.index.max() == chat.df.index.weekday.max()) + assert(counts.index.min() == chat.df.index.weekday.min()) + + + +def test_interventions_hourweekday(): + + filename = 'tests/chats/example_1.txt' + chat = WhatsAppChat.from_txt(filename) + counts = interventions(chat, date_mode='hourweekday', msg_length=False) + + assert(isinstance(counts, pd.DataFrame)) + # Asswert chat df and counts df have same users + assert(set(chat.users) == set(counts.columns)) + + # Check range days + assert(counts.index.levels[0].max() == chat.df.index.weekday.max()) + assert(counts.index.levels[0].min() == chat.df.index.weekday.min()) + + # Check range hours + assert(counts.index.levels[1].max() == chat.df.index.hour.max()) + assert(counts.index.levels[1].min() == chat.df.index.hour.min()) + + +def test_interventions_hourweekday_msg_length(): + + filename = 'tests/chats/example_1.txt' + chat = WhatsAppChat.from_txt(filename) + counts = interventions(chat, date_mode='hourweekday', msg_length=True) + + assert(isinstance(counts, pd.DataFrame)) + # Asswert chat df and counts df have same users + assert(set(chat.users) == set(counts.columns)) + + # Check range days + assert(counts.index.levels[0].max() == chat.df.index.weekday.max()) + assert(counts.index.levels[0].min() == chat.df.index.weekday.min()) + + # Check range hours + assert(counts.index.levels[1].max() == chat.df.index.hour.max()) + assert(counts.index.levels[1].min() == chat.df.index.hour.min()) + +def test_interventions_error(): + + filename = 'tests/chats/example_1.txt' + chat = WhatsAppChat.from_txt(filename) + with pytest.raises(ValueError): + counts = interventions(chat, date_mode='error', msg_length=False) + with pytest.raises(ValueError): + counts = interventions(chat, date_mode='error', msg_length=True) diff --git a/whatstk/analysis/base.py b/whatstk/analysis/base.py index 96ae5c1..6f7303b 100644 --- a/whatstk/analysis/base.py +++ b/whatstk/analysis/base.py @@ -32,7 +32,7 @@ def interventions(chat, date_mode='date', msg_length=False): pandas.DataFrame: DataFrame with shape NxU, where N: number of time-slots and U: number of users. Raises: - whatstk.exceptions.InterventionModeError: if invalid mode is chosen. + ValueError: if invalid mode is chosen. """ if date_mode == 'date': @@ -47,7 +47,7 @@ def interventions(chat, date_mode='date', msg_length=False): elif date_mode == 'month': n_interventions = _interventions(chat, [chat.df.index.month], msg_length) else: - raise InterventionModeError("Mode {} is not implemented. Valid modes are 'date', 'hour', 'weekday', " + raise ValueError("Mode {} is not implemented. Valid modes are 'date', 'hour', 'weekday', " "'hourweekday' and 'month".format(date_mode)) if date_mode == 'hourweekday': diff --git a/whatstk/objects.py b/whatstk/objects.py index dad60dd..80d0e87 100644 --- a/whatstk/objects.py +++ b/whatstk/objects.py @@ -1,6 +1,5 @@ from whatstk.utils.parser import generate_regex, parse_chat, remove_alerts_from_df from whatstk.utils.auto_header import extract_header_from_text -from whatstk.utils.exceptions import InterventionModeError diff --git a/whatstk/utils/exceptions.py b/whatstk/utils/exceptions.py index 9e0f417..25cf1eb 100644 --- a/whatstk/utils/exceptions.py +++ b/whatstk/utils/exceptions.py @@ -1,6 +1 @@ """Library exceptions.""" - -class InterventionModeError(Exception): - """Raised when a non-implemented mode is selected.""" - - pass \ No newline at end of file From 5fdd794bd1592ba9a7a76bf5a442bbbfc9c75176 Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 21:19:53 +0200 Subject: [PATCH 21/23] fixed shape method --- whatstk/objects.py | 1 + 1 file changed, 1 insertion(+) diff --git a/whatstk/objects.py b/whatstk/objects.py index 80d0e87..bf45c89 100644 --- a/whatstk/objects.py +++ b/whatstk/objects.py @@ -99,6 +99,7 @@ def __len__(self): """ return len(self.df) + @property def shape(self): """Get shape of DataFrame-formatted chat. From 6924f4b00a005a539bdf71f7d22eaa58af71338d Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 22:32:49 +0200 Subject: [PATCH 22/23] add badge and known issues --- README.md | 15 +++++++++++---- tests/test_objects.py | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 39937bb..bbe3430 100755 --- a/README.md +++ b/README.md @@ -3,9 +3,13 @@ ![Package version](https://img.shields.io/badge/whatstk-v0.2.4-teal.svg?style=for-the-badge&color=25D366&logo=whatsapp) [![Build Status](https://travis-ci.com/lucasrodes/whatstk.svg?branch=develop)](https://travis-ci.com/lucasrodes/whatstk) +[![codecov](https://codecov.io/gh/lucasrodes/whatstk/branch/master/graph/badge.svg)](https://codecov.io/gh/lucasrodes/whatstk) [![Python 3.6](https://img.shields.io/badge/python-3.7|3.8-blue.svg)](https://www.python.org/downloads/release/python-3/) [![Documentation](https://img.shields.io/badge/documentation-royalblue.svg)](docs/index.md) -[![GitHub license](https://img.shields.io/github/license/lucasrodes/whatstk.svg)](https://github.com/lucasrodes/whatstk/blob/master/LICENSE) +[![GitHub +license](https://img.shields.io/github/license/lucasrodes/whatstk.svg)](https://github.com/lucasrodes/whatstk/blob/master/LICENSE) + + > [Get the Desktop App](https://lcsrg.me/whatstk-gui) @@ -28,7 +32,7 @@ Make sure to first obtain the chat to be analyzed. Export it as a `txt` file usi Check more on how-to use it in the [docs](docs/index.md) -#### Obtain a dataframe from your chat log file +### Obtain a dataframe from your chat log file Load your chat using the object `WhatsAppChat`. Example below we use chat [example.txt](chats/example.txt) @@ -68,7 +72,7 @@ header format. In our example, it would be: `hformat = '%d.%m.%y, %H:%M - %name: _Note 2: If your chat uses 12h clock, it may not work as expected. If it is your case, please report it in the issues section._ -#### Plot the cumulative messages sent by day +### Plot the cumulative messages sent by day Once you have your `WhatsAppChat` object, you can easily get the number of interventions per user per, say, `day` using the method `interventions()` with `date_mode` argument set to `'day'`. With this, some minor processing, `plotly` and `vis` method from `whatstk.plot` you can get really insightful plots. @@ -86,7 +90,7 @@ plot(vis(counts_cumsum, 'cumulative number of messages sent per day')) ![](assets/example1.png) -### What's the header? +## What's the header? The chat file syntax can differ between devices, OS and language settings, which makes it hard some times to correctly parse the data and make WhatsTK work correctly. The header appears for each message sent in the chat. It contains a timestamp and the name of the user that sent the message. @@ -149,6 +153,9 @@ header unit. +## Known issues +- 12h clock header format is not supported. + ## Contribute We are very open to have collaborators. You can freely fork and issue a pull request with your updates! diff --git a/tests/test_objects.py b/tests/test_objects.py index 00db51d..942af9e 100644 --- a/tests/test_objects.py +++ b/tests/test_objects.py @@ -1,5 +1,6 @@ from whatstk.objects import WhatsAppChat import pandas as pd +import pytest def test_object_auto(): @@ -22,3 +23,20 @@ def test_object_hformat(): hformat = '[%y/%m/%d %H:%M] %name:' chat = WhatsAppChat.from_txt(filename) assert(isinstance(chat.df, pd.DataFrame)) + + +def test_object_error(): + filename = 'tests/chats/example_1.txt' + with pytest.raises(ValueError): + chat = WhatsAppChat.from_txt(filename, auto_header=False) + + +def test_object_len_shape(): + filename = 'tests/chats/example_1.txt' + hformat = '%d.%m.%y, %H:%M - %name:' + chat = WhatsAppChat.from_txt(filename) + l = len(chat) + assert(isinstance(l, int)) + s = chat.shape + assert(isinstance(s, tuple)) + assert(len(s)==2) From 4d50e224bd1369edd97b8be6e6b17ff2c5f82096 Mon Sep 17 00:00:00 2001 From: lucas rg Date: Fri, 1 May 2020 22:43:43 +0200 Subject: [PATCH 23/23] generated new docs --- docs/index.md | 13 ++----------- make-docs.sh | 4 +++- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/docs/index.md b/docs/index.md index 9cb0221..915f4de 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,7 +17,6 @@ * [parse\_chat](#.whatstk.utils.parser.parse_chat) * [remove\_alerts\_from\_df](#.whatstk.utils.parser.remove_alerts_from_df) * [whatstk.utils.exceptions](#.whatstk.utils.exceptions) - * [InterventionModeError](#.whatstk.utils.exceptions.InterventionModeError) * [whatstk.objects](#.whatstk.objects) * [WhatsAppChat](#.whatstk.objects.WhatsAppChat) * [\_\_init\_\_](#.whatstk.objects.WhatsAppChat.__init__) @@ -120,7 +119,7 @@ The unit of time can be chosen by means of argument `date_mode`. **Raises**: -- `whatstk.exceptions.InterventionModeError` - if invalid mode is chosen. +- `ValueError` - if invalid mode is chosen. ## whatstk.core @@ -254,15 +253,6 @@ Tries to get rid of alert/notification messages Library exceptions. - -### InterventionModeError - -```python -class InterventionModeError(Exception) -``` - -Raised when a non-implemented mode is selected. - ## whatstk.objects @@ -338,6 +328,7 @@ Get length of DataFrame #### shape ```python + | @property | def WhatsAppChat.shape() ``` diff --git a/make-docs.sh b/make-docs.sh index 4198a64..a6aff6a 100644 --- a/make-docs.sh +++ b/make-docs.sh @@ -1,5 +1,7 @@ -# Make sure to have pydoc-markdown:develop installed +# Make sure to have pydoc-markdown (develop branch) installed # pip install git+https://github.com/NiklasRosenstein/pydoc-markdown.git@develop +# +# Then simply execute `sh make-docs.sh` # Script to make documentation mkdir -p docs