-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
@MarkRivers @decarlof I see huge code duplication with the current inheritance scheme. For instance, we have 3 classes tomoscan2bm, tomoscan2bm_step, and tomoscan2b_stream inherited from tomoscan_pso, tomoscan_step, and tomoscan_stream, respectively. However, functionality of these inherited classes is very similar (or even just 100% copy). I suggest to employ dynamic conditional inheritance implemented like this:
class TomoscanPSO():
def __init__(self):
print(f'inheritance from class Pso')
class TomoscanSTEP():
def __init__(self):
print(f'inheritance from class Step')
class TomoscanStream():
def __init__(self):
print(f'inheritance from class Stream')
mdict = {'STEP': TomoscanSTEP,
'PSO': TomoscanPSO,
'STREAM': TomoscanStream
}
def makeclass(type):
class Tomoscan2BM(mdict[type]):
def __init__(self):
super().__init__()
print(f'class 2BM')
return Tomoscan2BM()
a = makeclass('STEP')
In this case, there will be only one class Tomoscan2BM instead of 3, variable 'type' can be taken from the command line.
Metadata
Metadata
Assignees
Labels
No labels