-
Notifications
You must be signed in to change notification settings - Fork 280
Feature: Expr and GenExpr support numpy unary func like np.sin
#1170
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
Open
Zeroto521
wants to merge
49
commits into
scipopt:master
Choose a base branch
from
Zeroto521:expr/unary
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
452ca36
Add numpy ufunc support for expression classes
Zeroto521 4d911c1
Introduce ExprLike base class for expressions
Zeroto521 b119224
Fix unary ufunc mapping in ExprLike class
Zeroto521 4a65d98
Add tests for unary operations and numpy compatibility
Zeroto521 2d8945f
Merge branch 'master' into expr/unary
Zeroto521 01658f4
Update CHANGELOG.md
Zeroto521 f0aacb6
Add colon to ExprLike class definition
Zeroto521 7e78cac
Fix test expectations for variable names in unary ops
Zeroto521 196f43a
Fix expected output format in test_unary
Zeroto521 6dd2c93
Fix expected output for sin function in test_unary
Zeroto521 ee4c6f6
Merge branch 'master' into expr/unary
Zeroto521 e76b0d6
Add _evaluate method to Constant class
Zeroto521 06b4df4
Update genexpr power tests for sqrt handling
Zeroto521 a76ef44
Update test_unary to use two variables instead of three
Zeroto521 5611d52
Refactor expression classes with ExprLike base
Zeroto521 3402b32
Merge branch 'master' into expr/unary
Zeroto521 925cb43
Add __array_ufunc__ to ExprLike type stub
Zeroto521 857c969
Merge branch 'expr/unary' of https://github.com/Zeroto521/PySCIPOpt i…
Zeroto521 c94177c
Update numpy import and type annotations in stubs
Zeroto521 588cba4
Update __array_ufunc__ type hints to use np.ufunc and str
Zeroto521 cd642f9
Reorder and add math functions in scip.pyi
Zeroto521 f8e6132
Reorder Operator and PATCH declarations in scip.pyi
Zeroto521 940fd93
Remove @disjoint_base decorator from ExprLike
Zeroto521 900fdc3
Fix UNARY_MAPPER to use local math function references
Zeroto521 c85be94
Update typing for UNARY_MAPPER in scip.pyi
Zeroto521 4f6058a
Remove unused UNARY_MAPPER from type stub
Zeroto521 a1501e6
Add return type annotations to ExprLike methods
Zeroto521 259f4ce
Merge branch 'master' into expr/unary
Zeroto521 cfa8d5a
Merge branch 'master' into expr/unary
Zeroto521 0517639
Merge branch 'master' into expr/unary
Zeroto521 c82d570
Merge branch 'master' into expr/unary
Zeroto521 9c78ad6
Format: add blank line in GenExpr class
Zeroto521 55c1343
Refactor unary tests and add more unary ops
Zeroto521 b4d45b1
Add array assertions for unary ops
Zeroto521 3688217
Add test for invalid unary arcsin operation
Zeroto521 2579e87
Merge branch 'master' into expr/unary
Zeroto521 8c4b75f
Merge branch 'master' into expr/unary
Zeroto521 bc873b8
Update CHANGELOG: numpy unary function notes
Zeroto521 4621945
Merge branch 'master' into expr/unary
Zeroto521 ad7370a
pyscipopt.sqrt(2) will return a Constant class
Zeroto521 590859d
Expect NotImplementedError for genexpr ** sqrt(2)
Zeroto521 cce6c92
Dispatch numpy ufuncs for expr functions
Zeroto521 766759b
Update expr tests for MatrixExpr and repr
Zeroto521 69f470a
Fix ufunc dispatch for scalars
Zeroto521 d388a77
Rename _dispatch_ufunc to _wrap_ufunc
Zeroto521 c4dfdb3
Use MatrixGenExpr for ufunc results
Zeroto521 243231a
Potential fix for pull request finding
Zeroto521 9333fdb
Update CHANGELOG.md
Zeroto521 92851c8
Reject 'out' kwarg in __array_ufunc__
Zeroto521 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
ExprLikeis the base class and also a duck type.It defines the behavior, and its subclass defines the data.
I will use
ExprLiketo splitVariableandExprin the future.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.
What is the main benefit of this?
Uh oh!
There was an error while loading. Please reload this page.
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.
Variableis the subclass ofExpr. SoVariablecould operate likeExpr. And we don't have to add additional logic to handleVariable. This idea is good.But the relationships among
Variable,Term, andExprare very confusing.Variableis the unit of calculation. Why is it a subclass ofExpr?So
ExprLikecould splitVariableandExpr. And letVariablework withExpreasily.ExprLikeis a duck type, and it defines the operator's inputs and outputs.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.
For now,
ExprLikecould save code.__array_ufunc__won't repeat in Expr, and GenExpr.