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

Function to convert string or list of strings to list of strings #766

Closed
rstoneback opened this issue Apr 20, 2021 · 1 comment · Fixed by #772
Closed

Function to convert string or list of strings to list of strings #766

rstoneback opened this issue Apr 20, 2021 · 1 comment · Fixed by #772
Milestone

Comments

@rstoneback
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
We have had a few discussions, and implementations, about dealing with string inputs.

Describe the solution you'd like
A function in pysat.utils that converts inputs to a list of strings. There are at least two so far, one in _instrument.py, the other in _files.py that are already very close.

        starts = np.asarray(start)
        if starts.shape == ():
            starts = [starts.tolist()]
        elif starts.shape[0] > 1:
            starts = starts.squeeze().tolist()
        elif starts.shape[0] == 1:
            starts = starts.tolist()

and

            # User provided some inputs
            starts = np.asarray([start])
            stops = np.asarray([stop])

            # Ensure consistency if list-like already
            if len(starts.shape) > 1:
                starts = starts[0]
            if len(stops.shape) > 1:
                stops = stops[0]

Describe alternatives you've considered
Leave as is. Makes writing functions harder and leaves a potential area to discuss.

Additional context
Distinguishing strings from arrays would be great.

@rstoneback
Copy link
Collaborator Author

rstoneback commented Apr 21, 2021

Call it listify (suggestion from @aburrell)

@jklenzing jklenzing added this to the 3.1.0 Release milestone Apr 21, 2021
@rstoneback rstoneback linked a pull request Apr 30, 2021 that will close this issue
10 tasks
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.

2 participants