information_formulas¶
shortfx.fxExcel.information_formulas
¶
Excel Information Functions Module.
This module provides Excel-compatible validation and error handling functions for shortfx. Functions include: - IS Functions: ISBLANK, ISERR, ISERROR, ISEVEN, ISLOGICAL, ISNA, ISNONTEXT, ISNUMBER, ISODD, ISOMITTED, ISTEXT - Error handling: ERROR_TYPE
All functions follow Excel naming conventions and behavior.
Note: Functions like CELL, INFO, ISREF, and ISFORMULA are excluded because they depend on Excel's application context (cells, worksheets, references) which don't exist in standalone Python execution.
Functions¶
ERROR_TYPE(error_val: Any) -> Optional[int]
¶
Return a number corresponding to an error type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error_val
|
Any
|
Error value to analyze. |
required |
Returns:
| Type | Description |
|---|---|
Optional[int]
|
Optional[int]: Error number, or None if not an error. - 1: #NULL! - 2: #DIV/0! - 3: #VALUE! - 4: #REF! - 5: #NAME? - 6: #NUM! - 7: #N/A |
Example
ERROR_TYPE(ZeroDivisionError()) 2 ERROR_TYPE(42) None
Cost: O(1)
Source code in shortfx/fxExcel/information_formulas.py
ISBLANK(value: Any) -> bool
¶
Return TRUE if the value is blank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to test. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is blank, False otherwise. |
Example
ISBLANK(None) True ISBLANK("") True ISBLANK("text") False
Cost: O(1)
Source code in shortfx/fxExcel/information_formulas.py
ISERR(value: Any) -> bool
¶
Return TRUE if the value is any error value except #N/A.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to test. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is error (except #N/A), False otherwise. |
Example
ISERR(ValueError()) True ISERR("#N/A") False
Cost: O(1)
Source code in shortfx/fxExcel/information_formulas.py
ISERROR(value: Any) -> bool
¶
Return TRUE if the value is any error value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to test. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is any error, False otherwise. |
Example
ISERROR(ValueError()) True ISERROR(42) False
Cost: O(1)
Source code in shortfx/fxExcel/information_formulas.py
ISEVEN(number: Union[int, float]) -> bool
¶
Return TRUE if the number is even.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
Union[int, float]
|
Number to test. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if number is even, False otherwise. |
Example
ISEVEN(4) True ISEVEN(3) False
Cost: O(1)
Source code in shortfx/fxExcel/information_formulas.py
ISLOGICAL(value: Any) -> bool
¶
Return TRUE if the value is a logical value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to test. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is boolean, False otherwise. |
Example
ISLOGICAL(True) True ISLOGICAL(1) False
Cost: O(1)
Source code in shortfx/fxExcel/information_formulas.py
ISNA(value: Any) -> bool
¶
Return TRUE if the value is the #N/A error value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to test. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is #N/A, False otherwise. |
Example
ISNA("#N/A") True ISNA(ValueError()) False
Cost: O(1)
Source code in shortfx/fxExcel/information_formulas.py
ISNONTEXT(value: Any) -> bool
¶
Return TRUE if the value is not text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to test. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is not text, False otherwise. |
Example
ISNONTEXT(42) True ISNONTEXT("text") False
Cost: O(1)
Source code in shortfx/fxExcel/information_formulas.py
ISNUMBER(value: Any) -> bool
¶
Return TRUE if the value is a number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to test. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is numeric, False otherwise. |
Example
ISNUMBER(42) True ISNUMBER(3.14) True ISNUMBER("42") False
Cost: O(1)
Source code in shortfx/fxExcel/information_formulas.py
ISODD(number: Union[int, float]) -> bool
¶
Return TRUE if the number is odd.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
Union[int, float]
|
Number to test. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if number is odd, False otherwise. |
Example
ISODD(3) True ISODD(4) False
Cost: O(1)
Source code in shortfx/fxExcel/information_formulas.py
ISOMITTED(value: Any) -> bool
¶
Check if a value is missing in a LAMBDA expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to test. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value was omitted, False otherwise. |
Example
ISOMITTED(inspect.Parameter.empty) True ISOMITTED(42) False
Cost: O(1)
Source code in shortfx/fxExcel/information_formulas.py
ISTEXT(value: Any) -> bool
¶
Return TRUE if the value is text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to test. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is text, False otherwise. |
Example
ISTEXT("hello") True ISTEXT(42) False
Cost: O(1)
Source code in shortfx/fxExcel/information_formulas.py
N(value: Any) -> Union[int, float]
¶
Return a value converted to a number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to convert. |
required |
Returns:
| Type | Description |
|---|---|
Union[int, float]
|
Union[int, float]: Numeric value. - Numbers return themselves - True returns 1, False returns 0 - Dates return serial number - Everything else returns 0 |
Example
N(42) 42 N(True) 1 N("text") 0
Cost: O(1)
Source code in shortfx/fxExcel/information_formulas.py
NA() -> str
¶
Return the error value #N/A.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
"#N/A" error value. |
Example
NA() '#N/A'
Cost: O(1)
TYPE(value: Any) -> int
¶
Returns the type of a value as a numeric code.
Follows Excel's TYPE function convention: 1 = Number (int or float) 2 = Text (str) 4 = Logical (bool) 16 = Error (Exception) 64 = Array (list, tuple, or numpy array)
Excel function: TYPE
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value whose type to determine. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Type code (1, 2, 4, 16, or 64). |
Usage Example
TYPE(42) 1 TYPE(3.14) 1 TYPE("hello") 2 TYPE(True) 4 TYPE([1, 2, 3]) 64 TYPE(ValueError()) 16
Cost: O(1)