Skip to content

KeyError due to setting a dictionary with a cppyy string instead of a python string.  #212

@matthew-w-lundy

Description

@matthew-w-lundy

When running the vegas branch the following error appears:

8
Traceback (most recent call last):
File "/global/home/hpc5308/.local/ENV/bin/v2dl3-vegas", line 8, in
sys.exit(cli())
File "/global/home/hpc5308/.local/ENV/lib/python3.8/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
File "/global/home/hpc5308/.local/ENV/lib/python3.8/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/global/home/hpc5308/.local/ENV/lib/python3.8/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/global/home/hpc5308/.local/ENV/lib/python3.8/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/global/home/hpc5308/.local/ENV/lib/python3.8/site-packages/pyV2DL3/script/v2dl3_for_vegas.py", line 261, in cli
ea_file = EffectiveAreaFile(ea_file)
File "/global/home/hpc5308/.local/ENV/lib/python3.8/site-packages/pyV2DL3/vegas/EffectiveAreaFile.py", line 58, in init
self.axis_dict, self.index_dict = self.build_index()
File "/global/home/hpc5308/.local/ENV/lib/python3.8/site-packages/pyV2DL3/vegas/EffectiveAreaFile.py", line 96, in build_index
check_num *= len(np.unique(index_dict[k]))
KeyError: 'Azimuth'

In index_dict the keys are set to <class cppyy.gbl.std.string at 0x22b4ac90> instead of a <class 'str'>. These should be equivalent but they throw a key error in some configurations. If you add the line "name=str(name)" above this section of the code https://github.com/VERITAS-Observatory/V2DL3/blob/ee2a5fc6a06cfe1a826db9073fb09536357033b9/pyV2DL3/vegas/EffectiveAreaFile.py#L79C1-L79C42 it will work. This might be good as a small commit to the main branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    VEGASSpecific to the VEGAS branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions