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

Fix/get df with default args #1231

Merged
merged 5 commits into from
Apr 12, 2024

Conversation

Oisin-M
Copy link
Contributor

@Oisin-M Oisin-M commented Apr 9, 2024

Previous error was due to attempting to index on the default argument of keys=None.

Changes

Changed

keys = [keys] if isinstance(keys, str) else keys
key = keys[0]

...

if keys is None:
   df = data.to_df()
elif key in data.var_names:
   df = obs_df(data, keys, layer=layer)
elif key in data.obs_names:
   df = var_df(data, keys, layer=layer)
else:
   ...

to

if keys is None:
   df = data.to_df()
else:
   keys = [keys] if isinstance(keys, str) else keys
   key = keys[0]
   if key in data.var_names:
      df = obs_df(data, keys, layer=layer)
   elif key in data.obs_names:
      df = var_df(data, keys, layer=layer)
   else:
      ...

and added accompanying test.

Closes #649

@WeilerP WeilerP merged commit f21651c into theislab:main Apr 12, 2024
6 checks passed
@WeilerP
Copy link
Member

WeilerP commented Apr 12, 2024

Thanks, @Oisin-M!

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 this pull request may close these issues.

get_df fails with default arguments
2 participants