Implements the binary step function Parameters: vector (ndarray): A vector that consists of numeric values Returns: vector (ndarray): Input vector after applying binary step function >>> vector = np.array([-1.2, 0, 2, 1.45, -3.7, 0.3]) >>> binary_step(vector)
(vector: np.ndarray)
| 12 | |
| 13 | |
| 14 | def binary_step(vector: np.ndarray) -> np.ndarray: |
| 15 | """ |
| 16 | Implements the binary step function |
| 17 | |
| 18 | Parameters: |
| 19 | vector (ndarray): A vector that consists of numeric values |
| 20 | |
| 21 | Returns: |
| 22 | vector (ndarray): Input vector after applying binary step function |
| 23 | |
| 24 | >>> vector = np.array([-1.2, 0, 2, 1.45, -3.7, 0.3]) |
| 25 | >>> binary_step(vector) |
| 26 | array([0, 1, 1, 1, 0, 1]) |
| 27 | """ |
| 28 | |
| 29 | return np.where(vector >= 0, 1, 0) |
| 30 | |
| 31 | |
| 32 | if __name__ == "__main__": |
nothing calls this directly
no outgoing calls
no test coverage detected