Skip to content

indentation issue/logic issue in core/Ions.py #286

@jslavin

Description

@jslavin

Hi Ken et al.,

I think I found a bug in core/Ions.py
It's in the if block that starts on line 149:
if setup:
if self.IonStr in chdata.MasterList:
...
else:
if verbose:
print(' ion %s not in masterlist, just various attributes, ionization, recombination rates'%(self.IonStr))

So, currently if setup is False and verbose is True it will print a message that the ion is not in masterlist. I think what is intended is for that block to be indented one level more. Then there is the question of the indentation of the next statements, which as currently written execute only if setup is False:
if np.any(temperature) is not None:
self.Temperature = np.atleast_1d(temperature)
self.Ntemp = self.Temperature.size
self.setupIonrec()
Was it intended that these be executed when ion is not in masterlist?
I ran into this because if you create an instance of ion with 'mg_1' as the ion, and then invoke the recombRate() method, you get an exception because the temperature is not defined.
I'm not sure what the proper behavior in this case is, but it seems clear that the current code is not correct.

Jon

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions