Example #1
0
def _register(name, type, force=0):
    """Register the type object.  Raise an exception if it is already registered
    unless force is true.
    """
    if typeDict.has_key(name) and not force:
        raise ValueError("Type %s has already been registered" % name)
    typeDict[name] = type
    return type
Example #2
0
def _register(name, type, force=0):
    """Register the type object.  Raise an exception if it is already registered
    unless force is true.
    """
    if typeDict.has_key(name) and not force:
        raise ValueError("Type %s has already been registered" % name)
    typeDict[name] = type
    return type
Example #3
0
 def __new__(type, name, bytes, default, typeno):
     """__new__() implements a 'quasi-singleton pattern because attempts
     to create duplicate types return the first created instance of that
     particular type parameterization,  i.e. the second time you try to
     create "Int32",  you get the original Int32, not a new one.
     """
     if typeDict.has_key(name):
         self = typeDict[name]
         if self.bytes != bytes or self.default != default or self.typeno != typeno:
             raise ValueError("Redeclaration of existing NumericType with different parameters.")
         return self
     else:
         return _numerictype.__new__(type, name, bytes, default, typeno)
Example #4
0
 def __new__(type, name, bytes, default, typeno):
     """__new__() implements a 'quasi-singleton pattern because attempts
     to create duplicate types return the first created instance of that
     particular type parameterization,  i.e. the second time you try to
     create "Int32",  you get the original Int32, not a new one.
     """
     if typeDict.has_key(name):
         self = typeDict[name]
         if self.bytes != bytes or self.default != default or self.typeno != typeno:
             raise ValueError(
                 "Redeclaration of existing NumericType with different parameters."
             )
         return self
     else:
         return _numerictype.__new__(type, name, bytes, default, typeno)
Example #5
0
def IsType(rep):
    """Determines whether the given object or string, 'rep', represents
    a numarray type."""
    return isinstance(rep, NumericType) or typeDict.has_key(rep)
Example #6
0
def IsType(rep):
    """Determines whether the given object or string, 'rep', represents
    a numarray type."""
    return isinstance(rep, NumericType) or typeDict.has_key(rep)