Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _internal_get_standardized_data(self: P, instance: P) -> np.ndarray:
raise NotSupportedError(f"Export to standardized data space is not implemented for {self.name}")
def _internal_set_std_data(self: BP, data: np.ndarray, instance: BP, deterministic: bool = False) -> BP:
raise NotSupportedError(f"Import from standardized data space is not implemented for {self.name}") # type: ignore
def _internal_get_std_data(self: BP, instance: BP) -> np.ndarray:
raise NotSupportedError(f"Export to standardized data space is not implemented for {self.name}") # type: ignore
def get_value_hash(self) -> t.Hashable:
"""Hashable object representing the current value of the instance
"""
val = self.value
if isinstance(val, (str, bytes, float, int)):
return val
elif isinstance(val, np.ndarray):
return val.tobytes()
else:
raise NotSupportedError(f"Value hash is not supported for object {self.name}")
def _internal_set_standardized_data(self: P, data: np.ndarray, instance: P, deterministic: bool = False) -> P:
raise NotSupportedError(f"Import from standardized data space is not implemented for {self.name}")
def get_value_hash(self) -> t.Hashable:
"""Hashable object representing the current value of the instance
"""
val = self.value
if isinstance(val, (str, bytes, float, int)):
return val
elif isinstance(val, np.ndarray):
return val.tobytes()
else:
raise NotSupportedError(f"Value hash is not supported for object {self.name}")
def dimension(self) -> int:
"""Dimension of the standardized space for this parameter
i.e size of the vector returned by get_standardized_data()
"""
if self._dimension is None:
try:
self._dimension = self.get_standardized_data().size
except NotSupportedError:
self._dimension = 0
return self._dimension