Skip to content

Commit 49822c8

Browse files
adding type hinting
1 parent 244fe33 commit 49822c8

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

smodels/experiment/databaseObj.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from smodels.experiment.expAuxiliaryFuncs import cleanWalk
2929
from smodels.experiment.exceptions import SModelSExperimentError as SModelSError
3030
from smodels.base.smodelsLogging import logger
31+
from typing import Union
3132
import logging
3233
os.environ["OMP_NUM_THREADS"] = "2"
3334

@@ -78,9 +79,10 @@ class Database(object):
7879
Delegates all calls to SubDatabases.
7980
"""
8081

81-
def __init__(self, base=None, force_load=None,
82-
progressbar=False, subpickle=True,
83-
combinationsmatrix=None):
82+
def __init__(self, base : Union[str,None] = None,
83+
force_load : Union[str,None] = None,
84+
progressbar : bool = False, subpickle : bool = True,
85+
combinationsmatrix : Union[dict,None] = None ):
8486
"""
8587
:param base: path to the database, or pickle file (string), or http
8688
address. If None, "official", or "official_fastlim",
@@ -128,8 +130,8 @@ def expResultList(self):
128130
lists = [x.expResultList for x in self.subs]
129131
return self.mergeLists(lists)
130132

131-
def mergeLists(self, lists):
132-
""" small function, merges lists of ERs """
133+
def mergeLists( self, lists : list ) -> list:
134+
""" small function, merges lists of expResults """
133135
D = {}
134136
for tmp in lists:
135137
for t in tmp:
@@ -144,7 +146,10 @@ def mergeLists(self, lists):
144146
return list(D.values())
145147

146148
def mergeERs(self, o1, r2):
147-
""" merge the content of exp res r1 and r2 """
149+
""" merge the content of exp res o1 and r2
150+
:param o1: other1, an experimentalResult
151+
:param r2: experimental Result 2
152+
"""
148153
r1 = copy.deepcopy(o1)
149154
r1.globalInfo = r2.globalInfo
150155
dids = [x.getID() for x in o1.datasets]
@@ -164,7 +169,7 @@ def mergeERs(self, o1, r2):
164169
r1.datasets[idx].txnameList.append(txn)
165170
return r1
166171

167-
def createBinaryFile(self, filename=None):
172+
def createBinaryFile(self, filename : Union[None,os.PathLike] = None ):
168173
""" create a pcl file from all the subs """
169174
## make sure we have a model to pickle with the database!
170175
logger.debug(f" * create {filename}")
@@ -344,8 +349,11 @@ class SubDatabase(object):
344349
SubDatabase object. Holds a list of ExpResult objects.
345350
"""
346351

347-
def __init__(self, base=None, force_load=None,
348-
progressbar=False, subpickle=True, combinationsmatrix=None):
352+
def __init__(self, base : Union[str,None] = None,
353+
force_load : Union[str,None] = None,
354+
progressbar : bool= False,
355+
subpickle : bool= True,
356+
combinationsmatrix : Union[dict,None] = None ):
349357
"""
350358
:param base: path to the database, or pickle file (string), or http
351359
address. If None, "official", or "official_fastlim",

0 commit comments

Comments
 (0)