-
Notifications
You must be signed in to change notification settings - Fork 13
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
Increase user flexibility #58
Conversation
Going forward, instead of simple True/False, function options will have "selectors" that are non-Boolean but mutually exclusive. This will give the user more flexibilty going forward. In the process, discovered some convenience functions for setting module level constants.
This was done by extending UserOptions. The new implementation does not change any existing behavior, but it is forwards-compatible with doing so.
A new options system will be used going forward to enable a cleaner API. The existing API is implemented in terms of this options system. A major change is the creation of the Resolver class which implements most of the logic that used to be in the Payload class. Additionally, some backwards-compatibility transforms have been added to adapt old-to-new APIs.
This was found online as a nice way to use enum classes as bit flags. This requires C++14.
This is in opposition to the previous method of implementing a series boolean functions. This makes getting the type use a single call. All the peculiarities of the previous logic are maintained, including the odd treatment of floats as integers additionally.
The function returns different values based on what is found, and this can be mapped to NumberFlags from there.
Logic for determining what type is what is now simpified by having the calling fucntion perform this analysis by examining the bit flags created by the evaluator's type checker. This enables lots of internal logic to be removed from evaluator. Additionally, a bunch of helper code at the top-level was able to be removed. Such a strong case for "choose your abstractions wisely".
The calling code from fastnumbers.cpp has been moved to implementation.cpp. This separates the concerns of interfacing with Python and driving the evaluation. This will make future updates more straightforward.
Files and classes have been reorganized to be more maintainable.
These setters now accept a selector, so user calling of these functions is much cleaner.
To work around old behavior, the character parser and unicode parser would say that integers are both integer and float. Going forward, we want to be able to toggle that behavior, so the logic to make that decision has been moved higher, into the "implementation" file.
All C++ exceptions will be caught and converted to a SystemError so that at the very least users will be able to know where the issue is coming from.
These replace the is* functions with a simpler API. - Implement functions in C - Add to type hints - Update tests to use check_* functions instead of is* - Add tests to validate equivalence from check_* to is* - Update README to use new functions - Update docstrings - Update changelog
These replace the fast_* functions with more flexible API. - Implement functions in C - Add to type hints - Update tests to use try_* functions instead of fast_* - Add tests to validate equivalence from try_* to fast_* - Update README to use new functions - Update docstrings - Update changelog
Codecov ReportBase: 97.59% // Head: 92.50% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #58 +/- ##
==========================================
- Coverage 97.59% 92.50% -5.09%
==========================================
Files 4 5 +1
Lines 665 934 +269
==========================================
+ Hits 649 864 +215
- Misses 16 70 +54
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
7e7052f
to
b7efb70
Compare
This will close issues #37, #39, and #40.
This change introduces a new suite of functions with more flexible APIs than the older functions.
fast_real
->try_real
fast_float
->try_float
fast_int
->try_int
fast_forceint
->try_forceint
isreal
->check_real
isfloat
->check_float
isint
->check_int
isintlike
->check_intlike
The older functions remain (and will never be deleted), but have documentation that reflects that the newer are preferred. These newer names better reflect the intent behind the functions.
Internally, the top-level code has been modularized to separate the concerns of options parsing and actually driving the functionality - this helped to provide basically two interfaces for each functionality and will help with future planned performance improvements.
Additionally, internal type checking has been simplified by shifting where abstraction occurs.