bbalasub1 / glmnet_python

GNU General Public License v3.0
199 stars 93 forks source link

Merging dict syntaxError #4

Closed hanfang closed 7 years ago

hanfang commented 7 years ago

Hi @bbalasub1 ,

In glmnetSet.py and glmnetControl.py, there are two lines that are not compatible with python 3.4.5:

options = {**options, **opts}
ivals = {**ivals, **pars}   # update values

In python 3.4.5, the below works:

options = merge_dicts(options, opts)
ivals = merge_dicts(ivals, pars)

The reason is because {**A, **B} is supported after python 3.5.

Note:

def merge_dicts(*dict_args):
    """
    Given any number of dicts, shallow copy and merge into a new dict,
    precedence goes to key value pairs in latter dicts.
    """
    result = {}
    for dictionary in dict_args:
        result.update(dictionary)
    return result
bbalasub1 commented 7 years ago

Thanks. Merged now.