From f24bd8be47458a2757e8fbb7d4648f0501a291d6 Mon Sep 17 00:00:00 2001 From: ni1o1 <53589767+ni1o1@users.noreply.github.com> Date: Mon, 10 Oct 2022 09:18:33 +0800 Subject: [PATCH 1/7] rename the `mobile_stay_duration` method name --- src/transbigdata/mobilephonedata.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/transbigdata/mobilephonedata.py b/src/transbigdata/mobilephonedata.py index 128434f..7452633 100644 --- a/src/transbigdata/mobilephonedata.py +++ b/src/transbigdata/mobilephonedata.py @@ -33,7 +33,7 @@ import pandas as pd import numpy as np from .grids import GPS_to_grid, grid_to_centre - +import warnings def mobile_stay_move(data, params, col=['ID', 'dataTime', 'longitude', 'latitude'], @@ -118,7 +118,7 @@ def mobile_stay_move(data, params, return stay, move -def mobile_stay_dutation(staydata, col=['stime', 'etime'], start_hour=8, end_hour=20): +def mobile_stay_duration(staydata, col=['stime', 'etime'], start_hour=8, end_hour=20): ''' Input the stay point data to identify the duration during night and day time. @@ -177,6 +177,10 @@ def mobile_stay_dutation(staydata, col=['stime', 'etime'], start_hour=8, end_hou return duration_night, duration_day +def mobile_stay_dutation(*args, **kwargs): + warnings.warn("This method is renamed as transbigdata.mobile_stay_duration") + return mobile_stay_duration(*args, **kwargs) + def mobile_identify_home(staydata, col=['uid','stime', 'etime','LONCOL', 'LATCOL'], start_hour=8, end_hour=20 ): ''' Identify home location from mobile phone stay data. The rule is to identify the locations with longest @@ -202,7 +206,7 @@ def mobile_identify_home(staydata, col=['uid','stime', 'etime','LONCOL', 'LATCOL etime = col[2] stay = staydata.copy() if ('duration_night' not in stay.columns) | ('duration_day' not in stay.columns): - stay['duration_night'], stay['duration_day'] = mobile_stay_dutation( + stay['duration_night'], stay['duration_day'] = mobile_stay_duration( stay, col = [stime,etime],start_hour=start_hour, end_hour=end_hour) # 夜晚最常停留地 home = stay.groupby([col[0],*col[3:]])['duration_night'].sum().reset_index() @@ -253,7 +257,7 @@ def mobile_identify_work(staydata, col=['uid', 'stime', 'etime', 'LONCOL', 'LATC stay_workdays['nextday'] = pd.to_datetime( stay_workdays[stime].dt.date+pd.Timedelta(1, unit='days')) stay_workdays[etime] = stay_workdays[[etime, 'nextday']].min(axis=1) - stay_workdays['duration_night'], stay_workdays['duration_day'] = mobile_stay_dutation( + stay_workdays['duration_night'], stay_workdays['duration_day'] = mobile_stay_duration( stay_workdays, col = [stime,etime],start_hour=start_hour, end_hour=end_hour) # 白天最常活动地 From 016cb4dece230fc8262689b9227682f7729c28d7 Mon Sep 17 00:00:00 2001 From: ni1o1 <53589767+ni1o1@users.noreply.github.com> Date: Mon, 10 Oct 2022 10:26:09 +0800 Subject: [PATCH 2/7] update tests --- src/transbigdata/mobilephonedata.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/transbigdata/mobilephonedata.py b/src/transbigdata/mobilephonedata.py index 7452633..3691f7b 100644 --- a/src/transbigdata/mobilephonedata.py +++ b/src/transbigdata/mobilephonedata.py @@ -177,9 +177,9 @@ def mobile_stay_duration(staydata, col=['stime', 'etime'], start_hour=8, end_hou return duration_night, duration_day -def mobile_stay_dutation(*args, **kwargs): - warnings.warn("This method is renamed as transbigdata.mobile_stay_duration") - return mobile_stay_duration(*args, **kwargs) +def mobile_stay_dutation(*args, **kwargs): + warnings.warn("This method is renamed as transbigdata.mobile_stay_duration") # pragma: no cover + return mobile_stay_duration(*args, **kwargs) # pragma: no cover def mobile_identify_home(staydata, col=['uid','stime', 'etime','LONCOL', 'LATCOL'], start_hour=8, end_hour=20 ): ''' From fbf551e7a9cec8d98fc267b13adc44425cb005bc Mon Sep 17 00:00:00 2001 From: ni1o1 <53589767+ni1o1@users.noreply.github.com> Date: Sun, 23 Oct 2022 09:43:45 +0800 Subject: [PATCH 3/7] update test --- src/transbigdata/tests/test_getbusdata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transbigdata/tests/test_getbusdata.py b/src/transbigdata/tests/test_getbusdata.py index 5cc44f6..8c53966 100644 --- a/src/transbigdata/tests/test_getbusdata.py +++ b/src/transbigdata/tests/test_getbusdata.py @@ -27,7 +27,7 @@ def test_getadmin(self): '深圳市', ak='2305ee7c82c147f11aac58fcc5bb7f19',jscode = '694338a096c6c50b74e5d74f411c9ab5', subdistricts=True) except: # pragma: no cover t+=1 # pragma: no cover - assert '深圳市' in admin['name'].sum() + assert '深圳市' in list(admin['name']) def test_getisochrone(self): From 05cec5428b63061de6ba7c80e586a6052b7b4b45 Mon Sep 17 00:00:00 2001 From: ni1o1 <53589767+ni1o1@users.noreply.github.com> Date: Sun, 23 Oct 2022 09:50:18 +0800 Subject: [PATCH 4/7] Update test_getbusdata.py --- src/transbigdata/tests/test_getbusdata.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/transbigdata/tests/test_getbusdata.py b/src/transbigdata/tests/test_getbusdata.py index 8c53966..1e82c97 100644 --- a/src/transbigdata/tests/test_getbusdata.py +++ b/src/transbigdata/tests/test_getbusdata.py @@ -21,10 +21,13 @@ def test_getadmin(self): admin = 0 t = 0 - while (type(admin)==int)&(t<5): + while (type(admin)==int)&(t<10): try: admin, _ = tbd.getadmin( - '深圳市', ak='2305ee7c82c147f11aac58fcc5bb7f19',jscode = '694338a096c6c50b74e5d74f411c9ab5', subdistricts=True) + '深圳市', + ak='2305ee7c82c147f11aac58fcc5bb7f19', + jscode = '694338a096c6c50b74e5d74f411c9ab5', + subdistricts=True) except: # pragma: no cover t+=1 # pragma: no cover assert '深圳市' in list(admin['name']) From b511f3d80af07854cf33d861d154bd7e3b538a26 Mon Sep 17 00:00:00 2001 From: ni1o1 <53589767+ni1o1@users.noreply.github.com> Date: Mon, 31 Oct 2022 13:40:16 +0800 Subject: [PATCH 5/7] fix bug in tbd.mobile_stay_move and tbd.mobile_plot_activity --- src/transbigdata/mobilephonedata.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/transbigdata/mobilephonedata.py b/src/transbigdata/mobilephonedata.py index 3691f7b..4a50404 100644 --- a/src/transbigdata/mobilephonedata.py +++ b/src/transbigdata/mobilephonedata.py @@ -81,6 +81,8 @@ def mobile_stay_move(data, params, stay['duration'] = (pd.to_datetime(stay['etime']) - pd.to_datetime(stay['stime'])).dt.total_seconds() stay = stay[stay['duration'] >= activitytime].copy() + stay = stay[[uid, 'stime','LONCOL', 'LATCOL','etime','lon','lat', 'duration']] + ''' # Renumber the status stay['status_id'] = ((stay['LONCOL'] != stay['LONCOL'].shift()) | (stay['LATCOL'] != stay['LATCOL'].shift()) | @@ -96,6 +98,7 @@ def mobile_stay_move(data, params, [stay['LONCOL'], stay['LATCOL']], params) stay['duration'] = (pd.to_datetime(stay['etime']) - pd.to_datetime(stay['stime'])).dt.total_seconds() + ''' # Identify move move = stay.copy() move['stime_next'] = move['stime'].shift(-1) @@ -279,8 +282,9 @@ def mobile_identify_work(staydata, col=['uid', 'stime', 'etime', 'LONCOL', 'LATC return work + def mobile_plot_activity(data, col=['stime', 'etime', 'LONCOL', 'LATCOL'], - figsize=(10, 5), dpi=250): + figsize=(10, 5), dpi=250,shuffle=True): ''' Plot the activity plot of individual @@ -290,6 +294,11 @@ def mobile_plot_activity(data, col=['stime', 'etime', 'LONCOL', 'LATCOL'], activity information of one person col : List The column name.[starttime,endtime,LONCOL,LATCOL] of activities + figsize : List + The figure size + dpi : Number + shuffle : bool + Whether to shuffle the activity ''' stime, etime, LONCOL, LATCOL = col activity = data.copy() @@ -318,10 +327,11 @@ def mobile_plot_activity(data, col=['stime', 'etime', 'LONCOL', 'LATCOL'], time.strptime(x, '%Y-%m-%d %H:%M:%S'))).astype('int64') activityinfo = activity[[LONCOL, LATCOL]].drop_duplicates() indexs = list(range(1, len(activityinfo)+1)) - np.random.shuffle(indexs) + if shuffle: + np.random.shuffle(indexs) activityinfo['index'] = indexs import matplotlib as mpl - norm = mpl.colors.Normalize(vmin=0, vmax=len(activityinfo)) + norm = mpl.colors.Normalize(vmin=1, vmax=len(activityinfo)+1) from matplotlib.colors import ListedColormap import seaborn as sns cmap = ListedColormap(sns.hls_palette( From 45c1d561fb7f8328b6e56af7fe532cffde32cebb Mon Sep 17 00:00:00 2001 From: Qing Yu <53589767+ni1o1@users.noreply.github.com> Date: Mon, 31 Oct 2022 13:41:01 +0800 Subject: [PATCH 6/7] Update tests.yml --- .github/workflows/tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f093a1a..8699410 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,8 +10,6 @@ on: pull_request: branches: - '*' - schedule: - - cron: '59 23 * * *' workflow_dispatch: inputs: version: From 05555ed9897803e504403bd4c8ab93f1f5f3f41e Mon Sep 17 00:00:00 2001 From: ni1o1 <53589767+ni1o1@users.noreply.github.com> Date: Mon, 31 Oct 2022 13:46:14 +0800 Subject: [PATCH 7/7] ready to update 0.4.15 --- docs/source/conf.py | 4 ++-- setup.py | 2 +- src/transbigdata/__init__.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 36a3600..c104a91 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -25,8 +25,8 @@ author = 'Qing Yu' # The full version, including alpha/beta/rc tags -release = '0.4.14' -version = '0.4.14' +release = '0.4.15' +version = '0.4.15' html_logo = "_static/logo-wordmark-light.png" html_favicon = '_static/logo2.ico' # -- General configuration --------------------------------------------------- diff --git a/setup.py b/setup.py index 7148068..d0f25e3 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="transbigdata", - version="0.4.14", + version="0.4.15", author="Qing Yu", author_email="yuq@sustech.edu.cn", description="A Python package developed for transportation spatio-temporal big data processing and analysis.", diff --git a/src/transbigdata/__init__.py b/src/transbigdata/__init__.py index dae5238..8612373 100644 --- a/src/transbigdata/__init__.py +++ b/src/transbigdata/__init__.py @@ -33,7 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ -__version__ = '0.4.14' +__version__ = '0.4.15' __author__ = 'Qing Yu ' # module level doc-string