iiasa / pysquirrel

MIT License
6 stars 1 forks source link

Turn Region.parent_code into a property #18

Closed phackstock closed 3 months ago

phackstock commented 4 months ago

I would turn Region.parent_code into an property. The reason for that is that all the information to get the parent_code is already contained in the class. The property would then look like this:

@property
def parent_code(self) -> str | None:
    return self.code[:-1] if self.level > 1 else None

this would also make the _load function shorter and easier to read.

dc-almeida commented 3 months ago

Was also considering doing a forward reference, make the parent attribute the same region class and that way the functionality of parent searching is imbedded in the class itself

phackstock commented 3 months ago

Ah yes, that would be a nice idea too. I'm not sure we'd need that functionality. \ Don't let that stop you ff you want to implement it though.