Skip to content

Commit

Permalink
Add __repr__ to Optimum and PleiotropicOptima
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen committed Nov 25, 2024
1 parent d1e9786 commit 49afb30
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions fwdpy11/genetic_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TimingError(Exception):
@attr_add_asblack
@attr_class_pickle_with_super
@attr_class_to_from_dict
@attr.s(auto_attribs=True, frozen=True)
@attr.s(auto_attribs=True, frozen=True, auto_detect=True)
class Optimum(_ll_Optimum):
"""
Parameters for a trait optimum.
Expand Down Expand Up @@ -95,11 +95,16 @@ def validate_when(self, attribute, value):
def __attrs_post_init__(self):
super(Optimum, self).__init__(self.optimum, self.VS, self.when)

def __repr__(self) -> str:
return (
f"fwdpy11.Optimum(optimum={self.optimum}, VS={self.VS}, when={self.when})"
)


@attr_add_asblack
@attr_class_pickle_with_super
@attr_class_to_from_dict
@attr.s(auto_attribs=True, frozen=True, eq=False)
@attr.s(auto_attribs=True, frozen=True, eq=False, auto_detect=True)
class PleiotropicOptima(_ll_PleiotropicOptima):
"""
Parameters for multiple trait optima
Expand Down Expand Up @@ -144,6 +149,10 @@ def __eq__(self, other):

return optima_equal and VS_equal and when_equal

def __repr__(self) -> str:
args = f"optima={self.optima}, VS={self.VS}, when={self.when}"
return f"(fwdpy11.PleiotropicOptima({args}))"


@attr.s(auto_attribs=True, frozen=True)
class GaussianStabilizingSelection(_ll_GaussianStabilizingSelection):
Expand Down

0 comments on commit 49afb30

Please sign in to comment.