Skip to content

Commit 83d9bc1

Browse files
committed
Rename dict-like class and add docstring
1 parent 5dcbba1 commit 83d9bc1

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

dataikuapi/dss/ml.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from ..utils import DataikuException
22
from ..utils import DataikuUTF8CSVReader
33
from ..utils import DataikuStreamedHttpUTF8CSVReader
4-
from ..utils import DSSExtendableDict
4+
from ..utils import DSSExtensibleDict
55
import json
66
import time
77
from .metrics import ComputedMetrics
@@ -722,7 +722,7 @@ def get_partial_dependencies(self):
722722
return DSSPartialDependencies(data)
723723

724724

725-
class DSSSubpopulationModality(DSSExtendableDict):
725+
class DSSSubpopulationModality(DSSExtensibleDict):
726726
"""
727727
Object to read details of a subpopulation analysis modality
728728
@@ -804,7 +804,7 @@ def contains(self, value):
804804
return value == self.value
805805

806806

807-
class DSSSubpopulationAnalysis(DSSExtendableDict):
807+
class DSSSubpopulationAnalysis(DSSExtensibleDict):
808808
"""
809809
Object to read details of a subpopulation analysis of a trained model
810810
@@ -871,7 +871,7 @@ def get_raw(self):
871871
return self.internal_dict
872872

873873

874-
class DSSSubpopulationAnalyses(DSSExtendableDict):
874+
class DSSSubpopulationAnalyses(DSSExtensibleDict):
875875
"""
876876
Object to read details of subpopulation analyses of a trained model
877877
@@ -912,7 +912,7 @@ def get_analysis(self, feature):
912912
raise ValueError("Subpopulation analysis for feature '%s' cannot be found" % feature)
913913

914914

915-
class DSSPartialDependence(DSSExtendableDict):
915+
class DSSPartialDependence(DSSExtensibleDict):
916916
"""
917917
Object to read details of partial dependence of a trained model
918918
@@ -939,7 +939,7 @@ def get_raw(self):
939939
return self.internal_dict
940940

941941

942-
class DSSPartialDependencies(DSSExtendableDict):
942+
class DSSPartialDependencies(DSSExtensibleDict):
943943
"""
944944
Object to read details of partial dependencies of a trained model
945945

dataikuapi/utils.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,16 @@ def str_to_bool(s):
9595
yield [none_if_throws(caster)(val)
9696
for (caster, val) in dku_zip_longest(casters, uncasted_tuple)]
9797

98-
class DSSExtendableDict(dict):
98+
class DSSExtensibleDict(dict):
99+
"""
100+
Utility to define dict-like objects that can be sub-classed.
101+
102+
Behaves like dict for most common operations. In particular,
103+
it is possible to update an instance of `:class:`dataikuapi.dss.ml.DSSExtensibleDict`
104+
with either a dict or another instance of `:class:`dataikuapi.dss.ml.DSSExtensibleDict`.
105+
106+
Provides an `internal_dict` dict field that is the actual holder of the data.
107+
"""
99108

100109
def __init__(self, orig_dict=None):
101110
if orig_dict is None:
@@ -149,7 +158,7 @@ def setdefault(self, key, default_value=None):
149158
return self.internal_dict.setdefault(key, default_value)
150159

151160
def update(self, *args, **kwargs):
152-
if len(args) == 1 and isinstance(args[0], DSSExtendableDict):
161+
if len(args) == 1 and isinstance(args[0], DSSExtensibleDict):
153162
self.internal_dict.update(args[0].internal_dict, **kwargs)
154163
else:
155164
self.internal_dict.update(*args, **kwargs)

0 commit comments

Comments
 (0)