-
Notifications
You must be signed in to change notification settings - Fork 395
Added physical quantity: BitRate #383
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
Conversation
Base: BitPerSecond (bit/s, bps) + Prefixes: "Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Kibi", "Mebi", "Gibi", "Tebi", "Pebi", "Exbi" Additional: BytePerSecond (B/s) + Prefixes: "Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Kibi", "Mebi", "Gibi", "Tebi", "Pebi", "Exbi"
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.
The rest of it looks good, so please address the test case values and this should be ready to go!
|
||
protected override double ExabytesPerSecondInOneBitPerSecond => 0.125d * 1e-18d; | ||
|
||
protected override double ExbibitsPerSecondInOneBitPerSecond => 1d / Math.Pow(1024, 6); |
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.
Test cases values should not be computations but rather some constant value looked up in a reference source as a double check that we got it right. The most typical mistake is to get the function inverted by mistake both in the implementation and in the test case (by copy & paste), so using a second source of truth is a good way to mitigate that. For infinite fractions, 7 significant digits is usually plenty. We also prefer the scientific e
notation for these values.
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.
Hello, thank you for your review.
For that physical quantity we took a page from "InformationTests.cs" file where methods are expressed the same way. For instance:
protected override double ExabytesInOneBit => 0.125d*1e-18d;
protected override double ExbibitsInOneBit => 1d/Math.Pow(1024, 6);
However, we got your point and we will proceed as requested with the following modifications (these are related to the previous examples):
ExabytesPerSecondInOneBitPerSecond => 0.125d * 1e-18d;
changed to:
ExabytesPerSecondInOneBitPerSecond => 1.25E-19;
and
protected override double ExbibitsPerSecondInOneBitPerSecond => 1d / Math.Pow(1024, 6);
changed to:
protected override double ExbibitsPerSecondInOneBitPerSecond => 8.67361738E-19;
Are these formats correct?
Do we change all the others units affected by the same issue?
- ExbibitsPerSecondInOneBitPerSecond => 1d / Math.Pow(1024, 6);
- ExbibytesPerSecondInOneBitPerSecond => 8d / Math.Pow(1024, 6);
- GibibitsPerSecondInOneBitPerSecond => 1d / Math.Pow(1024, 3);
- GibibytesPerSecondInOneBitPerSecond => 1d / 8 / Math.Pow(1024, 3);
- GigabytesPerSecondInOneBitPerSecond => 0.125d * 1e-9d;
- KibibitsPerSecondInOneBitPerSecond => 1d / 1024d;
- KibibytesPerSecondInOneBitPerSecond => 1d / 8 / 1024d;
- MebibitsPerSecondInOneBitPerSecond => 1d / Math.Pow(1024, 2);
- MebibytesPerSecondInOneBitPerSecond => 1d / 8 / Math.Pow(1024, 2);
- MegabytesPerSecondInOneBitPerSecond => 0.125d * 1e-6d;
- PebibitsPerSecondInOneBitPerSecond => 1d / Math.Pow(1024, 5);
- PebibytesPerSecondInOneBitPerSecond => 1d / 8 / Math.Pow(1024, 5);
- PetabytesPerSecondInOneBitPerSecond => 0.125d * 1e-15d;
- TebibitsPerSecondInOneBitPerSecond => 1d / Math.Pow(1024, 4);
- TebibytesPerSecondInOneBitPerSecond => 1d / 8 / Math.Pow(1024, 4);
- TerabytesPerSecondInOneBitPerSecond => 0.125d * 1e-12d;
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 that looks good to me, and yes please also address all other units. If you know other PRs also have computations in the test case values, then it's good if you address those too as the same feedback would be addressed there.
We probably have some discrepancies in the code base, but have started building a contribution guideline #328 that will try to keep things more consistent moving forward.
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.
Ok, done.
We noticed a possible mistake in ExbibytesInOneBit of InformationTests.cs (and then in ExbibytesPerSecondInOneBitPerSecond of BitRateTests.cs which we've already fixed).
Actually is:
protected override double ExbibytesInOneBit => 8d/Math.Pow(1024, 6);
but it should be:
protected override double ExbibytesInOneBit => 1d/8/Math.Pow(1024, 6);
Do you agree?
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.
Good catch, this looks a mistake for sure. These values are so small (1e-18
) so they are dwarfed by the way-too-large default tolerance of 1e-5
. We are discussing #350 using relative errors instead, and this is probably a good use case for exactly that.
I pushed a fix in beadd3d. I guess ideally the tolerance values should have been updated to be more strict too, but then all values should be updated and not just the exbibytes one, so I didn't bother. Also we are probably rewriting to relative test value tolerances soon anyway and will have to revisit the values then.
Thanks, I'll have to recheck all the new values then this should be good to go. |
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.
Test values are correct.
Base unit: BitPerSecond (bit/s, bps) + Prefixes: "Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Kibi", "Mebi", "Gibi", "Tebi", "Pebi", "Exbi"
Additional unit: BytePerSecond (B/s) + Prefixes: "Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Kibi", "Mebi", "Gibi", "Tebi", "Pebi", "Exbi"