diff --git a/corebridge/__init__.py b/corebridge/__init__.py index 6232f7a..11ef092 100644 --- a/corebridge/__init__.py +++ b/corebridge/__init__.py @@ -1 +1 @@ -__version__ = "0.2.10" +__version__ = "0.2.13" diff --git a/corebridge/aicorebridge.py b/corebridge/aicorebridge.py index 8ffe37b..316970d 100644 --- a/corebridge/aicorebridge.py +++ b/corebridge/aicorebridge.py @@ -133,11 +133,11 @@ def get_callargs(self:AICoreModule, **kwargs): return { K:self.processor_signature.parameters[K].annotation( - kwargs.get( + self.init_kwargs.get( K, - metadata.get( - K, - self.init_kwargs.get( + kwargs.get( + K, + metadata.get( K, self.processor_signature.parameters[K].default ) diff --git a/corebridge/core.py b/corebridge/core.py index 83b0afe..8fdf481 100644 --- a/corebridge/core.py +++ b/corebridge/core.py @@ -16,11 +16,11 @@ except: pass -# %% ../nbs/00_core.ipynb 6 +# %% ../nbs/00_core.ipynb 7 def set_time_index_zone(df:pd.DataFrame, timezone): if isinstance(df.index, pd.DatetimeIndex): df.index.name = 'time' - if not hasattr(df.index, 'tz'): + if not hasattr(df.index, 'tz') or not df.index.tz or not df.index.tz: df.index = df.index.tz_localize('UTC').tz_convert(timezone) elif str(df.index.tz) != timezone: df.index = df.index.tz_convert(timezone) @@ -28,13 +28,13 @@ def set_time_index_zone(df:pd.DataFrame, timezone): return df -# %% ../nbs/00_core.ipynb 7 +# %% ../nbs/00_core.ipynb 9 def timeseries_dataframe( data:typing.Union[pd.DataFrame, pd.Series, dict, np.ndarray, np.recarray], timezone='UTC', columnnames=None): - """Convert various data formats to timeseries DataFrame""" + """Convert various tabular data formats to timeseries DataFrame""" if isinstance(data, pd.DataFrame): df = data @@ -76,7 +76,7 @@ def timeseries_dataframe( return set_time_index_zone(df, timezone) -# %% ../nbs/00_core.ipynb 8 +# %% ../nbs/00_core.ipynb 11 def timeseries_dataframe_from_datadict( data:dict, timecolumns, @@ -107,7 +107,7 @@ def timeseries_dataframe_from_datadict( return df -# %% ../nbs/00_core.ipynb 9 +# %% ../nbs/00_core.ipynb 15 def timeseries_dataframe_to_datadict( data:typing.Union[pd.DataFrame, pd.Series, dict], recordformat:str='split', diff --git a/nbs/00_core.ipynb b/nbs/00_core.ipynb index 81fbc6c..866733c 100644 --- a/nbs/00_core.ipynb +++ b/nbs/00_core.ipynb @@ -85,7 +85,7 @@ "def set_time_index_zone(df:pd.DataFrame, timezone):\n", " if isinstance(df.index, pd.DatetimeIndex):\n", " df.index.name = 'time'\n", - " if not hasattr(df.index, 'tz'):\n", + " if not hasattr(df.index, 'tz') or not df.index.tz or not df.index.tz:\n", " df.index = df.index.tz_localize('UTC').tz_convert(timezone)\n", " elif str(df.index.tz) != timezone:\n", " df.index = df.index.tz_convert(timezone)\n", @@ -160,6 +160,13 @@ " return set_time_index_zone(df, timezone)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, @@ -197,6 +204,173 @@ " return df\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
value
time
2023-05-04 10:04:49+00:0016.72
2023-05-04 10:24:51+00:0016.65
2023-05-04 10:44:53+00:0016.55
\n", + "
" + ], + "text/plain": [ + " value\n", + "time \n", + "2023-05-04 10:04:49+00:00 16.72\n", + "2023-05-04 10:24:51+00:00 16.65\n", + "2023-05-04 10:44:53+00:00 16.55" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "timeseries_dataframe_from_datadict([\n", + " {\n", + " \"time\":\"2023-05-04T10:04:49.000Z\",\n", + " \"value\":16.72\n", + " },\n", + " {\n", + " \"time\":\"2023-05-04T10:24:51.000Z\",\n", + " \"value\":16.65\n", + " },\n", + " {\n", + " \"time\":\"2023-05-04T10:44:53.000Z\",\n", + " \"value\":16.55\n", + " }\n", + " ], timecolumns=['time'])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
value
time
2023-05-04 12:04:49+02:0016.72
2023-05-04 12:24:51+02:0016.65
2023-05-04 12:44:53+02:0016.55
\n", + "
" + ], + "text/plain": [ + " value\n", + "time \n", + "2023-05-04 12:04:49+02:00 16.72\n", + "2023-05-04 12:24:51+02:00 16.65\n", + "2023-05-04 12:44:53+02:00 16.55" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "set_time_index_zone( timeseries_dataframe_from_datadict([\n", + " {\n", + " \"time\":\"2023-05-04T10:04:49\",\n", + " \"value\":16.72\n", + " },\n", + " {\n", + " \"time\":\"2023-05-04T10:24:51\",\n", + " \"value\":16.65\n", + " },\n", + " {\n", + " \"time\":\"2023-05-04T10:44:53\",\n", + " \"value\":16.55\n", + " }\n", + " ], timecolumns=['time']), timezone='Europe/Amsterdam')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, diff --git a/nbs/01_aicorebridge.ipynb b/nbs/01_aicorebridge.ipynb index 4de829d..1208ce0 100644 --- a/nbs/01_aicorebridge.ipynb +++ b/nbs/01_aicorebridge.ipynb @@ -255,6 +255,7 @@ " return {\n", " K:self.processor_signature.parameters[K].annotation(\n", " self.init_kwargs.get(\n", + " K,\n", " kwargs.get(\n", " K,\n", " metadata.get(\n", diff --git a/settings.ini b/settings.ini index 3af196e..2683f38 100644 --- a/settings.ini +++ b/settings.ini @@ -5,7 +5,7 @@ ### Python library ### repo = corebridge lib_name = %(repo)s -version = 0.2.10 +version = 0.2.13 min_python = 3.7 license = apache2 black_formatting = False