Skip to content

Conversation

xngw
Copy link

@xngw xngw commented Jun 21, 2022

References to other Issues or PRs

Brief description of what is fixed or changed

Fixed a bug that MinMaxBase.new() does not use global parameter for argument "evaluate"

Other comments

Release Notes

  • functions
    • The symbolic Min and Max functions now respect the global evaluate flag.

@sympy-bot
Copy link

sympy-bot commented Jun 21, 2022

Hi, I am the SymPy bot (v167). 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
    • The symbolic Min and Max functions now respect the global evaluate flag. (#23663 by @hsiang-wu)

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

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. -->


#### Brief description of what is fixed or changed

Fixed a bug that MinMaxBase.__new__() does not use global parameter for argument "evaluate"

#### Other comments


#### Release Notes

<!-- Write the release notes for this release below between the BEGIN and END
statements. The basic format is a bulleted list with the name of the subpackage
and the release note for this PR. For example:

* solvers
  * Added a new solver for logarithmic equations.

* functions
  * Fixed a bug with log of integers.

or if no release note(s) should be included use:

NO ENTRY

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
  * The symbolic Min and Max functions now respect the global evaluate flag.
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@github-actions
Copy link

github-actions bot commented Jun 21, 2022

Benchmark results from GitHub Actions

Lower numbers are good, higher numbers are bad. A ratio less than 1
means a speed up and greater than 1 means a slowdown. Green lines
beginning with + are slowdowns (the PR is slower then master or
master is slower than the previous release). Red lines beginning
with - are speedups.

Significantly changed benchmark results (PR vs master)

Significantly changed benchmark results (master vs previous release)

       before           after         ratio
     [77f1d79c]       [a28a214e]
     <sympy-1.10.1^0>                 
+      98.1±0.7ms        179±0.6ms     1.83  sum.TimeSum.time_doit

Full benchmark results can be found as artifacts in GitHub Actions
(click on checks at the top of the PR).

@@ -380,7 +380,8 @@ def real_root(arg, n=None, evaluate=None):

class MinMaxBase(Expr, LatticeOp):
def __new__(cls, *args, **assumptions):
evaluate = assumptions.pop('evaluate', True)
from sympy.core.parameters import global_parameters
evaluate = assumptions.pop('evaluate', global_parameters.evaluate)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a test for this in sympy/functions/elementary/tests/test_miscellaneous.py?

Copy link
Author

Choose a reason for hiding this comment

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

Yes.

Copy link
Author

Choose a reason for hiding this comment

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

I also added a new context NoEvaluation in the test file. This ensures that even if the new test_minmax_no_evaluate fails, it will not affect other tests by always setting the gp.evaluate back to True at its exit. Otherwise, we risk ending up in an environment where gp.evaluate=False for other tests if test_minmax_no_evaluate raises errors.

Copy link
Collaborator

Choose a reason for hiding this comment

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

There already is a context manager for this:

In [10]: from sympy import *

In [11]: x = symbols('x')

In [12]: with evaluate(False):
    ...:     s = x + x
    ...: 

In [13]: s
Out[13]: x + x

Copy link
Author

Choose a reason for hiding this comment

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

Thx, I'll switch to that.

@oscarbenjamin
Copy link
Collaborator

I'm not sure what causes the matplotlib failures in the 3.11 optional dependency tests but it's not caused by this PR.

@oscarbenjamin
Copy link
Collaborator

Looks good. Thanks!

@oscarbenjamin oscarbenjamin merged commit 18afc6b into sympy:master Jun 22, 2022
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.

3 participants