-
Notifications
You must be signed in to change notification settings - Fork 370
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
Precision setting improvement #446
Precision setting improvement #446
Conversation
48bcfb5
to
72c280c
Compare
I know why it fails and will do a fix; probably by changing what "user_set_precise_times" stores. Please comment if you read the changes and agree/disagree. |
@@ -183,6 +183,7 @@ class spike_detector : public Node | |||
Buffers_ B_; | |||
|
|||
bool user_set_precise_times_; | |||
long user_set_precision_value; |
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.
user_set_precision_value
is a private member. Therefore, the name should end in a _
.
@sepehrmn I understand your goal now. Your code is mostly fine, but I would still think to structure it somewhat differently, so that almost all responsibility is placed in the First, I would add in
In
This keeps responsibilities clearer between classes. |
Thanks @heplesser ! There is a small problem with using
If "precise_times" is not set by the user but precision is explicitly set to 3 (which is also the default value), without adding another variable to the spike_detector, for this special case it would be impossible to correctly set it to the user specified value (3). Adding another variable defeats the purpose of moving the precision setting to the recording_device. i have a new solution. It works but I will double check and Clang-format it later. |
|
||
else | ||
{ | ||
device_.set_precise(true, device_.get_precision()); |
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.
Does this operation do anything? It just fetches the precision from the device and sets it again.
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 is a bit confusing. I want to change set_precise method later and add two separate methods for changing precision and precise_times in a later version. If I remove this line, if precise models exist and user has not set "precise_times", it would not be set to true.
@sepehrmn Thanks for noticing my oversight, I had not considered the case that the user explicitly sets the precision to the default value. The separation of responsibilities between is now fine. But I think the case distinctions in if ( kernel().event_delivery_manager.get_off_grid_communication()
and not device_.is_precise_times_user_set() )
{
const long precision = device_.is_precision_user_set() ? device_.get_precision : 15;
device_.set_precision(true, precision);
std::string msg = String::compose(
"Precise neuron models exist: the property precise_times "
"of the %1 with gid %2 has been set to true",
get_name(),
get_gid() ) );
if ( device_.is_precision_user_set() )
{
msg += ".";
}
else
{
msg += String::compose(", precision has been set to %1", precision);
}
LOG( M_INFO, "spike_detector::calibrate", msg);
} should suffice; it also avoids some code duplication. |
@sepehrmn It seems the checks have failed due to code-formatting problems. Could you fix those? |
@sepehrmn Good work! Now we just need a test, which would also illustrate the different cases you want to cover (users setting/not setting precise / precision before / after simulating). Ideally, the test should be written in SLI, but since it involves checking what is written to spike-detector output files, it might be easier to write the test in Python. |
@heplesser Many thanks! I added more tests to the existing SLI script to check the value of precision as this implicitly tells us the number of floating points written to file. Please let me know if this suffices. |
0bfd1e9
to
d88eef1
Compare
d88eef1
to
7790bcc
Compare
Tests are failing due to travis-ci/packer-templates#221. Please don't merge until that is resolved. I will to check how to incorporate this changes into the upcoming nestio framework. |
@sepehrmn The test looks fine. 👍 subject to all tests passing (when the Travis MPI problems will be solved). |
@jougs Could you be the second reviewer for this PR since you anyways are looking at it in connection to NEST IO? |
Two minor notes:
Despite my notes it looks also fine to me. 👍 |
Thanks! Done. |
If there are precise models and a user sets "precise_times" to true, everything goes fine. But if there are precise models and it is not set, there can be a few problems:
1st problem: The precision value set by the user is ignored and it is set to 15. NEST does give the warning message below and it prints the value set, but it does not directly point to why the specified "precision" value was ignored and how one can set it to other than 15. This pull request makes it so that the value set for precision is never ignored.
2nd problem: The default precision is 3 on recording_device, but if precise models exist and "precise times" is not set, spike_detector deviates from this and sets it to 15. It makes sense to use a higher precision for precise models as pointed out in #431 , so this pull request makes sure that unless a precision is specified by the user, it is set to 3 when there are no precise models and 15 when there are. Currently, it can use 3 even if there are precise models and this is not consistent.