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
Read only property #4549
Read only property #4549
Conversation
We can't call the enum field |
Should a constant parameter be |
src/shogun/base/AnyParameter.h
Outdated
@@ -37,7 +37,8 @@ namespace shogun | |||
HYPER = 1u << 0, | |||
GRADIENT = 1u << 1, | |||
MODEL = 1u << 2, | |||
AUTO = 1u << 10 | |||
AUTO = 1u << 10, | |||
CONST = 1u << 11 |
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.
READ_ONLY
might be a better name to avoid clashes
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.
yup, I didn't realise that it could clash with C++ keywords...
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.
Yes!
This error should pop up in a few meta examples now
I think always read only, never put able. And then we try to use factories.... let’s see if that approach works at least. Can you mark feature matrix of dense feats also read only? |
So should the kernel ,for example, only be initialised with |
Exactly! That’s the the point |
@@ -11,7 +11,8 @@ Labels labels_test = labels(f_labels_test) | |||
#![create_features] | |||
|
|||
#![create_appropriate_kernel_and_mean_function] | |||
Kernel k = kernel("GaussianKernel", lhs=features_train, rhs=features_train, log_width=0.0) | |||
Kernel k = kernel("GaussianKernel", log_width=0.0) |
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.
yes!
@@ -922,7 +922,8 @@ void CKernel::register_params() { | |||
"Cache size in MB."); | |||
|
|||
SG_ADD( | |||
&lhs, "lhs", "Feature vectors to occur on left hand side."); | |||
&lhs, "lhs", "Feature vectors to occur on left hand side.", | |||
ParameterProperties::READONLY); |
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.
rhs should also be read-only
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.
add rhs
and then we can merge this.
example implementation renamed const to readonly t t
3b7a658
to
fa82eb3
Compare
@karlnapf i'm just wondering in case of DenseFeatures the |
Unfortunately no. It was my preferred solution as well but the any framework makes the compiler freak out if we do that (e.g clone, put) and then when I talked to @lisitsyn and he had some other reasons why not to do that. This pr here is the result of our discussion |
@vigsterkr I am just afraid adding constness would make things more complex. It could make sense in pure C++ but since we pass the runtime boundary in the interfaces it might be not that good. |
Ah and this also nearly doubles the amount of generated template code. |
SG_ADD( | ||
&rhs, "rhs", "Feature vectors to occur on right hand side.", | ||
ParameterProperties::READONLY); | ||
SG_ADD(&lhs_equals_rhs, "lhs_equals_rhs", |
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.
also readonly!
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.
Fine to merge from my side!
CI problems? |
* example implementation * replaced put with init in kernel
@karlnapf Is this what you had in mind?