Skip to content

Commit

Permalink
Corrected doc for gamma_reg, added docstring to call method in argpar…
Browse files Browse the repository at this point in the history
…ser and specified input types
  • Loading branch information
Matteo Wohlrapp committed Jul 2, 2024
1 parent 570e8a8 commit 1198eeb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/doc_usage_cmd.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ To run DomainLab, the minimum necessary parameters are:
```yaml
gamma_reg:
dann: 0.05
diva: 0.2
dial: 0.2
default: 0.1 # value for every other instance
```
Gamma reg is available for the trainers, as well as the
dann and jigen model.
- **Early Stopping (`--es`):** Steps for early stopping.
- **Random Seed (`--seed`):** Seed for reproducibility.
Expand Down
16 changes: 15 additions & 1 deletion domainlab/arg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,22 @@
class ParseValuesOrKeyValuePairs(argparse.Action):
"""Class used for arg parsing where values are provided in a key value format"""

def __call__(self, parser, namespace, values, option_string=None):
def __call__(self, parser: argparse.ArgumentParser,
namespace: argparse.Namespace, values: str, option_string: str = None):
"""
Handle parsing of key value pairs, or a single value instead
Args:
parser (argparse.ArgumentParser): The ArgumentParser object.
namespace (argparse.Namespace): The namespace object to store parsed values.
values (str): The string containing key=value pairs or a single float value.
option_string (str, optional): The option string that triggered this action (unused).
Raises:
ValueError: If the values cannot be parsed to float.
"""
if "=" in values:
my_dict = {} if "=" in values:
my_dict = {}
for kv in values.split(","):
k, v = kv.split("=")
Expand Down

0 comments on commit 1198eeb

Please sign in to comment.