Skip to content

Slicing of SolutionArray raises error #804

@ischoegl

Description

@ischoegl

System information

  • Cantera version: 2.5.0a4
  • OS: Ubuntu
  • Python/MATLAB version: Python 3.6.8

Expected behavior

Slicing of SolutionArray objects should work as usual (as indexing is implemented).

Actual behavior

Slicing does not work.

To Reproduce

Steps to reproduce the behavior:

In [1]: import cantera as ct
   ...: gas = ct.Solution('gri30.yaml')
   ...: arr = ct.SolutionArray(gas, 10)

In [2]: arr[0]
Out[2]: <cantera.composite.SolutionArray at 0x7ffa61a364e0>

In [3]: arr[:]
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-47ed00660ce3> in <module>()
----> 1 arr[:]

/usr/local/lib/python3.6/dist-packages/cantera/composite.py in __getitem__(self, index)
    534     def __getitem__(self, index):
    535         states = self._states[index]
--> 536         shape = states.shape[:-1]
    537         return SolutionArray(self._phase, shape, states)
    538 

AttributeError: 'list' object has no attribute 'shape'

Additional context

The error message clearly points at the issue.

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