diff --git a/CHANGELOG.md b/CHANGELOG.md index f7c5cd63..7348f6a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Optional multi-core/GPU support for statistics calculation in `create_parameter_weights.py` +- Argument Parser updated to use action="store_true" instead of 0/1 for boolean arguments. + (https://github.com/mllam/neural-lam/pull/72) + @ErikLarssonDev + +- Optional multi-core/GPU support for statistics calculation in `create_parameter_weights.py` [\#22](https://github.com/mllam/neural-lam/pull/22) @sadamov diff --git a/README.md b/README.md index 7dc6c7ab..41b03219 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ Run `python -m neural_lam.create_mesh` with suitable options to generate the gra The graphs used for the different models in the [paper](https://arxiv.org/abs/2309.17370) can be created as: * **GC-LAM**: `python -m neural_lam.create_mesh --graph multiscale` -* **Hi-LAM**: `python -m neural_lam.create_mesh --graph hierarchical --hierarchical 1` (also works for Hi-LAM-Parallel) +* **Hi-LAM**: `python -m neural_lam.create_mesh --graph hierarchical --hierarchical` (also works for Hi-LAM-Parallel) * **L1-LAM**: `python -m neural_lam.create_mesh --graph 1level --levels 1` The graph-related files are stored in a directory called `graphs`. diff --git a/neural_lam/create_mesh.py b/neural_lam/create_mesh.py index 40f7ba0e..21b8bf6e 100644 --- a/neural_lam/create_mesh.py +++ b/neural_lam/create_mesh.py @@ -169,10 +169,9 @@ def main(input_args=None): ) parser.add_argument( "--plot", - type=int, - default=0, + action="store_true", help="If graphs should be plotted during generation " - "(default: 0 (false))", + "(default: False)", ) parser.add_argument( "--levels", @@ -182,9 +181,8 @@ def main(input_args=None): ) parser.add_argument( "--hierarchical", - type=int, - default=0, - help="Generate hierarchical mesh graph (default: 0, no)", + action="store_true", + help="Generate hierarchical mesh graph (default: False)", ) args = parser.parse_args(input_args) diff --git a/neural_lam/create_parameter_weights.py b/neural_lam/create_parameter_weights.py index 74058d38..4867e609 100644 --- a/neural_lam/create_parameter_weights.py +++ b/neural_lam/create_parameter_weights.py @@ -156,9 +156,8 @@ def main(): ) parser.add_argument( "--distributed", - type=int, - default=0, - help="Run the script in distributed mode (1) or not (0) (default: 0)", + action="store_true", + help="Run the script in distributed mode (default: False)", ) args = parser.parse_args() distributed = bool(args.distributed) diff --git a/neural_lam/train_model.py b/neural_lam/train_model.py index 39f7aecd..c1a6cb89 100644 --- a/neural_lam/train_model.py +++ b/neural_lam/train_model.py @@ -41,10 +41,9 @@ def main(input_args=None): ) parser.add_argument( "--subset_ds", - type=int, - default=0, + action="store_true", help="Use only a small subset of the dataset, for debugging" - "(default: 0=false)", + "(default: false)", ) parser.add_argument( "--seed", type=int, default=42, help="random seed (default: 42)" @@ -71,10 +70,9 @@ def main(input_args=None): ) parser.add_argument( "--restore_opt", - type=int, - default=0, + action="store_true", help="If optimizer state should be restored with model " - "(default: 0 (false))", + "(default: false)", ) parser.add_argument( "--precision", @@ -118,11 +116,10 @@ def main(input_args=None): ) parser.add_argument( "--output_std", - type=int, - default=0, + action="store_true", help="If models should additionally output std.-dev. per " "output dimensions " - "(default: 0 (no))", + "(default: False (no))", ) # Training options @@ -135,10 +132,9 @@ def main(input_args=None): ) parser.add_argument( "--control_only", - type=int, - default=0, + action="store_true", help="Train only on control member of ensemble data " - "(default: 0 (False))", + "(default: False)", ) parser.add_argument( "--loss", @@ -233,7 +229,7 @@ def main(input_args=None): pred_length=args.ar_steps, split="train", subsample_step=args.step_length, - subset=bool(args.subset_ds), + subset=args.subset_ds, control_only=args.control_only, ), args.batch_size, @@ -247,7 +243,7 @@ def main(input_args=None): pred_length=max_pred_length, split="val", subsample_step=args.step_length, - subset=bool(args.subset_ds), + subset=args.subset_ds, control_only=args.control_only, ), args.batch_size, @@ -313,7 +309,7 @@ def main(input_args=None): pred_length=max_pred_length, split="test", subsample_step=args.step_length, - subset=bool(args.subset_ds), + subset=args.subset_ds, ), args.batch_size, shuffle=False, diff --git a/plot_graph.py b/plot_graph.py index 90462194..e47e62c0 100644 --- a/plot_graph.py +++ b/plot_graph.py @@ -38,9 +38,8 @@ def main(): ) parser.add_argument( "--show_axis", - type=int, - default=0, - help="If the axis should be displayed (default: 0 (No))", + action="store_true", + help="If the axis should be displayed (default: False)", ) args = parser.parse_args() diff --git a/tests/test_mllam_dataset.py b/tests/test_mllam_dataset.py index e12a57ae..5c8b7aa1 100644 --- a/tests/test_mllam_dataset.py +++ b/tests/test_mllam_dataset.py @@ -118,7 +118,7 @@ def test_load_reduced_meps_dataset(meps_example_reduced_filepath): def test_create_graph_reduced_meps_dataset(): args = [ "--graph=hierarchical", - "--hierarchical=1", + "--hierarchical", "--data_config=data/meps_example_reduced/data_config.yaml", "--levels=2", ]