Skip to content

Commit 645223c

Browse files
authored
Make build_multi_table_dictionary_domain private by convention (#396)
Eliminate the eponymous public (by convention) function, deprecated in v10. Partial backport of the relevant v10 change c942f3f.
1 parent 34bf8a8 commit 645223c

File tree

4 files changed

+21
-35
lines changed

4 files changed

+21
-35
lines changed

khiops/core/helpers.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@
2222
from khiops.core.internals.runner import get_runner
2323

2424

25-
def build_multi_table_dictionary_domain(
25+
def _build_multi_table_dictionary_domain(
2626
dictionary_domain, root_dictionary_name, secondary_table_variable_name
2727
):
2828
"""Builds a multi-table dictionary domain from a dictionary with a key
29-
3029
Parameters
3130
----------
3231
dictionary_domain : `.DictionaryDomain`
@@ -36,6 +35,11 @@ def build_multi_table_dictionary_domain(
3635
secondary_table_variable_name : str
3736
Name, in the root dictionary, for the "table" variable of the secondary table.
3837
38+
Returns
39+
-------
40+
`.DictionaryDomain`
41+
The new dictionary domain
42+
3943
Raises
4044
------
4145
`TypeError`
@@ -45,6 +49,16 @@ def build_multi_table_dictionary_domain(
4549
- the dictionary domain doesn't contain at least a dictionary
4650
- the dictionary domain's root dictionary doesn't have a key set
4751
"""
52+
53+
# This is a special-purpose function whose goal is to assist in preparing the
54+
# coclustering deployment.
55+
# This function builds a new root dictionary and adds it to an existing dictionary
56+
# domain.
57+
# The new root dictionary only contains one field, which references a preexisting
58+
# dictionary from the input dictionary domain as a new (secondary) Table variable.
59+
# The preexisting dictionary must have a key set on it, as this is the join key
60+
# with the new root table.
61+
4862
# Check that `dictionary_domain` is a `DictionaryDomain`
4963
if not isinstance(dictionary_domain, DictionaryDomain):
5064
raise TypeError(
@@ -279,7 +293,7 @@ def deploy_coclustering(
279293
# Create a root dictionary containing the keys
280294
root_dictionary_name = "CC_" + dictionary_name
281295
table_variable_name = "Table_" + dictionary_name
282-
domain = build_multi_table_dictionary_domain(
296+
domain = _build_multi_table_dictionary_domain(
283297
tmp_domain, root_dictionary_name, table_variable_name
284298
)
285299

khiops/sklearn/estimators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import khiops.core as kh
4545
import khiops.core.internals.filesystems as fs
4646
from khiops.core.dictionary import DictionaryDomain
47-
from khiops.core.helpers import build_multi_table_dictionary_domain
47+
from khiops.core.helpers import _build_multi_table_dictionary_domain
4848
from khiops.core.internals.common import is_dict_like, is_list_like, type_error_message
4949
from khiops.sklearn.dataset import (
5050
Dataset,
@@ -862,7 +862,7 @@ def _create_coclustering_model_domain(
862862
assert isinstance(output_dir, str)
863863

864864
# Build multi-table dictionary domain out of the input domain
865-
mt_domain = build_multi_table_dictionary_domain(
865+
mt_domain = _build_multi_table_dictionary_domain(
866866
domain,
867867
self.model_main_dictionary_name_,
868868
self.model_secondary_table_variable_name,

tests/test_core.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from khiops.core.internals.runner import KhiopsLocalRunner, KhiopsRunner
2424
from khiops.core.internals.scenario import ConfigurableKhiopsScenario
2525
from khiops.core.internals.version import KhiopsVersion
26-
from tests.test_helper import KhiopsTestHelper
2726

2827
# Disable warning about access to protected member: These are tests
2928
# pylint: disable=protected-access
@@ -2434,33 +2433,6 @@ def test_invalid_versions(self):
24342433
with self.assertRaises(ValueError):
24352434
KhiopsVersion(version)
24362435

2437-
@staticmethod
2438-
def _build_multi_table_dictionary_args():
2439-
resources_directory = KhiopsTestHelper.get_resources_dir()
2440-
dictionaries_dir = os.path.join(resources_directory, "dictionary", "ref_kdic")
2441-
splice_domain = kh.read_dictionary_file(
2442-
os.path.join(dictionaries_dir, "SpliceJunction.kdic")
2443-
)
2444-
monotable_domain = kh.DictionaryDomain()
2445-
monotable_domain.add_dictionary(
2446-
splice_domain.get_dictionary("SpliceJunctionDNA")
2447-
)
2448-
output_directory = os.path.join(
2449-
resources_directory, "dictionary", "output_kdic"
2450-
)
2451-
root_dict_name = "SpliceJunction"
2452-
secondary_table_variable_name = "DNA"
2453-
multi_table_dict_out_path = os.path.join(
2454-
output_directory, "SpliceJunctionTest.kdic"
2455-
)
2456-
2457-
return {
2458-
"dictionary_file_path_or_domain": monotable_domain,
2459-
"root_dictionary_name": root_dict_name,
2460-
"secondary_table_variable_name": secondary_table_variable_name,
2461-
"output_dictionary_file_path": multi_table_dict_out_path,
2462-
}
2463-
24642436
def test_scenario_generation(self):
24652437
"""Test the scenario generation from template and arguments"""
24662438
templates = {

tests/test_helper_functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import pandas as pd
1616

1717
from khiops.core.dictionary import DictionaryDomain
18-
from khiops.core.helpers import build_multi_table_dictionary_domain, visualize_report
18+
from khiops.core.helpers import _build_multi_table_dictionary_domain, visualize_report
1919
from khiops.sklearn import train_test_split_dataset
2020

2121

@@ -78,7 +78,7 @@ def test_build_multi_table_dictionary_domain(self):
7878
ref_multi_table_domain = DictionaryDomain(ref_multi_table_domain_specification)
7979

8080
# Build multi-table dictionary domain from the montable dictionary domain
81-
multi_table_domain = build_multi_table_dictionary_domain(
81+
multi_table_domain = _build_multi_table_dictionary_domain(
8282
monotable_domain, "A_Prefix_SpliceJunctionDNA", "A_Name_SpliceJunctionDNA"
8383
)
8484

0 commit comments

Comments
 (0)