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
Pu/typing #590
Conversation
This pull request introduces 1 alert when merging bcf1d7f into 074831e - view on LGTM.com new alerts:
|
Codecov Report
@@ Coverage Diff @@
## develop #590 +/- ##
===========================================
- Coverage 92.70% 92.50% -0.20%
===========================================
Files 162 163 +1
Lines 37840 38342 +502
Branches 5256 5314 +58
===========================================
+ Hits 35078 35468 +390
- Misses 2756 2868 +112
Partials 6 6
|
This pull request introduces 1 alert when merging 8f481a3 into 074831e - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 3767279 into 074831e - view on LGTM.com new alerts:
|
@izulin what about is this PR? |
This pull request introduces 3 alerts when merging 782a2cf into 6870a3a - view on LGTM.com new alerts:
|
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.
Sorry for the late review
- Have you checked how types are affecting our benchmarks?
- We call
getRawValue
a lot. Isn't there a single place to do that?
I will test some more later
src/Config.ts
Outdated
/** | ||
* Symbol used to denote currency numbers. | ||
* | ||
* @default '$' | ||
* | ||
* @category Number | ||
*/ | ||
currencySymbol: string, |
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.
Isn't this an oversimplification? Each cell can have a different currency, especially with currency conversion functions. I'm not sure a single symbol is enough. We should have something similar to parseDate callback but with row/column so each cell can be parsed differently? I think we've discussed this before #314
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.
GS accepts only one currency symbol at a given moment in the whole spreadsheet.
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.
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, I see. What do you propose then?
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.
This is tricky. Currency is different than Date (which is parsed from a string / on the editor entry). As we did it, parsing "$20" to currency from string, is different than what GS or XL does. They store some kind of metadata with the format. Value is the formula bar is unchanged numeric:
And entered "$20" is a string. We will have incompatibility here with all the spreadsheets if we keep parsing it to CurrencyType. What we're tracking here is the number formatting, ie. date can have two different formats and they are still passed through the formula:
What you did is great to track the Type and set the correct cell editor (number/date/text) in the Handsontable, that is what @jansiegel asked for.
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.
Internally should be doable. We can save the format on CurrenctyType and DateType as an object property. And when the type is requested with API both will be available (DateType and DateType.format). This is rather an extension of what we have here.
The problem is how to set the Type and/or Format. Because all we've got is an array of simple types and no metadata: ['1', '1%', '1$', '01/01/1900', '12:00', '01/01/1900 12:00']
. Guess our problem is how to get/set formats from that input. Where:
1
is NumericType1%
is PercentType1$
is StringType (for all spreadsheets 💣 )01/01/1900
is DateType, but...01 01 1900
,01 Jan 1900
,01 January 1900
and others are also recognized 🙈
so there is no automatic recognition of the CurrencyType. It's a number with formatting. But take a look at the date type, it's a DateType with different formatting. I guess number, format is also tracked. Try setting scientific at A1 and then add other formats to it =A1+B1
etc. The first cell (in the formula) format is applied to the result.
Excel has a lot more info, and the CELL function is proof of that: https://support.microsoft.com/en-us/office/cell-function-51bd39a5-f338-4dbe-a33f-955d67c2b2cf with all the properties you can request for a cell.
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.
Discussed and resolved in #599.
/** | ||
* Argument should be passed with full type information. | ||
* (e.g. Date/DateTime/Time/Currency/Percentage for numbers) | ||
*/ | ||
passSubtype?: boolean, |
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.
Do we have to mark it in function metadata? If we know that the argument has a returnNumberType
set, we may assume that it should be passed as a full type?
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.
If we know that the argument has a returnNumberType set, we may assume that it should be passed as a full type?
Not really. Most functions ignore input types. Some functions (usualy logical ones) use the type, e.g. IF etc.
Some other function set output type (e.g. financial).
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.
So shouldn't this be up to the function to decide?
I believe it already does but based on some metadata to the Core, which may be confusing and adds to the complexity of custom functions
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.
So shouldn't this be up to the function to decide?
Why not keep it in metadata, since it is a pretty automatic decision (you either want raw data, or rich data).
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.
I don't have better arguments. Metadata is fine.
Co-authored-by: Wojciech Czerniak <wojciech.czerniak@gmail.com>
@voodoo11 benchmarked
Not to my knowledge.
|
Co-authored-by: Wojciech Czerniak <wojciech.czerniak@gmail.com>
Co-authored-by: Wojciech Czerniak <wojciech.czerniak@gmail.com>
This pull request introduces 3 alerts when merging 6c73576 into 6870a3a - view on LGTM.com new alerts:
|
This pull request introduces 3 alerts when merging 90091b5 into 6870a3a - view on LGTM.com new alerts:
|
This pull request introduces 3 alerts when merging 06fe4d8 into 6870a3a - view on LGTM.com new alerts:
|
And what are the results, any difference?
Ok |
Evaluation slowed down by 20% average, but overall build time increased only by 5% at most. |
We can also change Known limitations file as (btw also complex numbers are now supported :) ) |
* config * extra val * passes tests * linter * refactor * linter * docs * exports * Update src/HyperFormula.ts Co-authored-by: Wojciech Czerniak <wojciech.czerniak@gmail.com> * docs * Update src/HyperFormula.ts Co-authored-by: Wojciech Czerniak <wojciech.czerniak@gmail.com> * refactor * . * bug * linter Co-authored-by: Wojciech Czerniak <wojciech.czerniak@gmail.com>
This pull request introduces 6 alerts when merging bdc742d into 4c318ea - view on LGTM.com new alerts:
|
This pull request introduces 3 alerts when merging 625abcd into 4c318ea - view on LGTM.com new alerts:
|
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.
Cool! I think we're good here 🏆 The documentation could be improved though:
- Here: https://handsontable.github.io/hyperformula/guide/types-of-values.html we should add Currency and Percent types to the list, and after sections about
getCellType
andgetCellValueType
we should add two sections for the new methods:getCellValueFormat
andgetCellValueDetailedType
- the new
returnNumberType
andpassSubtype
properties should have a mention on https://handsontable.github.io/hyperformula/guide/custom-functions.html page
CHANGELOG.md
Outdated
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
|
|||
### Added | |||
- Added support for row and column reordering. (#343) | |||
- Added type inferrence for subtypes for number. (#313) | |||
- Added parsing of number literals containing '%' or currency symbol (default '$'). |
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.
Please add the issue/PR number
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.
done
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.
we're not really explaining many aspects of metadata, e.g. automatic coercions of arguments. The missing part is part of runFunction
wrapper, which is not mandatory for usage. The same for returnNumberType
and passSubtype
-- those are from runFunction
wrapper.
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.
Yup. We have an issue #557 to update the docs after the runFunction
was introduced
This pull request introduces 3 alerts when merging 2198e1d into 8befe02 - view on LGTM.com new alerts:
|
Context
Related with #313
How has this been tested?
Types of changes
Related issue(s):
Checklist: