relationalai.std.math.sinh()
sinh(number: Number|Producer) -> Expression
Calculates the hyperbolic sine of a number.
If number
is a Producer
, sinh()
filters out any non-numeric values from the producer.
Must be called in a rule or query context.
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
number | Producer or Python Number object | The value to calculate the hyperbolic sine of. |
Returns
Section titled “Returns”An Expression
object.
Example
Section titled “Example”Use sinh()
to calculate the hyperbolic sine of a value in radians:
import relationalai as raifrom relationalai.std import math
# =====# SETUP# =====
model = rai.Model("MyModel")Portfolio = model.Type("Portfolio")Investment = model.Type("Investment")
# Define portfolios and their investments.with model.rule(): portfolio1 = Portfolio.add(id=1).set(name="Portfolio1") portfolio1.investments.extend([ Investment.add(id=1).set(name="InvestmentA", growth_rate=0.5), Investment.add(id=2).set(name="InvestmentB", growth_rate=1.0), ])
portfolio2 = Portfolio.add(id=2).set(name="Portfolio2") portfolio2.investments.extend([ Investment.add(id=3).set(name="InvestmentC", growth_rate=1.2), Investment.add(id=4).set(name="InvestmentD", growth_rate="N/A"), # Non-numeric value ])
# =======# EXAMPLE# =======
# Set a growth_sinh property to the hyperbolic sine of each investment's growth rate.with model.rule(): portfolio = Portfolio() investment = portfolio.investments investment.set(growth_sinh=math.sinh(investment.growth_rate))
# Since sinh() filters out non-numeric values, the growth_sinh property# is not set for the investment with ID 4.with model.query() as select: portfolio = Portfolio() investment = portfolio.investments response = select(portfolio.name, investment.name, investment.growth_sinh)
print(response.results)# name name2 growth_sinh# 0 Portfolio1 InvestmentA 0.521095# 1 Portfolio1 InvestmentB 1.175201# 2 Portfolio2 InvestmentC 1.509461# 3 Portfolio2 InvestmentD NaN