# Uncertainties should not all be zero error

**URL:** <https://hepdata-forum.cern.ch/t/uncertainties-should-not-all-be-zero-error/22>\
**Category:** Submission\
**Created:** [15 April 2021 09:40 UTC](https://hepdata-forum.cern.ch/t/uncertainties-should-not-all-be-zero-error/22 "2021-04-15T09:40:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vveckaln](https://hepdata-forum.cern.ch/letter_avatar_proxy/v4/letter/v/ecccb3/32.png) [@vveckaln](https://hepdata-forum.cern.ch/u/vveckaln)\
**Post date:** [15 April 2021 09:40 UTC](https://hepdata-forum.cern.ch/t/uncertainties-should-not-all-be-zero-error/22/1 "2021-04-15T09:40:27Z")

</div>

I have a yaml file:

```
dependent_variables:
- header:
    name: N
  values:
    - errors:
    - label: Total
      symerror: 0.00
    value: 0.0
  - errors:
    - label: Total
      symerror: 0.012174
    value: 24.978
  - errors:
    - label: Total
      symerror: 0.00
    value: 0.0
 independent_variables:
- header:
    name: n
    units: n
  values:
  - high: 1.5
    low: 0.5
  - high: 2.5
    low: 1.5
  - high: 3.5
    low: 2.5

```

It is obvious that where the binconent is 0.0 the error is 0.0. However the yaml validation produces an error `b"Uncertainties should not all be zero in {'errors': [{'label': 'Total', 'symerror': 0.0}], 'value': 0.0}"`

In order to escape this problem I twitch the yaml file

```
  dependent_variables:
    - header:
        name: N
      values:
        - errors:
        - label: Total
          symerror: 0.01
        value: 0.0
      - errors:
        - label: Total
          symerror: 0.012174
        value: 24.978
      - errors:
        - label: Total
          symerror: 0.01
        value: 0.0
     independent_variables:
    - header:
        name: n
        units: n
      values:
      - high: 1.5
        low: 0.5
      - high: 2.5
        low: 1.5
      - high: 3.5
        low: 2.5

```

Does not seem right

---

<div class="post-metadata">

**Author:** ![GraemeWatt](https://hepdata-forum.cern.ch/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@GraemeWatt](https://hepdata-forum.cern.ch/u/GraemeWatt)\
**Post date:** [16 April 2021 10:06 UTC](https://hepdata-forum.cern.ch/t/uncertainties-should-not-all-be-zero-error/22/2 "2021-04-16T10:06:32Z")

</div>

Thanks for the question. If the bin content is zero, you can miss out the `errors` completely, i.e.

```auto
dependent_variables:
- header:
    name: N
  values:
  - value: 0.0
  - errors:
    - label: Total
      symerror: 0.012174
    value: 24.978
  - value: 0.0

```

I’ll add an explanation to the [submission docs](https://hepdata-submission.readthedocs.io/en/latest/data_yaml.html#uncertainties).

---

<div class="post-metadata">

**Author:** ![vveckaln](https://hepdata-forum.cern.ch/letter_avatar_proxy/v4/letter/v/ecccb3/32.png) [@vveckaln](https://hepdata-forum.cern.ch/u/vveckaln)\
**Post date:** [16 April 2021 17:01 UTC](https://hepdata-forum.cern.ch/t/uncertainties-should-not-all-be-zero-error/22/3 "2021-04-16T17:01:33Z")

</div>

How can I achieve this effect programmatically in hepdata\_lib?  
What I need to change in

```
data.add_uncertainty(unc)
table.add_variable(data)
submission.add_table(table)
```

---

<div class="post-metadata">

**Author:** ![GraemeWatt](https://hepdata-forum.cern.ch/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@GraemeWatt](https://hepdata-forum.cern.ch/u/GraemeWatt)\
**Post date:** [19 April 2021 16:57 UTC](https://hepdata-forum.cern.ch/t/uncertainties-should-not-all-be-zero-error/22/4 "2021-04-19T16:57:00Z")

</div>

I’ve added a new second paragraph to the [Uncertainties](https://hepdata-submission.readthedocs.io/en/latest/data_yaml.html#uncertainties) section of the submission documentation. I don’t think it’s currently possible to omit the `errors` using [hepdata\_lib](https://github.com/HEPData/hepdata_lib). I’ve opened a [GitHub issue](https://github.com/HEPData/hepdata_lib/issues/159), but for now you might need to post-process the YAML files produced by `hepdata_lib` to remove the `errors`.

Alternatively, if the bin content is zero for the 0.5-1.5 and 2.5-3.5 bins of your example, couldn’t you just remove these rows completely from the HEPData table, i.e. only give results for the bin 1.5-2.5 with non-zero content?

---

<div class="post-metadata">

**Author:** ![GraemeWatt](https://hepdata-forum.cern.ch/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@GraemeWatt](https://hepdata-forum.cern.ch/u/GraemeWatt)\
**Post date:** [3 June 2021 14:46 UTC](https://hepdata-forum.cern.ch/t/uncertainties-should-not-all-be-zero-error/22/5 "2021-06-03T14:46:27Z")

</div>

The latest [hepdata-lib v0.5.0](https://pypi.org/project/hepdata-lib/0.5.0/) now automatically suppresses the `errors` key (with a warning message) if all uncertainties are zero for a particular bin.

---

<div class="post-metadata">

**Author:** ![GraemeWatt](https://hepdata-forum.cern.ch/letter_avatar_proxy/v4/letter/g/6f9a4e/32.png) [@GraemeWatt](https://hepdata-forum.cern.ch/u/GraemeWatt)\
**Post date:** [19 November 2021 18:45 UTC](https://hepdata-forum.cern.ch/t/uncertainties-should-not-all-be-zero-error/22/6 "2021-11-19T18:45:26Z")

</div>

Closed on 19 November 2021 18:45 UTC


