Skip to content

Commit

Permalink
Merge pull request #32 from FAST-HEP/BK_postproc-fix_split_number_dims
Browse files Browse the repository at this point in the history
Fix split function to work with numeric columns as well
  • Loading branch information
benkrikler authored Apr 21, 2020
2 parents d8dcb17 + dd616ca commit a641a67
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.2] - 2020-04-21
### Fixed
- Fix `split` function in postproc module to work with numbers, PR #32 [@benkrikler](github.com/benkrikler)

## [0.6.1] - 2020-04-20
### Added
- Option to specify which columns contain bin values rather than labels, PR #31 [@benkrikler](github.com/benkrikler)
Expand Down
2 changes: 1 addition & 1 deletion fast_plotter/postproc/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def to_tuple(obj):
result = group.copy()
if return_meta:
meta = dict(zip(axis, split_val))
split_name = "--".join(map("_".join, meta.items()))
split_name = "--".join(["{}_{}".format(*i) for i in meta.items()])
meta["split_name"] = split_name
result = (result, meta)
out_dfs.append(result)
Expand Down
2 changes: 1 addition & 1 deletion fast_plotter/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ def split_version(version):
return tuple(result)


__version__ = '0.6.1'
__version__ = '0.6.2'
version_info = split_version(__version__) # noqa
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.6.1
current_version = 0.6.2
commit = True
tag = False

Expand Down
12 changes: 9 additions & 3 deletions tests/postproc/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,15 @@ def test_rename_dim(binned_df):
assert result.index.names == ["integers", "CATEGORICALS", "interval"]


# def test_split():
# #def split(df, axis, keep_split_dim, return_meta=True):
# pass
def test_split(binned_df):
results = funcs.split(binned_df, "cat", keep_split_dim=True)
assert len(results) == 2
assert all([r[0].index.nlevels == 3 for r in results])

results = funcs.split(binned_df, "int", keep_split_dim=True)
assert len(results) == 4
assert all([r[0].index.nlevels == 3 for r in results])


# def test_reorder_dimensions():
# #def reorder_dimensions(df, order):
Expand Down

0 comments on commit a641a67

Please sign in to comment.