Skip to content
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

Convert inv to literal pow #141

Merged
merged 4 commits into from
Nov 19, 2020
Merged

Convert inv to literal pow #141

merged 4 commits into from
Nov 19, 2020

Conversation

MasonProtter
Copy link
Member

@MasonProtter MasonProtter commented Nov 19, 2020

Should accomplish the goal "make sure inv does not get introduced, only negative powers do." in #133

I also made a random global I noticed a global const. Does MPOLY_CLEANUP even need to be a global, or can it just be internal?

@shashi
Copy link
Member

shashi commented Nov 19, 2020

Okay I think this could work... Although we should run reverse CI with ModelingToolkit. Because this is the weird part about not having invs:

julia> g(f)=f(2,-2)
g (generic function with 1 method)

julia> g(^)
ERROR: DomainError with -2:
Cannot raise an integer x to a negative power -2.
Make x or -2 a float by adding a zero decimal (e.g., 2.0^-2 or 2^-2.0 instead of 2^-2), or write 1/x^2, float(x)^-2, x^float(-2) or (x//1)^-2
Stacktrace:
 [1] ^(::Int64, ::Int64) at ./intfuncs.jl:273
 [2] g(::typeof(^)) at ./REPL[19]:1
 [3] top-level scope at REPL[20]:1
 [4] run_repl(::REPL.AbstractREPL, ::Any) at /build/julia/src/julia-1.5.2/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:288

inv converts the base into float first.

@shashi shashi merged commit e28359c into master Nov 19, 2020
@shashi
Copy link
Member

shashi commented Nov 19, 2020

When I recently looked into this, invs were actually gone without this fix... I think it could have been because we made things Real by default (in MTK at least -- which is what I was testing, but I'm not sure how that should change anything)

@shashi shashi deleted the pow-rework branch November 19, 2020 19:29
@MasonProtter
Copy link
Member Author

inv was mostly gone, but appears through Base.literal_pow before this PR. I'm surprised CI passed, it failed for me locally because of a problem with literal_pow in the fuzzer. I'll make a new PR with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants