-
Notifications
You must be signed in to change notification settings - Fork 16
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
print(AmorphousLayer) and print(UnitCell) fail #158
Comments
Hi @ghlqz, Many thanks for reporting this issue. I will check my latest commits and changes in the dependencies to nail this down asap. Best Daniel |
If I remember correctly, this problem was introduced with one of the latest I will try, if I can implement a simple workaround or otherwise switch to a more recent converter for tabular output. Best Daniel |
@ghlqz I will follow your proposal and convert all quantities to strings before handing them over to the |
I created an PR #159 which should fix this issue. |
closing |
I am currently starting to work with udkm1Dsim and encountered a problem in following the examples in the documentation. Printing an amorphous layer or a unit cell throws an error, "ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()". Some debugging showed that an array "output" is generated in the respective
__str__
functions of the AmorphousLayer and UnitCell classes which cannot be handled by the tabulate command (it also does not have the proper np.shape() ).The problematic array entries are actually inherited from the
__str__
of the Layer class. There, some variables are not converted to strings. An example is the Debye-Waller factor, which remains a quantity object with unit which leads to the error.A possible workaround is to replace
['Debye Waller Factor', self.deb_wal_fac.to('meter**2')],
by
['Debye Waller Factor', '{:.4~P}'.format(1.0*self.deb_wal_fac.to('meter**2'))],
in
__str__
of the class Layer (and analogous for the other affected variables; the 1.0 factor converts the default integer value to a float because otherwise the format throws an error).Is this behavior due to some library version conflict, or actually a bug? I am currently using
Python 3.11.5
NumPy 1.26.4
udkm1Dsim 2.0.2
tabulate 0.9.0
Pint 0.24.3
Thanks!
The text was updated successfully, but these errors were encountered: