-
Notifications
You must be signed in to change notification settings - Fork 424
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
Math module - rename divceil family #19012
Comments
As all these names are essentially operators, I suggest staying away from camel casing. I have never seen the case where name than implies an operator, even if it is implemented with a routine, was written as camel cased. Some of us stay away from camel casing anything less than 8 (or even 10) letters, and especially when they are made up of 2 or 3 words/abbreviations where readability says that you cannot afford to have any one of those 2 or 3 appear to have more or less emphasis than the other. My 2c even if it does not follow the Style Rules. I actually thought that Chapel had a Style Guide but they seem to be quoted as Rules. |
Looking at other languages: Python uses Java uses I don't see either combination for Rust, but I do see an I think Julia's So it seems like there's not a consistent ordering between the two parts but that they are frequently viewed as separable either with underscores or with casing. So we're free to make our own choice here, but I do think the operator point is worth considering - I'm going to bring it up on the style guide issue.
Sorry, that's probably a communication issue on my part - it should still be considered a guide for users but in aiming for consistency with our standard modules, we're treating it as rules for things that live there. We don't want to dictate that users must write their code a certain way, but if something is going to get contributed to the standard modules in the future, we'd like to have a clear precedent to point to. |
I though it was C++ which has divceil and divfloor. Remember that there are 5 rounding modes for which IEEE 754 wants support. But languages which do more than just truncated division, most often only do floored division because that is the most common. I think that Meta has a set of templates that does all five in C++. Note that ceil and floor are verbs in English, so you ceil and floor an argument but the routines of those names then return a ceiling and floor. So ceil is technically not an abbreviation. English is so weird! Is the complete list in Chapel just divceil, divfloor, divceilpos, divfloorpos? Are you going to reserve divroundaway and divroundeven? I think divroundtrunc is covered by the operator Is these appear in an expression, using capitals in a camel case name distracts the eyes from the expression, and even more so if these are operators. Then again, I find that the amalgamation of more than two words with lowercase has me looking at camelCase. |
I thought that Python has a real floor'ed division - the operator |
Prep for an upcoming ad-hoc subteam (scheduled for the two week sprint starting August 8th) 1. What is the API being presented? /* Returns :proc:`~AutoMath.ceil`\(`m`/`n`),
i.e., the fraction `m`/`n` rounded up to the nearest integer.
If the arguments are of unsigned type, then
fewer conditionals will be evaluated at run time.
*/
proc divceil(param m: integral, param n: integral) param { … }
proc divceil(m: integral, n: integral) { … }
/* Returns :proc:`~AutoMath.floor`\(`m`/`n`),
i.e., the fraction `m`/`n` rounded down to the nearest integer.
If the arguments are of unsigned type, then
fewer conditionals will be evaluated at run time.
*/
proc divfloor(param m: integral, param n: integral) param { … }
proc divfloor(m: integral, n: integral) { … }
// And the unstable:
/*
A variant of :proc:`divceil` that performs no runtime checks.
The user must ensure that both arguments are strictly positive
(not 0) and are of a signed integer type (not `uint`).
*/
proc divceilpos(m: integral, n: integral) { … }
/*
A variant of :proc:`divfloor` that performs no runtime checks.
The user must ensure that both arguments are strictly positive
(not 0) and are of a signed integer type (not `uint`).
*/
proc divfloorpos(m: integral, n: integral) { … } How is it intended to be used?These are convenience functions for combining division and a rounding operation on that result. The unstable “pos” variants are for extra performance when certain conditions are assured (though they are unstable due to questions about their actual utility in practice). How is it being used in Arkouda and CHAMPS?None of these functions are used in Arkouda or CHAMPS 2. What's the history of the feature, if it already exists?divceil and divfloor were added in 2011, and divceil was used in some histogram tests that were previously relying doing explicit ceil calls on divisions. divceilpos and divfloorpos were originally added in a side module, UtilMath, also in 2011. This module was deleted in 2015 and the two functions merged into the Math module at that time. Documentation of the functions was added in 2015. Used to be included in all user programs by default, but we recently decided to stop doing that. 3. What's the precedent in other languages, if they support it?a. Python Searching for operators led me to NumPy has There seems to be no equivalent for the b. C/C++ Though I asserted above that C had c. Rust Rust provides There seems to be no equivalent for the d. Swift I don’t see equivalents for Swift. e. Julia Julia provides Julia also provides f. Go I don’t see equivalents in Go. 4. Are there known Github issues with the feature?
5. Are there features it is related to? What impact would changing or adding this feature have on those other features?
6. How do you propose to solve the problem?A. Leave as is
B. rename to
C. rename
D. rename to
E. rename to
F. rename to
I would probably follow B. I’m pretty against F and would rather not leave them as is. |
Am I understanding that we'll make |
They have already been marked unstable, so no additional work is needed to make them unstable |
In our discussion today, we decided to camel case all the functions. In addition to the options listed above, Jade also proposed marking these functions unstable and when we have more extensive rounding support, adding a proc div(x, y, rounding = ceil) // where ceil is an enum constant We talked a bit about if we would want this to be shared with BigInteger's handling of rounding modes. If it used the same name as the BigInteger enum today, we could move that enum to Math and re-export it from BigInteger to avoid making it a breaking change. But doing so would force us to support all rounding modes for BigInteger as well, which would likely mean implementing some ourselves (which wouldn't be as optimized as the ones supported by GMP). We ultimately decided against this course of action, so will just camel case the functions. |
[reviewed by @jabraham17] Renamed the following functions to follow our capitalization scheme: - divceil to divCeil - divceilpos to divCeilPos - divfloor to divFloor - divfloorpos to divFloorPos Resolves #19012 Since the version of these functions that was included in all programs by default was deprecated during this release cycle, I've merely updated the version in Math.chpl for the new names and adjusted the deprecation message in AutoMath.chpl to mention the renaming of the function in addition to the arguments. Updated several standard and package modules to use the new names. Updated the documentation links in Math.chpl to link to the new names. Updated the deprecation message tests for the new expected output and the unstable tests for divCeilPos and divFloorPos to use the new names (so they don't trigger the deprecation warnings instead). Updated several tests to use the new names. For the submitted shootouts, updated the expected deprecation message for the change, as we want those tests to stay in line with the version on the site. Passed a full paratest with futures
div
andceil
are two different abbreviations, so this name anddivfloor
should be camelCased to match our other library functions, e.g.divCeil
anddivFloor
.divCeil
does look a little odd to me, but maybe I just need to get used to it.divceilpos
anddivfloorpos
are a little less clear to me. These variants assume that the result will be positive and of a signed integer type. The brainless renaming would bedivCeilPos
anddivFloorPos
, but it seems likely we can think of better names. I'm not coming up with any myself, anyone else?The text was updated successfully, but these errors were encountered: