-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AnyParameterProperties tests #4414
Changes from 16 commits
9bc6414
00dcc2f
e296c3f
b1fb379
02298ad
d94653f
64668b5
462492a
1188b86
fdb2d01
28d5d6e
cd7aa44
e202eb9
5e2255d
896f0a8
caf1798
722e46c
b601b90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -691,3 +691,67 @@ TEST(Any, lazy_cloneable_visitable) | |
EXPECT_FALSE(any.visitable()); | ||
EXPECT_THROW(any.visit(nullptr), std::logic_error); | ||
} | ||
|
||
TEST(AnyParameterProperties, old_api_default) | ||
{ | ||
AnyParameterProperties params = AnyParameterProperties(); | ||
|
||
EXPECT_EQ( | ||
params.get_model_selection(), | ||
EModelSelectionAvailability::MS_NOT_AVAILABLE); | ||
EXPECT_EQ( | ||
params.get_gradient(), EGradientAvailability::GRADIENT_NOT_AVAILABLE); | ||
EXPECT_FALSE(params.get_model()); | ||
} | ||
|
||
TEST(AnyParameterProperties, new_api_default) | ||
{ | ||
AnyParameterProperties params = AnyParameterProperties(); | ||
|
||
EXPECT_FALSE(params.has_property(ParameterProperties::MODEL)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As said, putting them explicitly means we have to update the test when new properties arrive. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For that we would need a method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue is that if you do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I can add a method with something like:
|
||
EXPECT_FALSE(params.has_property(ParameterProperties::GRADIENT)); | ||
EXPECT_FALSE(params.has_property(ParameterProperties::HYPER)); | ||
} | ||
|
||
TEST(AnyParameterProperties, old_custom_ctor) | ||
{ | ||
AnyParameterProperties params = AnyParameterProperties( | ||
"test", EModelSelectionAvailability::MS_NOT_AVAILABLE, | ||
EGradientAvailability::GRADIENT_AVAILABLE, true); | ||
|
||
EXPECT_EQ(params.get_description(), "test"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep here we can/should test |
||
EXPECT_EQ( | ||
params.get_model_selection(), | ||
EModelSelectionAvailability::MS_NOT_AVAILABLE); | ||
EXPECT_EQ(params.get_gradient(), EGradientAvailability::GRADIENT_AVAILABLE); | ||
EXPECT_TRUE(params.get_model()); | ||
|
||
EXPECT_TRUE(params.has_property( | ||
ParameterProperties::MODEL | ParameterProperties::GRADIENT)); | ||
EXPECT_FALSE(params.has_property( | ||
ParameterProperties::HYPER & ParameterProperties::GRADIENT)); | ||
EXPECT_TRUE(params.has_property( | ||
~ParameterProperties::HYPER & ParameterProperties::GRADIENT)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this doesnt make sense. You cannot check that a property is not set using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup, I found it a bit odd when I wrote it. It seems unnecessarily convoluted... |
||
EXPECT_FALSE(params.has_property(ParameterProperties::HYPER)); | ||
} | ||
|
||
TEST(AnyParameterProperties, new_custom_ctor) | ||
{ | ||
AnyParameterProperties params = AnyParameterProperties( | ||
"test", ParameterProperties::MODEL | ParameterProperties::GRADIENT); | ||
|
||
EXPECT_EQ(params.get_description(), "test"); | ||
EXPECT_EQ( | ||
params.get_model_selection(), | ||
EModelSelectionAvailability::MS_NOT_AVAILABLE); | ||
EXPECT_EQ(params.get_gradient(), EGradientAvailability::GRADIENT_AVAILABLE); | ||
EXPECT_TRUE(params.get_model()); | ||
|
||
EXPECT_TRUE(params.has_property( | ||
ParameterProperties::MODEL | ParameterProperties::GRADIENT)); | ||
EXPECT_FALSE(params.has_property( | ||
ParameterProperties::HYPER & ParameterProperties::GRADIENT)); | ||
EXPECT_TRUE(params.has_property( | ||
~ParameterProperties::HYPER & ParameterProperties::GRADIENT)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above |
||
EXPECT_FALSE(params.has_property(ParameterProperties::HYPER)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get model is not part of the old API or? Just realising this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't, but the constructor of the old API still sets the ParameterProperties::MODEL bit, so I just thought it would be appropriate to add this check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be covered in the test below where we check that nothing is set after construction.
The old api test is more to make sure we didnt change the behaviour of the code, so remove it here.