MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / __init__

Method __init__

numpy_ml/utils/data_structures.py:479–493  ·  view source on GitHub ↗

A dictionary subclass which returns the key value if it is not in the dict. Parameters ---------- encoder : function or None A function which is applied to a key before adding / retrieving it from the dictionary. If None, the function

(self, encoder=None)

Source from the content-addressed store, hash-verified

477
478class Dict(dict):
479 def __init__(self, encoder=None):
480 """
481 A dictionary subclass which returns the key value if it is not in the
482 dict.
483
484 Parameters
485 ----------
486 encoder : function or None
487 A function which is applied to a key before adding / retrieving it
488 from the dictionary. If None, the function defaults to the
489 identity. Default is None.
490 """
491 super(Dict, self).__init__()
492 self._encoder = encoder
493 self._id_max = 0
494
495 def __setitem__(self, key, value):
496 if self._encoder is not None:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected