X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=src%2Fpyutils%2Ftypez%2Frate.py;h=a4947e6b2cc15a6fc24a3ce99c461b0a0741c780;hb=278d163705facc2276cd464414fb490ef6af50ab;hp=5fc3f6540f218bc76d2ffdc4197be599571bde84;hpb=c256f84c53368730ee07c26dc29d3a66456501c0;p=pyutils.git diff --git a/src/pyutils/typez/rate.py b/src/pyutils/typez/rate.py index 5fc3f65..a4947e6 100644 --- a/src/pyutils/typez/rate.py +++ b/src/pyutils/typez/rate.py @@ -17,6 +17,25 @@ class Rate(object): percentage: Optional[float] = None, percent_change: Optional[float] = None, ): + """Constructs a new :class:`Rate` from a multiplier, percentage, or + percent change. One and only one of these may be passed. These are + a little confusing so here's an example... + + .. note:: + + A multiplier of 1.5x is the same as a percentage of 150% and + is also the same as a 50% change. Let's examine an original + amount of 100. Multiplying it by a 1.5x multiplier yields 150. + Multiplying it by 150% yields 150. Increasing it by 50% also + yields 150. + + Args: + multiplier: provides the number that you would multiply a base + amount by to modify it + percentage: provides the multiplier as a percentage + percent_change: provides the multiplier as a percent change to + the base amount + """ count = 0 if multiplier is not None: if isinstance(multiplier, str): @@ -39,9 +58,25 @@ class Rate(object): ) def apply_to(self, other): + """Applies the rate to a base number. + + Args: + other: the base to apply the change rate to. + + Returns: + The result after the change. + """ return self.__mul__(other) def of(self, other): + """Applies the rate to a base number. + + Args: + other: the base to apply the change rate to. + + Returns: + The result after the change. + """ return self.__mul__(other) def __float__(self):