From fa271b85825375a23f791c673344703f02b9950e Mon Sep 17 00:00:00 2001 From: rahul-tuli Date: Wed, 31 Jan 2024 09:46:17 -0500 Subject: [PATCH] Fix misleading docstring Add test --- src/sparsezoo/utils/registry.py | 1 - tests/sparsezoo/utils/test_registry.py | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/sparsezoo/utils/registry.py b/src/sparsezoo/utils/registry.py index d85c83c2..d8d8bc6d 100644 --- a/src/sparsezoo/utils/registry.py +++ b/src/sparsezoo/utils/registry.py @@ -104,7 +104,6 @@ class Cifar(Dataset): @Dataset.register(alias=["cifar-10-dataset", "cifar_100_dataset"]) class Cifar(Dataset): pass - Note: aliases will NOT be standardized for lookup in the registry. # load as "cifar-dataset" cifar = Dataset.load_from_registry("cifar-dataset") diff --git a/tests/sparsezoo/utils/test_registry.py b/tests/sparsezoo/utils/test_registry.py index e22650ec..67c9a778 100644 --- a/tests/sparsezoo/utils/test_registry.py +++ b/tests/sparsezoo/utils/test_registry.py @@ -71,6 +71,16 @@ class Foo1(foo): assert {"foo1"} == set(foo.registered_names()) assert {"name-3", "name-4"} == set(foo.registered_aliases()) + def test_alias_is_standardized(self, foo): + alias = "Name_3" + expected_standardized_alias = "name-3" + + @foo.register(alias=[alias]) + class Foo1(foo): + pass + + assert {expected_standardized_alias} == set(foo.registered_aliases()) + def test_key_error_on_duplicate_alias(self, foo): # once we register an object under one alias, we can't # register it under the same alias once again