Instatiate the :class:`ScalarValue` while recognizing :class:`Zero`
        and :class:`One`.

        :class:`Scalar` instances as `val` (including
        :class:`ScalarExpression` instances) are left unchanged. This makes
        :meth:`ScalarValue.create` a safe method for converting unknown objects
        to :class:`Scalar`.

def create(cls, val):
        """Instatiate the :class:`ScalarValue` while recognizing :class:`Zero`
        and :class:`One`.

        :class:`Scalar` instances as `val` (including
        :class:`ScalarExpression` instances) are left unchanged. This makes
        :meth:`ScalarValue.create` a safe method for converting unknown objects
        to :class:`Scalar`.
        """
        if val in cls._invalid:
            raise ValueError("Invalid value %r" % val)
        if val == 0:
            return Zero
        elif val == 1:
            return One
        elif isinstance(val, Scalar):
            return val
        else:
            # We instantiate ScalarValue directly to avoid the overhead of
            # super().create(). Thus, there is no caching for scalars (which is
            # probably a good thing)
            return cls(val)