Skip to content

Moving to a python3-compatible code

Nicolas Mounet requested to merge python3_compatibility into master

Ensuring python3-compatible code, while keeping python2 compatibility. The code was tested with both python 2.7 and 3.9 (including on HTCondor).

In particular:

  • calls to print modified (parentheses added, removing print >> for prints to file),
  • time.clock() -> time.time()
  • np.int(...) -> int(...)
  • // instead of / for integer division,
  • removing split and replace functions from string module (using corresponding methods from str objects instead),
  • list added whenever needed (with e.g. range, items(), map),
  • all semi-colons ; removed,
  • using npz format for saving pickles and numpy arrays, and various options changed there,
  • handling of HTCondor batch job modified, and DELPHI_script.py as well.

There were also a few additional changes:

  • a test script for noise (eta) calculation was added (with comparison with an approximated approach) in DELPHI_Python/test_scripts/test_noise.py . This replaces the one that was directly in DELPHI_Python/Noise.py, now removed (to avoid useless matplotlib imports when launching DELPHI calculations),
  • an old test script with various outdated tunespread claculations was removed in DELPHI_Python/test_scripts/,
  • the README.txt in DELPHI_Python/test_scripts/ has been changed accordingly,
  • clean-up of the LHC example script.
Edited by Nicolas Mounet

Merge request reports