(state_string: str)
| 22 | |
| 23 | |
| 24 | def get_kwargs(state_string: str) -> dict: |
| 25 | # This is a utility function for getting the kwargs for |
| 26 | # `GenerateRGBPoints()` as a dict. |
| 27 | # If `GenerateRGBPoints()` is not present, or if it is called |
| 28 | # more than one time, `None` is returned. |
| 29 | search_str = 'RGBPoints=GenerateRGBPoints(' |
| 30 | num_occurrences = state_string.count(search_str) |
| 31 | if num_occurrences != 1: |
| 32 | return None |
| 33 | |
| 34 | # Find the start index of the kwargs |
| 35 | start_idx = state_string.find(search_str) + len(search_str) |
| 36 | # Find the next '),' and assume it is the end of the kwargs |
| 37 | end_idx = state_string.find('),', start_idx) |
| 38 | |
| 39 | # Extract the section of code |
| 40 | section = state_string[start_idx:end_idx] |
| 41 | |
| 42 | # Convert the arguments into a kwargs dictionary |
| 43 | return eval(f'dict({section})') |
| 44 | |
| 45 | |
| 46 | def are_close(array1: List[float], array2: List[float]) -> bool: |
no test coverage detected