Skip to content

Commit

Permalink
added frame.data(list). fixes #35
Browse files Browse the repository at this point in the history
  • Loading branch information
Kay-Robert Dormann committed Oct 18, 2024
1 parent 3580a00 commit 2158833
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions amep/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ def keys(self) -> list:

return datakeys
def data(
self, *args, ptype: int | None = None, zerofill: bool = False,
self, *args: str | list[str], ptype: int | None = None, zerofill: bool = False,
return_keys: bool = False) -> tuple[list, np.ndarray]:
r'''
Returns the entire data frame for all particles or for
Expand All @@ -788,9 +788,10 @@ def data(
Parameters
----------
*args : str
*args : str | list[str]
Parameter keys. One wildcard character asterisk can be used, see
note above.
note above. Either multiple strings or lists of strings are
allowed, a combination should not be used.
ptype : int | list, optional
Particle type. Is internally converted to a list and all matching
ptypes are returned. The default is None.
Expand All @@ -812,10 +813,21 @@ def data(
data = None
datakeys = []

# allow lists of keys as input
islist=False
listresult=[]
for arg in args:
if isinstance(arg, (list, np.ndarray)):
islist=True
listresult.append(self.data(*arg, ptype = ptype, zerofill = zerofill, return_keys = return_keys))
if islist:
if len(args)==1:
return listresult[0]
return listresult

# return all data if no arguments are given
if len(args)==0:
args = self.keys

else:
# Transform list of all given keys by allowing semi-wildcard matches
# One asterisk * is allowed.
Expand Down

0 comments on commit 2158833

Please sign in to comment.