-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expressions: add zip, repeat, sqrt, log, pow along with docs
- Loading branch information
1 parent
cf00519
commit 3e80c45
Showing
24 changed files
with
1,193 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
title: Log | ||
order: 0 | ||
status: published | ||
--- | ||
|
||
### Log | ||
|
||
Function in `num` namespace to get the logarithm of a number. | ||
|
||
#### Parameters | ||
<Expandable title="base" type="float" defaultVal="2.718281828459045"> | ||
The base of the logarithm. By default, the base is set to `e` (Euler's number). | ||
</Expandable> | ||
|
||
#### Returns | ||
<Expandable type="Expr"> | ||
Returns an expression object denoting the logarithm of the input data. The | ||
data type of the resulting expression is `float` if the input was `int` or | ||
`float` and `Optional[float]` if the input was `Optional[int]` or | ||
`Optional[float]`. | ||
|
||
For negative numbers, the result is `NaN` (Not a Number). | ||
</Expandable> | ||
|
||
<pre snippet="api-reference/expressions/num#log" | ||
status="success" message="Computing logarithm of a number"> | ||
</pre> | ||
|
||
#### Errors | ||
<Expandable title="Invoking on a non-numeric type"> | ||
Error during `typeof` or `eval` if the input expression is not of type int, | ||
float, optional int or optional float. | ||
</Expandable> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
title: Pow | ||
order: 0 | ||
status: published | ||
--- | ||
|
||
### Pow | ||
|
||
Function in `num` namespace to exponentiate a number. | ||
|
||
#### Parameters | ||
<Expandable title="exponent" type="Expr"> | ||
The exponent to which the base is raised - expected to be a numeric expression. | ||
</Expandable> | ||
|
||
#### Returns | ||
<Expandable type="Expr"> | ||
Returns an expression object denoting the result of the exponentiation. | ||
|
||
The base data type of the resulting expression is `int` if both the base and | ||
exponent are `int`, otherwise it is `float`. | ||
|
||
If any of the base or exponent is `Optional`, the resulting expression is | ||
also `Optional` of the base data type. | ||
</Expandable> | ||
|
||
<pre snippet="api-reference/expressions/num#pow" status="success" | ||
message="Exponentiating a number"> | ||
</pre> | ||
|
||
#### Errors | ||
|
||
<Expandable title="Invoking on a non-numeric type"> | ||
Error during `typeof` or `eval` if the input expression is not of type int, | ||
float, optional int or optional float. | ||
</Expandable> | ||
|
||
|
||
<Expandable title="Exponentiation of negative integers"> | ||
A runtime error will be raised if the exponent is a negative integer and the | ||
base is also an integer. | ||
|
||
In such cases, it's advised to convert either the base or the exponent to be a | ||
float. | ||
</Expandable> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
title: Sqrt | ||
order: 0 | ||
status: published | ||
--- | ||
|
||
### Sqrt | ||
|
||
Function in `num` namespace to get the square root of a number. | ||
|
||
#### Returns | ||
<Expandable type="Expr"> | ||
Returns an expression object denoting the square root of the input data. | ||
|
||
The data type of the resulting expression is `float` if the input is `int` or | ||
`float` and `Optional[float]` if the input is `Optional[int]` or `Optional[float]`. | ||
</Expandable> | ||
|
||
:::info | ||
The square root of a negative number is represented as `NaN` in the output. | ||
::: | ||
|
||
<pre snippet="api-reference/expressions/num#sqrt" | ||
status="success" message="Getting square root of a number"> | ||
</pre> | ||
|
||
#### Errors | ||
<Expandable title="Invoking on a non-numeric type"> | ||
Error during `typeof` or `eval` if the input expression is not of type int, | ||
float, optional int or optional float. | ||
</Expandable> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
title: Repeat | ||
order: 0 | ||
status: published | ||
--- | ||
### Repeat | ||
|
||
Repeat an expression `n` times to create a list. | ||
|
||
#### Parameters | ||
<Expandable title="value" type="Expr"> | ||
The expression to repeat. | ||
</Expandable> | ||
|
||
<Expandable title="by" type="Expr"> | ||
The number of times to repeat the value - can evaluate to a different count for | ||
each row. | ||
</Expandable> | ||
|
||
|
||
<pre snippet="api-reference/expressions/basic#repeat" | ||
status="success" message="Repeating booleans to create list"> | ||
</pre> | ||
|
||
#### Returns | ||
<Expandable type="Expr"> | ||
Returns an expression object denoting the result of the repeat expression. | ||
</Expandable> | ||
|
||
|
||
#### Errors | ||
<Expandable title="Invalid input types"> | ||
An error is thrown if the `by` expression is not of type int. | ||
In addition, certain types (e.g. lists) are not supported as input for `value`. | ||
</Expandable> | ||
|
||
<Expandable title="Negative count"> | ||
An error is thrown if the `by` expression evaluates to a negative integer. | ||
</Expandable> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
title: Zip | ||
order: 0 | ||
status: published | ||
--- | ||
### Zip | ||
|
||
Zip two or more lists into a list of structs. | ||
|
||
#### Parameters | ||
<Expandable title="struct" type="Struct"> | ||
The struct to hold the zipped values. Unlike other top level expressions, | ||
`zip` is written as `Struct.zip(kwarg1=expr1, kwarg2=expr2, ...)`. | ||
</Expandable> | ||
|
||
<Expandable title="kwargs" type="Dict[str, Expr]"> | ||
A dictionary of key-value pairs where the key is the name of the field in the | ||
struct and the value is the expression to zip. | ||
|
||
Expressions are expected to evaluate to lists of a type that can be converted to | ||
the corresponding field type in the struct. | ||
</Expandable> | ||
|
||
|
||
<pre snippet="api-reference/expressions/basic#zip" status="success" | ||
message="Zipping two lists into a list of structs"> | ||
</pre> | ||
|
||
#### Returns | ||
<Expandable type="Expr"> | ||
Returns an expression object denoting the result of the zip expression. | ||
</Expandable> | ||
|
||
:::info | ||
When zipping lists of unequal length, similar to Python's zip function, the | ||
resulting list will be truncated to the length of the shortest list, possibly | ||
zero. | ||
::: | ||
|
||
#### Errors | ||
<Expandable title="Mismatching types"> | ||
An error is thrown if the types of the lists to zip are not compatible with the | ||
field types in the struct. | ||
</Expandable> | ||
|
||
<Expandable title="Non-list types"> | ||
An error is thrown if the expressions to zip don't evaluate to lists. | ||
</Expandable> |
Oops, something went wrong.