Skip to content
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

Align the nsecs field of the timestamps. #45

Merged
merged 1 commit into from
Dec 28, 2015

Conversation

iwanders
Copy link
Contributor

This change ensures that the nsecs field is always right aligned such that the least significant digit of the secs field aligns with the least significant digit of the secs field. This makes it easier to inspect how far into the second the time has progressed.

Before:

  stamp: 
    secs: 1450885486
    nsecs: 3398683

After:

  stamp: 
    secs: 1450885486
    nsecs:   3398683

A minor aesthetic change, but this makes it easier to look for the start of a certain second, as well as easier to read because the values of the same significance are always on the same position.

Hopefully it doesn't break anyone's scripts relying on the output; there still is always a space after the semicolon, but below the 100ms there are multiple spaces between the semicolon and the number.

@@ -121,7 +121,7 @@ def strify_message(val, indent='', time_offset=None, current_time=None, field_fi
nsec_str = '\n%snsecs: ' % indent + (format_str % val.nsecs)
return sec_str + nsec_str
else:
return '\n%ssecs: %s\n%snsecs: %s'%(indent, val.secs, indent, val.nsecs)
return '\n%ssecs: %s\n%snsecs:% 10d'%(indent, val.secs, indent, val.nsecs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this make more sense: nsecs: %9d

@iwanders
Copy link
Contributor Author

I completely agree, your suggestion more clearly explains the intent of the formatting.

@dirk-thomas
Copy link
Member

The change looks good to me now. Thanks for the PR and updating it.

Please squash the changes into a single commit before the merge.

This change ensures that the nsecs field is always right aligned such
that the least significant digit of the nsecs field aligns with the
least significant digit of the secs field. This makes it easier to
inspect how far into the second the time has progressed.

The format specification explains the intent; always one space and
aligned to the right with a minimum width of 9 characters.
@iwanders
Copy link
Contributor Author

This should be it.

@dirk-thomas
Copy link
Member

Great. Thanks.

dirk-thomas added a commit that referenced this pull request Dec 28, 2015
Align the nsecs field of the timestamps.
@dirk-thomas dirk-thomas merged commit fbc164d into ros:indigo-devel Dec 28, 2015
@iwanders
Copy link
Contributor Author

Due to our change the regression test fails (at this test: test_genpy_message.py#L568), would you like me to add a commit that introduces the spaces to fix this?

@dirk-thomas
Copy link
Member

I noticed the failing test after merging. If you could create a new PR which fixes the problem that works be great. Thanks.

@iwanders iwanders deleted the improvement_nsecs_alignment branch December 31, 2015 08:40
iwanders added a commit to iwanders/genpy that referenced this pull request Dec 31, 2015
The alignment of the nsecs field was changed in
fbc164d and merged with pull request
ros#45, this caused the regression test for the timestamp field to
fail.

This commit updates the comparison value of the regression tests to
reflect the new alignment.
iwanders added a commit to iwanders/genpy that referenced this pull request Dec 31, 2015
The alignment of the nsecs field was changed in fbc164d
and merged with pull request ros#45, this caused the regression test for
the timestamp field to fail.

This commit updates the comparison value of the regression tests to reflect
the new alignment.
iwanders added a commit to iwanders/genpy that referenced this pull request Dec 31, 2015
The alignment of the nsecs field was changed in edb9c5a
and merged with pull request ros#45, this caused the regression test for
the timestamp field to fail.

This commit updates the comparison value of the regression tests to reflect
the new alignment.
iwanders added a commit to iwanders/genpy that referenced this pull request Dec 31, 2015
The alignment of the nsecs field was changed in ros/genpy@edb9c5a
and merged with pull request ros#45, this caused the regression test for
the timestamp field to fail.

This commit updates the comparison value of the regression tests to reflect
the new alignment.
iwanders added a commit to iwanders/genpy that referenced this pull request Dec 31, 2015
The alignment of the nsecs field was changed in ros/genpy@edb9c5a
(pull request ros#45), this caused the regression test for
the timestamp field to fail.

This commit updates the comparison value of the regression tests to reflect
the new alignment.
iwanders added a commit to iwanders/genpy that referenced this pull request Dec 31, 2015
The alignment of the nsecs field was changed in ros/genpy@edb9c5a
(pull request ros#45), this caused the regression test for
the timestamp field to fail.

This commit updates the comparison value of the regression tests to reflect
the new alignment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants