Repository: Qiskit/qiskit

Issue:
Division by Zero Error on Progress Bar
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**: 0.11.0
- **Python version**: 3.7.4 
- **Operating system**: MacOS Catalina

### What is the current behavior?
The problem doesn't seem to happen on github master, I couldn't recreate it. It is happening with code from Pypi:

Getting division by zero error on progress bar routine:

```
File "/Users/manoel/anaconda3/envs/QiskitenvProd/lib/python3.7/site-packages/qiskit/chemistry/core/hamiltonian.py", line 268, in run
    _add_aux_op(fer_op.total_particle_number())
  File "/Users/manoel/anaconda3/envs/QiskitenvProd/lib/python3.7/site-packages/qiskit/chemistry/core/hamiltonian.py", line 264, in _add_aux_op
    self._two_qubit_reduction))
  File "/Users/manoel/anaconda3/envs/QiskitenvProd/lib/python3.7/site-packages/qiskit/chemistry/core/hamiltonian.py", line 450, in _map_fermionic_operator_to_qubit
    qubit_op = fer_op.mapping(map_type=qubit_mapping, threshold=0.00000001)
  File "/Users/manoel/anaconda3/envs/QiskitenvProd/lib/python3.7/site-packages/qiskit/chemistry/fermionic_operator.py", line 385, in mapping
    task_args=(threshold,), num_processes=aqua_globals.num_processes)
  File "/Users/manoel/anaconda3/envs/QiskitenvProd/lib/python3.7/site-packages/qiskit/tools/parallel.py", line 134, in parallel_map
    raise error
  File "/Users/manoel/anaconda3/envs/QiskitenvProd/lib/python3.7/site-packages/qiskit/tools/parallel.py", line 125, in parallel_map
    Publisher().publish("terra.parallel.done", len(results))
  File "/Users/manoel/anaconda3/envs/QiskitenvProd/lib/python3.7/site-packages/qiskit/tools/events/pubsub.py", line 135, in publish
    return self._broker.dispatch(event, *args, **kwargs)
  File "/Users/manoel/anaconda3/envs/QiskitenvProd/lib/python3.7/site-packages/qiskit/tools/events/pubsub.py", line 97, in dispatch
    subscriber.callback(*args, **kwargs)
  File "/Users/manoel/anaconda3/envs/QiskitenvProd/lib/python3.7/site-packages/qiskit/tools/events/progressbar.py", line 138, in _update_progress_bar
    self.update(progress)
  File "/Users/manoel/anaconda3/envs/QiskitenvProd/lib/python3.7/site-packages/qiskit/tools/events/progressbar.py", line 158, in update
    filled_length = int(round(50 * n / self.iter))
ZeroDivisionError: division by zero
```

### Steps to reproduce the problem
Created the simple test case I could think of, enable logging:
```
import logging
from qiskit.chemistry.drivers import PySCFDriver
from qiskit.chemistry.core import Hamiltonian, QubitMappingType, TransformationType
from qiskit.chemistry import set_qiskit_chemistry_logging

set_qiskit_chemistry_logging(logging.DEBUG)

driver = PySCFDriver('H 0.0 0.0 0.0; H 0.0 0.0 0.735')
qmolecule = driver.run()
operator = Hamiltonian(qubit_mapping=QubitMappingType.PARITY,
                       transformation=TransformationType.PARTICLE_HOLE,
                       two_qubit_reduction=True,
                       freeze_core=True,
                       orbital_reduction=[])
operator.run(qmolecule)
```


### What is the expected behavior?
It should not throw an exception on the progressbar routine.


### Suggested solutions
I had a quick fix on progressbar.py update method which may not be optimal but fixed the problem (testing for n != 0):
```
def update(self, n):
        if n != 0:
            filled_length = int(round(50 * n / self.iter))
            pbar = '█' * filled_length + '-' * (50 - filled_length)
            time_left = self.time_remaining_est(n)
            self.output_handler.write('\r|%s| %s%s%s [%s]' % (pbar, n, '/', self.iter, time_left))
            if n == self.iter:
                self.output_handler.write('\n')
        self.output_handler.flush()
```




Discussion:
So I am not sure what is going on here.  `update` should be called once you have completed a task, and thus `self.iter` should be non-zero.
I ran into this with the latest release installed via `pip install qiskit` on macOS 10.15.2 (see version below). I could not replicate it using the above snippet, but I attached a program that does. In any case, the right thing to do here is protect against div-by-0 regardless, because nobody wants a progress bar exception to halt their quantum program, and if `self.iter` should indeed not be 0 at this point then that assertion needs to be made earlier.

I patched my version like this just to get beyond it:
```filled_length = int(round(50 * n / (self.iter if self.iter > 0 else 1)))```

```
{   'qiskit': '0.15.0',
    'qiskit-aer': '0.4.0',
    'qiskit-aqua': '0.6.4',
    'qiskit-ibmq-provider': '0.4.6',
    'qiskit-ignis': '0.2.0',
    'qiskit-terra': '0.12.0'}
```
[script_h2_cc-pvdz.py.txt](https://github.com/Qiskit/qiskit-terra/files/4208953/script_h2_cc-pvdz.py.txt)


I just did a little digging and the source of this issue is that aqua is calling `parallel_map` with an empty list of values to map. This isn't handled by parallel_map so it tries to launch 0 parallel tasks which confuses the `progress_bar` because it doesn't make any sense to have a bar without any tasks. While this is easy to fix by just adding a check in `parallel_map` for an empty list for values and returning an empty list, this does seem more like an aqua bug to me. Like, why is parallel map being called without any values?

Resolving patch:
diff --git a/qiskit/tools/parallel.py b/qiskit/tools/parallel.py
--- a/qiskit/tools/parallel.py
+++ b/qiskit/tools/parallel.py
@@ -102,6 +102,8 @@ def parallel_map(  # pylint: disable=dangerous-default-value
         terra.parallel.update: One of the parallel task has finished.
         terra.parallel.finish: All the parallel tasks have finished.
     """
+    if len(values) == 0:
+        return []
     if len(values) == 1:
         return [task(values[0], *task_args, **task_kwargs)]
 


Test patch: