Skip to content

Commit

Permalink
Adjust width better.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhsamuel committed Jan 30, 2018
1 parent 891b8ad commit c86d6cb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion python/fixfmt/PyTickTime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Type PyTickTime::type_ = PyTypeObject{
(PySequenceMethods*) nullptr, // tp_as_sequence
(PyMappingMethods*) nullptr, // tp_as_mapping
(hashfunc) nullptr, // tp_hash
(ternaryfunc) tp_call, // tp_call
(ternaryfunc) wrap<PyTickTime, tp_call>, // tp_call
(reprfunc) nullptr, // tp_str
(getattrofunc) nullptr, // tp_getattro
(setattrofunc) nullptr, // tp_setattro
Expand Down
6 changes: 5 additions & 1 deletion python/fixfmt/npfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#-------------------------------------------------------------------------------

DEFAULT_CFG = {
"min_width" : 0,
"bool": {
"min_width" : 0,
"true" : "true",
Expand Down Expand Up @@ -175,11 +176,12 @@ def choose_formatter_datetime64(values, min_width=0, cfg=DEFAULT_CFG["time"]):
else:
precision = min_prec

precision = -1 if precision < 1 else precision
return TickTime(10 ** scale, precision)


def choose_formatter_str(arr, min_width=0, cfg=DEFAULT_CFG["string"]):
min_width = max(min_width, cfg["min_width"])
min_width = max(min_width, cfg["min_width"])

size = cfg["size"]
if size is None:
Expand All @@ -199,6 +201,8 @@ def choose_formatter_str(arr, min_width=0, cfg=DEFAULT_CFG["string"]):


def choose_formatter(arr, min_width=0, cfg=DEFAULT_CFG):
min_width = max(min_width, cfg["min_width"])

dtype = arr.dtype
if dtype.kind == "b":
return choose_formatter_bool(arr, min_width, cfg=cfg["bool"])
Expand Down
2 changes: 1 addition & 1 deletion python/fixfmt/test/test_choose_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_non_contiguous():

fmt = choose_formatter(arr.time)
assert isinstance(fmt, fixfmt.TickTime)
assert fmt.precision == 0
assert fmt.precision == -1

fmt = choose_formatter(arr.fast)
assert isinstance(fmt, fixfmt.TickTime)
Expand Down

0 comments on commit c86d6cb

Please sign in to comment.