Skip to content

Commit

Permalink
Add file "particle_to_dict.py"
Browse files Browse the repository at this point in the history
  • Loading branch information
mili1247 authored and Hao Lu committed Dec 21, 2020
1 parent 2e63a05 commit c13b23a
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions testsuite/python/particle_to_dict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# Copyright (C) 2020 The ESPResSo project
#
# This file is part of ESPResSo.
#
# ESPResSo is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ESPResSo is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

import unittest as ut
import numpy as np
import espressomd


class ParticleDictionaryTest(ut.TestCase):
box_l = 30.
system = espressomd.System(box_l=3 * [box_l])

def test(self):
p = self.system.part.add(
pos=np.random.uniform(
size=(
10, 3)) * self.box_l)
pp = str(p)
pdict = p.to_dict()
p.remove()
self.system.part.add(pdict)
self.assertEqual(str(self.system.part.select()), pp)


if __name__ == "__main__":
ut.main()

0 comments on commit c13b23a

Please sign in to comment.