MXFusion icon indicating copy to clipboard operation
MXFusion copied to clipboard

Implement "FactorGraph.get_component(str)" method

Open meissnereric opened this issue 5 years ago • 1 comments

In a few cases (namely, when building models of repeated layers), I've noticed people doing things like:

z = variables[getattr(self.model, 'inducing_inputs_' + str(layer))]

which seems a bit unsafe. A better way of accessing the components here would be to just have a getter function on the FactorGraph that returns the component of that name.

def get_component(self, name):
    ...

meissnereric avatar Apr 18 '19 18:04 meissnereric

Why it is unsafe? I think it is the python way to call self.model.inducing_inputs_str(layer) dynamically.

zhenwendai avatar May 10 '19 14:05 zhenwendai