MCPcopy Create free account
hub / github.com/Kitware/ParaView / get_kwargs

Function get_kwargs

Remoting/Application/Testing/Python/PythonSMTraceTest6.py:24–43  ·  view source on GitHub ↗
(state_string: str)

Source from the content-addressed store, hash-verified

22
23
24def 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
46def are_close(array1: List[float], array2: List[float]) -> bool:

Callers 1

Calls 2

countMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected