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

feat(number): add parameter fractionDigits in float #1855

Merged
merged 30 commits into from
Jan 18, 2024

Conversation

xDivisionByZerox
Copy link
Member

Fixes #1596.

Since datatype.float and datatype.number now have significant differences compared to number.float I put the legacy implementation for the datatype functions directly into that module, without referencing the new implementation of the NumberModule.
This allows us to more freely change the new APIs without having a fear of breaking something in the legacy one.

@xDivisionByZerox xDivisionByZerox added p: 1-normal Nothing urgent c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs m: number Something is referring to the number module labels Feb 17, 2023
@xDivisionByZerox xDivisionByZerox self-assigned this Feb 17, 2023
@xDivisionByZerox xDivisionByZerox changed the title refactor(datatype): legacy float implementation refactor(number): replace precision with fractionDigits in float Feb 17, 2023
@xDivisionByZerox xDivisionByZerox force-pushed the refactor/float/change-precision-to-fraction-digits branch from 8d0e3ae to cb35103 Compare February 17, 2023 13:49
@codecov
Copy link

codecov bot commented Feb 17, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d71bc47) 99.57% compared to head (0e9171c) 99.57%.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #1855      +/-   ##
==========================================
- Coverage   99.57%   99.57%   -0.01%     
==========================================
  Files        2807     2807              
  Lines      250411   250448      +37     
  Branches     1143     1149       +6     
==========================================
+ Hits       249349   249372      +23     
- Misses       1034     1048      +14     
  Partials       28       28              
Files Coverage Δ
src/modules/finance/index.ts 100.00% <100.00%> (ø)
src/modules/location/index.ts 99.20% <100.00%> (ø)
src/modules/number/index.ts 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

test/number.spec.ts Outdated Show resolved Hide resolved
test/__snapshots__/number.spec.ts.snap Outdated Show resolved Hide resolved
@xDivisionByZerox xDivisionByZerox requested a review from a team February 18, 2023 02:18
@xDivisionByZerox xDivisionByZerox marked this pull request as ready for review February 18, 2023 02:18
@xDivisionByZerox xDivisionByZerox requested a review from a team as a code owner February 18, 2023 02:18
src/modules/number/index.ts Outdated Show resolved Hide resolved
@Shinigami92
Copy link
Member

Adding the new parameter fractionDigits should have been an addition, not a replacement

Around 3 month ago, with many discussions and looking deeper into it, we finally came to the conclusion that we want to officially want to support this behavior to achieve "steps"
like 0.4 would result in 0.0, 0.4, 0.8, 1.2, ...
Using equivalent math with some logarithmic functions resulted in just painfully headaches and are not suitable for persons that are not trained in math

But as #1855 (comment) pointed to #1596 (comment) we want to XOR the parameter, so you will get a FakerError when you pass both parameters the same time as they are incompatible

@matthewmayer
Copy link
Contributor

Would it be better to make stepped values a seperate method? so faker.number.float takes {max, min, precision} and e.g. faker.number.stepped takes {max, min, step}. I feel it's trying to stuff too much into one method.

@Shinigami92
Copy link
Member

Would it be better to make stepped values a seperate method? so faker.number.float takes {max, min, precision} and e.g. faker.number.stepped takes {max, min, step}. I feel it's trying to stuff too much into one method.

I mark this for needs decision and we can discuss next meeting

@Shinigami92 Shinigami92 added the s: needs decision Needs team/maintainer decision label Feb 18, 2023
@ST-DDT
Copy link
Member

ST-DDT commented Feb 18, 2023

Would it be better to make stepped values a seperate method? so faker.number.float takes {max, min, precision} and e.g. faker.number.stepped takes {max, min, step}. I feel it's trying to stuff too much into one method.

I mark this for needs decision and we can discuss next meeting

Lets continue the discussion in the related issue to give our community the ability to input their suggestions so we can take them into consideration, when deciding this.

#1596

@ST-DDT
Copy link
Member

ST-DDT commented Feb 23, 2023

Team decision

The proposal to move the precision/step logic into a different method has been rejected.
We will keep this precision/step option in the float method's single signature and document that the parameters are mutually exclusive.

@ST-DDT
Copy link
Member

ST-DDT commented Feb 23, 2023

We will first refactor the method precision -> step.
Then continue with the fractionDigits PR.

@ST-DDT ST-DDT added s: on hold Blocked by something or frozen to avoid conflicts and removed s: needs decision Needs team/maintainer decision labels Feb 23, 2023
@ST-DDT ST-DDT requested review from Shinigami92 and a team January 14, 2024 11:47
matthewmayer
matthewmayer previously approved these changes Jan 14, 2024
src/modules/number/index.ts Outdated Show resolved Hide resolved
src/modules/number/index.ts Outdated Show resolved Hide resolved
src/modules/number/index.ts Outdated Show resolved Hide resolved
test/modules/datatype.spec.ts Outdated Show resolved Hide resolved
test/modules/datatype.spec.ts Outdated Show resolved Hide resolved
test/modules/datatype.spec.ts Outdated Show resolved Hide resolved
test/modules/number.spec.ts Outdated Show resolved Hide resolved
@ST-DDT ST-DDT dismissed stale reviews from matthewmayer and themself via e1d13a5 January 18, 2024 10:31
@ST-DDT ST-DDT self-assigned this Jan 18, 2024
@ST-DDT ST-DDT requested review from matthewmayer, Shinigami92 and a team January 18, 2024 10:44
Copy link
Contributor

@matthewmayer matthewmayer left a comment

Choose a reason for hiding this comment

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

i think the documentation to the whole method could still use an overall rewrite, but as its not really specific to this parameter change i'll do that as a seperate PR after this is merged.

@ST-DDT ST-DDT merged commit 41d8778 into next Jan 18, 2024
20 checks passed
@ST-DDT ST-DDT deleted the refactor/float/change-precision-to-fraction-digits branch January 18, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: feature Request for new feature m: number Something is referring to the number module p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug
Projects
No open projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Refactor number.float parameter precision to fractionDigits
4 participants