Skip to content

Bug fix in gstlal_ll_inspiral_event_plotter: change random -> numpy.random

Divya Singh requested to merge event_plotter_importerror into master

Event plotter in Charlie(LL-SSM) failed with the following error:

Traceback (most recent call last):
  File "/usr/bin/gstlal_ll_inspiral_event_plotter", line 508, in <module>
    event_plotter.start()
  File "/usr/lib64/python3.6/site-packages/gstlal/events.py", line 122, in start
    self.process()
  File "/usr/lib64/python3.6/site-packages/gstlal/events.py", line 111, in process
    self.handle()
  File "/usr/bin/gstlal_ll_inspiral_event_plotter", line 227, in handle
    self.upload_ranking_data(event)
  File "/usr/bin/gstlal_ll_inspiral_event_plotter", line 292, in upload_ranking_data
    self.upload_file('ranking statistic PDFs', 'ranking_data.xml.gz', 'ranking_statistic', ranking_fobj.getvalue(), event['gid'])
  File "/usr/bin/gstlal_ll_inspiral_event_plotter", line 283, in upload_file
    time.sleep(random.lognormal(math.log(self.retry_delay), .5))
NameError: name 'random' is not defined

There is no import for random in gstlal_ll_inspiral_event_plotter, but we import numpy, so I changed random.lognormal to numpy.random.lognormal.

Made the same change in event_uploader where from scipy import random was being used, but scipy.random does not exist.

Test:

Singularity> python3
Python 3.6.8 (default, Nov  8 2022, 11:32:15) 
[GCC 8.5.0 20210514 (Red Hat 8.5.0-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import math
>>> numpy.random.lognormal(math.log(100), .5)
113.7853913304434
Edited by Divya Singh

Merge request reports

Loading