From d67e0f731f232136be784d155b508bf7a345b90a Mon Sep 17 00:00:00 2001 From: 1p22geo <1p22geodecki@gmail.com> Date: Thu, 6 Jun 2024 11:54:00 +0200 Subject: [PATCH] merge: minor import fixes --- engine/renderpreview.py | 3 ++- libschrodinger/gauss.py | 4 ++-- libschrodinger/particle.py | 5 +++++ libschrodinger/potential.py | 4 ++-- libschrodinger/quark/baryon.py | 7 ++++--- libschrodinger/quark/hadron.py | 7 ++++--- pyproject.toml | 2 +- 7 files changed, 20 insertions(+), 12 deletions(-) diff --git a/engine/renderpreview.py b/engine/renderpreview.py index d3bd621..9122710 100644 --- a/engine/renderpreview.py +++ b/engine/renderpreview.py @@ -9,6 +9,7 @@ import libschrodinger.graphs import libschrodinger.figlocation import libschrodinger.constants +import libschrodinger.interaction def renderpreview(state, mobile=False): @@ -26,7 +27,7 @@ def renderpreview(state, mobile=False): for potential in potentials: V_total += potential.V for p2 in particles: - if p2._id != particle._id: + if p2.__id != particle.__id: V_total += ( libschrodinger.interaction.Interactions.get_relative_potential( config, particle, p2 diff --git a/libschrodinger/gauss.py b/libschrodinger/gauss.py index e7de731..05e08ac 100644 --- a/libschrodinger/gauss.py +++ b/libschrodinger/gauss.py @@ -62,7 +62,7 @@ def __init__( vx=0.0, vy=0.0, ): - self._id = uuid.uuid4() + self.__id = uuid.uuid4() self.config = config self.vx = vx self.vy = vy @@ -110,7 +110,7 @@ def propagate( return # Interact with other particles for p in particles: - if p._id == self._id: + if p._id == self.__id: continue pass # interact with particle diff --git a/libschrodinger/particle.py b/libschrodinger/particle.py index 14a5271..8b06558 100644 --- a/libschrodinger/particle.py +++ b/libschrodinger/particle.py @@ -1,4 +1,5 @@ import numpy as np +import uuid import libschrodinger.config import libschrodinger.figlocation @@ -26,6 +27,10 @@ class Particle: or to `matplotlib.pyplot` """ + _id: uuid.UUID + """ + ID of the particle. + """ def __init__(self, config): self.config = config diff --git a/libschrodinger/potential.py b/libschrodinger/potential.py index 15b3af9..c2d5024 100644 --- a/libschrodinger/potential.py +++ b/libschrodinger/potential.py @@ -12,12 +12,12 @@ class Potential: """ configuration for the domain """ - x_center: float | None + x_center: float """ defaults to center of domain, the centerpoint of the potential """ - y_center: float | None + y_center: float """ defaults to center of domain, the centerpoint of the potential diff --git a/libschrodinger/quark/baryon.py b/libschrodinger/quark/baryon.py index 4363f24..77f9f8b 100644 --- a/libschrodinger/quark/baryon.py +++ b/libschrodinger/quark/baryon.py @@ -3,6 +3,7 @@ import libschrodinger.quark.hadron import libschrodinger.quark.color import libschrodinger.quark.meson +import libschrodinger.quark.quark class Baryon(libschrodinger.quark.hadron.Hadron): @@ -95,7 +96,7 @@ def propagate(self, V, particles, frame): ), ) particles.append(m) - self._meson = m._id # to access or delete this meson later on + self._meson = m.__id # to access or delete this meson later on self.quarks[0].color_charge = libschrodinger.quark.color.rotate( libschrodinger.quark.color.COLOR.GREEN, self.rotation ) @@ -131,7 +132,7 @@ def propagate(self, V, particles, frame): ), ) particles.append(m) - self._meson = m._id # to access or delete this meson later on + self._meson = m.__id # to access or delete this meson later on self.quarks[1].color_charge = libschrodinger.quark.color.rotate( libschrodinger.quark.color.COLOR.BLUE, self.rotation ) @@ -167,7 +168,7 @@ def propagate(self, V, particles, frame): ), ) particles.append(m) - self._meson = m._id # to access or delete this meson later on + self._meson = m.__id # to access or delete this meson later on self.quarks[2].color_charge = libschrodinger.quark.color.rotate( libschrodinger.quark.color.COLOR.GREEN, self.rotation ) diff --git a/libschrodinger/quark/hadron.py b/libschrodinger/quark/hadron.py index 7726339..1aee2e5 100644 --- a/libschrodinger/quark/hadron.py +++ b/libschrodinger/quark/hadron.py @@ -5,6 +5,7 @@ import libschrodinger.config import libschrodinger.potential import libschrodinger.quark.quark +import libschrodinger.figlocation class Hadron(libschrodinger.particle.Particle): @@ -36,7 +37,7 @@ class Hadron(libschrodinger.particle.Particle): """ def __init__(self, config, quarks: list[libschrodinger.quark.quark.Quark]): - self._id = uuid.uuid4() + self.__id = uuid.uuid4() self.config = config self.psi = np.zeros((config.Nx, config.Ny), dtype="complex128") self.quarks = quarks @@ -77,7 +78,7 @@ def draw(self, graph: "libschrodinger.graphs.GraphDisplay", V: np.ndarray, x, y, def propagate( self, V: np.ndarray, particles: list[libschrodinger.particle.Particle], frame: int - ): + ) -> list["libschrodinger.particle.Particle"] | None: """ propagate the wave function in a potential field @@ -102,7 +103,7 @@ def propagate( return # Interact with other particles for p in particles: - if p._id == self._id: + if p._id == self.__id: continue pass # interact with particle diff --git a/pyproject.toml b/pyproject.toml index ddbfb0e..f61fef1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "libschrodinger" -version = "1.3.0" +version = "1.3.1" authors = [ { name="1p22geo", email="1p22geodecki@gmail.com" }, { name="KacperTZSTI", email="kacper.m.trzop@gmail.com" },