Skip to content

TyperError about the data indexing problem #3610

@soulstealer-star

Description

@soulstealer-star

Hi there is still some error from the OPM FLOW REFERENCE manual for the Python code part.

In the part of APPENDIX D: PYTHON INTERFACE TO OPM FLOW, one example is as follow:

kw = deck["WELSPECS"] 
print(f"Keyword has {len(kw)} records")
for record in kw:
    well = record["WELL"].get_str()
    group = record[1].get_str()
    print(f"Well {num}: {well} is part of group{group})

After I load a new deck to this code, the main error occurs on this code: well = record["WELL"].get_str()

The error is:

well = record["WELL"].get_str()
**TypeError: __getitem__(): incompatible function arguments. The following argument types are supported:
1. (self: opm.opmcommon_python.DeckRecord, arg0: int) -> Opm::DeckItem**

Which means I cannot use the keyword index to get the values,only can use the int number. Also there is other example in the manual using the same kind of code.

Is this because the latest python library really doesn't support keyword indexing now, or do I need to use some other method?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions