|
1 | 1 | """License:
|
2 |
| - Distributed under the OSI-approved Apache License, Version 2.0. See |
3 |
| - accompanying file Copyright.txt for details. |
| 2 | +Distributed under the OSI-approved Apache License, Version 2.0. See |
| 3 | +accompanying file Copyright.txt for details. |
4 | 4 | """
|
5 | 5 |
|
6 | 6 | from functools import singledispatchmethod
|
@@ -296,14 +296,17 @@ def _(self, name, content, shape=[], start=[], count=[], operations=None):
|
296 | 296 |
|
297 | 297 | if not variable:
|
298 | 298 | # Sequence variables
|
299 |
| - if isinstance(content, np.ndarray): |
300 |
| - variable = self._io.define_variable(name, content, shape, start, count) |
301 |
| - elif isinstance(content, list): |
302 |
| - if shape == [] and count == []: |
303 |
| - shape = [len(content)] |
304 |
| - count = shape |
305 |
| - start = [0] |
| 299 | + if isinstance(content, (list, np.ndarray)): |
| 300 | + if isinstance(content, list): |
| 301 | + content = np.asarray(content) |
| 302 | + |
| 303 | + # If shape, start, and count is not specified, use the numpy array's shape |
| 304 | + if shape == [] and start == [] and count == []: |
| 305 | + shape = list(content.shape) |
| 306 | + start = [0] * content.ndim |
| 307 | + count = shape[:] |
306 | 308 | variable = self._io.define_variable(name, content, shape, start, count)
|
| 309 | + |
307 | 310 | # Scalar variables
|
308 | 311 | elif isinstance(content, str):
|
309 | 312 | variable = self._io.define_variable(name, content)
|
|
0 commit comments