MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / check_valid_numpy

Function check_valid_numpy

data/recon_dataset.py:78–103  ·  view source on GitHub ↗

Checks if a numpy array is valid (not None and has the expected shape). Raises an error if the array is None or has an unexpected shape.

(array, name)

Source from the content-addressed store, hash-verified

76
77
78def check_valid_numpy(array, name):
79 """
80 Checks if a numpy array is valid (not None and has the expected shape).
81 Raises an error if the array is None or has an unexpected shape.
82 """
83 if array is None:
84 print(f"{name} is None")
85 return True
86
87 if not isinstance(array, np.ndarray):
88 print(f"{name} must be a numpy.ndarray, got {type(array)}")
89 return True
90
91 if array.size == 0:
92 print(f"{name} is empty")
93 return True
94
95 if np.isnan(array).any():
96 print(f"{name} contains NaN values")
97 return True
98
99 if np.isinf(array).any():
100 print(f"{name} contains Inf values")
101 return True
102
103 return False # No exception raised, array is valid
104
105
106class SftJSONLIterableReconDataset(DistributedIterableDataset):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected