Skip to content

Commit c660e69

Browse files
authored
Merge pull request #42 from histogrammar/popmon_hgr_migration
Minor extra updates for popmon migration of histogrammar
2 parents daa5e3b + e29254a commit c660e69

File tree

6 files changed

+28
-19
lines changed

6 files changed

+28
-19
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Histograms and other aggregators may also be converted into CUDA code for inclus
1919
PyCUDA is available, they can also be filled from Numpy arrays by JIT-compiling the CUDA code.
2020
This Python implementation of histogrammar been tested to guarantee compatibility with its Scala implementation.
2121

22-
Latest Python release: v1.0.21 (Mar 2021).
22+
Latest Python release: v1.0.22 (Mar 2021).
2323

2424
Announcements
2525
=============

histogrammar/dfinterface/histogram_filler_base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ def __init__(
129129
# these get filled during execution
130130
self._hists = {}
131131

132+
def set_logger(self, logger):
133+
"""Set logger of module
134+
135+
:param logger: input logger
136+
"""
137+
self.logger = logger
138+
132139
def assert_dataframe(self, df):
133140
"""assert dataframe datatype"""
134141
raise NotImplementedError("assert_dataframe not implemented!")

histogrammar/dfinterface/make_histograms.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import copy
2222
import logging
23+
import warnings
2324

2425
import numpy as np
2526
import pandas as pd
@@ -159,16 +160,17 @@ def make_histograms(
159160
if not isinstance(bin_specs, (type(None), dict)):
160161
raise RuntimeError("bin_specs object is not a dictionary")
161162
bin_specs = copy.copy(bin_specs) if isinstance(bin_specs, dict) else {}
162-
if time_axis in bin_specs:
163-
raise RuntimeError(
164-
f'time-axis "{time_axis}" already found in binning specifications.'
163+
if time_axis not in bin_specs:
164+
# convert time width and offset to nanoseconds
165+
time_specs = {
166+
"binWidth": float(pd.Timedelta(time_width).value),
167+
"origin": float(pd.Timestamp(time_offset).value),
168+
}
169+
bin_specs[time_axis] = time_specs
170+
else:
171+
warnings.warn(
172+
f'time-axis "{time_axis}" already found in binning specifications. not overwriting.'
165173
)
166-
# convert time width and offset to nanoseconds
167-
time_specs = {
168-
"binWidth": float(pd.Timedelta(time_width).value),
169-
"origin": float(pd.Timestamp(time_offset).value),
170-
}
171-
bin_specs[time_axis] = time_specs
172174

173175
cls = PandasHistogrammar if isinstance(df, pd.DataFrame) else SparkHistogrammar
174176
hist_filler = cls(

histogrammar/version.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import re
44

55
name = "histogrammar"
6-
__version__ = "1.0.21"
7-
version = "1.0.21"
8-
full_version = "1.0.21"
6+
__version__ = "1.0.22"
7+
version = "1.0.22"
8+
full_version = "1.0.22"
99
release = True
1010

1111
version_info = tuple(re.split(r"[-\.]", __version__))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
MAJOR = 1
2424
REVISION = 0
25-
PATCH = 21
25+
PATCH = 22
2626
DEV = False
2727
# NOTE: also update version at: README.rst
2828

tests/test_pandas_histogrammar.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_make_histograms_no_time_axis():
9696
assert time_axis == ""
9797
assert "date" in hists
9898
h = hists["date"]
99-
assert h.binWidth == 751582381944448.0
99+
assert h.binWidth == 751582381944440.9
100100
for cols in features:
101101
cols = cols.split(":")
102102
assert len(cols) == 1
@@ -121,23 +121,23 @@ def test_make_histograms_with_time_axis():
121121
assert time_axis == "date"
122122
assert "date:age" in hists
123123
h = hists["date:age"]
124-
assert h.binWidth == 751582381944448.0
124+
assert h.binWidth == 751582381944440.9
125125
for cols in features:
126126
cols = cols.split(":")
127127
assert len(cols) == 2 and cols[0] == "date"
128128
for f, bs in bin_specs.items():
129129
assert len(bs) == 2
130130
assert "date:age" in bin_specs
131131
dateage = bin_specs["date:age"]
132-
assert dateage[0]["binWidth"] == 751582381944448.0
132+
assert dateage[0]["binWidth"] == 751582381944440.9
133133
assert dateage[1]["binWidth"] == 2.0
134134
assert dateage[1]["origin"] == 9.5
135135

136136
# test get_bin_specs 1
137137
bin_specs = get_bin_specs(hists)
138138
assert "date:age" in bin_specs
139139
dateage = bin_specs["date:age"]
140-
assert dateage[0]["binWidth"] == 751582381944448.0
140+
assert dateage[0]["binWidth"] == 751582381944440.9
141141
assert dateage[1]["binWidth"] == 2.0
142142
assert dateage[1]["origin"] == 9.5
143143

@@ -150,7 +150,7 @@ def test_make_histograms_with_time_axis():
150150

151151
# test get_bin_specs 3
152152
bin_specs = get_bin_specs(hists["date:age"])
153-
assert bin_specs[0]["binWidth"] == 751582381944448.0
153+
assert bin_specs[0]["binWidth"] == 751582381944440.9
154154
assert bin_specs[1]["binWidth"] == 2.0
155155
assert bin_specs[1]["origin"] == 9.5
156156

0 commit comments

Comments
 (0)