by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 20:01
    sigurdsvela commented #19685
  • 19:51
    codecov[bot] commented #19680
  • 19:34
    sympy-bot updated the wiki
  • 19:34
    sympy-bot commented #19596
  • 19:34
    smichr commented #19596
  • 19:34

    smichr on master

    Impoved simplification for sign… Made suggested changes Update sympy/functions/elementa… and 6 more (compare)

  • 19:34
    smichr closed #19596
  • 19:34
    smichr closed #19484
  • 18:54

    oscarbenjamin on master

    printing: Update the example to… Convert the example to a doctes… Merge pull request #19622 from … (compare)

  • 18:54
    oscarbenjamin closed #19622
  • 18:54
    oscarbenjamin commented #19622
  • 18:53
    oscarbenjamin commented #19040
  • 18:50
    oscarbenjamin labeled #19688
  • 18:50
    oscarbenjamin milestoned #19688
  • 18:50
    oscarbenjamin commented #19688
  • 18:16

    oscarbenjamin on sympy-1.6.1

    (compare)

  • 18:16
    AlanPearl closed #19688
  • 18:16
    AlanPearl commented #19688
  • 18:08
    sachin-4099 synchronize #19680
Ehren Metcalfe
@ehren
There's also the rational flag, sympify("x + 1.0",rational=True), though it's possible the xreplace approach is still faster.
Ehren Metcalfe
@ehren
if you don't already have a str representation xreplace probably is faster (though agree avoiding Floats in the first place would be best)
Ehren Metcalfe
@ehren
@FabioLuporini nsimplify(x+1.0, rational=True) should be faster as well (looks like it just iterates over expr.atoms(Float))
Fabio Luporini
@FabioLuporini
Hi @eric-wieser -- I totally agree. We did try, that was indeed the very first thing, but no luck. IIRC, it's a by-product of an earlier xreplace. @mloubout may wanna elaborate. Anyway, here's the code, quite ugly admittedly:
https://github.com/devitocodes/devito/blob/master/devito/types/basic.py#L951-L954
basically, this is the kind of transformation we're after: https://github.com/devitocodes/devito/blob/master/devito/ir/equations/algorithms.py#L82

@FabioLuporini nsimplify(x+1.0, rational=True) should be faster as well (looks like it just iterates over expr.atoms(Float))

ah, thanks @ehren . This is worth a shot!

lemme see if I can look up why we can't work around the Float in the first place
Fabio Luporini
@FabioLuporini
I can't. I'll try these, thanks again! I'll poke Mathias to elaborate on why we can't work around those Floats.
Eric Wieser
@eric-wieser
@FabioLuporini: Have you tried sticking a breakpoint at sympy.Float.__new__ to work out where the float is being introduced?
Mathias Louboutin
@mloubout

Thanks for your answers and ideas. In short

o prevent the Float getting in there in the first place.

This one is only partially doable as it will depend what users do. So we can control some of it but it is very likely we will end up with Float no matter what.

nsimplify(x+1.0, rational=True)

Yes we tried this one, I found out that this is still quite slower than brute force sympify+xreplace atoms. (a small test on x + 2.0 benchmarks nsimplify at ~2.5ms and brtute force at ~25.6 µs ). If it was a one time thing we would definitely go the nsimplify that is a lot nicer, however we touch this line thousands of times in some cases and speed is critical.

Eric Wieser
@eric-wieser

This one is only partially doable as it will depend what users do.

Can you give an example of the type of thing a user might do which would result in this?

Mathias Louboutin
@mloubout
These are basically indices of sympy Function that are passed to code generation (and therefore need int in C). So one could want to have the Function and any point and use subs/xreplace (i.e f.subs({x: x + .5 h_x})) which would result in a float.
Eric Wieser
@eric-wieser
If users are writing the line of code f.subs({x: x + .5 h_x}), can you educate them to write f.subs({x: x + S.Half* h_x}) instead?
Or are they not writing that code?
Mathias Louboutin
@mloubout
I could yes, but the general user we have is not that versed in sympy and CS in general so we would have to answer issues/questions quite often.
Eric Wieser
@eric-wieser
Emitting a warning if expr.atoms(Float) is non-empty would be one way to do that
Soumi Bardhan
@Soumi7
Hi! I wanted to discuss a propective project for GSOD. Where can I do that?
3 replies
Mathias Louboutin
@mloubout
A warning would work I suppose, may need to add a lot of it in different places. I prefer to be robust to user input though rather that a lot of restrivtive warnings. @FabioLuporini what do you think
Fabio Luporini
@FabioLuporini
I don't think I'd like that sort of warnings
and it wouldn't really fix the "issue" would it? because after the warning, we'd still have to process the Floats, and I'm afraid lots of codes are currently doing that
Fabio Luporini
@FabioLuporini
so a crazy thing could be to subclass h_x's mul and turn .5 into S.Half (and related generalisations)
Mathias Louboutin
@mloubout
That'd be quite the work, especially considering what case led to the sympify part (some people do weird stuff^^).
Eric Wieser
@eric-wieser
You could do an ast rewrite too, possibly
Ehren Metcalfe
@ehren
If you already possess the user input as a string then sympify(expr_str, rational=True) uses an ast rewrite (no call is made to nsimplify)
Mathias Louboutin
@mloubout
We have user input as expression and need to keep the expression as there is a lot of metadata associated with it
Eric Wieser
@eric-wieser
That metadata might include the fact that a user deliberately requested a Float. Are you sure you want to ignore those users and use rationals anyway?
Mathias Louboutin
@mloubout
Yes we want to enforce rationals (actually integers or integer division) as these will be indexing of C arrays and can't be floats
bjonnh
@bjonnh
I'm trying to optimize (fit) parameters from: https://pastebin.com/raw/F2WX0Ncw
What I have are the D_a, D_b and g_ab and I want to get a curve_fit from numpy for all the rest
in some cases, I get float values out, and numpy is happy, in some other cases, the output of the lambdified function is still symbolic, such as: 1/(1.07677275611132e-17(1/(0.1D_a_eff/(1.0D_a_eff + 0.1) + 0.1))*5.0 + 1.0000001734153)
I'm sure I'm missing something simple here but I can't find what
you can try with: numpy_function(0.004, 0.0004,0.1, 0.1, 5.0, 5.0, 0.0, 1)
bjonnh
@bjonnh
ok I guess I'm not using that like I should at all
Fabio Luporini
@FabioLuporini
out of curiosity, is there any plan on releasing 1.6.1, just like we had 1.5.1 shortly after 1.5? we're unfortunately stuck with 1.5.1, but the patches we've submitted have been merged into sympy master, so... well, I guess I'm just looking forward to the next release :)
2 replies
(there was a regression with 1.6 concerning, IIRC, collect or one of its sibling functions)
Zachariah Etienne
@zachetienne
Hi all. I found a major performance regression in sympy-dev (i.e., within the past 24 hours), and reported it here: sympy/sympy#19534 . It's appearing in series() I would appreciate if those of you who might have an idea of which patch might be at fault (again, happened within the past 24 hours), to share that info with me. Thanks!
1 reply
anupamme
@anupamme_twitter
Hello I have noob question: I am coming from using Pysat (https://pysathq.github.io/), and there to represent a boolean formula, there is a defined type formula (https://pysathq.github.io/docs/html/api/formula.html). Is there something similar in sympy to represent algebraic formulas?
Aaron Meurer
@asmeurer
what do you mean by algebraic formulas?
SymPy can represent local predicates if that is what you mean https://docs.sympy.org/latest/modules/logic.html
1 reply
Eric Wieser
@eric-wieser

What is the expected behavior of sympy.latex(1e200)? Should it behave the same as sympy.latex(Float(1e200))? Should it just be str(1e200)?

Right now it's in this weird limbo where it respects the decimal separator, but makes a mess of e formatting instead of using x10^...

Sri.
@SriLikesToSing
HI everyone im a high schooler going to 11th grade and I am completely new to open source. I love mathematics so i was naturally inclined to this python library. I have no idea where to start whatsoever and I dont know how to fix or start fixing bugs. If anyone can help me I would really appreciate it!
Megan Ly
@meganly
Welcome @SriLikesToSing. Take a look at the issues tagged Easy to Fix and pick one that looks interesting. If you get stuck ask a question about it.
Mathias Louboutin
@mloubout
Is there a way to dynamically change the size of the sympy cache? The only way I found is via the environment variable SYMPY_CACHE_SIZE but it seems to be a hard constant that can't be change inside a sctipt/function/.....
MicheleCotrufo
@MicheleCotrufo

Is there a way to specify that the identity operator must act as identity also on the adjoint operators?

from sympy.physics.quantum.dagger import Dagger
from sympy.physics.quantum.operator import Operator
from sympy.physics.quantum import IdentityOperator
A = Operators('A')
Identity = IdentityOperator()
A * Identity #This gives A, correctly
B = Dagger(A)
B * Identity #This returns A^\dagger I . so it does not remove the identity operator

Akhil Rajput
@akhil-dh1
How can we correctly remove whitespaces from a file?
3 replies
Daniel Tran
@needham25
Hello, where do I send my first email to introduce myself?
1 reply
Dhruv Mendiratta
@dhruvmendiratta6
Can someone review PR #19487
Ron Avitzur
@RonAvitzur_twitter
I'm embedding SymPy into a self-contained C++ app. The call to pybind11::module::import("sympy"); takes about 4 seconds on my machine. I had thought that embedding the .pyc files would speed that up, but I see no change. Any advice?
1 reply
Michael
@decimad
Say I have f(t) = 0.13716814159292+0.0457429677474317𝑒^(−1843.26425719312𝑡)−0.182911109340352𝑒^(−460.969143814478𝑡) as function, how can I get symply.nsolve to find a solution for f(t) = 0.06?
Michael
@decimad
Please scrap my request, I could make it work with the 'bisect'-solver
mcpl-sympy
@mcpl-sympy
Can anyone review #19066? This PR is ready but hasn't got any review for a month.