Open Camaltra opened 2 months ago
i also come with the same error
Hi!
While writing the PR for the ease of install the package environment, I've tried to run the main file.
It end up with an error detected in the file awg/Field.py when trying created the Xdata.
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.
self.Xdata = np.array([self._x,self._y])
self._y
is always a empty list and self._x can be populated andlen(self._x) >= 0
and so, we can't actually tried to convert them into a single array.I don't have the whole code context, and so, I don't come with any solution, but here is a catch. We can implement a validation step such as:
if len(self._x) != len(self._y): raise ValueError
But not sure it will smth we currently want.
Also another catch on the same file, in the
__init__()
method, we give a mutable default arg which can causse issues. Here for more detailsdef __init__(self,X, E, H = []): --------------------------------- def __init__(self, X, E, H=None): if H is None: H = []
Hope I could help!
the author has an other repository called "awg-matlab", its code can run normally.
Hi,
The python AWG module was never really tested, I had an intern convert the Matlab model to python during my Master’s. There is a lot of space for improvement.
The Matlab model currently published works well and was used in a SiEPIC training, but is a simple 1D field model with built-in approximations. It’s a good start, but I have a more robust, physically accurate model which was developed later for a publication which I never got around to releasing.
Is there a demand for this?
Cheers, Daniel
Get Outlook for iOShttps://aka.ms/o0ukef
From: 加味溫膽湯 @.> Sent: Sunday, August 4, 2024 7:45:41 AM To: dnrobin/awg-python @.> Cc: Subscribed @.***> Subject: Re: [dnrobin/awg-python] Error while running main file in awg/Fields.py file (Issue #5)
Hi!
While writing the PR for the ease of install the package environment, I've tried to run the main file.
It end up with an error detected in the file awg/Field.py when trying created the Xdata. ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part. self.Xdata = np.array([self._x,self._y]) self._y is always a empty list and self._x can be populated and len(self._x) >= 0 and so, we can't actually tried to convert them into a single array.
I don't have the whole code context, and so, I don't come with any solution, but here is a catch. We can implement a validation step such as:
if len(self._x) != len(self._y): raise ValueError
But not sure it will smth we currently want.
Also another catch on the same file, in the init() method, we give a mutable default arg which can causse issues. Here for more detailshttps://florimond.dev/en/posts/2018/08/python-mutable-defaults-are-the-source-of-all-evil
def init(self,X, E, H = []):
def init(self, X, E, H=None): if H is None: H = []
Hope I could help!
the author has an other repository called "awg-matlab", its code can run normally.
— Reply to this email directly, view it on GitHubhttps://github.com/dnrobin/awg-python/issues/5#issuecomment-2267512844, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACY3OLIO63XZ5KT2FIW5OV3ZPYH6LAVCNFSM6AAAAABL3HZCQSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRXGUYTEOBUGQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hi!
While writing the PR for the ease of install the package environment, I've tried to run the main file.
It end up with an error detected in the file awg/Field.py when trying created the Xdata.
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.
self.Xdata = np.array([self._x,self._y])
self._y
is always a empty list and self._x can be populated andlen(self._x) >= 0
and so, we can't actually tried to convert them into a single array.I don't have the whole code context, and so, I don't come with any solution, but here is a catch. We can implement a validation step such as:
But not sure it will smth we currently want.
Also another catch on the same file, in the
__init__()
method, we give a mutable default arg which can causse issues. Here for more detailsHope I could help!