scenic.core.utils

Assorted utility functions.

Summary of Module Members

Functions

areEquivalent

Whether two objects are equivalent, i.e. have the same properties.

argsToString

cached

Decorator for making a method with no arguments cache its result

cached_property

get_type_args

Version of typing.get_args supporting Python 3.7.

get_type_origin

Version of typing.get_origin supporting Python 3.7.

Classes

DefaultIdentityDict

Dictionary which is the identity map by default.

Member Details

cached(oldMethod)[source]

Decorator for making a method with no arguments cache its result

areEquivalent(a, b)[source]

Whether two objects are equivalent, i.e. have the same properties.

This is only used for debugging, e.g. to check that a Distribution is the same before and after pickling. We don’t want to define __eq__ for such objects since for example two values sampled with the same distribution are equivalent but not semantically identical: the code:

X = (0, 1)
Y = (0, 1)

does not make X and Y always have equal values!

class DefaultIdentityDict[source]

Dictionary which is the identity map by default.

The map works on all objects, even unhashable ones, but doesn’t support all of the standard mapping operations.

get_type_origin(tp)[source]

Version of typing.get_origin supporting Python 3.7.

get_type_args(tp)[source]

Version of typing.get_args supporting Python 3.7.