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

Function get_id

src/wrf/util.py:3083–3115  ·  view source on GitHub ↗

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='')

Source from the content-addressed store, hash-verified

3081
3082
3083def 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
3118def geo_bounds(var=None, wrfin=None, varname=None, timeidx=0, method="cat",

Callers 5

ll_to_xyFunction · 0.85
xy_to_llFunction · 0.85
getvarFunction · 0.85
geo_boundsFunction · 0.85
vinterpFunction · 0.85

Calls 5

is_multi_fileFunction · 0.85
get_filepathFunction · 0.85
is_mappingFunction · 0.85
get_iterableFunction · 0.85
viewitemsFunction · 0.85

Tested by

no test coverage detected