Skip to content

Commit

Permalink
Expose all settings via brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasZahradnik committed May 8, 2024
1 parent 034a90b commit 8a2f273
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions neuralogic/core/settings/__init__.py
Expand Up @@ -145,6 +145,15 @@ def create_proxy(self) -> SettingsProxy:
def create_disconnected_proxy(self) -> SettingsProxy:
return SettingsProxy(**self.params)

def __setitem__(self, key, value):
for proxy in self._proxies.copy():
proxy[key] = value

def __getitem__(self, item):
for proxy in self._proxies.copy():
return proxy[item]
raise ValueError("No Java background settings instance has been yet initialized")

def _update(self, parameter: str, value: Any) -> None:
if parameter not in self.params:
raise NotImplementedError
Expand Down
6 changes: 6 additions & 0 deletions neuralogic/core/settings/settings_proxy.py
Expand Up @@ -268,5 +268,11 @@ def get_transformation_function(self, transformation: Transformation):
transformation_name = str(transformation)
return self.settings_class.parseTransformation(transformation_name)

def __setitem__(self, key, value):
setattr(self.settings, key, value)

def __getitem__(self, item):
return getattr(self.settings, item)

def to_json(self) -> str:
return self.settings.exportToJson()

0 comments on commit 8a2f273

Please sign in to comment.