From 431b857e307cb22d532a8810e09af42744e57196 Mon Sep 17 00:00:00 2001 From: mlauer154 Date: Tue, 13 Feb 2024 17:22:25 -0600 Subject: [PATCH] Updated docs and removed "fixed" attribute from Point --- pymead/core/geometry_collection.py | 5 ++-- pymead/core/point.py | 37 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/pymead/core/geometry_collection.py b/pymead/core/geometry_collection.py index 64e9b783..f1c33630 100644 --- a/pymead/core/geometry_collection.py +++ b/pymead/core/geometry_collection.py @@ -450,8 +450,7 @@ def remove_pymead_obj(self, pymead_obj: PymeadObj, promotion_demotion: bool = Fa else: self.canvas.removeItem(pymead_obj.canvas_item) - def add_point(self, x: float, y: float, name: str or None = None, fixed: bool = False, - assign_unique_name: bool = True): + def add_point(self, x: float, y: float, name: str or None = None, assign_unique_name: bool = True): """ Adds a point by value to the geometry collection @@ -471,7 +470,7 @@ def add_point(self, x: float, y: float, name: str or None = None, fixed: bool = Point Object reference """ - point = Point(x=x, y=y, name=name, fixed=fixed) + point = Point(x=x, y=y, name=name) point.x().geo_col = self point.y().geo_col = self self.add_pymead_obj_by_ref(point, assign_unique_name=assign_unique_name) diff --git a/pymead/core/point.py b/pymead/core/point.py index 98ac783b..1551c0a4 100644 --- a/pymead/core/point.py +++ b/pymead/core/point.py @@ -9,6 +9,11 @@ class Point(PymeadObj): + """ + The ``Point`` is the lowest-level geometry object in `pymead`. All curves in `pymead` are tied directly to ``Point`` + objects. For example, instances of this class are used to define the endpoints of finite lines and control points of + Bézier curves. + """ def __init__(self, x: float, y: float, name: str or None = None, setting_from_geo_col: bool = False): super().__init__(sub_container="points") self._x = None @@ -26,9 +31,25 @@ def __init__(self, x: float, y: float, name: str or None = None, setting_from_ge self.set_y(y) def x(self): + """ + Getter for the point's ``x`` parameter. + + Returns + ------- + LengthParam + The point's ``x`` parameter + """ return self._x def y(self): + """ + Getter for the point's ``y`` parameter. + + Returns + ------- + LengthParam + The point's ``y`` parameter + """ return self._y def set_x(self, x: LengthParam or float): @@ -46,6 +67,14 @@ def set_y(self, y: LengthParam or float): self._y.point = self def set_name(self, name: str): + """ + Extends the base ``set_name()`` by also renaming the point's ``x`` and ``y`` parameters. + + Parameters + ---------- + name: str + Name for the point + """ # Rename the x and y parameters of the Point if self.x() is not None: self.x().set_name(f"{name}.x") @@ -55,6 +84,14 @@ def set_name(self, name: str): super().set_name(name) def as_array(self): + """ + Gives a one-dimensional, two-element array representation of the point (:math:`x` and :math:`y` values) + + Returns + ------- + np.ndarray + One-dimensional array containing the point's :math:`x` and :math:`y` values + """ return np.array([self.x().value(), self.y().value()]) @classmethod