From f924e5b6bb565091f135e74145fd21e8694cab6d Mon Sep 17 00:00:00 2001 From: Victor MORAND Date: Tue, 29 Apr 2025 18:18:21 +0200 Subject: [PATCH 1/3] example on default value --- docs/experiments/config.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/experiments/config.md b/docs/experiments/config.md index 205b0ea4..b6fa7879 100644 --- a/docs/experiments/config.md +++ b/docs/experiments/config.md @@ -217,6 +217,33 @@ class MyConfig(Config): - `type` is the type of the argument (more details below) - `value` default value of the argument (if any). _If the value equals to the default, the argument will not be included in the signature computation_. This allows to add new parameters without changing the signature of past experiments (if the configuration is equivalent with the default value of course, otherwise do not use a default value!). +### Default Values + +Adding a new parameter to a `Config` with a default value will not change the original `id`. + +For instance, if the original class is: + +```python +class myConfig(Config): + a: Param[int] + +obj = myConfig(a = 2) +id_old = obj.id +``` + +Then when using the deflaut value for parameter b will yield an object with the same identifier. +```python +class myConfig(Config): + a: Param[int] + b: Param[int] = 4 + +obj = myConfig(a = 2) +new_id = obj.id + +>>> new_id == old_id +>>> True +``` + ### Constants Constants are special parameters that cannot be modified. They are useful to note that the From f8025f0e8e29826abc7f9011f2c33bb6f6d83c09 Mon Sep 17 00:00:00 2001 From: Victor MORAND Date: Wed, 30 Apr 2025 09:27:59 +0200 Subject: [PATCH 2/3] fix identifier --- docs/experiments/config.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/experiments/config.md b/docs/experiments/config.md index b6fa7879..0acae084 100644 --- a/docs/experiments/config.md +++ b/docs/experiments/config.md @@ -228,7 +228,7 @@ class myConfig(Config): a: Param[int] obj = myConfig(a = 2) -id_old = obj.id +id_old = obj.identifier() ``` Then when using the deflaut value for parameter b will yield an object with the same identifier. @@ -238,7 +238,7 @@ class myConfig(Config): b: Param[int] = 4 obj = myConfig(a = 2) -new_id = obj.id +new_id = obj.identifier() >>> new_id == old_id >>> True From e40d7e3f5d82225bed3d36b45835f7aa616ed251 Mon Sep 17 00:00:00 2001 From: Benjamin Piwowarski Date: Wed, 30 Apr 2025 09:53:33 +0200 Subject: [PATCH 3/3] Update config.md Use `__identifier__` method --- docs/experiments/config.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/experiments/config.md b/docs/experiments/config.md index 0acae084..49c4fff2 100644 --- a/docs/experiments/config.md +++ b/docs/experiments/config.md @@ -224,21 +224,21 @@ Adding a new parameter to a `Config` with a default value will not change the or For instance, if the original class is: ```python -class myConfig(Config): +class MyConfig(Config): a: Param[int] -obj = myConfig(a = 2) -id_old = obj.identifier() +obj = MyConfig(a = 2) +id_old = obj.__identifier__() ``` -Then when using the deflaut value for parameter b will yield an object with the same identifier. +Then when using the default value for parameter b will yield an object with the same identifier. ```python class myConfig(Config): a: Param[int] b: Param[int] = 4 obj = myConfig(a = 2) -new_id = obj.identifier() +new_id = obj.__identifier__() >>> new_id == old_id >>> True