Skip to content

implement LArray.from_dict or from_dict top-level function #581

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

Open
gdementen opened this issue Feb 15, 2018 · 5 comments
Open

implement LArray.from_dict or from_dict top-level function #581

gdementen opened this issue Feb 15, 2018 · 5 comments

Comments

@gdementen
Copy link
Contributor

def from_dict(d):
    return LArray(list(d.values()), Axis(d.keys()))
@gdementen
Copy link
Contributor Author

and/or modify behavior of LArray(dict) which currently creates a "scalar" LArray with the dict, which is a bit weird.

@alixdamman alixdamman added this to the 0.29 milestone Feb 16, 2018
@gdementen gdementen self-assigned this Mar 1, 2018
@gdementen
Copy link
Contributor Author

stack(d) could work for this use case, but it currently does not.
It assumes that if we pass a dict, we need a real Axis object (to get labels order). On Python 3.7, this is no longer a necessary precaution. And even on Python < 3.7, this is annoying when you do not care about the order. Maybe changing the assert into a warning for python < 3.7 would be the right move, or even no warning in the code but a warning in the doc? After all when you iterate on a dict it does not output a warning.

@gdementen gdementen removed this from the 0.29 milestone Jul 4, 2018
@gdementen gdementen changed the title implement LArray.from_dict implement LArray.from_dict or add support for simple dict in stack Jul 4, 2018
@alixdamman
Copy link
Collaborator

As long as we add one or several examples, no warnings at all seems fine to me.

@gdementen gdementen removed their assignment Jul 4, 2018
@alixdamman alixdamman added this to the 0.31 milestone Dec 21, 2018
@alixdamman alixdamman modified the milestones: 0.31, 0.30 Apr 4, 2019
gdementen added a commit that referenced this issue Jun 20, 2019
* generalized it to more than one dimension (closes #56)

  - works for both stack([(ndkey, value), ...], axis=axes) and stack({ndkey: value}, several_axes)
  - deprecated axis argument in favor of axes

* changed the exception when using **kwargs without an axis on Python < 3.6 to a warning

* allowed using a dict without axis (closes #581, closes #755)

  This will produces a warning on Python < 3.7

* added support for res_axes
gdementen added a commit that referenced this issue Jun 26, 2019
* generalized it to more than one dimension (closes #56)

  - works for both stack([(ndkey, value), ...], axis=axes) and stack({ndkey: value}, several_axes)
  - deprecated axis argument in favor of axes

* changed the exception when using **kwargs without an axis on Python < 3.6 to a warning

* allowed using a dict without axis (closes #581, closes #755)

  This will produces a warning on Python < 3.7

* added support for res_axes
@gdementen
Copy link
Contributor Author

@alixdamman the functionality is now in stack, but LArray.from_dict might be more readable/more discoverable, so we might want to add it as a simple alias anyway. Thoughts?

@alixdamman
Copy link
Collaborator

alixdamman commented Jun 26, 2019

stack is really generic and so yes, it would be nice to have an explicit alias.

@gdementen gdementen reopened this Jun 26, 2019
@gdementen gdementen changed the title implement LArray.from_dict or add support for simple dict in stack implement LArray.from_dict or from_dict top-level function Jun 26, 2019
@gdementen gdementen removed this from the 0.31 milestone Aug 1, 2019
@alixdamman alixdamman added this to the nice_to_have milestone Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants