(key, val)
return True
Checks if a dictionary item can be pickled

    Parameters
    ----------
    key : try
        key for dictionary element
    val : None
        element of dictionary

    Returns
    -------
    picklable: bool
        whether the dictionary item can be pickled
Checks if a dictionary item can be pickled
Checks if a dictionary item can be pickled
def should_pickle(key, val):
    """
    Checks if a dictionary item can be pickled

    Parameters
    ----------
    key : try
        key for dictionary element
    val : None
        element of dictionary

    Returns
    -------
    picklable: bool
        whether the dictionary item can be pickled
    """
    try:
        ## make sure object can be pickled and then re-read
        # pickle object
        pickled = codecs.encode(pickle.dumps(val), "base64").decode()
        # unpickle object
        unpickled = pickle.loads(codecs.decode(pickled.encode(), "base64"))
    except (
        pickle.PicklingError,
        tf.errors.InvalidArgumentError,
        TypeError,
        tf.errors.InternalError,
        OverflowError,
        TypingError,
        AttributeError,
    ) as e:
        warn("Did not pickle {}: {}".format(key, e))
        return False
    return True
def should_pickle ( key , val ) : try : ## make sure object can be pickled and then re-read # pickle object pickled = codecs . encode ( pickle . dumps ( val ) , "base64" ) . decode ( ) # unpickle object unpickled = pickle . loads ( codecs . decode ( pickled . encode ( ) , "base64" ) ) except ( pickle . PicklingError , tf . errors . InvalidArgumentError , TypeError , tf . errors . InternalError , OverflowError , TypingError , AttributeError , ) as e : warn ( "Did not pickle {}: {}" . format ( key , e ) ) return False return True