lwang-astro / PeTar

PeTar is a high-performance N-body code for modelling the evolution of star clusters and tidal streams, including the effect of galactic potential, dynamics of binary and hierarchical system, single and binary stellar evolution.
MIT License
71 stars 19 forks source link

Binary object has no host attribute #44

Closed JoRdAnB421 closed 1 year ago

JoRdAnB421 commented 1 year ago

Hi Long,

I have encountered a bug using the binary object petar.Binary(), specifically when using the function .generateBinaryID() . The following is my code snippet:

p1, p2 = (petar.Particle(interrupt_mode='bse'), petar.Particle(interrupt_mode='bse'))
prim= petar.Binary(p1, p2, simple_mode=False, base_output=True)

prim.loadtxt(os.path.join(dataDir, 'data.0.binary'))

prim.generateBinaryID()

Whilst the files load fine, the last call to the function prim.generateBinaryID() raises the following error

""" AttributeError Traceback (most recent call last)

in 4 prim.loadtxt(os.path.join(dataDir, 'data.0.binary')) 5 bid = functions.CantorPair(prim.p1.id, prim.p2.id) ----> 6 prim.addNewMember(key='bid', member=bid ) ~/petar/include/petar/base.py in addNewMember(self, key, member) 437 self.ncols += dimension 438 diff_ncols += dimension --> 439 self.updateHostNcols(diff_ncols) 440 441 def getherDataToArray(self, origin_format=True): ~/petar/include/petar/base.py in updateHostNcols(self, _diff_ncols) 740 741 def updateHostNcols(self, _diff_ncols): --> 742 if (self.host!=None): 743 if (issubclass(type(self.host), DictNpArrayMix)): 744 self.host.ncols += _diff_ncols AttributeError: 'Binary' object has no attribute 'host' """ I have checked the binary object and can confirm that even when the binary is initialized it has no attribute named host, on the other hand, the particle object does have a host attribute.
lwang-astro commented 1 year ago

This bug has been fixed in one version of master branch. You can updated to the newest master branch.