Return the cache id. The cache id is used as a caching key for various routines. If the object type is a mapping, then the result will also be a mapping of each key to the object id for the value. Args: obj (:obj:`object`): Any object type. prefix (:obj:`str`): A
(obj, prefix='')
| 3081 | |
| 3082 | |
| 3083 | def get_id(obj, prefix=''): |
| 3084 | """Return the cache id. |
| 3085 | |
| 3086 | The cache id is used as a caching key for various routines. If the |
| 3087 | object type is a mapping, then the result will also be a |
| 3088 | mapping of each key to the object id for the value. |
| 3089 | |
| 3090 | Args: |
| 3091 | |
| 3092 | obj (:obj:`object`): Any object type. |
| 3093 | |
| 3094 | prefix (:obj:`str`): A string to help with recursive calls. |
| 3095 | |
| 3096 | Returns: |
| 3097 | |
| 3098 | :obj:`int` or :obj:`dict`: If the *obj* parameter is not a mapping, |
| 3099 | then the object id is returned. Otherwise, a mapping of each |
| 3100 | key to the object id for the value is returned. |
| 3101 | |
| 3102 | """ |
| 3103 | if not is_multi_file(obj): |
| 3104 | return hash(prefix + get_filepath(obj)) |
| 3105 | |
| 3106 | # For sequences, the hashing string will be the list ID and the |
| 3107 | # path for the first file in the sequence |
| 3108 | if not is_mapping(obj): |
| 3109 | _obj = get_iterable(obj) |
| 3110 | _next = next(iter(_obj)) |
| 3111 | return get_id(_next, prefix + str(id(obj))) |
| 3112 | |
| 3113 | # For each key in the mapping, recursively call get_id until |
| 3114 | # until a non-mapping is found |
| 3115 | return {key: get_id(val, prefix) for key, val in viewitems(obj)} |
| 3116 | |
| 3117 | |
| 3118 | def geo_bounds(var=None, wrfin=None, varname=None, timeidx=0, method="cat", |
no test coverage detected