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
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=============
Expand Down
7 changes: 7 additions & 0 deletions histogrammar/dfinterface/histogram_filler_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down
20 changes: 11 additions & 9 deletions histogrammar/dfinterface/make_histograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import copy
import logging
import warnings

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions histogrammar/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

MAJOR = 1
REVISION = 0
PATCH = 21
PATCH = 22
DEV = False
# NOTE: also update version at: README.rst

Expand Down
10 changes: 5 additions & 5 deletions tests/test_pandas_histogrammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -121,23 +121,23 @@ 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"
for f, bs in bin_specs.items():
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

# test get_bin_specs 1
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

Expand All @@ -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

Expand Down