zackxconti / bnmetamodel_gh

Repo for bnmetamodel lib version for Lab Mouse Grasshopper plug-in.
1 stars 2 forks source link

Refactor BN_Metamodel_easy.changeNumBinsDict to make result #53

Open kallewesterling opened 1 year ago

kallewesterling commented 1 year ago

This code does not modify the behaviour of the instance of the BN_Metamodel_easy. In fact, it does not have any effect at all, I believe.

class BN_Metamodel_easy:
    def changeNumBinsDict (dict):
        BN_Metamodel_easy.numBinsDict = dict

Suggested solution

Here, we change the instance of the class that has been instantiated. (I have also fixed the keyword argument dict so that it follows readability convention.)

class BN_Metamodel_easy:
    def changeNumBinsDict (self, bins):
        self.numBinsDict = bins

Tested

class Test:
    def __init__(self, val=1):
        self.val = val

    def change_value(self, val):
        Test.val = val

Implementation:

test = Test()
print(test.val)
test.change_value(5)
print(test.val)

test = Test()
print(test.val)

Result:

1
1
1