-
Notifications
You must be signed in to change notification settings - Fork 161
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
Improved documentation, moved to float.gd, added IsRealFloat filter, … #2016
Improved documentation, moved to float.gd, added IsRealFloat filter, … #2016
Conversation
…removed bad Round method for floats
Codecov Report
@@ Coverage Diff @@
## master #2016 +/- ##
===========================================
- Coverage 66% 52.21% -13.79%
===========================================
Files 898 424 -474
Lines 273286 223086 -50200
Branches 12771 10418 -2353
===========================================
- Hits 180372 116486 -63886
- Misses 90087 103927 +13840
+ Partials 2827 2673 -154
|
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.
Could you please amend the commit message to follow our general guidelines, i.e.: first a single line summary with ideally only 50-60 chars; then an empty line, then a full description of the commit.
E.g.:
Improve float documentation and interface
This commit does:
* introduce IsRealFloat and IsComplexFloat
* remove Overlaps and ...
* ...
This way, when bisecting regressions in a year from now, one does not have to wonder whether this commit did certain things on purpose or by accident.
lib/float.gi
Outdated
end ); | ||
|
||
InstallMethod( SignFloat, "for floats", [ IsFloat ], -1, | ||
InstallMethod( SignFloat, "for real floats", [ IsRealFloat ], -1, | ||
function ( x ) | ||
if x < Zero(x) then return -1; elif IsZero(x) then return 0; else return 1; fi; |
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 still incorrect for negative zero.
lib/float.gd
Outdated
## <Oper Name="Zeta" Arg="f"/> | ||
## <Oper Name="Gamma" Arg="f"/> | ||
## <Description> | ||
## These are all standard math functions, directly copied from the standard math library; see <C>man 3 math</C> for their list. |
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.
When you say "standard math library", what you mean? The C math library? Or maybe the POSIX math library? Or the linux (glibc) math library? Or something else?
These are all different things. And for me (on OS X), several of the functions listed above have either a different name in man 3 math
(ignore case differences), e.g. CubeRoot(vs
cbrt),
Square(vs.
sqrt),
Hypothenuse(vs.
hypot), or they are missing altogether, e.g.
Zeta,
Frac,
SinCos,
Gamma`
So I would be very hesitant to mention man 3 math
here, at least like this. I really think there should be one mansection for each of the above, with a description of what it does, and possibly the name of the corresponding function in a specific standard, such as ISO C, and/or perhaps references to Clause 9 of IEEE 754.
lib/float.gd
Outdated
DeclareAttribute("Erf", IsFloat); | ||
DeclareAttribute("Zeta", IsFloat); | ||
DeclareAttribute("Gamma", IsFloat); | ||
#DeclareAttribute("ComplexI", IsFloat); #obsolete |
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 ComplexI
is effectively removed, but (a) this is not visible in the commit message, and (b) why is this commented out left in at all?
lib/float.gd
Outdated
DeclareAttribute("Mid", IsFloatInterval); | ||
DeclareAttribute("AbsoluteDiameter", IsFloatInterval); | ||
DeclareAttribute("RelativeDiameter", IsFloatInterval); | ||
#DeclareOperation("Diameter", IsFloat); |
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.
Why is this commented out line here?
@@ -252,23 +252,21 @@ end); | |||
|
|||
############################################################################# | |||
## Default methods | |||
## | |||
## These methods have priority -1, because they are inefficient. | |||
## Hopefully every float implementation implements them better. |
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 understand this: If a float implementation implements them better, then it would install its methods for its own filter, which would be a subfilter of IsRealFloat
or IsComplexFloat
, and hence would automatically have a higher rank.
Or perhaps you are concerned about float implementations which implement neither IsRealFloatnor
IsComplexFloat(such as
floatright now, as
IsRealFloator
IsComplexFloatdo not yet exist on
master`) ? But then this should be said so explicitly
DeclareAttribute("AbsoluteDiameter", IsFloat); | ||
DeclareAttribute("RelativeDiameter", IsFloat); | ||
#DeclareOperation("Diameter", IsFloat); | ||
DeclareOperation("Overlaps", [IsFloat,IsFloat]); |
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 Overlaps
is removed, too, but this isn't noted in the commit message either.
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.
@laurentbartholdi also you need to look at the Travis test which builds GAP manuals - it does not detect all problems well enough - i.e. it fails if the manual build failed dramatically, but passes if it has unresolved or multiply defined references. The log at https://travis-ci.org/gap-system/gap/jobs/314787107 shows that there are two multiply defined references: to AbsoluteValue
and Norm
.
Dear @fingolfin:
Thanks for your thorough review of my code! I mainly agree with all you
suggest, but here are some further comments:
+InstallMethod( SignFloat, "for real floats", [ IsRealFloat ], -1,
function ( x )
if x < Zero(x) then return -1; elif IsZero(x) then return 0; else return 1; fi;
This is still incorrect for negative zero.
Hmmm... there's no standard "SignFloat" in IEEE754, as far as I see;
however, there's a sign bit. I wanted SignFloat to be the same as SignInt,
but for floats; that's maybe not so useful. On the other hand, I would be
happy to scrap "SignFloat" which anyways is ambiguous on what it does to
negative zero, and have SignBit with Float->Bool signature. What do you
think?
+## <Description>
+## These are all standard math functions, directly copied from the standard math library; see <C>man 3 math</C> for their list.
When you say "standard math library", what you mean? The C math library?
Or maybe the POSIX math library? Or the linux (glibc) math library? Or
something else?
Yes, I looked them up in /usr/local/math.h and gave them more GAPish
names. sincos exists on Linux, it's called __sincos on Mac OSX.
+#DeclareAttribute("ComplexI", IsFloat); #obsolete
So ComplexI is effectively removed, but (a) this is not visible in the
commit message, and (b) why is this commented out left in at all?
I will amend the commit message. I believe it should be removed, but I
wanted to keep a trace of that decision. I understand it's also part of the
git history, so one could remove the commented line.
+DeclareAttribute("Mid", IsFloatInterval);
+DeclareAttribute("AbsoluteDiameter", IsFloatInterval);
+DeclareAttribute("RelativeDiameter", IsFloatInterval);
+#DeclareOperation("Diameter", IsFloat);
Why is this commented out line here?
I'd rather leave this one in: I really want to declare an operation
"Diameter", synonym of "AbsoluteDiameter" which is the most common one.
There was a clash with other packages declaring Diameter, so temporarily I
would leave it out before the interval interface is settled.
In lib/float.gi
<#2016 (comment)>:
> @@ -252,23 +252,21 @@ end);
#############################################################################
## Default methods
+##
+## These methods have priority -1, because they are inefficient.
+## Hopefully every float implementation implements them better.
I don't understand this: If a float implementation implements them better,
then it would install its methods for its own filter, which would be a
subfilter of IsRealFloat or IsComplexFloat, and hence would automatically
have a higher rank.
Or perhaps you are concerned about float implementations which implement
neither IsRealFloatnorIsComplexFloat(such asfloatright now, asIsRealFloat
orIsComplexFloatdo not yet exist onmaster`) ? But then this should be
said so explicitly
Yes, I'd rather make sure that the method only kicks in as a last resort.
I'll add a comment.
|
Re Of course Re: Re "leaving a trace on the decision to remove ComplexI": First, as you say yourself, this is what the git history is for. Second, even if one argues that this is not enough, I'd argue that leaving an commented out line declaring Re: |
Manual building log looks OK now (the unresolved references are because of the links to Example package from doc/dev manual - I will fix that). @fingolfin are you happy to merge this? If so, this is certainly an improvement, worth to put in 4.9.0. |
@alex-konovalov I don't have time to review this again, but I don't object. Right now, it's your review that is blocking a merge, though. |
@laurentbartholdi it seems that this now requires a new release of float, isn't it? |
Deal @alex: sorry, I forgot to mention this! Yes, I had bundled float 0.9.0
with the requirement "gap >= 4.9"; I hope that's the good way to do it.
|
@laurentbartholdi ok, now after this change has been merged, float 0.9.0 works fine. |
Improved float documentation and interface
This commit overhauls the documentation of the floateans in GAP, and adds and removes some commands from the interface: