Skip to content

Commit

Permalink
Updated docs and removed "fixed" attribute from Point
Browse files Browse the repository at this point in the history
  • Loading branch information
mlauer154 committed Feb 13, 2024
1 parent 5b4fa6d commit 431b857
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pymead/core/geometry_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
37 changes: 37 additions & 0 deletions pymead/core/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -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")
Expand All @@ -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
Expand Down

0 comments on commit 431b857

Please sign in to comment.