max choice is n-1 (#521)

close #520
This commit is contained in:
Chi Wang 2022-04-23 15:33:35 -07:00 committed by GitHub
parent 46f80dfa16
commit f301bf8d8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -369,7 +369,9 @@ def denormalize(
n = len(domain.categories)
if isinstance(value, list):
# denormalize list
choice = int(np.floor(value[-1] * n))
choice = min(
n - 1, int(np.floor(value[-1] * n))
) # max choice is n-1
config_denorm[key] = point = value[choice]
point["_choice_"] = choice
continue
@ -379,8 +381,8 @@ def denormalize(
]
else:
assert key in normalized_reference_config
if np.floor(value * n) == np.floor(
normalized_reference_config[key] * n
if min(n - 1, np.floor(value * n)) == min(
n - 1, np.floor(normalized_reference_config[key] * n)
):
config_denorm[key] = reference_config[key]
else: # ****random value each time!****

View File

@ -1 +1 @@
__version__ = "1.0.0"
__version__ = "1.0.1"