diff --git a/CHANGELOG.md b/CHANGELOG.md index b5cee53..7f3d403 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ 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.1] - 2020-04-20 +### 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.6.0] - 2020-04-17 ### Added - Proper support for non-constant interval widths 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..8bfe4c1 100644 --- a/fast_plotter/__main__.py +++ b/fast_plotter/__main__.py @@ -6,6 +6,7 @@ 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 @@ -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("=") diff --git a/fast_plotter/postproc/__main__.py b/fast_plotter/postproc/__main__.py index 41b0123..ad96d18 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 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