Exemplo n.º 1
0
    def _TypeCheckValue(cls, value: typing.Union[float, int]) -> None:
        if not isinstance(value, float) and not isinstance(value, int):
            raise Exceptions.IncorrectTypeException(value, "value",
                                                    (float, int))

        if not ToolsNumbers.IsRealNumber(value):
            raise ValueError("Value is not a real number.")
Exemplo n.º 2
0
	def _ValueToString (self, value: typing.Union[float, int]) -> str:
		if not isinstance(value, float) and not isinstance(value, int):
			raise Exceptions.IncorrectTypeException(value, "value", (float, int))

		if not Numbers.IsRealNumber(value):
			raise Exception("'value' is not a real number.")

		return str(value)
Exemplo n.º 3
0
	def _ParseValueString (self, valueString: str) -> typing.Union[float, int]:
		if not isinstance(valueString, str):
			raise Exceptions.IncorrectTypeException(valueString, "valueString", (str,))

		parsedInput = Parse.ParseNumber(valueString)  # type: typing.Union[float, int]

		if not Numbers.IsRealNumber(parsedInput):
			raise Exception("Input string cannot be parsed to a real number.")

		return parsedInput
Exemplo n.º 4
0
    def _ValueToString(self, value: typing.Union[float, int]) -> str:
        if not isinstance(value, float) and not isinstance(value, int):
            raise Exceptions.IncorrectTypeException(value, "value",
                                                    (float, int))

        if not Numbers.IsRealNumber(value):
            raise Exception("'value' is not a real number.")

        humanRealLifePregnancyDays = Guides.HumanPregnancyGuide.Guide.PregnancyTime / 1440  # type: float
        valueString = str(value * humanRealLifePregnancyDays)  # type: str

        return valueString
Exemplo n.º 5
0
    def _ParseValueString(self, valueString: str) -> typing.Union[float, int]:
        if not isinstance(valueString, str):
            raise Exceptions.IncorrectTypeException(valueString, "valueString",
                                                    (str, ))

        requestedHumanPregnancyDays = Parse.ParseNumber(
            valueString)  # type: typing.Union[float, int]

        if not Numbers.IsRealNumber(requestedHumanPregnancyDays):
            raise Exception("Input string cannot be parsed to a real number.")

        humanRealLifePregnancyDays = Guides.HumanPregnancyGuide.Guide.PregnancyTime / 1440  # type: float
        value = requestedHumanPregnancyDays / humanRealLifePregnancyDays  # type: float

        return value
Exemplo n.º 6
0
    def _ValueToString(self, value: typing.Union[float, int]) -> str:
        if not isinstance(value, float) and not isinstance(value, int):
            raise Exceptions.IncorrectTypeException(value, "value",
                                                    (float, int))

        if not Numbers.IsRealNumber(value):
            raise Exception("'value' is not a real number.")

        humanCycleGuide = Guides.HumanCycleMenstrualGuide.Guide
        humanRealLifeCycleDays = (
            humanCycleGuide.FollicularLength.Mean +
            humanCycleGuide.LutealLength.Mean) / 1440  # type: float
        valueString = str(value * humanRealLifeCycleDays)  # type: str

        return valueString
Exemplo n.º 7
0
    def _ParseValueString(self, valueString: str) -> typing.Union[float, int]:
        if not isinstance(valueString, str):
            raise Exceptions.IncorrectTypeException(valueString, "valueString",
                                                    (str, ))

        requestedHumanCycleDays = Parse.ParseNumber(
            valueString)  # type: typing.Union[float, int]

        if not Numbers.IsRealNumber(requestedHumanCycleDays):
            raise Exception("Input string cannot be parsed to a real number.")

        humanCycleGuide = Guides.HumanCycleMenstrualGuide.Guide
        humanRealLifeCycleDays = (
            humanCycleGuide.FollicularLength.Mean +
            humanCycleGuide.LutealLength.Mean) / 1440  # type: float
        value = requestedHumanCycleDays / humanRealLifeCycleDays

        return value