Repository: deepchecks/deepchecks

Issue:
[BUG] misdirected links for custom checks display
**Describe the bug**
After adding a SingleDatasetBaseCheck custom to a suite and running it, both added links in summary table lead to the info regarding the check on the train data set.

**To Reproduce**
1. run the added python script
2. open html output
3. click the links in the summary table for OutlierDetection checks

**Expected behavior**
the check for test dataset should lead to the current location in form

script:

```
import numpy as np
import pandas as pd
from deepchecks.datasets.classification import iris
from sklearn.model_selection import train_test_split
from deepchecks.suites import full_suite
from deepchecks import SingleDatasetBaseCheck, CheckResult, Dataset, CheckRunContext, ConditionResult, ConditionCategory
from PyNomaly import loop
import io


class OutlierDetection(SingleDatasetBaseCheck):
    """Check which returns the probability of being an outlier via the LoOP method."""

    def run_logic(self, context: CheckRunContext, dataset_type: str = 'train') -> CheckResult:
        if dataset_type == 'train':
            dataset = context.train.data
        else:
            dataset = context.test.data

        m = loop.LocalOutlierProbability(dataset, extent=3, n_neighbors=20).fit()
        prob_vector = m.local_outlier_probabilities

        ## Create the check result visualization
        top_5_idx = np.argsort(prob_vector)[-5:]
        top_5_values = [prob_vector[i] for i in top_5_idx]
        dataset_outliers = dataset.iloc[top_5_idx, :]
        dataset_outliers.insert(0, 'Outlier_prob', top_5_values)
        dataset_outliers.sort_values('Outlier_prob', ascending=False, inplace=True)

        return CheckResult(prob_vector, display=[dataset_outliers])


def outliers_counter(probability_vector: np.ndarray, threshold=0.7, allowed_outliers=1):
    num_outliers = np.sum(probability_vector >= threshold)
    if num_outliers <= allowed_outliers:
        return ConditionResult(True)
    else:
        error_msg = f'Found {num_outliers} outliers in dataset'
        return ConditionResult(False, error_msg, ConditionCategory.WARN)


# Load Data
iris_df = iris.load_data(data_format='Dataframe', as_train_test=False)
label_col = 'target'
df_train, df_test = train_test_split(iris_df, stratify=iris_df[label_col], random_state=0)
ds_train = Dataset(df_train, label=label_col, cat_features=[])
ds_test = Dataset(df_test, label=label_col, cat_features=[])

check = OutlierDetection().add_condition('Number of outliers in dataset', outliers_counter)
# result = check.run(ds_train)
# print(result)
# print(result.value)

suite = full_suite()
suite.add(check=check)
suite_result = suite.run(train_dataset=ds_train, test_dataset=ds_test)
suite_result.save_as_html('my_suite.html')
html_out = io.StringIO()
suite_result.save_as_html(file=html_out)
```



Discussion:

Resolving patch:
diff --git a/deepchecks/core/check_result.py b/deepchecks/core/check_result.py
--- a/deepchecks/core/check_result.py
+++ b/deepchecks/core/check_result.py
@@ -133,8 +133,7 @@ def display_check(self, unique_id: str = None, as_widget: bool = False,
             box_children = []
         check_html = ''
         if unique_id:
-            check_id = f'{self.check.__class__.__name__}_{unique_id}'
-            check_html += f'<h4 id="{check_id}">{self.get_header()}</h4>'
+            check_html += f'<h4 id="{self.get_check_id(unique_id)}">{self.get_header()}</h4>'
         else:
             check_html += f'<h4>{self.get_header()}</h4>'
         if hasattr(self.check.__class__, '__doc__'):
@@ -370,6 +369,11 @@ def get_header(self) -> str:
         """Return header for display. if header was defined return it, else extract name of check class."""
         return self.header or self.check.name()
 
+    def get_check_id(self, unique_id: str = '') -> str:
+        """Return check id (used for href)."""
+        header = self.get_header().replace(' ', '')
+        return f'{header}_{unique_id}'
+
     def process_conditions(self) -> List[Condition]:
         """Process the conditions results from current result and check."""
         self.conditions_results = self.check.conditions_decision(self)
diff --git a/deepchecks/core/display_pandas.py b/deepchecks/core/display_pandas.py
--- a/deepchecks/core/display_pandas.py
+++ b/deepchecks/core/display_pandas.py
@@ -92,8 +92,7 @@ def get_conditions_table(check_results: Union['CheckResult', List['CheckResult']
             icon = cond_result.get_icon() if icon_html else cond_result.category.value
             check_header = check_result.get_header()
             if unique_id and check_result.have_display():
-                check_id = f'{check_result.check.__class__.__name__}_{unique_id}'
-                link = f'<a href=#{check_id}>{check_header}</a>'
+                link = f'<a href=#{check_result.get_check_id(unique_id)}>{check_header}</a>'
             else:
                 link = check_header
                 # if it has no display show on bottom for the category (lower priority)
@@ -131,8 +130,7 @@ def get_result_navigation_display(check_results: List['CheckResult'], unique_id:
     for check_result in check_results:
         if check_result.have_display():
             check_header = check_result.get_header()
-            check_id = f'{check_result.check.__class__.__name__}_{unique_id}'
-            link = f'<a href=#{check_id}>{check_header}</a>'
+            link = f'<a href=#{check_result.get_check_id(unique_id)}>{check_header}</a>'
             summary = get_docs_summary(check_result.check)
             table.append([link, summary])
 


Test patch: