diff --git a/python/mesa_pd/Module.py b/python/mesa_pd/Module.py index 57d989ffa2df7e57cd794fbaf8b11a9593b7a080..6b9b4006b76c65e654cf46c5b4b4018025ee859d 100644 --- a/python/mesa_pd/Module.py +++ b/python/mesa_pd/Module.py @@ -2,7 +2,6 @@ from pathlib import Path import shutil -import os class Module: @@ -38,14 +37,14 @@ class Module: def rename(self): for filename in (f for f in self.context['module_path'].glob('**/*') if f.is_file()): filedata = None - #print(f'renaming module name: {filename}') + # print(f'renaming module name: {filename}') with open(filename, encoding="utf-8") as fin: - filedata = fin.read() + filedata = fin.read() filedata = filedata.replace('mesa_pd', self.context['name']) with open(filename, 'w', encoding="utf-8") as fout: - fout.write(filedata) + fout.write(filedata) def generate(self, folder_check=True): print(f"This operation will overwrite the content of: {self.context['module_path']}") diff --git a/python/mesa_pd/__init__.py b/python/mesa_pd/__init__.py index d68cd8086f9c0494613e440877cdfb5531cfd55d..afd5f1063ec53cd12a4ab908b2d0a63a98235f65 100644 --- a/python/mesa_pd/__init__.py +++ b/python/mesa_pd/__init__.py @@ -1,3 +1,3 @@ from .Module import Module -__all__ = ['Module'] \ No newline at end of file +__all__ = ['Module'] diff --git a/python/mesa_pd/data/ContactHistory.py b/python/mesa_pd/data/ContactHistory.py index 08e80a6f4d436299b861a6c18899d288705a8f97..4189f6648f680debca389adb208076a40cab6d59 100644 --- a/python/mesa_pd/data/ContactHistory.py +++ b/python/mesa_pd/data/ContactHistory.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import numpy as np from ..utility import TerminalColor, find, generate_file @@ -25,7 +24,7 @@ class ContactHistory(): def add_property(self, name, type, defValue=""): prop = find(lambda x: x['name'] == name, self.context['properties']) - if (prop == None): + if (prop is None): # print(f"{TerminalColor.GREEN} creating property: {name} {TerminalColor.DEFAULT}") self.context['properties'].append(create_contact_history_property(name, type, defValue=defValue)) else: @@ -54,8 +53,7 @@ class ContactHistory(): print("=" * 90) def generate(self, module): - ctx = {} - ctx['module'] = module + ctx = {'module': module} ctx.update(self.context) generate_file(module['module_path'], 'data/ContactHistory.templ.h', ctx, filename='data/ContactHistory.h') diff --git a/python/mesa_pd/data/ContactStorage.py b/python/mesa_pd/data/ContactStorage.py index 9dd669381367a17856505fca40f0bde7fdd7cfff..2d68864c9ea9e21de65bc3474ef34b81f63534b9 100644 --- a/python/mesa_pd/data/ContactStorage.py +++ b/python/mesa_pd/data/ContactStorage.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import numpy as np from ..utility import TerminalColor, find, generate_file @@ -26,7 +25,7 @@ class ContactStorage(): def add_property(self, name, type, defValue=""): prop = find(lambda x: x['name'] == name, self.context['properties']) - if (prop == None): + if (prop is None): # print(f"{TerminalColor.GREEN} creating property: {name} {TerminalColor.DEFAULT}") self.context['properties'].append(create_contact_storage_property(name, type, defValue=defValue)) else: @@ -55,8 +54,7 @@ class ContactStorage(): print("=" * 90) def generate(self, module): - ctx = {} - ctx['module'] = module + ctx = {'module': module} ctx.update(self.context) generate_file(module['module_path'], 'data/ContactStorage.templ.h', ctx, filename='data/ContactStorage.h') diff --git a/python/mesa_pd/data/LinkedCells.py b/python/mesa_pd/data/LinkedCells.py index 5ff4c9b8d1477e347093394ad3e2fa5356359877..04e2f8064064245c6411939924c9285086abe5e6 100644 --- a/python/mesa_pd/data/LinkedCells.py +++ b/python/mesa_pd/data/LinkedCells.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import numpy as np from ..utility import generate_file diff --git a/python/mesa_pd/data/ParticleStorage.py b/python/mesa_pd/data/ParticleStorage.py index 76e840dff6eaca7da936110e4cd7668a626a6802..5571f95581ef7db82a3015218618e6bdd1d5e43a 100644 --- a/python/mesa_pd/data/ParticleStorage.py +++ b/python/mesa_pd/data/ParticleStorage.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import numpy as np from ..utility import find, TerminalColor, generate_file @@ -27,8 +26,8 @@ def create_particle_property(name, type, access="grs", defValue="", syncMode="AL """ if (type == 'bool'): - raise RuntimeError(f"Due to flaws in the implementation of std::vector<bool>, bool is not supported as a " - f"property type! Please use char instead.") + raise RuntimeError("Due to flaws in the implementation of std::vector<bool>, bool is not supported as a " + "property type! Please use char instead.") # sort access specifier and remove duplicates foo = "".join(sorted(access)) @@ -65,7 +64,7 @@ class ParticleStorage(): def add_property(self, name, type, access="grs", defValue="", syncMode="ALWAYS"): prop = find(lambda x: x['name'] == name, self.context['properties']) - if (prop == None): + if (prop is None): # print(f"{TerminalColor.GREEN} creating particle property: {name} {TerminalColor.DEFAULT}") self.context['properties'].append( create_particle_property(name, type, access=access, defValue=defValue, syncMode=syncMode)) diff --git a/python/mesa_pd/data/ShapeStorage.py b/python/mesa_pd/data/ShapeStorage.py index 512cb2b29dfc4a2d55ae98e5429532a8b291e9f8..b72534aa7279006cb4549091f21e4a454fd97e33 100644 --- a/python/mesa_pd/data/ShapeStorage.py +++ b/python/mesa_pd/data/ShapeStorage.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import numpy as np from ..utility import generate_file diff --git a/python/mesa_pd/data/SparseLinkedCells.py b/python/mesa_pd/data/SparseLinkedCells.py index b0ee85de8c5ef589c0fc5749a71a41cfe8931d35..30af89a3440258ff071b332b31c043a3af8a67a5 100644 --- a/python/mesa_pd/data/SparseLinkedCells.py +++ b/python/mesa_pd/data/SparseLinkedCells.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import numpy as np from ..utility import generate_file diff --git a/python/mesa_pd/data/__init__.py b/python/mesa_pd/data/__init__.py index b75df12ceb6ad1f2fb66bac271704f522c83397f..64ba6a95e82c4a3ad986a3482d1cfd3dad260d7e 100644 --- a/python/mesa_pd/data/__init__.py +++ b/python/mesa_pd/data/__init__.py @@ -11,4 +11,5 @@ __all__ = ['ContactHistory', 'ContactStorage', 'LinkedCells', 'ParticleStorage', + 'ShapeStorage', 'SparseLinkedCells'] diff --git a/python/mesa_pd/kernel/VelocityVerlet.py b/python/mesa_pd/kernel/VelocityVerlet.py index 74eca6c1393700d08a64b7a0a97f6de7060f15a1..7ec1320564a6c0c63a74fe834d60976c505a3001 100644 --- a/python/mesa_pd/kernel/VelocityVerlet.py +++ b/python/mesa_pd/kernel/VelocityVerlet.py @@ -5,7 +5,7 @@ from mesa_pd.utility import generate_file class VelocityVerlet: - def __init__(self, integrate_rotation = True): + def __init__(self, integrate_rotation=True): self.context = {'bIntegrateRotation': integrate_rotation, 'interface': []} self.context['interface'].append(create_access("position", "walberla::mesa_pd::Vec3", access="gs")) self.context['interface'].append(create_access("linearVelocity", "walberla::mesa_pd::Vec3", access="gs")) diff --git a/python/mesa_pd/mpi/Notifications.py b/python/mesa_pd/mpi/Notifications.py index 5be06cbf48583a1b677ef0dcad0612102112b46c..cea6a3aace6643e3d821ae61e61ffd4d76081db2 100644 --- a/python/mesa_pd/mpi/Notifications.py +++ b/python/mesa_pd/mpi/Notifications.py @@ -2,19 +2,20 @@ from ..utility import generate_file + class Notifications: - def __init__(self, particle_storage): - self.ps = particle_storage + def __init__(self, particle_storage): + self.ps = particle_storage - def generate(self, module): - ctx = {'module': module, 'particle' : self.ps.get_context()} + def generate(self, module): + ctx = {'module': module, 'particle': self.ps.get_context()} - generate_file(module['module_path'], 'mpi/notifications/ParseMessage.templ.h', ctx) - generate_file(module['module_path'], 'mpi/notifications/ParticleCopyNotification.templ.h', ctx) - generate_file(module['module_path'], 'mpi/notifications/ParticleGhostCopyNotification.templ.h', ctx) - generate_file(module['module_path'], 'mpi/notifications/NewGhostParticleNotification.templ.h', ctx) - generate_file(module['module_path'], 'mpi/notifications/ParticleMigrationNotification.templ.h', ctx) - generate_file(module['module_path'], 'mpi/notifications/ParticleRemoteMigrationNotification.templ.h', ctx) - generate_file(module['module_path'], 'mpi/notifications/ParticleRemovalInformationNotification.templ.h', ctx) - generate_file(module['module_path'], 'mpi/notifications/ParticleRemovalNotification.templ.h', ctx) - generate_file(module['module_path'], 'mpi/notifications/ParticleUpdateNotification.templ.h', ctx) + generate_file(module['module_path'], 'mpi/notifications/ParseMessage.templ.h', ctx) + generate_file(module['module_path'], 'mpi/notifications/ParticleCopyNotification.templ.h', ctx) + generate_file(module['module_path'], 'mpi/notifications/ParticleGhostCopyNotification.templ.h', ctx) + generate_file(module['module_path'], 'mpi/notifications/NewGhostParticleNotification.templ.h', ctx) + generate_file(module['module_path'], 'mpi/notifications/ParticleMigrationNotification.templ.h', ctx) + generate_file(module['module_path'], 'mpi/notifications/ParticleRemoteMigrationNotification.templ.h', ctx) + generate_file(module['module_path'], 'mpi/notifications/ParticleRemovalInformationNotification.templ.h', ctx) + generate_file(module['module_path'], 'mpi/notifications/ParticleRemovalNotification.templ.h', ctx) + generate_file(module['module_path'], 'mpi/notifications/ParticleUpdateNotification.templ.h', ctx) diff --git a/python/mesa_pd/mpi/PropertyNotification.py b/python/mesa_pd/mpi/PropertyNotification.py index f7bced94f832e9b2f9ecde2b5136e22b7af0d554..0e027cd1e88c82b85fb2da394511a5f04cf3af66 100644 --- a/python/mesa_pd/mpi/PropertyNotification.py +++ b/python/mesa_pd/mpi/PropertyNotification.py @@ -9,7 +9,7 @@ class PropertyNotification: def add_property(self, name, type, reset_value): prop = find(lambda x: x['name'] == name, self.context['properties']) - if (prop == None): + if (prop is None): self.context['properties'].append({'name': name, 'type': type, 'resetValue': reset_value}) else: if not (prop['type'] == type and prop['name'] == name and prop['resetValue'] == reset_value): diff --git a/python/mesa_pd/mpi/__init__.py b/python/mesa_pd/mpi/__init__.py index e74f708e8376e0db1f56a421f37a2ab9bcf45017..bc467408ffb43db712e3a388f722ab261ee0e915 100644 --- a/python/mesa_pd/mpi/__init__.py +++ b/python/mesa_pd/mpi/__init__.py @@ -15,6 +15,7 @@ from .SyncNextNeighborsNoGhosts import SyncNextNeighborsNoGhosts __all__ = ['BroadcastProperty', 'ClearGhostOwnerSync', 'ClearNextNeighborSync', + 'Notifications', 'PropertyNotification', 'ReduceContactHistory', 'ReduceProperty', diff --git a/python/mesa_pd/utility.py b/python/mesa_pd/utility.py index b5a86337d29245a4aaff6454b0fb90ae8622ea4d..7af8daf50890bf6d714e4a764f70f8271ba3fc36 100644 --- a/python/mesa_pd/utility.py +++ b/python/mesa_pd/utility.py @@ -31,7 +31,7 @@ def get_jinja_environment(): def generate_file(path, template, context={}, filename=None): - if filename == None: + if filename is None: filename = template.replace(".templ", "") env = get_jinja_environment() print(f"generating: {(path / filename)}")