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

Click #595

Merged
merged 23 commits into from
Mar 21, 2019
Merged

Click #595

merged 23 commits into from
Mar 21, 2019

Conversation

doutriaux1
Copy link
Contributor

No description provided.

@doutriaux1 doutriaux1 requested a review from lee1043 March 7, 2019 22:18
@gleckler1
Copy link
Contributor

@doutriaux1 I'll try to take her for a spin tomorrow... is there an example somewhere?

@lee1043
Copy link
Contributor

lee1043 commented Mar 8, 2019

@doutriaux1 below is error message I am getting when I tried with this update.

Deprecation warning: please use 'import pcmdi_metrics.driver.pmp_parser.PMPParser'
LOOKING AT PATTERN: *.json in ./json_files
We are looking at 5 Json Files:
Traceback (most recent call last):
  File "/export_backup/lee1043/git/click/modal/generate_modal.py", line 167, in <module>
    data = J(**dic)(squeeze=1)
  File "build/bdist.linux-x86_64/egg/pcmdi_metrics/io/base.py", line 645, in __call__
RuntimeError: You requested to merge axis is '['model', 'realization']' which is not valid. Axes: ['variable', u'model', u'realization', u'reference', u'mode', u'season', u'statistic']

I don't know why it complains it cannot find model and realization while they were listed as Axes. It may be because of the dictionary key thing, u? Any idea?

Error coming from here:

"You requested to merge axis is '{}' which is not valid. Axes: {}".format(merger, axes_ids))

@lee1043
Copy link
Contributor

lee1043 commented Mar 8, 2019

@doutriaux1 I think I nailed the cause of my error.

(Pdb) merge
[['model', 'realization'], ['mode', 'season']]
(Pdb) merger
['model', 'realization']
(Pdb) axes_ids
['variable', u'model', u'realization', u'reference', u'mode', u'season', u'statistic']
(Pdb) merger in axes_ids
False
  • Is merge always be list of list, including two pairs of axes? or could it be just a list of two axes? If it could be a list of two axes, current code should work. But it seems my case is not. In my parameter, my merger is like following: merge = [["model", "realization"], ["mode", "season"]], so it is a list of lists.
  • I think the error for my case is coming from checking merger in axes_ids at below linked line of code, rather than checking merger[0] in axes_ids or merger[1] in axes_ids
    if not merger in axes_ids:

@lee1043
Copy link
Contributor

lee1043 commented Mar 8, 2019

Below and attached (please remove .TXT at the end of file name) are a toy code that I wrote to flatten list of lists. Hope this help.

import itertools

def flatten(list0):
    """
    NOTE: Flatten given list of lists to list
    input
    - list0: list, string, list of lists, etc.
    output
    - list2: flat list
    """
    if isinstance(list0, list):
        list1 = [([x] if isinstance(x, str) else x) for x in list0]
        list2 = list(itertools.chain(*list1))
    else:
        list2 = [list0]
    return list2
merge1 = [["model", "realization"], ["mode", "season"]]  # WORK
merge2 = ["model", "realization"] # WORK
merge3 = [["model", "realization"], ["mode", "season"], 'test']  # WORK
merge4 = [["realization"], ["mode", "season"], 'test0', ['test1', 'test2']]  # WORK
merge5 = 'model'  # WORK
merge6 = [[['model', 'realization'], ['mode', 'season']], 'test0']  # NOT WORK
print(flatten(merge1))
print(flatten(merge2))
print(flatten(merge3))
print(flatten(merge4))
print(flatten(merge5))
print(flatten(merge6))
['model', 'realization', 'mode', 'season']
['model', 'realization']
['model', 'realization', 'mode', 'season', 'test']
['realization', 'mode', 'season', 'test0', 'test1', 'test2']
['model']
[['model', 'realization'], ['mode', 'season'], 'test0']

flatten_list_of_list.ipynb.TXT
flatten_list_of_list.py.TXT
flatten_list_of_list.html.TXT

@doutriaux1
Copy link
Contributor Author

@lee1043 always a list of list.

@lee1043
Copy link
Contributor

lee1043 commented Mar 11, 2019

@doutriaux1 good to learn, thanks for confirming.

Copy link
Contributor

@lee1043 lee1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@doutriaux1 it fixed the x-axis combination error problem, as shown at PCMDI/click#7. Thank you for the update. I confirm the PR is ready to be merged.

@doutriaux1 doutriaux1 merged commit 8e149e0 into master Mar 21, 2019
@doutriaux1 doutriaux1 deleted the click branch March 21, 2019 21:25
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.

3 participants