From c2183b4850add0c0f7e0a25ad3ad5e70aeea821e Mon Sep 17 00:00:00 2001 From: Ari Hartikainen Date: Mon, 17 Jun 2024 10:54:05 +0300 Subject: [PATCH 1/4] parse str bool values --- arviz/data/io_cmdstan.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arviz/data/io_cmdstan.py b/arviz/data/io_cmdstan.py index a744cba9ed..643a735e96 100644 --- a/arviz/data/io_cmdstan.py +++ b/arviz/data/io_cmdstan.py @@ -738,6 +738,7 @@ def _process_configuration(comments): elif "=" in comment: match_int = re.search(r"^(\S+)\s*=\s*([-+]?[0-9]+)$", comment) match_float = re.search(r"^(\S+)\s*=\s*([-+]?[0-9]+\.[0-9]+)$", comment) + match_str_bool = re.search(r"^(\S+)\s*=\s*(true|false)$", comment) match_str = re.search(r"^(\S+)\s*=\s*(\S+)$", comment) match_empty = re.search(r"^(\S+)\s*=\s*$", comment) if match_int: @@ -746,6 +747,9 @@ def _process_configuration(comments): elif match_float: key, value = match_float.group(1), match_float.group(2) results[key] = float(value) + elif match_str_bool: + key, value = match_str_bool.group(1), match_str_bool(2) + results[key] = value == "true" elif match_str: key, value = match_str.group(1), match_str.group(2) results[key] = value @@ -800,7 +804,7 @@ def _read_output(path): # split dataframe to warmup and draws saved_warmup = ( - int(pconf.get("save_warmup", 0)) + int(pconf.get("save_warmup", False)) * int(pconf.get("num_warmup", 0)) // int(pconf.get("thin", 1)) ) From ad065d985467cce1756d4f7645a7b8e82ce5507e Mon Sep 17 00:00:00 2001 From: Ari Hartikainen Date: Mon, 17 Jun 2024 10:56:15 +0300 Subject: [PATCH 2/4] Revert bool to default int --- arviz/data/io_cmdstan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arviz/data/io_cmdstan.py b/arviz/data/io_cmdstan.py index 643a735e96..f587159a43 100644 --- a/arviz/data/io_cmdstan.py +++ b/arviz/data/io_cmdstan.py @@ -804,7 +804,7 @@ def _read_output(path): # split dataframe to warmup and draws saved_warmup = ( - int(pconf.get("save_warmup", False)) + int(pconf.get("save_warmup", 0)) * int(pconf.get("num_warmup", 0)) // int(pconf.get("thin", 1)) ) From 78c496059ba6417134ddd8203be79107526b5d3c Mon Sep 17 00:00:00 2001 From: Ari Hartikainen Date: Tue, 18 Jun 2024 12:51:46 +0300 Subject: [PATCH 3/4] Fix re access --- arviz/data/io_cmdstan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arviz/data/io_cmdstan.py b/arviz/data/io_cmdstan.py index f587159a43..0c6951de61 100644 --- a/arviz/data/io_cmdstan.py +++ b/arviz/data/io_cmdstan.py @@ -748,7 +748,7 @@ def _process_configuration(comments): key, value = match_float.group(1), match_float.group(2) results[key] = float(value) elif match_str_bool: - key, value = match_str_bool.group(1), match_str_bool(2) + key, value = match_str_bool.group(1), match_str_bool.group(2) results[key] = value == "true" elif match_str: key, value = match_str.group(1), match_str.group(2) From 53d0a37d20a9ffac035f49e5ad48c06e620fb5b3 Mon Sep 17 00:00:00 2001 From: Ari Hartikainen Date: Tue, 18 Jun 2024 12:53:14 +0300 Subject: [PATCH 4/4] Transform bool to int --- arviz/data/io_cmdstan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arviz/data/io_cmdstan.py b/arviz/data/io_cmdstan.py index 0c6951de61..b8e256632f 100644 --- a/arviz/data/io_cmdstan.py +++ b/arviz/data/io_cmdstan.py @@ -749,7 +749,7 @@ def _process_configuration(comments): results[key] = float(value) elif match_str_bool: key, value = match_str_bool.group(1), match_str_bool.group(2) - results[key] = value == "true" + results[key] = int(value == "true") elif match_str: key, value = match_str.group(1), match_str.group(2) results[key] = value