From 2dff0fca68d1f7f105afb89ea02fca0605336d43 Mon Sep 17 00:00:00 2001 From: Ben Krikler Date: Thu, 16 Apr 2020 01:16:12 +0200 Subject: [PATCH 1/7] Add option to control the column names used for values when opening files --- fast_plotter/postproc/__main__.py | 5 ++++- fast_plotter/postproc/functions.py | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fast_plotter/postproc/__main__.py b/fast_plotter/postproc/__main__.py index 41b0123..06a0f9a 100644 --- a/fast_plotter/postproc/__main__.py +++ b/fast_plotter/postproc/__main__.py @@ -19,6 +19,9 @@ def make_parser(): help="A yaml to configure the post-processing step") parser.add_argument("-o", "--outdir", default=".", help="The name of the output directory") + parser.add_argument("-V", "--value-cols", default=r"(.*sumw2?|n)", + help="A regular expression to control which columns are" \ + " identified as values and not bin labels") parser.add_argument("files", nargs="+", help="Input dataframes that need merging together") return parser @@ -50,7 +53,7 @@ def main(args=None): if args.debug_dfs: logger.setLevel(logging.DEBUG) - dfs = open_many(args.files) + dfs = open_many(args.files, value_columns=args.value_cols) sequence = read_processing_cfg(args.post_process, args.outdir) for stage in sequence: diff --git a/fast_plotter/postproc/functions.py b/fast_plotter/postproc/functions.py index 5592739..2d9fc4c 100644 --- a/fast_plotter/postproc/functions.py +++ b/fast_plotter/postproc/functions.py @@ -1,5 +1,6 @@ import os import six +import re import numpy as np import pandas as pd import logging @@ -365,7 +366,7 @@ def normalise_group(df, groupby_dimensions, apply_if=None, use_column=None): return normed -def open_many(file_list, return_meta=True): +def open_many(file_list, value_columns=r"(.*sumw2?|n)", return_meta=True): """ Open a list of dataframe files """ dfs = [] @@ -373,7 +374,7 @@ def open_many(file_list, return_meta=True): df = pd.read_csv(fname, comment='#') drop_cols = [col for col in df.columns if "Unnamed" in col] df.drop(drop_cols, inplace=True, axis="columns") - index_cols = [col for col in df.columns if "sumw" not in col and col != "n"] + index_cols = [col for col in df.columns if not re.match(value_columns, col)] df.set_index(index_cols, inplace=True, drop=True) if return_meta: name = fname From d7759958bce27004b0e6464745ff49bfac837721 Mon Sep 17 00:00:00 2001 From: Ben Krikler Date: Mon, 20 Apr 2020 09:15:06 +0200 Subject: [PATCH 2/7] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ed6d6c..20524d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.5.2] - 2020-04-20 +### Added +- Option to specify which columns contain bin values rather than labels, PR #31 [@benkrikler](github.com/benkrikler) + ## [0.5.1] - 2020-04-7 ### Fixed - Bugs in post-processing modules, PR #29 [@benkrikler](github.com/benkrikler) From 2fb2187c0b2d9207acdee5a481330fa5f9cf7124 Mon Sep 17 00:00:00 2001 From: Ben Krikler Date: Mon, 20 Apr 2020 09:16:13 +0200 Subject: [PATCH 3/7] Remove line slash --- fast_plotter/postproc/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fast_plotter/postproc/__main__.py b/fast_plotter/postproc/__main__.py index 06a0f9a..ad96d18 100644 --- a/fast_plotter/postproc/__main__.py +++ b/fast_plotter/postproc/__main__.py @@ -20,7 +20,7 @@ def make_parser(): parser.add_argument("-o", "--outdir", default=".", help="The name of the output directory") parser.add_argument("-V", "--value-cols", default=r"(.*sumw2?|n)", - help="A regular expression to control which columns are" \ + help="A regular expression to control which columns are" " identified as values and not bin labels") parser.add_argument("files", nargs="+", help="Input dataframes that need merging together") From 7436092b7966d819a99af715a39c717f95eda046 Mon Sep 17 00:00:00 2001 From: Ben Krikler Date: Mon, 20 Apr 2020 09:16:30 +0200 Subject: [PATCH 4/7] =?UTF-8?q?Bump=20version:=200.5.1=20=E2=86=92=200.5.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fast_plotter/version.py | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fast_plotter/version.py b/fast_plotter/version.py index cd7cc73..a48875b 100644 --- a/fast_plotter/version.py +++ b/fast_plotter/version.py @@ -12,5 +12,5 @@ def split_version(version): return tuple(result) -__version__ = '0.5.1' +__version__ = '0.5.2' version_info = split_version(__version__) # noqa diff --git a/setup.cfg b/setup.cfg index 644ec11..a3662e2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.5.1 +current_version = 0.5.2 commit = True tag = False From 70bd178fb9153ca60319471b9f2755640e22286e Mon Sep 17 00:00:00 2001 From: Ben Krikler Date: Mon, 20 Apr 2020 09:21:03 +0200 Subject: [PATCH 5/7] Fix package version number reporting --- CHANGELOG.md | 3 +++ fast_plotter/__init__.py | 5 ++++- fast_plotter/__main__.py | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20524d0..90b9fa5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Option to specify which columns contain bin values rather than labels, PR #31 [@benkrikler](github.com/benkrikler) +### Fixed +- Report package version number properly, PR #31 + ## [0.5.1] - 2020-04-7 ### Fixed - Bugs in post-processing modules, PR #29 [@benkrikler](github.com/benkrikler) diff --git a/fast_plotter/__init__.py b/fast_plotter/__init__.py index 0f8b330..2b084e3 100644 --- a/fast_plotter/__init__.py +++ b/fast_plotter/__init__.py @@ -1,5 +1,8 @@ # -*- coding: utf-8 -*- +from .version import __version__, version_info + + +__all__ = ["__version__", "version_info"] __author__ = """Ben Krikler""" __email__ = 'fast-hep@cern.ch' -__version__ = '0.3.0' diff --git a/fast_plotter/__main__.py b/fast_plotter/__main__.py index c0e173a..e9503de 100644 --- a/fast_plotter/__main__.py +++ b/fast_plotter/__main__.py @@ -9,6 +9,7 @@ from .utils import read_binned_df, weighting_vars # noqa from .utils import decipher_filename, mask_rows # noqa from .plotting import plot_all, add_annotations # noqa +from .version import __version__ logger = logging.getLogger("fast_plotter") @@ -42,6 +43,7 @@ def arg_parser(args=None): help="Scale the MC yields by this lumi") parser.add_argument("-y", "--yscale", default="log", choices=["log", "linear"], help="Use this scale for the y-axis") + parser.add_argument('--version', action='version', version='%(prog)s ' + __version__) def split_equals(arg): return arg.split("=") From 9fc11b124cc5f59b49a82216a3e8e7403bdfea3b Mon Sep 17 00:00:00 2001 From: Ben Krikler Date: Mon, 20 Apr 2020 09:22:55 +0200 Subject: [PATCH 6/7] =?UTF-8?q?Bump=20version:=200.6.0=20=E2=86=92=200.6.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fast_plotter/version.py | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fast_plotter/version.py b/fast_plotter/version.py index 06ce1a9..6ab19f1 100644 --- a/fast_plotter/version.py +++ b/fast_plotter/version.py @@ -12,5 +12,5 @@ def split_version(version): return tuple(result) -__version__ = '0.6.0' +__version__ = '0.6.1' version_info = split_version(__version__) # noqa diff --git a/setup.cfg b/setup.cfg index c0b1009..043a87b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.6.0 +current_version = 0.6.1 commit = True tag = False From c1663d3a69e6290aae076ea11f2a3180f36179c0 Mon Sep 17 00:00:00 2001 From: Ben Krikler Date: Mon, 20 Apr 2020 09:24:51 +0200 Subject: [PATCH 7/7] Fix import of version number --- fast_plotter/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fast_plotter/__main__.py b/fast_plotter/__main__.py index e9503de..8bfe4c1 100644 --- a/fast_plotter/__main__.py +++ b/fast_plotter/__main__.py @@ -6,10 +6,10 @@ import logging import matplotlib matplotlib.use('Agg') +from .version import __version__ # noqa from .utils import read_binned_df, weighting_vars # noqa from .utils import decipher_filename, mask_rows # noqa from .plotting import plot_all, add_annotations # noqa -from .version import __version__ logger = logging.getLogger("fast_plotter")