Skip to content

Complex numbers functions - #580

Merged
izulin merged 35 commits into
developfrom
pu/complex
Dec 8, 2020
Merged

izulin merged 35 commits into
developfrom
pu/complex

Conversation

@izulin

@izulin izulin commented Dec 2, 2020 •

Copy link
Copy Markdown
Contributor

Context

Added 26 math functions COMPLEX, IMABS, IMAGINARY, IMARGUMENT, IMCONJUGATE, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMDIV, IMEXP, IMLN, IMLOG10, IMLOG2, IMPOWER, IMPRODUCT, IMREAL, IMSEC, IMSECH, IMSIN, IMSINH, IMSQRT, IMSUB, IMSUM, IMTAN.

Also, solves #581

How has this been tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature or improvement (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Additional language file or change to the existing one (translations)

Related issue(s):

  1. Complex Number type #281
  2. ATAN2 function #581

Checklist:

  • My code follows the code style of this project,
  • My change requires a change to the documentation,
  • I described the modification in the CHANGELOG.md file.

@izulin izulin changed the title Pu/complex Complex numbers functions. Dec 2, 2020
@izulin izulin changed the title Complex numbers functions. Complex numbers functions Dec 2, 2020
Comment thread CHANGELOG.md Resolved
@izulin
izulin changed the base branch from develop to pu/numberliterals December 2, 2020 21:15
Comment thread CHANGELOG.md Resolved
@codecov

codecov Bot commented Dec 2, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #580 (ab822b5) into develop (9671de4) will increase coverage by 0.21%.
The diff coverage is 99.19%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #580      +/-   ##
===========================================
+ Coverage    92.38%   92.59%   +0.21%     
===========================================
  Files          161      162       +1     
  Lines        36293    37282     +989     
  Branches      5261     5406     +145     
===========================================
+ Hits         33528    34520     +992     
+ Misses        2758     2755       -3     
  Partials         7        7              
Impacted Files Coverage Δ
src/interpreter/plugin/FunctionPlugin.ts 84.02% <90.00%> (+0.03%) ⬆️
src/interpreter/ArithmeticHelper.ts 89.03% <94.77%> (+3.51%) ⬆️
src/error-message.ts 100.00% <100.00%> (ø)
src/i18n/languages/csCZ.ts 100.00% <100.00%> (ø)
src/i18n/languages/daDK.ts 100.00% <100.00%> (ø)
src/i18n/languages/deDE.ts 100.00% <100.00%> (ø)
src/i18n/languages/enGB.ts 100.00% <100.00%> (ø)
src/i18n/languages/esES.ts 100.00% <100.00%> (ø)
src/i18n/languages/fiFI.ts 100.00% <100.00%> (ø)
src/i18n/languages/frFR.ts 100.00% <100.00%> (ø)
... and 14 more

@wojciechczerniak wojciechczerniak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does that mean we have #281 implemented?

What will ISTEXT and ISNUMBER return for complex number?
What will happen if we add two references that have complex numbers?
What is the expected result for VALUE function?

Comment thread src/i18n/languages/daDK.ts Resolved
Comment thread test/interpreter/function-imtan.spec.ts Resolved
Comment thread CHANGELOG.md Resolved
Comment thread src/interpreter/ArithmeticHelper.ts Resolved
Comment thread src/interpreter/ArithmeticHelper.ts Resolved
if(unit !== 'i' && unit !== 'j') {
return new CellError(ErrorType.VALUE, ErrorMessage.ShouldBeIorJ)
}
return coerceComplexToString([re, im], unit)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we coerceComplexToString at this level? If we have nested functions we will coerce to string and back from string. Maybe we should coerceComplexToString only when the value is requested by getCellValue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I know its tempting, but it will be hard to do do without some ugly hacking in the engine. When we return the value from function, we need to know whether it is going to be used as a string or complex value, which depends on the 'above' function.

Base automatically changed from pu/numberliterals to develop December 3, 2020 12:52
@izulin

izulin commented Dec 3, 2020

Copy link
Copy Markdown
Contributor Author

Does that mean we have #281 implemented?

Yes.

What will ISTEXT and ISNUMBER return for complex number?

Yes, No.

What will happen if we add two references that have complex numbers?

Same thing that happens when adding two strings.

What is the expected result for VALUE function?

Error.

izulin and others added 4 commits December 3, 2020 17:04
Co-authored-by: Wojciech Czerniak <wojciech.czerniak@gmail.com>

@bardek8 bardek8 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perfect, no problems with consistency 💯

@wojciechczerniak wojciechczerniak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! 🏆

@izulin
izulin merged commit a9ee306 into develop Dec 8, 2020
@izulin
izulin deleted the pu/complex branch December 8, 2020 14:55
@izulin izulin mentioned this pull request Dec 8, 2020
@wojciechczerniak wojciechczerniak mentioned this pull request Dec 9, 2020
36 of 38 tasks
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