matthuszagh / pyems

High-level python interface to OpenEMS with automatic mesh generation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gcpw_optimize_width.py: AttributeError: 'numpy.float64' object has no attribute 'rint'

biergaizi opened this issue · comments

I was trying to run the demo gcpw_optimize_width.py, unfortunately it fails.

$ python3 gcpw_optimize_width.py 
/usr/lib64/python3.9/site-packages/numpy/core/_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
  return array(a, dtype, copy=False, order=order)
AttributeError: 'numpy.float64' object has no attribute 'rint'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/code/pyems/examples/gcpw_optimize_width.py", line 77, in <module>
    res = minimize(
  File "/usr/lib64/python3.9/site-packages/scipy/optimize/_minimize.py", line 606, in minimize
    return _minimize_neldermead(fun, x0, args, callback, **options)
  File "/usr/lib64/python3.9/site-packages/scipy/optimize/optimize.py", line 689, in _minimize_neldermead
    fsim[k] = func(sim[k])
  File "/usr/lib64/python3.9/site-packages/scipy/optimize/optimize.py", line 427, in function_wrapper
    return function(*(wrapper_args + args))
  File "/home/user/code/pyems/examples/gcpw_optimize_width.py", line 35, in gcpw
    Microstrip(
  File "/home/user/.local/lib/python3.9/site-packages/pyems-0.1.0-py3.9.egg/pyems/structure.py", line 959, in __init__
  File "/home/user/.local/lib/python3.9/site-packages/pyems-0.1.0-py3.9.egg/pyems/structure.py", line 996, in construct
  File "/home/user/.local/lib/python3.9/site-packages/pyems-0.1.0-py3.9.egg/pyems/structure.py", line 1006, in _construct_port
  File "/home/user/.local/lib/python3.9/site-packages/pyems-0.1.0-py3.9.egg/pyems/port.py", line 456, in __init__
  File "/home/user/.local/lib/python3.9/site-packages/pyems-0.1.0-py3.9.egg/pyems/port.py", line 493, in _set_trace
  File "/home/user/.local/lib/python3.9/site-packages/pyems-0.1.0-py3.9.egg/pyems/csxcad.py", line 133, in construct_box
  File "/home/user/.local/lib/python3.9/site-packages/pyems-0.1.0-py3.9.egg/pyems/csxcad.py", line 513, in _add_box
  File "/home/user/.local/lib/python3.9/site-packages/pyems-0.1.0-py3.9.egg/pyems/fp.py", line 33, in fp_nearest
  File "<__array_function__ internals>", line 5, in around
  File "/usr/lib64/python3.9/site-packages/numpy/core/fromnumeric.py", line 3262, in around
    return _wrapfunc(a, 'round', decimals=decimals, out=out)
  File "/usr/lib64/python3.9/site-packages/numpy/core/fromnumeric.py", line 55, in _wrapfunc
    return _wrapit(obj, method, *args, **kwds)
  File "/usr/lib64/python3.9/site-packages/numpy/core/fromnumeric.py", line 44, in _wrapit
    result = getattr(asarray(obj), method)(*args, **kwds)
TypeError: loop of ufunc does not support argument 0 of type numpy.float64 which has no callable rint method

Fixed in 6f3a3be. This is taking a long time to run and the simulation could probably use some improvements. But, that's a separate issue.