in hiplot/experiment.py [0:0]
def validate(self) -> "Experiment":
"""
Makes sure that this object is valid. Raises a :class:`hiplot.ExperimentValidationError` otherwise.
Experiments with circular references, non-existent parents, or without datapoints are invalid.
"""
seen: tp.Set[str] = set()
dp_lookup: tp.Dict[str, Datapoint] = {dp.uid: dp for dp in self.datapoints}
for p in self.datapoints:
if p.uid not in seen:
seen_now: tp.Set[str] = {p.uid}
dp = p
while dp.from_uid is not None and dp.from_uid not in seen:
if dp.from_uid in seen_now:
raise ExperimentValidationCircularRef(f"Circular reference in {p} parents ({len(seen_now)}-th parent)")
seen_now.add(dp.from_uid)
if dp.from_uid not in dp_lookup:
raise ExperimentValidationMissingParent(f"Datapoint ({dp.uid}) parent ({dp.from_uid}) not found")
dp = dp_lookup[dp.from_uid]
seen |= seen_now
p.validate()
if not self.datapoints:
raise ExperimentValidationError('Not a single datapoint')
validate_colormap(self.colormap)
return self