Skip to content

Commit dbb1f3e

Browse files
authored
Merge pull request #36 from histogrammar/1.0.x
1.0.x
2 parents d397e73 + 2d38941 commit dbb1f3e

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ See [histogrammar.org](http://histogrammar.org) for a complete introduction to H
77

88
This is a pure Python implementation for Python versions 2.7, and 3.4, 3.5, 3.6, 3.7
99

10-
Latest Python release: v1.0.10 (Sep 2019).
10+
Latest Python release: v1.0.11 (Nov 2019).
1111

1212
Support of Histogrammar is provided on a best-effort basis only.
1313

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
# built documents.
4848
#
4949
# The short X.Y version.
50-
version = "1.0.10"
50+
version = "1.0.11"
5151
# The full version, including alpha/beta/rc tags.
52-
release = "1.0.10"
52+
release = "1.0.11"
5353

5454
# The language for content autogenerated by Sphinx. Refer to documentation
5555
# for a list of supported languages.

histogrammar/primitives/categorize.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def __init__(self, quantity, value=Count()):
8181
self.bins = {}
8282
if value is not None:
8383
self.contentType = value.name
84+
else:
85+
self.contentType = "Count"
8486
super(Categorize, self).__init__()
8587
self.specialize()
8688

@@ -286,11 +288,18 @@ def toJsonFragment(self, suppressName):
286288
else:
287289
binsName = None
288290

291+
if len(self.bins) > 0:
292+
bins_type = list(self.bins.values())[0].name
293+
elif self.value is not None:
294+
bins_type = self.value.name
295+
else:
296+
bins_type = self.contentType
297+
289298
return maybeAdd({
290299
# for json serialization all keys need to be strings, else json libs throws TypeError
291300
# e.g. boolean keys get converted to strings here
292301
"entries": floatToJson(self.entries),
293-
"bins:type": self.value.name if self.value is not None else self.contentType,
302+
"bins:type": bins_type,
294303
"bins": dict((str(k), v.toJsonFragment(True)) for k, v in self.bins.items()),
295304
}, **{"name": None if suppressName else self.quantity.name,
296305
"bins:name": binsName})

histogrammar/primitives/sparselybin.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ def __init__(self, binWidth, quantity, value=Count(), nanflow=Count(), origin=0.
106106
self.value = value
107107
if value is not None:
108108
self.contentType = value.name
109+
else:
110+
self.contentType = "Count"
109111
self.bins = {}
110112
self.nanflow = nanflow.copy()
111113
self.origin = origin
@@ -424,10 +426,17 @@ def toJsonFragment(self, suppressName):
424426
else:
425427
binsName = None
426428

429+
if len(self.bins) > 0:
430+
bins_type = list(self.bins.values())[0].name
431+
elif self.value is not None:
432+
bins_type = self.value.name
433+
else:
434+
bins_type = self.contentType
435+
427436
return maybeAdd({
428437
"binWidth": floatToJson(self.binWidth),
429438
"entries": floatToJson(self.entries),
430-
"bins:type": self.value.name if self.value is not None else self.contentType,
439+
"bins:type": bins_type,
431440
"bins": dict((str(i), v.toJsonFragment(True)) for i, v in self.bins.items()),
432441
"nanflow:type": self.nanflow.name,
433442
"nanflow": self.nanflow.toJsonFragment(False),

0 commit comments

Comments
 (0)