Skip to content
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

Get Phase.__str__ to work at least in basic fashion #219

Merged
merged 1 commit into from Mar 8, 2021
Merged

Conversation

mhvk
Copy link
Owner

@mhvk mhvk commented Mar 8, 2021

Fixes #216

Not very pretty but easiest way to work around fact that np.array2string does not allow one to override formatting of structured dtype.

@mhvk mhvk added bug Something isn't working phases labels Mar 8, 2021
@mhvk mhvk added this to the 0.2 milestone Mar 8, 2021
@mhvk mhvk merged commit f0f08cc into master Mar 8, 2021
@mhvk mhvk deleted the phase-str branch March 8, 2021 15:18
@theXYZT
Copy link
Contributor

theXYZT commented Mar 8, 2021

What does this do? self.view(f"V{self.dtype.itemsize}")? I have never seen a "Vx" string used before in views and such.

@mhvk
Copy link
Owner Author

mhvk commented Mar 8, 2021

@theXYZT - it views as a "void" dtype, which stands for a pure binary blob which some number of bytes. For some reason, np.array2string allows one to override how those are represented, but not how a structured array is represented (it assumes you just want to print the individual elements of the structure).

@theXYZT
Copy link
Contributor

theXYZT commented Mar 13, 2021

This fails for scalar phases now, haha!

x = Phase(1.0)
str(x)

should throw an error now: AttributeError: 'numpy.void' object has no attribute 'to_string'

@mhvk
Copy link
Owner Author

mhvk commented Mar 13, 2021

Oops.... Fixed by #220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working phases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Phase __str__() doesn't always return a string
2 participants