Skip to content

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

Merged
merged 3 commits into from
Jan 24, 2018
Merged

Conversation

baxcoders
Copy link
Contributor

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"

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"
@angularsen angularsen self-assigned this Jan 16, 2018
@angularsen angularsen self-requested a review January 16, 2018 19:31
Copy link
Owner

@angularsen angularsen left a 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);
Copy link
Owner

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.

Copy link
Contributor Author

@baxcoders baxcoders Jan 17, 2018

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;

Copy link
Owner

@angularsen angularsen Jan 17, 2018

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.

Copy link
Contributor Author

@baxcoders baxcoders Jan 22, 2018

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?

Copy link
Owner

@angularsen angularsen Jan 22, 2018

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.

@angularsen
Copy link
Owner

Thanks, I'll have to recheck all the new values then this should be good to go.

Copy link
Contributor

@0xferit 0xferit left a 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.

@angularsen angularsen merged commit d40fb8e into angularsen:master Jan 24, 2018
@baxcoders baxcoders deleted the Module_07 branch January 26, 2018 17:04
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.

3 participants