Skip to content

Conversation

@mohitacecode
Copy link
Contributor

@mohitacecode mohitacecode commented Jan 21, 2020

References to other Issues or PRs

Fixes #18421

Brief description of what is fixed or changed

floor(float(0)) now give 0 instead of 0.0 and ceiling(float(0)) now gives 0 instead of 0.0.

I have Called the _eval_number first in the eval method present in RoundFunction Class which is present in functions/elementary/integers.py

Other comments

Release Notes

  • functions
    • floor and ceiling with float arguments now return Integers

@sympy-bot
Copy link

sympy-bot commented Jan 21, 2020

Hi, I am the SymPy bot (v149). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

  • functions

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.6.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->
Fixes #18421

#### Brief description of what is fixed or changed
`floor(float(0))` now give 0 instead of `0.0` and `ceiling(float(0))` now gives 0 instead of `0.0`.

I have Called the _eval_number first in the eval method present in RoundFunction Class which is present in functions/elementary/integers.py
#### Other comments

#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
*   functions
     *  floor and ceiling with float arguments now return Integers
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@sylee957
Copy link
Member

This needs tests.
And this should be strictly checking for the isinstance or compare with the singletons
What about adding assert floor(float(0)) is S.Zero, assert ceil(float(0)) is S.Zero to the test files?

@mohitacecode
Copy link
Contributor Author

mohitacecode commented Jan 21, 2020

Can you check the changes if they seems right to you?
@sylee957

v = cls._eval_number(arg)
if v is not None:
return v

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there should only be one blank line here

Copy link
Contributor Author

@mohitacecode mohitacecode Jan 21, 2020

Choose a reason for hiding this comment

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

I just removed it.

@mohitacecode
Copy link
Contributor Author

I think assert floor(float(0)) is S.Zero, assert ceil(float(0)) is S.Zero should work. @sylee957

@codecov
Copy link

codecov bot commented Jan 21, 2020

Codecov Report

Merging #18424 into master will increase coverage by 0.021%.
The diff coverage is 100%.

@@              Coverage Diff              @@
##            master    #18424       +/-   ##
=============================================
+ Coverage   75.312%   75.334%   +0.021%     
=============================================
  Files          635       638        +3     
  Lines       167042    167123       +81     
  Branches     39417     39418        +1     
=============================================
+ Hits        125804    125901       +97     
+ Misses       35703     35684       -19     
- Partials      5535      5538        +3

@asmeurer
Copy link
Member

Please be more descriptive in your pull request descriptions. Every function in SymPy has an eval method, so simply saying that you changed the logic of an eval method doesn't say much. You should also mention what the actual logic change is. This also needs a release notes entry, where you can describe this as well (from the point of view of an end-user).

@mohitacecode mohitacecode changed the title Change the logic of the eval method Change the logic of the eval method present in RoundFunction Class (integers.py) Jan 22, 2020
@mohitacecode
Copy link
Contributor Author

Please be more descriptive in your pull request descriptions. Every function in SymPy has an eval method, so simply saying that you changed the logic of an eval method doesn't say much. You should also mention what the actual logic change is. This also needs a release notes entry, where you can describe this as well (from the point of view of an end-user).

Sure I will keep that in mind always from now on :)

@mohitacecode
Copy link
Contributor Author

mohitacecode commented Jan 22, 2020

Ping @sylee957 @oscarbenjamin

@mohitacecode mohitacecode requested a review from sylee957 January 22, 2020 17:53
v = cls._eval_number(arg)
if v is not None:
return v
from sympy import im
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that the import should be at the top of the method. Also perhaps there should be a blank line after return v.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Pay attention to things like line spacing when editing the code. Look at the code around and try to match the style

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I will not overlooked these things from now on

@oscarbenjamin
Copy link
Collaborator

The release note should be something like "floor and ceiling with float arguments now return Integers"

@oscarbenjamin
Copy link
Collaborator

Looks good.

@oscarbenjamin oscarbenjamin merged commit fe8853f into sympy:master Jan 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Floor and ceiling functions are returning floats for zero

6 participants