-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix read and write from pmb.df
#116
Conversation
You may want to discuss it with @RudolfWeeber, he is planning to rewrite the bond id management in the next release of ESPResSo. It would be best if we could update pyMBE at the same time we update the bond id management in ESPResSo. |
Should we discuss it today during the ESPResSo coding day or better in our meeting scheduled next week? In principle the issue with |
@jngrad I tested the handling of the Should then keep this PR as it is, or you think is better that we remove support for tracking of import espressomd
from espressomd import interactions
from espressomd import checkpointing
restart=True
# Set-up the checkpoint
checkpoint = checkpointing.Checkpoint(checkpoint_id=f"mycheckpoint",
checkpoint_path=".")
if restart:
checkpoint.load()
else:
Box_L = 7.5*pmb.units.nm
espresso_system = espressomd.System(box_l = [Box_L.to('reduced_length').magnitude]*3)
espresso_system.time_step=0.1
checkpoint.register("espresso_system")
bond = interactions.HarmonicBond(k = 0,
r_0 = 1)
bond1 = interactions.HarmonicBond(k = 1,
r_0 = 1)
bond2 = interactions.HarmonicBond(k = 2,
r_0 = 1)
bond_id = espresso_system.bonded_inter.add(bond)
bond_id1 = espresso_system.bonded_inter.add(bond1)
bond_id2 = espresso_system.bonded_inter.add(bond2)
for item in espresso_system.bonded_inter.items():
print(item)
espresso_system.bonded_inter.remove(bond_id1)
checkpoint.save()
for item in espresso_system.bonded_inter.items():
print(item) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the requested change, LGTM. The bond id business will need to be revisited when we refactor the bond storage mechanism in ESPResSo, but that project is months away.
Solves #102 and #114 finally.
Changed
pd.NA
is now enforced as value for empty cells inpmb.df
, this prevents transformation of variable types fromint
tofloat
which was breaking the code when readingpmb.df
from file (See Integer values inpmb.df
become float when reading a pyMBE dataframe from file #102).Fixed
pmb.df
from file does no longer change the variable type fromint
tofloat
when there are empty cells in the column.I had to do quite a bit of refactoring to make the code work with
pd.NA
because it behaves differently thannp.nan
, but I checked that all functional tests still run.@paobtorres @1234somesh this PR solves the issues you raised!