jpn-- / larch

Larch: a Python tool for choice modeling
http://larch.newman.me
GNU General Public License v3.0
41 stars 14 forks source link

OMX indices #23

Closed pedrocamargo closed 2 years ago

pedrocamargo commented 2 years ago

Indexing skims on arbitrary IDs returns an error

skims = larch.OMX(omx_file, mode='r' ) lx.Dataset.construct.from_omx(skims, indexes='taz')

Results in


AttributeError Traceback (most recent call last) Input In [58], in <cell line: 1>() ----> 1 lx.Dataset.construct.from_omx(skims, indexes='taz')

File D:\src\OuterLoop\gsm-poc.venv\lib\site-packages\larch\dataset\construct.py:14, in _steal..wrapper(*args, kwargs) 13 def wrapper(*args, *kwargs): ---> 14 return func(args, kwargs)

File D:\src\OuterLoop\gsm-poc.venv\lib\site-packages\sharrow\dataset.py:235, in from_omx(omx, index_names, indexes, renames) 228 indexes = { 229 index_names[0]: zero_based(omx_shape[0]), 230 index_names[1]: zero_based(omx_shape[1]), 231 } 232 if indexes is not None: 233 d["coords"] = { 234 index_name: {"dims": index_name, "data": index} --> 235 for index_name, index in indexes.items() 236 } 237 return xr.Dataset.from_dict(d)

AttributeError: 'str' object has no attribute 'items'

jpn-- commented 2 years ago

Are you following a code model somewhere in the docs, can you point me there? What version of sharrow is installed?

On Aug 25, 2022, at 5:37 PM, Pedro Camargo @.***> wrote:

 Indexing skims on arbitrary IDs returns an error

skims = larch.OMX(omx_file, mode='r' ) lx.Dataset.construct.from_omx(skims, indexes='taz')

Results in

`--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Input In [58], in <cell line: 1>() ----> 1 lx.Dataset.construct.from_omx(skims, indexes='taz')

File D:\src\OuterLoop\gsm-poc.venv\lib\site-packages\larch\dataset\construct.py:14, in _steal..wrapper(*args, kwargs) 13 def wrapper(*args, *kwargs): ---> 14 return func(args, kwargs)

File D:\src\OuterLoop\gsm-poc.venv\lib\site-packages\sharrow\dataset.py:235, in from_omx(omx, index_names, indexes, renames) 228 indexes = { 229 index_names[0]: zero_based(omx_shape[0]), 230 index_names[1]: zero_based(omx_shape[1]), 231 } 232 if indexes is not None: 233 d["coords"] = { 234 index_name: {"dims": index_name, "data": index} --> 235 for index_name, index in indexes.items() 236 } 237 return xr.Dataset.from_dict(d)

AttributeError: 'str' object has no attribute 'items'`

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

jpn-- commented 2 years ago

Should be fixed now if you update sharrow to 2.2.4.