Return the number of files in the sequence. This function will first try to call the builtin :meth:`len` function, but if that fails, the entire squence will be iterated over and counted. Args: wrfseq (iterable): An iterable type, which includes lists, tuples, dict
(wrfseq)
| 1785 | |
| 1786 | |
| 1787 | def _get_numfiles(wrfseq): |
| 1788 | """Return the number of files in the sequence. |
| 1789 | |
| 1790 | This function will first try to call the builtin :meth:`len` function, but |
| 1791 | if that fails, the entire squence will be iterated over and counted. |
| 1792 | |
| 1793 | Args: |
| 1794 | |
| 1795 | wrfseq (iterable): An iterable type, which includes lists, tuples, |
| 1796 | dictionaries, generators, and user-defined classes. |
| 1797 | |
| 1798 | Returns: |
| 1799 | |
| 1800 | :obj:`int`: The number of files in the sequence. |
| 1801 | |
| 1802 | """ |
| 1803 | try: |
| 1804 | return len(wrfseq) |
| 1805 | except TypeError: |
| 1806 | wrf_iter = iter(wrfseq) |
| 1807 | return sum(1 for _ in wrf_iter) |
| 1808 | |
| 1809 | |
| 1810 | def _join_files(wrfseq, varname, timeidx, is_moving, meta, _key): |