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

read_ipf_str(): Function fails with ValueError #200

Closed
dpmayerUSGS opened this issue Sep 18, 2023 · 0 comments · Fixed by #201
Closed

read_ipf_str(): Function fails with ValueError #200

dpmayerUSGS opened this issue Sep 18, 2023 · 0 comments · Fixed by #201

Comments

@dpmayerUSGS
Copy link
Contributor

plio version(s) affected: 1.5.3 - 1.5.4

Description

The normal way to parse the contents of a list of one or more Socet Set IPF files is with plio is via read_ipf(). plio does some magic with singledispatch to parse the input list before passing the name of each IPF file to read_ipf_str() which does the actual parsing. However, read_ipf() balks at any known valid input and emits a ValueError that traces back to read_ipf_str().

How to reproduce

from plio.io.io_bae import read_ipf,
input_data = ['example.ipf']
read_ipf(input_data)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usgs/cpkgs/appl/miniconda3_linux/envs/APPL-Tools/lib/python3.9/functools.py", line 888, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/usgs/cpkgs/appl/miniconda3_linux/envs/APPL-Tools/lib/python3.9/site-packages/plio/io/io_bae.py", line 103, in read_ipf_str
    d = np.hstack(np.array(d[3:]))
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (3299,) + inhomogeneous part.

Possible Solution

Change this line to d = np.hstack(np.array(d[3:], dtype=object))

I've tested this by writing a custom function that is equivalent to plio's read_ipf_str() but with the above change, and then passing the path of a single IPF to it.

Additional context

It's been a couple years since I've called read_ipf() so I'm not sure why this function suddenly stopped working. Perhaps NumPy got more strict about converting lists to arrays?

Any of the IPFs in https://github.com/DOI-USGS/plio/tree/main/plio/examples/SocetSet should be suitable for testing. I discovered the issue using IPFs associated with a particular project, and reproduced the issue with https://github.com/DOI-USGS/plio/blob/cd781053658934adcf3972b762f314e36a964131/plio/examples/SocetSet/P01_001540_1889_XI_08N204W.ipf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant