MCPcopy Create free account
hub / github.com/NCAR/wrf-python / get_iterable

Function get_iterable

src/wrf/util.py:375–406  ·  view source on GitHub ↗

Returns a resettable iterable object. In this context, resettable means that when :meth:`object.__iter__` is called, the iterable returned always points to the first element in the sequence, similar to how the list and tuple behave. Args: wrfseq (iterable): An iterable typ

(wrfseq)

Source from the content-addressed store, hash-verified

373
374
375def get_iterable(wrfseq):
376 """Returns a resettable iterable object.
377
378 In this context, resettable means that when :meth:`object.__iter__`
379 is called, the iterable returned always points to the first element
380 in the sequence, similar to how the list and tuple behave.
381
382 Args:
383
384 wrfseq (iterable): An iterable type, which includes lists, tuples,
385 dictionaries, generators, and user-defined classes.
386
387 Returns:
388
389 iterable: A resettable iterator object.
390
391 """
392 if not is_multi_file(wrfseq):
393 return wrfseq
394 else:
395 if not is_mapping(wrfseq):
396
397 if isinstance(wrfseq, (list, tuple, IterWrapper)):
398 return wrfseq
399 else:
400 return IterWrapper(wrfseq) # generator/custom iterable class
401
402 else:
403 if isinstance(wrfseq, dict):
404 return wrfseq
405 else:
406 return dict(wrfseq) # generator/custom iterable dict class
407
408
409# Helper to extract masked arrays from DataArrays that convert to NaN

Callers 6

ll_to_xyFunction · 0.85
xy_to_llFunction · 0.85
getvarFunction · 0.85
combine_filesFunction · 0.85
get_idFunction · 0.85
vinterpFunction · 0.85

Calls 3

is_multi_fileFunction · 0.85
is_mappingFunction · 0.85
IterWrapperClass · 0.85

Tested by

no test coverage detected