semvec/pypi-packages huggingface dataset:
pyhf-combine-converter 0.0.5
A package to translate between pyhf and Combine models
Requires Python: >=3.7

# pyhf to Combine converter

Tool to convert models from pyhf to CMS Combine and vise versa

[![DOI](https://zenodo.org/badge/492820903.svg)](https://zenodo.org/badge/latestdoi/492820903)

[![PyPI version](https://badge.fury.io/py/pyhf-combine-converter.svg)](https://badge.fury.io/py/pyhf-combine-converter)

This tool has been fully verified to produce the same model structure and expected yields, as well as to produce fits that are within 1% of the central value of each other. This has been done through the comparison of NLL plots, pull plots, and raw difference calculations.

## Environment for Combine

In order to use the package, one must first create a docker container that is capable of running Combine. To do so, enter the following commands once you have Docker installed.

```
docker pull pyhf/pyhf-combine-converter:cmssw-11.2.0-python3
docker run --rm -ti -P --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined -e CVMFS_MOUNTS="cms.cern.ch oasis.opensciencegrid.org" pyhf/pyhf-combine-converter:cmssw-11.2.0-python3
```

If the docker container is running, but the Combine commands are not being mounted correctly, run the following commands within the container:

```
source /cvmfs/cms.cern.ch/cmsset_default.sh
cmsenv
```

## Install

`pyhf-combine-converter` can be installed from PyPI. Inside of the Python environment containing Combine run

```
python3 -m pip install pyhf-combine-converter
```

## Use

`pyhf-combine-converter` provides a CLI API for bidirectional conversion between pyhf and Combine.

### Convert from pyhf to Combine

```
pyhf-to-combine $JSON_FILE_NAME --shape-file $SHAPES_FILE_NAME --out-datacard $DATACARD_FILE_NAME
```

### Convert from Combine to pyhf

```
combine-to-pyhf $DATACARD_FILE_NAME --out-file $JSON_FILE_NAME
```

Any questions or issues should be referred to the docs/ folder, in which the translation is put into more detail.

## Acknowledgements

This work was done as part of [Peter Ridolfi's IRIS-HEP Fellow project](https://iris-hep.org/fellows/peterridolfi.html) which was supported by NSF
cooperative agreement [OAC-1836650][NSF-award-1836650].
[![NSF Award Number](https://img.shields.io/badge/NSF-1836650-blue.svg)][NSF-award-1836650]

[NSF-award-1836650]: https://nsf.gov/awardsearch/showAward?AWD_ID=1836650
date_to 1.2.1
One friendly python function for parsing and converting to and between datetime.datetime, int, and string objects
Requires Python: >=3.10

# date_to - The easy date converter

![PyPI - Python Version](https://img.shields.io/pypi/pyversions/date_to?style=for-the-badge)
![GitHub](https://img.shields.io/github/license/ahaaster/date-to?style=for-the-badge)
![PyPI](https://img.shields.io/pypi/v/date-to?style=for-the-badge)

![Tests](https://github.com/ahaaster/date-to/actions/workflows/tests.yml/badge.svg)
![GitHub Pipenv locked dependency version](https://img.shields.io/github/pipenv/locked/dependency-version/ahaaster/date-to/dateparser)

## Convert any date to another with just one friendly function

```date_to()``` will convert your dates between datetime objects, unix timestamps, and strings. No more boilerplate and headaches of trying to keep track of your dates and their (lack) of timezones.

```date_to()``` utilises the dateparser library for string parsing, enabling [many kinds of string representations](https://dateparser.readthedocs.io/en/latest/index.html#features) of time to be converted into machine interpretable dates.
All output dates are rounded to second precision.

Default timezone conversion is to UTC. If you wish to convert your date to another timezone, simply provide the abbreviation of your desired timezone for the optional ```timezone=``` keyword argument.

## Installation

The ```date_to``` library is available on [PyPi](https://pypi.org/project/date_to/) and easily installed using pip:

```bash
pip install date_to
```

## Basic Use

```python
from date_to import date_to

some_date = "2001-09-11 17:20 EDT"

a = date_to(some_date)
b = date_to(some_date, "date")
c = date_to(some_date, str, timezone="JST")
d = date_to(some_date, to_type=int)

print(a, type(a))
print(b, type(b))
print(c, type(c))
print(d, type(d))
```

**Output:**

```text
2001-09-11 21:20:00+00:00 <class 'datetime.datetime'>
2001-09-11 21:20:00+00:00 <class 'datetime.datetime'>
2001-09-12T06:20:00+09:00 <class 'str'>
1000243200 <class 'int'>
```

### Accepted ```to_type``` Inputs

```python
import datetime as dt

accepted_object_inputs = str | int | float | dt.datetime | dt.date
accepted_string_inputs = {
    "str": ["str", "string", "text", ],
    "int": ["int", "timestamp", "epoch", "unix", "float", ],
    "date": ["datetime.datetime", "datetime", "date", "dt", "dt.datetime", "dt.date", ],
}
```

#### Parse Settings

If you wish to change the string parse conversion behaviour you can add a ```dict``` of keyword arguments to the function's ```parser_settings=``` optional keyword argument. Please refer to the [dateparser documentation](https://dateparser.readthedocs.io/en/latest/dateparser.html#dateparser.parse) for possible settings.

```python
DEFAULT_SETTINGS = {
    "TIMEZONE": "UTC",
    "PREFER_DAY_OF_MONTH": "first",
    "RETURN_AS_TIMEZONE_AWARE": True,
}
```