diff --git a/README.rst b/README.rst index 8976d04..b43f7db 100644 --- a/README.rst +++ b/README.rst @@ -19,7 +19,7 @@ Histograms and other aggregators may also be converted into CUDA code for inclus PyCUDA is available, they can also be filled from Numpy arrays by JIT-compiling the CUDA code. This Python implementation of histogrammar been tested to guarantee compatibility with its Scala implementation. -Latest Python release: v1.0.21 (Mar 2021). +Latest Python release: v1.0.22 (Mar 2021). Announcements ============= diff --git a/histogrammar/dfinterface/histogram_filler_base.py b/histogrammar/dfinterface/histogram_filler_base.py index 048818a..1d18b19 100644 --- a/histogrammar/dfinterface/histogram_filler_base.py +++ b/histogrammar/dfinterface/histogram_filler_base.py @@ -129,6 +129,13 @@ def __init__( # these get filled during execution self._hists = {} + def set_logger(self, logger): + """Set logger of module + + :param logger: input logger + """ + self.logger = logger + def assert_dataframe(self, df): """assert dataframe datatype""" raise NotImplementedError("assert_dataframe not implemented!") diff --git a/histogrammar/dfinterface/make_histograms.py b/histogrammar/dfinterface/make_histograms.py index 4b7a73d..1eb06bc 100644 --- a/histogrammar/dfinterface/make_histograms.py +++ b/histogrammar/dfinterface/make_histograms.py @@ -20,6 +20,7 @@ import copy import logging +import warnings import numpy as np import pandas as pd @@ -159,16 +160,17 @@ def make_histograms( if not isinstance(bin_specs, (type(None), dict)): raise RuntimeError("bin_specs object is not a dictionary") bin_specs = copy.copy(bin_specs) if isinstance(bin_specs, dict) else {} - if time_axis in bin_specs: - raise RuntimeError( - f'time-axis "{time_axis}" already found in binning specifications.' + if time_axis not in bin_specs: + # convert time width and offset to nanoseconds + time_specs = { + "binWidth": float(pd.Timedelta(time_width).value), + "origin": float(pd.Timestamp(time_offset).value), + } + bin_specs[time_axis] = time_specs + else: + warnings.warn( + f'time-axis "{time_axis}" already found in binning specifications. not overwriting.' ) - # convert time width and offset to nanoseconds - time_specs = { - "binWidth": float(pd.Timedelta(time_width).value), - "origin": float(pd.Timestamp(time_offset).value), - } - bin_specs[time_axis] = time_specs cls = PandasHistogrammar if isinstance(df, pd.DataFrame) else SparkHistogrammar hist_filler = cls( diff --git a/histogrammar/version.py b/histogrammar/version.py index 69d82cc..894a8eb 100644 --- a/histogrammar/version.py +++ b/histogrammar/version.py @@ -3,9 +3,9 @@ import re name = "histogrammar" -__version__ = "1.0.21" -version = "1.0.21" -full_version = "1.0.21" +__version__ = "1.0.22" +version = "1.0.22" +full_version = "1.0.22" release = True version_info = tuple(re.split(r"[-\.]", __version__)) diff --git a/setup.py b/setup.py index a946a35..38aa263 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ MAJOR = 1 REVISION = 0 -PATCH = 21 +PATCH = 22 DEV = False # NOTE: also update version at: README.rst diff --git a/tests/test_pandas_histogrammar.py b/tests/test_pandas_histogrammar.py index 868fd6e..ae03c41 100644 --- a/tests/test_pandas_histogrammar.py +++ b/tests/test_pandas_histogrammar.py @@ -96,7 +96,7 @@ def test_make_histograms_no_time_axis(): assert time_axis == "" assert "date" in hists h = hists["date"] - assert h.binWidth == 751582381944448.0 + assert h.binWidth == 751582381944440.9 for cols in features: cols = cols.split(":") assert len(cols) == 1 @@ -121,7 +121,7 @@ def test_make_histograms_with_time_axis(): assert time_axis == "date" assert "date:age" in hists h = hists["date:age"] - assert h.binWidth == 751582381944448.0 + assert h.binWidth == 751582381944440.9 for cols in features: cols = cols.split(":") assert len(cols) == 2 and cols[0] == "date" @@ -129,7 +129,7 @@ def test_make_histograms_with_time_axis(): assert len(bs) == 2 assert "date:age" in bin_specs dateage = bin_specs["date:age"] - assert dateage[0]["binWidth"] == 751582381944448.0 + assert dateage[0]["binWidth"] == 751582381944440.9 assert dateage[1]["binWidth"] == 2.0 assert dateage[1]["origin"] == 9.5 @@ -137,7 +137,7 @@ def test_make_histograms_with_time_axis(): bin_specs = get_bin_specs(hists) assert "date:age" in bin_specs dateage = bin_specs["date:age"] - assert dateage[0]["binWidth"] == 751582381944448.0 + assert dateage[0]["binWidth"] == 751582381944440.9 assert dateage[1]["binWidth"] == 2.0 assert dateage[1]["origin"] == 9.5 @@ -150,7 +150,7 @@ def test_make_histograms_with_time_axis(): # test get_bin_specs 3 bin_specs = get_bin_specs(hists["date:age"]) - assert bin_specs[0]["binWidth"] == 751582381944448.0 + assert bin_specs[0]["binWidth"] == 751582381944440.9 assert bin_specs[1]["binWidth"] == 2.0 assert bin_specs[1]["origin"] == 9.5