Home Forums Nazca type error when using sympy – fixed by converting to float

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #6276


    After struggling for a bit to find out why things didn’t work, I realized that nazca doesn’t play well with sympy. Is there a way to fix that in a future release? Here’s a toy example to demonstrate the problem:

    import nazca as nd
    from sympy import symbols, Eq, solve
    x, y = symbols('x y', positive=True)
    area = 4.7
    eq1 = Eq(x*y, area)
    eq2 = Eq(x, y)
    sol = solve((eq1, eq2), (x, y))[0]
    x0 = sol[0]
    y0 = sol[1]
    print(type(x0))  # sympy.core.numbers.Float
    # Instantiation raises a TypeError if using sympy numbers
    # uncomment these lines to convert sympy numbers to float
    # Note that I had to restart the kernel of my jupyter notebook after trying to instantiate a cell with sympy numbers
    # If I don't restart the kernel, I get an IndexError
    # x0 = float(x0)
    # y0 = float(y0)
    # print(type(x0))
    nd.strt(length=x0, width=y0, layer=1).put()

    Dear Bastien,

    What is the error you get? When I run it the error comes from matplotlib, not from Nazca.
    If I replace export_plt() with export_gds() it runs fine.


    Nazca 0.5.12, Matplotlib 3.3.2, Python 3.8.6. Error messsage:

    File "/usr/lib/python3/dist-packages/matplotlib/figure.py", line 321, in __init__
        if not np.isfinite(figsize).all() or (np.array(figsize) < 0).any():
    TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not
    be safely coerced to any supported types according to the casting rule ''safe''

    Dear Xaveer,

    Thank you for your answer. I get the same error message (using Nazca 0.5.12, Matplotlib 3.2.2, Python 3.7.3). I came across that error in a more complex code and wrongly identified the faulty line. It looks like the error is indeed coming from matplotlib (no error with export to gds) and not from the instantiation; sorry for the confusion. I guess the take home message is that one should be careful when using sympy types…

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.