Exemple #1
0
def store_if_dirty():
    # Only load from request cache here -- if it hasn't been loaded from memcache previously, it's not dirty.
    bingo_cache = REQUEST_CACHE.get(BingoCache.MEMCACHE_KEY)
    bingo_identity_cache = REQUEST_CACHE.get(BingoIdentityCache.key_for_identity(identity()))

    if bingo_cache:
        bingo_cache.store_if_dirty()

    if bingo_identity_cache:
        bingo_identity_cache.store_for_identity_if_dirty(identity())
Exemple #2
0
 def load_from_datastore():
     bingo_identity_cache = _GAEBingoIdentityRecord.load(identity())
     
     if bingo_identity_cache:
         bingo_identity_cache.purge()
         bingo_identity_cache.dirty = True
         bingo_identity_cache.store_for_identity_if_dirty(identity())
     else:
         bingo_identity_cache = BingoIdentityCache()
     
     return bingo_identity_cache
Exemple #3
0
def update(url, xml_src):
    """
    This is a correct method to update an identity in the database.
    PREPRO need to check that date or version is after old one so not vulnerable to replay attacks.
    """
    try:
        newid = identity.identity(xmlsrc=xml_src)
    except:
        dhnio.DprintException()
        return False

    if not newid.isCorrect():
        dhnio.Dprint(1,
                     "identitydb.update ERROR: incorrect identity " + str(url))
        return False

    try:
        if not newid.Valid():
            dhnio.Dprint(
                1, "identitydb.update ERROR identity not Valid" + str(url))
            return False
    except:
        dhnio.DprintException()
        return False

    filename = os.path.join(settings.IdentityCacheDir(),
                            nameurl.UrlFilename(url))
    if os.path.exists(filename):
        oldidentityxml = dhnio.ReadTextFile(filename)
        oldidentity = identity.identity(xmlsrc=oldidentityxml)

        if oldidentity.publickey != newid.publickey:
            dhnio.Dprint(
                1,
                "identitydb.update ERROR new publickey does not match old : SECURITY VIOLATION "
                + url)
            return False

        if oldidentity.signature != newid.signature:
            dhnio.Dprint(
                6,
                'identitydb.update have new data for ' + nameurl.GetName(url))
        else:
            idset(url, newid)
            return True

    dhnio.WriteFile(filename, xml_src)  # publickeys match so we can update it
    idset(url, newid)

    return True
Exemple #4
0
def get(url):
    """
    A smart way to get identity from cache.
    If not cached in memory but found on disk - will cache from disk.
    """
    if has_key(url):
        return idget(url)
    else:
        try:
            partfilename = nameurl.UrlFilename(url)
        except:
            dhnio.Dprint(1, "identitydb.get ERROR %s is incorrect" % str(url))
            return None

        filename = os.path.join(settings.IdentityCacheDir(), partfilename)
        if not os.path.exists(filename):
            dhnio.Dprint(6, "identitydb.get file %s not exist" % os.path.basename(filename))
            return None

        idxml = dhnio.ReadTextFile(filename)
        if idxml:
            idobj = identity.identity(xmlsrc=idxml)
            url2 = idobj.getIDURL()
            if url == url2:
                idset(url, idobj)
                return idobj

            else:
                dhnio.Dprint(1, "identitydb.get ERROR url=%s url2=%s" % (url, url2))
                return None

        dhnio.Dprint(6, "identitydb.get %s not found" % nameurl.GetName(url))
        return None
Exemple #5
0
def identity_test():

    #*****************************************************************************80
    #
    ## IDENTITY_TEST tests IDENTITY.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    14 February 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    from r8mat_print import r8mat_print

    print ''
    print 'IDENTITY_TEST'
    print '  IDENTITY computes the IDENTITY matrix.'

    m = 4
    n = m

    a = identity(m, n)
    r8mat_print(m, n, a, '  IDENTITY matrix:')

    print ''
    print 'IDENTITY_TEST'
    print '  Normal end of execution.'

    return
def identity_test ( ):

#*****************************************************************************80
#
## IDENTITY_TEST tests IDENTITY.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    14 February 2015
#
#  Author:
#
#    John Burkardt
#
  from r8mat_print import r8mat_print

  print ''
  print 'IDENTITY_TEST'
  print '  IDENTITY computes the IDENTITY matrix.'

  m = 4
  n = m

  a = identity ( m, n )
  r8mat_print ( m, n, a, '  IDENTITY matrix:' )

  print ''
  print 'IDENTITY_TEST'
  print '  Normal end of execution.'

  return
def init_request_cache_from_memcache():
    if not request_cache.cache.get("loaded_from_memcache"):
        request_cache.cache.update(
            memcache.get_multi([
                BingoCache.MEMCACHE_KEY,
                BingoIdentityCache.key_for_identity(identity())
            ]))
        request_cache.cache["loaded_from_memcache"] = True
    def get():
        init_request_cache_from_memcache()

        key = BingoIdentityCache.key_for_identity(identity())
        if not request_cache.cache.get(key):
            request_cache.cache[key] = BingoIdentityCache.load_from_datastore()

        return request_cache.cache[key]
Exemple #9
0
    def get():
        init_request_cache_from_memcache()

        key = BingoIdentityCache.key_for_identity(identity())
        if not REQUEST_CACHE.get(key):
            REQUEST_CACHE[key] = BingoIdentityCache.load_from_datastore()

        return REQUEST_CACHE[key]
Exemple #10
0
    def get():
        init_request_cache_from_memcache()

        key = BingoIdentityCache.key_for_identity(identity())
        if not request_cache.cache.get(key):
            request_cache.cache[key] = BingoIdentityCache.load_from_datastore()

        return request_cache.cache[key]
Exemple #11
0
def init_request_cache_from_memcache():
    global REQUEST_CACHE

    if not REQUEST_CACHE.get("loaded_from_memcache"):
        REQUEST_CACHE = memcache.get_multi([
            BingoCache.MEMCACHE_KEY,
            BingoIdentityCache.key_for_identity(identity())
        ])
        REQUEST_CACHE["loaded_from_memcache"] = True
def forward(network,x):
	W1,W2,W3=network["W1"],network["W2"],network["W3"]
	b1,b2,b3=network["b1"],network["b2"],network["b3"]

	a1=np.dot(x,W1)+b1
	z1=sigmoid(a1)
	a2=np.dot(z1,W2)+b2
	z2=sigmoid(a2)
	a3=np.dot(z2,W3)+b3
	y=identity(a3)

	return y
Exemple #13
0
    def __init__(self, num_class=51, num_frame=10, pretrained=False):
        super(LSTM_i, self).__init__()
        # Args.
        self.num_class = num_class
        self.num_frame = num_frame

        # Layers.
        self.inception = models.inception_v3(pretrained=pretrained)
        self.inception.fc = identity()

        self.lstm = nn.LSTM(input_size=2048, hidden_size=512, batch_first=True)
        self.classifier = nn.Linear(512, self.num_class)
        self.avgpool = nn.AvgPool2d((self.num_frame, 1), 1)
    def __init__(self, num_class=51, num_frame=10, pretrained=False):
        super(Inception_a, self).__init__()
        # Args.
        self.num_class = num_class
        self.num_frame = num_frame

        # Layers.
        self.inception = models.inception_v3(pretrained=pretrained)

        # Conv Pooling
        self.inception.fc = identity()
        self.avgpool = nn.AvgPool2d((self.num_frame, 1), 1)
        self.fc = nn.Linear(2048, self.num_class, bias=True)
def r8mat_is_inverse ( n, a, b ):

#*****************************************************************************80
#
## R8MAT_IS_INVERSE measures the error in a matrix inverse.
#
#  Discussion:
#
#    An R8MAT is a matrix of real values.
#
#    This routine returns the sum of the Frobenius norms of
#      A * B - I and B * A - I.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    23 March 2015
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, integer N, the order of the matrix.
#
#    Input, real A(N,N), the matrix.
#
#    Input, real B(M,N), the inverse matrix.
#
#    Output, real VALUE, the Frobenius norm
#    of the difference matrices A * B - I and B * A - I.
#
  from identity import identity
  from r8mat_mm import r8mat_mm
  from r8mat_sub import r8mat_sub
  from r8mat_norm_fro import r8mat_norm_fro

  ab = r8mat_mm ( n, n, n, a, b )
  ba = r8mat_mm ( n, n, n, b, a )
  id = identity ( n, n )
  d1 = r8mat_sub ( n, n, ab, id )
  d2 = r8mat_sub ( n, n, ba, id )
 
  value = r8mat_norm_fro ( n, n, d1 ) \
        + r8mat_norm_fro ( n, n, d2 )

  return value
Exemple #16
0
def permutation_random(n, key):

    #*****************************************************************************80
    #
    ## PERMUTATION_RANDOM returns the PERMUTATION_RANDOM matrix.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    27 March 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    #  Reference:
    #
    #    Albert Nijenhuis, Herbert Wilf,
    #    Combinatorial Algorithms,
    #    Academic Press, 1978, second edition,
    #    ISBN 0-12-519260-6.
    #
    #  Parameters:
    #
    #    Input, integer N, the order of the matrix.
    #
    #    Input, integer KEY, a positive value that selects the data.
    #
    #    Output, real A(N,N), the matrix.
    #
    from i4_uniform_ab import i4_uniform_ab
    from identity import identity

    a = identity(n, n)

    seed = key

    for i in range(0, n):
        i4_lo = i
        i4_hi = n - 1
        i2, seed = i4_uniform_ab(i4_lo, i4_hi, seed)
        if (i2 != i):
            for j in range(0, n):
                t = a[i, j]
                a[i, j] = a[i2, j]
                a[i2, j] = t

    return a
def permutation_random ( n, key ):

#*****************************************************************************80
#
## PERMUTATION_RANDOM returns the PERMUTATION_RANDOM matrix.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    27 March 2015
#
#  Author:
#
#    John Burkardt
#
#  Reference:
#
#    Albert Nijenhuis, Herbert Wilf,
#    Combinatorial Algorithms,
#    Academic Press, 1978, second edition,
#    ISBN 0-12-519260-6.
#
#  Parameters:
#
#    Input, integer N, the order of the matrix.
#
#    Input, integer KEY, a positive value that selects the data.
#
#    Output, real A(N,N), the matrix.
#
  from i4_uniform_ab import i4_uniform_ab
  from identity import identity

  a = identity ( n, n )

  seed = key

  for i in range ( 0, n ):
    i4_lo = i
    i4_hi = n - 1
    i2, seed = i4_uniform_ab ( i4_lo, i4_hi, seed )
    if ( i2 != i ):
      for j in range ( 0, n ):
        t = a[i,j]
        a[i,j] = a[i2,j]
        a[i2,j] = t

  return a
Exemple #18
0
    def __init__(self, num_class=51, num_frame=10, pretrained=False):
        super(LSTM_r, self).__init__()
        # Args.
        self.num_class = num_class
        self.num_frame = num_frame

        # Layers.
        self.resnet50 = models.resnet50(pretrained=pretrained)
        self.resnet50.fc = identity()

        self.lstm = nn.LSTM(input_size=2048,
                            hidden_size=2048,
                            batch_first=True)
        self.classifier = nn.Linear(2048, self.num_class)
Exemple #19
0
        def gae_bingo_start_response(status, headers, exc_info=None):

            if using_logged_in_bingo_identity():
                if get_identity_cookie_value():
                    # If using logged in identity, clear cookie b/c we don't need it
                    # and it can cause issues after logging out.
                    headers.append(("Set-Cookie", delete_identity_cookie_header()))
            else:
                # Not using logged-in identity. If current identity isn't already stored in cookie,
                # do it now.
                if identity() != get_identity_cookie_value():
                    headers.append(("Set-Cookie", set_identity_cookie_header()))

            return start_response(status, headers, exc_info)
Exemple #20
0
        def gae_bingo_start_response(status, headers, exc_info=None):

            if using_logged_in_bingo_identity():
                if get_identity_cookie_value():
                    # If using logged in identity, clear cookie b/c we don't need it
                    # and it can cause issues after logging out.
                    headers.append(
                        ("Set-Cookie", delete_identity_cookie_header()))
            else:
                # Not using logged-in identity. If current identity isn't already stored in cookie,
                # do it now.
                if identity() != get_identity_cookie_value():
                    headers.append(
                        ("Set-Cookie", set_identity_cookie_header()))

            return start_response(status, headers, exc_info)
Exemple #21
0
 def isMyIdentityValid(self, arg):
     """
     Condition method.
     """
     id_from_server = identity.identity(xmlsrc=arg)
     if not id_from_server.isCorrect():
         # print 'isCorrect - False'
         return False
     if not id_from_server.Valid():
         # print 'Valid - False'
         return False
     equal = self.new_identity.serialize() == id_from_server.serialize()
     # if not equal:
     # print 'not equal'
     # print self.new_identity.serialize()
     # print id_from_server.serialize()
     return equal
 def isMyIdentityValid(self, arg):
     """
     Condition method.
     """
     id_from_server = identity.identity(xmlsrc=arg)
     if not id_from_server.isCorrect():
         # print 'isCorrect - False'
         return False
     if not id_from_server.Valid():
         # print 'Valid - False'
         return False
     equal = self.new_identity.serialize() == id_from_server.serialize()
     # if not equal:
     # print 'not equal'
     # print self.new_identity.serialize()
     # print id_from_server.serialize()
     return equal
Exemple #23
0
    def fill_request_cache():
        """Load BingoCache/BingoIdentityCache from instance cache/memcache.

        This loads the shared BingoCache and the individual BingoIdentityCache
        for the current request's bingo identity and stores them both in the
        request cache.
        """
        if not request_cache.cache.get("bingo_request_cache_filled"):

            # Assume that we're going to grab both BingoCache and
            # BingoIdentityCache from memcache
            memcache_keys = [
                BingoCache.CACHE_KEY,
                BingoIdentityCache.key_for_identity(identity())
            ]

            # Try to grab BingoCache from instance cache
            bingo_instance = instance_cache.get(BingoCache.CACHE_KEY)
            if bingo_instance:
                # If successful, use instance cached version...
                request_cache.cache[BingoCache.CACHE_KEY] = bingo_instance
                # ...and don't load BingoCache from memcache
                memcache_keys.remove(BingoCache.CACHE_KEY)

            # Load necessary caches from memcache
            dict_memcache = memcache.get_multi(memcache_keys)

            # Decompress BingoCache if we loaded it from memcache
            if BingoCache.CACHE_KEY in dict_memcache:
                dict_memcache[BingoCache.CACHE_KEY] = CacheLayers.decompress(
                    dict_memcache[BingoCache.CACHE_KEY])

            # Update request cache with values loaded from memcache
            request_cache.cache.update(dict_memcache)

            if not bingo_instance:
                # And if BingoCache wasn't in the instance cache already, store
                # it with a 1-minute expiry
                instance_cache.set(BingoCache.CACHE_KEY,
                                   request_cache.cache.get(
                                       BingoCache.CACHE_KEY),
                                   expiry=CacheLayers.INSTANCE_SECONDS)

            request_cache.cache["bingo_request_cache_filled"] = True
Exemple #24
0
    def fill_request_cache():
        """Load BingoCache/BingoIdentityCache from instance cache/memcache.

        This loads the shared BingoCache and the individual BingoIdentityCache
        for the current request's bingo identity and stores them both in the
        request cache.
        """
        if not request_cache.cache.get("bingo_request_cache_filled"):

            # Assume that we're going to grab both BingoCache and
            # BingoIdentityCache from memcache
            memcache_keys = [
                BingoCache.CACHE_KEY,
                BingoIdentityCache.key_for_identity(identity())
            ]

            # Try to grab BingoCache from instance cache
            bingo_instance = instance_cache.get(BingoCache.CACHE_KEY)
            if bingo_instance:
                # If successful, use instance cached version...
                request_cache.cache[BingoCache.CACHE_KEY] = bingo_instance
                # ...and don't load BingoCache from memcache
                memcache_keys.remove(BingoCache.CACHE_KEY)

            # Load necessary caches from memcache
            dict_memcache = memcache.get_multi(memcache_keys)

            # Decompress BingoCache if we loaded it from memcache
            if BingoCache.CACHE_KEY in dict_memcache:
                dict_memcache[BingoCache.CACHE_KEY] = CacheLayers.decompress(
                        dict_memcache[BingoCache.CACHE_KEY])

            # Update request cache with values loaded from memcache
            request_cache.cache.update(dict_memcache)

            if not bingo_instance:
                # And if BingoCache wasn't in the instance cache already, store
                # it with a 1-minute expiry
                instance_cache.set(BingoCache.CACHE_KEY,
                        request_cache.cache.get(BingoCache.CACHE_KEY),
                        expiry=CacheLayers.INSTANCE_SECONDS)

            request_cache.cache["bingo_request_cache_filled"] = True
def identity_determinant_test ( ):

#*****************************************************************************80
#
## IDENTITY_DETERMINANT_TEST tests IDENTITY_DETERMINANT.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    14 February 2015
#
#  Author:
#
#    John Burkardt
#
  from identity import identity
  from r8mat_print import r8mat_print
 
  print ''
  print 'IDENTITY_DETERMINANT_TEST'
  print '  IDENTITY_DETERMINANT computes the determinant of the IDENTITY matrix.'
  print ''

  m = 4
  n = m

  a = identity ( m, n )
  r8mat_print ( m, n, a, '  IDENTITY matrix:' )

  value = identity_determinant ( n )

  print ''
  print '  Value =  %g' % ( value )

  print ''
  print 'IDENTITY_DETERMINANT_TEST'
  print '  Normal end of execution.'

  return
Exemple #26
0
def identity_determinant_test():

    #*****************************************************************************80
    #
    ## IDENTITY_DETERMINANT_TEST tests IDENTITY_DETERMINANT.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    14 February 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    from identity import identity
    from r8mat_print import r8mat_print

    print ''
    print 'IDENTITY_DETERMINANT_TEST'
    print '  IDENTITY_DETERMINANT computes the determinant of the IDENTITY matrix.'
    print ''

    m = 4
    n = m

    a = identity(m, n)
    r8mat_print(m, n, a, '  IDENTITY matrix:')

    value = identity_determinant(n)

    print ''
    print '  Value =  %g' % (value)

    print ''
    print 'IDENTITY_DETERMINANT_TEST'
    print '  Normal end of execution.'

    return
Exemple #27
0
def identity_condition_test():

    #*****************************************************************************80
    #
    ## IDENTITY_CONDITION_TEST tests IDENTITY_CONDITION.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    10 February 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    from identity import identity
    from r8mat_print import r8mat_print

    print ''
    print 'IDENTITY_CONDITION_TEST'
    print '  IDENTITY_CONDITION computes the condition of the IDENTITY matrix.'
    print ''

    m = 4
    n = m

    a = identity(m, n)
    r8mat_print(m, n, a, '  IDENTITY matrix:')

    value = identity_condition(n)

    print ''
    print '  Value =  %g' % (value)

    print ''
    print 'IDENTITY_CONDITION_TEST'
    print '  Normal end of execution.'

    return
def identity_condition_test ( ):

#*****************************************************************************80
#
## IDENTITY_CONDITION_TEST tests IDENTITY_CONDITION.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    10 February 2015
#
#  Author:
#
#    John Burkardt
#
  from identity import identity
  from r8mat_print import r8mat_print
 
  print ''
  print 'IDENTITY_CONDITION_TEST'
  print '  IDENTITY_CONDITION computes the condition of the IDENTITY matrix.'
  print ''

  m = 4
  n = m

  a = identity ( m, n )
  r8mat_print ( m, n, a, '  IDENTITY matrix:' )

  value = identity_condition ( n )

  print ''
  print '  Value =  %g' % ( value )

  print ''
  print 'IDENTITY_CONDITION_TEST'
  print '  Normal end of execution.'

  return
Exemple #29
0
def loadLocalIdentity():
    """
    The core method.

    The file [BitDust data dir]/metadata/localidentity keeps the user
    identity in XML format. Do read the local file and set into object
    in memory.
    """
    global _LocalIdentity
    global _LocalIDURL
    global _LocalName
    xmlid = ''
    filename = bpio.portablePath(settings.LocalIdentityFilename())
    if os.path.exists(filename):
        xmlid = bpio.ReadTextFile(filename)
        lg.out(
            6, 'my_id.loadLocalIdentity %d bytes read from\n        %s' %
            (len(xmlid), filename))
    if xmlid == '':
        lg.out(
            2, "my_id.loadLocalIdentity ERROR reading local identity from " +
            filename)
        return
    lid = identity.identity(xmlsrc=xmlid)
    if not lid.isCorrect():
        lg.out(2,
               "my_id.loadLocalIdentity ERROR loaded identity is not Correct")
        return
    if not lid.Valid():
        lg.out(2, "my_id.loadLocalIdentity ERROR loaded identity is not Valid")
        return
    _LocalIdentity = lid
    _LocalIDURL = lid.getIDURL()
    _LocalName = lid.getIDName()
    setTransportOrder(getOrderFromContacts(_LocalIdentity))
    lg.out(6, "my_id.loadLocalIdentity my name is [%s]" % lid.getIDName())
Exemple #30
0
def setLocalIdentityXML(idxml):
    """
    Construct identity object from XML string and save it to the memory.
    """
    setLocalIdentity(identity.identity(xmlsrc=idxml))
Exemple #31
0
def init_request_cache_from_memcache():
    if not request_cache.cache.get("loaded_from_memcache"):
        request_cache.cache.update(memcache.get_multi([BingoCache.MEMCACHE_KEY, BingoIdentityCache.key_for_identity(identity())]))
        request_cache.cache["loaded_from_memcache"] = True
Exemple #32
0
 def get(identity_val=None):
     key = BingoIdentityCache.key_for_identity(identity(identity_val))
     return CacheLayers.get(key,
             lambda: BingoIdentityCache.load_from_datastore(identity_val))
Exemple #33
0
 def _save_identity(self, inputfilename):
     """
     
     """
     lg.out(6, "id_server._save_identity " + inputfilename)
     if os.path.getsize(inputfilename) > 50000:
         lg.warn("input file too big - ignoring ")
         tmpfile.erase('idsrv', inputfilename, 'input file too big')
         # os.remove(inputfilename)
         return
     newxml = bpio.ReadTextFile(inputfilename)
     if len(newxml.strip()) < 500:
         lg.warn("input file too small - ignoring ")
         tmpfile.erase('idsrv', inputfilename, 'input file too small')
         # os.remove(inputfilename)
         return
     try:
         newidentity = identity.identity(xmlsrc=newxml)
     except:
         lg.warn("input file is wrong - ignoring ")
         tmpfile.erase('idsrv', inputfilename, 'input file is wrong')
         # os.remove(inputfilename)
         return
     tmpfile.erase('idsrv', inputfilename, 'id received')
     if not newidentity.isCorrect():
         lg.warn("has non-Correct identity")
         return
     if not newidentity.Valid():
         lg.warn("has non-Valid identity")
         return
     matchid = ""
     for idurl in newidentity.sources:
         protocol, host, port, filename = nameurl.UrlParse(idurl)
         if host == self.hostname:
             lg.out(4, "id_server._save_identity found match for us")
             matchid = idurl
             break
     if matchid == "":
         lg.warn("identity is not for this nameserver")
         return
     protocol, host, port, filename = nameurl.UrlParse(matchid)
     name, justxml = filename.split(".")
     # SECURITY check that name is simple
     if justxml != "xml":
         lg.warn("identity name " + filename)
         return
     if len(name) > settings.MaximumUsernameLength():
         lg.warn("identity name " + filename)
         return
     if len(name) < settings.MinimumUsernameLength():
         lg.warn("identity name " + filename)
         return
     for c in name:
         if c not in settings.LegalUsernameChars():
             lg.warn("identity name " + filename)
             return
     localfilename = os.path.join(settings.IdentityServerDir(), filename)
 #    lg.out(8,"id_server.SaveIdentity with filename " + localfilename)
     oldxml = ''
     # need to make sure id was not already used by different key - which would mean someone trying to steal identity
     if os.path.exists(localfilename):
         lg.out(6, "id_server._save_identity was already an identity with this name " + localfilename)
         oldxml = bpio.ReadTextFile(localfilename)
         oldidentity = identity.identity(xmlsrc=oldxml)
         if oldidentity.publickey != newidentity.publickey:
             lg.warn("new public key does not match old " + localfilename)
             return
     if newxml != oldxml:
         if not os.path.exists(localfilename):
             lg.out(6, "id_server._save_identity will save NEW Identity: " + filename)
         bpio.WriteFile(localfilename, newxml)
def test_condition():

    #*****************************************************************************80
    #
    ## TEST_CONDITION tests the L1 condition number computations.
    #
    #  Licensing:
    #
    #    This code is distributed under the GNU LGPL license.
    #
    #  Modified:
    #
    #    11 April 2015
    #
    #  Author:
    #
    #    John Burkardt
    #
    from aegerter import aegerter
    from aegerter import aegerter_condition
    from aegerter import aegerter_inverse
    from bab import bab
    from bab import bab_condition
    from bab import bab_inverse
    from bauer import bauer
    from bauer import bauer_condition
    from bauer import bauer_inverse
    from bis import bis
    from bis import bis_condition
    from bis import bis_inverse
    from biw import biw
    from biw import biw_condition
    from biw import biw_inverse
    from bodewig import bodewig
    from bodewig import bodewig_condition
    from bodewig import bodewig_inverse
    from boothroyd import boothroyd
    from boothroyd import boothroyd_condition
    from boothroyd import boothroyd_inverse
    from combin import combin
    from combin import combin_condition
    from combin import combin_inverse
    from companion import companion
    from companion import companion_condition
    from companion import companion_inverse
    from conex1 import conex1
    from conex1 import conex1_condition
    from conex1 import conex1_inverse
    from conex2 import conex2
    from conex2 import conex2_condition
    from conex2 import conex2_inverse
    from conex3 import conex3
    from conex3 import conex3_condition
    from conex3 import conex3_inverse
    from conex4 import conex4
    from conex4 import conex4_condition
    from conex4 import conex4_inverse
    from daub2 import daub2
    from daub2 import daub2_condition
    from daub2 import daub2_inverse
    from daub4 import daub4
    from daub4 import daub4_condition
    from daub4 import daub4_inverse
    from daub6 import daub6
    from daub6 import daub6_condition
    from daub6 import daub6_inverse
    from daub8 import daub8
    from daub8 import daub8_condition
    from daub8 import daub8_inverse
    from daub10 import daub10
    from daub10 import daub10_condition
    from daub10 import daub10_inverse
    from daub12 import daub12
    from daub12 import daub12_condition
    from daub12 import daub12_inverse
    from diagonal import diagonal
    from diagonal import diagonal_condition
    from diagonal import diagonal_inverse
    from dif2 import dif2
    from dif2 import dif2_condition
    from dif2 import dif2_inverse
    from downshift import downshift
    from downshift import downshift_condition
    from downshift import downshift_inverse
    from exchange import exchange
    from exchange import exchange_condition
    from exchange import exchange_inverse
    from fibonacci2 import fibonacci2
    from fibonacci2 import fibonacci2_condition
    from fibonacci2 import fibonacci2_inverse
    from gfpp import gfpp
    from gfpp import gfpp_condition
    from gfpp import gfpp_inverse
    from givens import givens
    from givens import givens_condition
    from givens import givens_inverse
    from hankel_n import hankel_n
    from hankel_n import hankel_n_condition
    from hankel_n import hankel_n_inverse
    from harman import harman
    from harman import harman_condition
    from harman import harman_inverse
    from hartley import hartley
    from hartley import hartley_condition
    from hartley import hartley_inverse
    from identity import identity
    from identity import identity_condition
    from identity import identity_inverse
    from ill3 import ill3
    from ill3 import ill3_condition
    from ill3 import ill3_inverse
    from jordan import jordan
    from jordan import jordan_condition
    from jordan import jordan_inverse
    from kershaw import kershaw
    from kershaw import kershaw_condition
    from kershaw import kershaw_inverse
    from lietzke import lietzke
    from lietzke import lietzke_condition
    from lietzke import lietzke_inverse
    from maxij import maxij
    from maxij import maxij_condition
    from maxij import maxij_inverse
    from minij import minij
    from minij import minij_condition
    from minij import minij_inverse
    from orth_symm import orth_symm
    from orth_symm import orth_symm_condition
    from orth_symm import orth_symm_inverse
    from oto import oto
    from oto import oto_condition
    from oto import oto_inverse
    from pascal1 import pascal1
    from pascal1 import pascal1_condition
    from pascal1 import pascal1_inverse
    from pascal3 import pascal3
    from pascal3 import pascal3_condition
    from pascal3 import pascal3_inverse
    from pei import pei
    from pei import pei_condition
    from pei import pei_inverse
    from r8_uniform_ab import r8_uniform_ab
    from r8mat_norm_l1 import r8mat_norm_l1
    from r8vec_uniform_ab import r8vec_uniform_ab
    from rodman import rodman
    from rodman import rodman_condition
    from rodman import rodman_inverse
    from rutis1 import rutis1
    from rutis1 import rutis1_condition
    from rutis1 import rutis1_inverse
    from rutis2 import rutis2
    from rutis2 import rutis2_condition
    from rutis2 import rutis2_inverse
    from rutis3 import rutis3
    from rutis3 import rutis3_condition
    from rutis3 import rutis3_inverse
    from rutis5 import rutis5
    from rutis5 import rutis5_condition
    from rutis5 import rutis5_inverse
    from summation import summation
    from summation import summation_condition
    from summation import summation_inverse
    from sweet1 import sweet1
    from sweet1 import sweet1_condition
    from sweet1 import sweet1_inverse
    from sweet2 import sweet2
    from sweet2 import sweet2_condition
    from sweet2 import sweet2_inverse
    from sweet3 import sweet3
    from sweet3 import sweet3_condition
    from sweet3 import sweet3_inverse
    from sweet4 import sweet4
    from sweet4 import sweet4_condition
    from sweet4 import sweet4_inverse
    from tri_upper import tri_upper
    from tri_upper import tri_upper_condition
    from tri_upper import tri_upper_inverse
    from upshift import upshift
    from upshift import upshift_condition
    from upshift import upshift_inverse
    from wilk03 import wilk03
    from wilk03 import wilk03_condition
    from wilk03 import wilk03_inverse
    from wilk04 import wilk04
    from wilk04 import wilk04_condition
    from wilk04 import wilk04_inverse
    from wilk05 import wilk05
    from wilk05 import wilk05_condition
    from wilk05 import wilk05_inverse
    from wilson import wilson
    from wilson import wilson_condition
    from wilson import wilson_inverse

    print ''
    print 'TEST_CONDITION'
    print '  Compute the L1 condition number of an example of each'
    print '  test matrix'
    print ''
    print '  Title                    N            COND            COND'
    print ''
    #
    #  AEGERTER
    #
    title = 'AEGERTER'
    n = 5
    cond1 = aegerter_condition(n)

    a = aegerter(n)
    b = aegerter_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  BAB
    #
    title = 'BAB'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    beta, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = bab_condition(n, alpha, beta)

    a = bab(n, alpha, beta)
    b = bab_inverse(n, alpha, beta)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  BAUER
    #
    title = 'BAUER'
    n = 6
    cond1 = bauer_condition()

    a = bauer()
    b = bauer_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  BIS
    #
    title = 'BIS'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    beta, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = bis_condition(alpha, beta, n)

    a = bis(alpha, beta, n, n)
    b = bis_inverse(alpha, beta, n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  BIW
    #
    title = 'BIW'
    n = 5
    cond1 = biw_condition(n)

    a = biw(n)
    b = biw_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  BODEWIG
    #
    title = 'BODEWIG'
    n = 4
    cond1 = bodewig_condition()

    a = bodewig()
    b = bodewig_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  BOOTHROYD
    #
    title = 'BOOTHROYD'
    n = 5
    cond1 = boothroyd_condition(n)

    a = boothroyd(n)
    b = boothroyd_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  COMBIN
    #
    title = 'COMBIN'
    n = 3
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    beta, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = combin_condition(alpha, beta, n)

    a = combin(alpha, beta, n)
    b = combin_inverse(alpha, beta, n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  COMPANION
    #
    title = 'COMPANION'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    x, seed = r8vec_uniform_ab(n, r8_lo, r8_hi, seed)
    cond1 = companion_condition(n, x)

    a = companion(n, x)
    b = companion_inverse(n, x)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  CONEX1
    #
    title = 'CONEX1'
    n = 4
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = conex1_condition(alpha)

    a = conex1(alpha)
    b = conex1_inverse(alpha)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  CONEX2
    #
    title = 'CONEX2'
    n = 3
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = conex2_condition(alpha)

    a = conex2(alpha)
    b = conex2_inverse(alpha)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  CONEX3
    #
    title = 'CONEX3'
    n = 5
    cond1 = conex3_condition(n)

    a = conex3(n)
    b = conex3_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  CONEX4
    #
    title = 'CONEX4'
    n = 4
    cond1 = conex4_condition()

    a = conex4()
    b = conex4_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DAUB2
    #
    title = 'DAUB2'
    n = 4
    cond1 = daub2_condition(n)

    a = daub2(n)
    b = daub2_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DAUB4
    #
    title = 'DAUB4'
    n = 8
    cond1 = daub4_condition(n)

    a = daub4(n)
    b = daub4_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DAUB6
    #
    title = 'DAUB6'
    n = 12
    cond1 = daub6_condition(n)

    a = daub6(n)
    b = daub6_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DAUB8
    #
    title = 'DAUB8'
    n = 16
    cond1 = daub8_condition(n)

    a = daub8(n)
    b = daub8_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DAUB10
    #
    title = 'DAUB10'
    n = 20
    cond1 = daub10_condition(n)

    a = daub10(n)
    b = daub10_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DAUB12
    #
    title = 'DAUB12'
    n = 24
    cond1 = daub12_condition(n)

    a = daub12(n)
    b = daub12_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DIAGONAL
    #
    title = 'DIAGONAL'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    x, seed = r8vec_uniform_ab(n, r8_lo, r8_hi, seed)
    cond1 = diagonal_condition(n, x)

    a = diagonal(n, n, x)
    b = diagonal_inverse(n, x)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DIF2
    #
    title = 'DIF2'
    n = 5
    cond1 = dif2_condition(n)

    a = dif2(n, n)
    b = dif2_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  DOWNSHIFT
    #
    title = 'DOWNSHIFT'
    n = 5
    cond1 = downshift_condition(n)

    a = downshift(n)
    b = downshift_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  EXCHANGE
    #
    title = 'EXCHANGE'
    n = 5
    cond1 = exchange_condition(n)

    a = exchange(n, n)
    b = exchange_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  FIBONACCI2
    #
    title = 'FIBONACCI2'
    n = 5
    cond1 = fibonacci2_condition(n)

    a = fibonacci2(n)
    b = fibonacci2_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  GFPP
    #
    title = 'GFPP'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = gfpp_condition(n, alpha)

    a = gfpp(n, alpha)
    b = gfpp_inverse(n, alpha)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  GIVENS
    #
    title = 'GIVENS'
    n = 5
    cond1 = givens_condition(n)

    a = givens(n, n)
    b = givens_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  HANKEL_N
    #
    title = 'HANKEL_N'
    n = 5
    cond1 = hankel_n_condition(n)

    a = hankel_n(n)
    b = hankel_n_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  HARMAN
    #
    title = 'HARMAN'
    n = 8
    cond1 = harman_condition()

    a = harman()
    b = harman_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  HARTLEY
    #
    title = 'HARTLEY'
    n = 5
    cond1 = hartley_condition(n)

    a = hartley(n)
    b = hartley_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  IDENTITY
    #
    title = 'IDENTITY'
    n = 5
    cond1 = identity_condition(n)

    a = identity(n, n)
    b = identity_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  ILL3
    #
    title = 'ILL3'
    n = 3
    cond1 = ill3_condition()

    a = ill3()
    b = ill3_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  JORDAN
    #
    title = 'JORDAN'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = jordan_condition(n, alpha)

    a = jordan(n, n, alpha)
    b = jordan_inverse(n, alpha)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  KERSHAW
    #
    title = 'KERSHAW'
    n = 4
    cond1 = kershaw_condition()

    a = kershaw()
    b = kershaw_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  LIETZKE
    #
    title = 'LIETZKE'
    n = 5
    cond1 = lietzke_condition(n)

    a = lietzke(n)
    b = lietzke_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  MAXIJ
    #
    title = 'MAXIJ'
    n = 5
    cond1 = maxij_condition(n)

    a = maxij(n, n)
    b = maxij_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  MINIJ
    #
    title = 'MINIJ'
    n = 5
    cond1 = minij_condition(n)

    a = minij(n, n)
    b = minij_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  ORTH_SYMM
    #
    title = 'ORTH_SYMM'
    n = 5
    cond1 = orth_symm_condition(n)

    a = orth_symm(n)
    b = orth_symm_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  OTO
    #
    title = 'OTO'
    n = 5
    cond1 = oto_condition(n)

    a = oto(n, n)
    b = oto_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  PASCAL1
    #
    title = 'PASCAL1'
    n = 5
    cond1 = pascal1_condition(n)

    a = pascal1(n)
    b = pascal1_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  PASCAL3
    #
    title = 'PASCAL3'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = pascal3_condition(n, alpha)

    a = pascal3(n, alpha)
    b = pascal3_inverse(n, alpha)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  PEI
    #
    title = 'PEI'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = pei_condition(alpha, n)

    a = pei(alpha, n)
    b = pei_inverse(alpha, n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  RODMAN
    #
    title = 'RODMAN'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = rodman_condition(n, alpha)

    a = rodman(n, n, alpha)
    b = rodman_inverse(n, alpha)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  RUTIS1
    #
    title = 'RUTIS1'
    n = 4
    cond1 = rutis1_condition()

    a = rutis1()
    b = rutis1_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  RUTIS2
    #
    title = 'RUTIS2'
    n = 4
    cond1 = rutis2_condition()

    a = rutis2()
    b = rutis2_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  RUTIS3
    #
    title = 'RUTIS3'
    n = 4
    cond1 = rutis3_condition()

    a = rutis3()
    b = rutis3_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  RUTIS5
    #
    title = 'RUTIS5'
    n = 4
    cond1 = rutis5_condition()

    a = rutis5()
    b = rutis5_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  SUMMATION
    #
    title = 'SUMMATION'
    n = 5
    cond1 = summation_condition(n)

    a = summation(n, n)
    b = summation_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  SWEET1
    #
    title = 'SWEET1'
    n = 6
    cond1 = sweet1_condition()

    a = sweet1()
    b = sweet1_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  SWEET2
    #
    title = 'SWEET2'
    n = 6
    cond1 = sweet2_condition()

    a = sweet2()
    b = sweet2_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  SWEET3
    #
    title = 'SWEET3'
    n = 6
    cond1 = sweet3_condition()

    a = sweet3()
    b = sweet3_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  SWEET4
    #
    title = 'SWEET4'
    n = 13
    cond1 = sweet4_condition()

    a = sweet4()
    b = sweet4_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  TRI_UPPER
    #
    title = 'TRI_UPPER'
    n = 5
    r8_lo = -5.0
    r8_hi = +5.0
    seed = 123456789
    alpha, seed = r8_uniform_ab(r8_lo, r8_hi, seed)
    cond1 = tri_upper_condition(alpha, n)

    a = tri_upper(alpha, n)
    b = tri_upper_inverse(alpha, n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  UPSHIFT
    #
    title = 'UPSHIFT'
    n = 5
    cond1 = upshift_condition(n)

    a = upshift(n)
    b = upshift_inverse(n)
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  WILK03
    #
    title = 'WILK03'
    n = 3
    cond1 = wilk03_condition()

    a = wilk03()
    b = wilk03_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  WILK04
    #
    title = 'WILK04'
    n = 4
    cond1 = wilk04_condition()

    a = wilk04()
    b = wilk04_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  WILK05
    #
    title = 'WILK05'
    n = 5
    cond1 = wilk05_condition()

    a = wilk05()
    b = wilk05_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  WILSON
    #
    title = 'WILSON'
    n = 4
    cond1 = wilson_condition()

    a = wilson()
    b = wilson_inverse()
    a_norm = r8mat_norm_l1(n, n, a)
    b_norm = r8mat_norm_l1(n, n, b)
    cond2 = a_norm * b_norm

    print '  %-20s  %4d  %14.6g  %14.6g' % (title, n, cond1, cond2)
    #
    #  Terminate.
    #
    print ''
    print 'TEST_CONDITION'
    print '  Normal end of execution.'

    return
Exemple #35
0
def init_request_cache_from_memcache():
    global REQUEST_CACHE

    if not REQUEST_CACHE.get("loaded_from_memcache"):
        REQUEST_CACHE = memcache.get_multi([BingoCache.MEMCACHE_KEY, BingoIdentityCache.key_for_identity(identity())])
        REQUEST_CACHE["loaded_from_memcache"] = True
Exemple #36
0
 def bitcoinkey(wifkey):
     unit = identity()
     unit.init_priv(wif=wifkey)
     pb = unit.get_pubkey()
     return unit.get_privkey()
Exemple #37
0
from identity import identity

unit = identity()
unit.init_priv(wif="5KUEwxHXTyWPoE6SLeomvqUQmN6o63Hzu7YFC9K6A4NKXh75QCr")
print("private key: ", unit.get_privkey())
print("private wif: ", unit.get_wifkey())
pb = unit.get_pubkey()
print("public key: ", pb)  #unit.get_pubkey())
print("address:", unit.get_addr())
#sig = unit.sign_data(data)
def test_condition ( ):

#*****************************************************************************80
#
## TEST_CONDITION tests the L1 condition number computations.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    11 April 2015
#
#  Author:
#
#    John Burkardt
#
  from aegerter             import aegerter
  from aegerter             import aegerter_condition
  from aegerter             import aegerter_inverse
  from bab                  import bab
  from bab                  import bab_condition
  from bab                  import bab_inverse
  from bauer                import bauer
  from bauer                import bauer_condition
  from bauer                import bauer_inverse
  from bis                  import bis
  from bis                  import bis_condition
  from bis                  import bis_inverse
  from biw                  import biw
  from biw                  import biw_condition
  from biw                  import biw_inverse
  from bodewig              import bodewig
  from bodewig              import bodewig_condition
  from bodewig              import bodewig_inverse
  from boothroyd            import boothroyd
  from boothroyd            import boothroyd_condition
  from boothroyd            import boothroyd_inverse
  from combin               import combin
  from combin               import combin_condition
  from combin               import combin_inverse
  from companion            import companion
  from companion            import companion_condition
  from companion            import companion_inverse
  from conex1               import conex1
  from conex1               import conex1_condition
  from conex1               import conex1_inverse
  from conex2               import conex2
  from conex2               import conex2_condition
  from conex2               import conex2_inverse
  from conex3               import conex3
  from conex3               import conex3_condition
  from conex3               import conex3_inverse
  from conex4               import conex4
  from conex4               import conex4_condition
  from conex4               import conex4_inverse
  from daub2                import daub2
  from daub2                import daub2_condition
  from daub2                import daub2_inverse
  from daub4                import daub4
  from daub4                import daub4_condition
  from daub4                import daub4_inverse
  from daub6                import daub6
  from daub6                import daub6_condition
  from daub6                import daub6_inverse
  from daub8                import daub8
  from daub8                import daub8_condition
  from daub8                import daub8_inverse
  from daub10               import daub10
  from daub10               import daub10_condition
  from daub10               import daub10_inverse
  from daub12               import daub12
  from daub12               import daub12_condition
  from daub12               import daub12_inverse
  from diagonal             import diagonal
  from diagonal             import diagonal_condition
  from diagonal             import diagonal_inverse
  from dif2                 import dif2
  from dif2                 import dif2_condition
  from dif2                 import dif2_inverse
  from downshift            import downshift
  from downshift            import downshift_condition
  from downshift            import downshift_inverse
  from exchange             import exchange
  from exchange             import exchange_condition
  from exchange             import exchange_inverse
  from fibonacci2           import fibonacci2
  from fibonacci2           import fibonacci2_condition
  from fibonacci2           import fibonacci2_inverse
  from gfpp                 import gfpp
  from gfpp                 import gfpp_condition
  from gfpp                 import gfpp_inverse
  from givens               import givens
  from givens               import givens_condition
  from givens               import givens_inverse
  from hankel_n             import hankel_n
  from hankel_n             import hankel_n_condition
  from hankel_n             import hankel_n_inverse
  from harman               import harman
  from harman               import harman_condition
  from harman               import harman_inverse
  from hartley              import hartley
  from hartley              import hartley_condition
  from hartley              import hartley_inverse
  from identity             import identity
  from identity             import identity_condition
  from identity             import identity_inverse
  from ill3                 import ill3
  from ill3                 import ill3_condition
  from ill3                 import ill3_inverse
  from jordan               import jordan
  from jordan               import jordan_condition
  from jordan               import jordan_inverse
  from kershaw              import kershaw
  from kershaw              import kershaw_condition
  from kershaw              import kershaw_inverse
  from lietzke              import lietzke
  from lietzke              import lietzke_condition
  from lietzke              import lietzke_inverse
  from maxij                import maxij
  from maxij                import maxij_condition
  from maxij                import maxij_inverse
  from minij                import minij
  from minij                import minij_condition
  from minij                import minij_inverse
  from orth_symm            import orth_symm
  from orth_symm            import orth_symm_condition
  from orth_symm            import orth_symm_inverse
  from oto                  import oto
  from oto                  import oto_condition
  from oto                  import oto_inverse
  from pascal1              import pascal1
  from pascal1              import pascal1_condition
  from pascal1              import pascal1_inverse
  from pascal3              import pascal3
  from pascal3              import pascal3_condition
  from pascal3              import pascal3_inverse
  from pei                  import pei
  from pei                  import pei_condition
  from pei                  import pei_inverse
  from r8_uniform_ab        import r8_uniform_ab
  from r8mat_norm_l1        import r8mat_norm_l1
  from r8vec_uniform_ab     import r8vec_uniform_ab
  from rodman               import rodman
  from rodman               import rodman_condition
  from rodman               import rodman_inverse
  from rutis1               import rutis1
  from rutis1               import rutis1_condition
  from rutis1               import rutis1_inverse
  from rutis2               import rutis2
  from rutis2               import rutis2_condition
  from rutis2               import rutis2_inverse
  from rutis3               import rutis3
  from rutis3               import rutis3_condition
  from rutis3               import rutis3_inverse
  from rutis5               import rutis5
  from rutis5               import rutis5_condition
  from rutis5               import rutis5_inverse
  from summation            import summation
  from summation            import summation_condition
  from summation            import summation_inverse
  from sweet1               import sweet1
  from sweet1               import sweet1_condition
  from sweet1               import sweet1_inverse
  from sweet2               import sweet2
  from sweet2               import sweet2_condition
  from sweet2               import sweet2_inverse
  from sweet3               import sweet3
  from sweet3               import sweet3_condition
  from sweet3               import sweet3_inverse
  from sweet4               import sweet4
  from sweet4               import sweet4_condition
  from sweet4               import sweet4_inverse
  from tri_upper            import tri_upper
  from tri_upper            import tri_upper_condition
  from tri_upper            import tri_upper_inverse
  from upshift              import upshift
  from upshift              import upshift_condition
  from upshift              import upshift_inverse
  from wilk03               import wilk03
  from wilk03               import wilk03_condition
  from wilk03               import wilk03_inverse
  from wilk04               import wilk04
  from wilk04               import wilk04_condition
  from wilk04               import wilk04_inverse
  from wilk05               import wilk05
  from wilk05               import wilk05_condition
  from wilk05               import wilk05_inverse
  from wilson               import wilson
  from wilson               import wilson_condition
  from wilson               import wilson_inverse

  print ''
  print 'TEST_CONDITION'
  print '  Compute the L1 condition number of an example of each'
  print '  test matrix'
  print ''
  print '  Title                    N            COND            COND'
  print ''
#
#  AEGERTER
#
  title = 'AEGERTER'
  n = 5
  cond1 = aegerter_condition ( n )

  a = aegerter ( n )
  b = aegerter_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  BAB
#
  title = 'BAB'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  beta, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = bab_condition ( n, alpha, beta )

  a = bab ( n, alpha, beta )
  b = bab_inverse ( n, alpha, beta )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  BAUER
#
  title = 'BAUER'
  n = 6
  cond1 = bauer_condition ( )

  a = bauer ( )
  b = bauer_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  BIS
#
  title = 'BIS'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  beta, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = bis_condition ( alpha, beta, n )

  a = bis ( alpha, beta, n, n )
  b = bis_inverse ( alpha, beta, n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  BIW
#
  title = 'BIW'
  n = 5
  cond1 = biw_condition ( n )

  a = biw ( n )
  b = biw_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  BODEWIG
#
  title = 'BODEWIG'
  n = 4
  cond1 = bodewig_condition ( )

  a = bodewig ( )
  b = bodewig_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  BOOTHROYD
#
  title = 'BOOTHROYD'
  n = 5
  cond1 = boothroyd_condition ( n )

  a = boothroyd ( n )
  b = boothroyd_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  COMBIN
#
  title = 'COMBIN'
  n = 3
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  beta, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = combin_condition ( alpha, beta, n )

  a = combin ( alpha, beta, n )
  b = combin_inverse ( alpha, beta, n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  COMPANION
#
  title = 'COMPANION'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  x, seed = r8vec_uniform_ab ( n, r8_lo, r8_hi, seed )
  cond1 = companion_condition ( n, x )

  a = companion ( n, x )
  b = companion_inverse ( n, x )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  CONEX1
#
  title = 'CONEX1'
  n = 4
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = conex1_condition ( alpha )

  a = conex1 ( alpha )
  b = conex1_inverse ( alpha )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  CONEX2
#
  title = 'CONEX2'
  n = 3
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = conex2_condition ( alpha )

  a = conex2 ( alpha )
  b = conex2_inverse ( alpha )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  CONEX3
#
  title = 'CONEX3'
  n = 5
  cond1 = conex3_condition ( n )

  a = conex3 ( n )
  b = conex3_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  CONEX4
#
  title = 'CONEX4'
  n = 4
  cond1 = conex4_condition ( )

  a = conex4 ( )
  b = conex4_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DAUB2
#
  title = 'DAUB2'
  n = 4
  cond1 = daub2_condition ( n )

  a = daub2 ( n )
  b = daub2_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DAUB4
#
  title = 'DAUB4'
  n = 8
  cond1 = daub4_condition ( n )

  a = daub4 ( n )
  b = daub4_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DAUB6
#
  title = 'DAUB6'
  n = 12
  cond1 = daub6_condition ( n )

  a = daub6 ( n )
  b = daub6_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DAUB8
#
  title = 'DAUB8'
  n = 16
  cond1 = daub8_condition ( n )

  a = daub8 ( n )
  b = daub8_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DAUB10
#
  title = 'DAUB10'
  n = 20
  cond1 = daub10_condition ( n )

  a = daub10 ( n )
  b = daub10_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DAUB12
#
  title = 'DAUB12'
  n = 24
  cond1 = daub12_condition ( n )

  a = daub12 ( n )
  b = daub12_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DIAGONAL
#
  title = 'DIAGONAL'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  x, seed = r8vec_uniform_ab ( n, r8_lo, r8_hi, seed )
  cond1 = diagonal_condition ( n, x )

  a = diagonal ( n, n, x )
  b = diagonal_inverse ( n, x )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DIF2
#
  title = 'DIF2'
  n = 5
  cond1 = dif2_condition ( n )

  a = dif2 ( n, n )
  b = dif2_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  DOWNSHIFT
#
  title = 'DOWNSHIFT'
  n = 5
  cond1 = downshift_condition ( n )

  a = downshift ( n )
  b = downshift_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  EXCHANGE
#
  title = 'EXCHANGE'
  n = 5
  cond1 = exchange_condition ( n )

  a = exchange ( n, n )
  b = exchange_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  FIBONACCI2
#
  title = 'FIBONACCI2'
  n = 5
  cond1 = fibonacci2_condition ( n )

  a = fibonacci2 ( n )
  b = fibonacci2_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  GFPP
#
  title = 'GFPP'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = gfpp_condition ( n, alpha )

  a = gfpp ( n, alpha )
  b = gfpp_inverse ( n, alpha )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  GIVENS
#
  title = 'GIVENS'
  n = 5
  cond1 = givens_condition ( n )

  a = givens ( n, n )
  b = givens_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  HANKEL_N
#
  title = 'HANKEL_N'
  n = 5
  cond1 = hankel_n_condition ( n )

  a = hankel_n ( n )
  b = hankel_n_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  HARMAN
#
  title = 'HARMAN'
  n = 8
  cond1 = harman_condition ( )

  a = harman ( )
  b = harman_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  HARTLEY
#
  title = 'HARTLEY'
  n = 5
  cond1 = hartley_condition ( n )

  a = hartley ( n )
  b = hartley_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  IDENTITY
#
  title = 'IDENTITY'
  n = 5
  cond1 = identity_condition ( n )

  a = identity ( n, n )
  b = identity_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  ILL3
#
  title = 'ILL3'
  n = 3
  cond1 = ill3_condition ( )

  a = ill3 ( )
  b = ill3_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  JORDAN
#
  title = 'JORDAN'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = jordan_condition ( n, alpha )

  a = jordan ( n, n, alpha )
  b = jordan_inverse ( n, alpha )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  KERSHAW
#
  title = 'KERSHAW'
  n = 4
  cond1 = kershaw_condition ( )

  a = kershaw ( )
  b = kershaw_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  LIETZKE
#
  title = 'LIETZKE'
  n = 5
  cond1 = lietzke_condition ( n )

  a = lietzke ( n )
  b = lietzke_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  MAXIJ
#
  title = 'MAXIJ'
  n = 5
  cond1 = maxij_condition ( n )

  a = maxij ( n, n )
  b = maxij_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  MINIJ
#
  title = 'MINIJ'
  n = 5
  cond1 = minij_condition ( n )

  a = minij ( n, n )
  b = minij_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  ORTH_SYMM
#
  title = 'ORTH_SYMM'
  n = 5
  cond1 = orth_symm_condition ( n )

  a = orth_symm ( n )
  b = orth_symm_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  OTO
#
  title = 'OTO'
  n = 5
  cond1 = oto_condition ( n )

  a = oto ( n, n )
  b = oto_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  PASCAL1
#
  title = 'PASCAL1'
  n = 5
  cond1 = pascal1_condition ( n )

  a = pascal1 ( n )
  b = pascal1_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  PASCAL3
#
  title = 'PASCAL3'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = pascal3_condition ( n, alpha )

  a = pascal3 ( n, alpha )
  b = pascal3_inverse ( n, alpha )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  PEI
#
  title = 'PEI'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = pei_condition ( alpha, n )

  a = pei ( alpha, n )
  b = pei_inverse ( alpha, n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  RODMAN
#
  title = 'RODMAN'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = rodman_condition ( n, alpha )

  a = rodman ( n, n, alpha )
  b = rodman_inverse ( n, alpha )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  RUTIS1
#
  title = 'RUTIS1'
  n = 4
  cond1 = rutis1_condition ( )

  a = rutis1 ( )
  b = rutis1_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  RUTIS2
#
  title = 'RUTIS2'
  n = 4
  cond1 = rutis2_condition ( )

  a = rutis2 ( )
  b = rutis2_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  RUTIS3
#
  title = 'RUTIS3'
  n = 4
  cond1 = rutis3_condition ( )

  a = rutis3 ( )
  b = rutis3_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  RUTIS5
#
  title = 'RUTIS5'
  n = 4
  cond1 = rutis5_condition ( )

  a = rutis5 ( )
  b = rutis5_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  SUMMATION
#
  title = 'SUMMATION'
  n = 5
  cond1 = summation_condition ( n )

  a = summation ( n, n )
  b = summation_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  SWEET1
#
  title = 'SWEET1'
  n = 6
  cond1 = sweet1_condition ( )

  a = sweet1 ( )
  b = sweet1_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  SWEET2
#
  title = 'SWEET2'
  n = 6
  cond1 = sweet2_condition ( )

  a = sweet2 ( )
  b = sweet2_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  SWEET3
#
  title = 'SWEET3'
  n = 6
  cond1 = sweet3_condition ( )

  a = sweet3 ( )
  b = sweet3_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  SWEET4
#
  title = 'SWEET4'
  n = 13
  cond1 = sweet4_condition ( )

  a = sweet4 ( )
  b = sweet4_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  TRI_UPPER
#
  title = 'TRI_UPPER'
  n = 5
  r8_lo = -5.0
  r8_hi = +5.0
  seed = 123456789
  alpha, seed = r8_uniform_ab ( r8_lo, r8_hi, seed )
  cond1 = tri_upper_condition ( alpha, n )

  a = tri_upper ( alpha, n )
  b = tri_upper_inverse ( alpha, n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  UPSHIFT
#
  title = 'UPSHIFT'
  n = 5
  cond1 = upshift_condition ( n )

  a = upshift ( n )
  b = upshift_inverse ( n )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  WILK03
#
  title = 'WILK03'
  n = 3
  cond1 = wilk03_condition ( )

  a = wilk03 ( )
  b = wilk03_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  WILK04
#
  title = 'WILK04'
  n = 4
  cond1 = wilk04_condition ( )

  a = wilk04 ( )
  b = wilk04_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  WILK05
#
  title = 'WILK05'
  n = 5
  cond1 = wilk05_condition ( )

  a = wilk05 ( )
  b = wilk05_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  WILSON
#
  title = 'WILSON'
  n = 4
  cond1 = wilson_condition ( )

  a = wilson ( )
  b = wilson_inverse ( )
  a_norm = r8mat_norm_l1 ( n, n, a )
  b_norm = r8mat_norm_l1 ( n, n, b )
  cond2 = a_norm * b_norm

  print '  %-20s  %4d  %14.6g  %14.6g' % ( title, n, cond1, cond2 )
#
#  Terminate.
#
  print ''
  print 'TEST_CONDITION'
  print '  Normal end of execution.'

  return
Exemple #39
0
def buildDefaultIdentity(name='', ip='', idurls=[]):
    """
    Use some local settings and config files to create some new identity.

    Nice to provide a user name or it will have a form like: [ip
    address]_[date].
    """
    if ip == '':
        ip = misc.readExternalIP(
        )  # bpio.ReadTextFile(settings.ExternalIPFilename())
    if name == '':
        name = ip.replace('.', '-') + '_' + time.strftime('%M%S')
    lg.out(4, 'my_id.buildDefaultIdentity: %s %s' % (name, ip))
    # create a new identity object
    # it is stored in memory and another copy on disk drive
    ident = identity.identity(xmlsrc=identity.default_identity_src)
    # this is my IDURL address
    # you can have many IDURL locations for same identity
    # just need to keep all them synchronized
    # this is identity propagate procedure, see p2p/propagate.py
    if len(idurls) == 0:
        idurls.append('http://localhost/' + name.lower() + '.xml')
    for idurl in idurls:
        ident.sources.append(idurl.encode("ascii").strip())
    # create a full list of needed transport methods
    # to be able to accept incoming traffic from other nodes
    new_contacts, new_order = buildProtoContacts(ident)
    if len(new_contacts) == 0:
        if settings.enableTCP() and settings.enableTCPreceiving():
            new_contacts['tcp'] = 'tcp://' + ip + ':' + str(
                settings.getTCPPort())
            new_order.append('tcp')
        if settings.enableUDP() and settings.enableUDPreceiving():
            x, servername, x, x = nameurl.UrlParse(ident.sources[0])
            new_contacts['udp'] = 'udp://%s@%s' % (name.lower(), servername)
            new_order.append('udp')
        if settings.enableHTTP() and settings.enableHTTPreceiving():
            new_contacts['http'] = 'http://' + ip + ':' + str(
                settings.getHTTPPort())
            new_order.append('http')
    # erase current contacts from my identity
    ident.clearContacts()
    # add contacts data to the local identity
    for proto in new_order:
        contact = new_contacts.get(proto, None)
        if contact is None:
            lg.warn('proto %s was not found in contacts' % proto)
            continue
        ident.setProtoContact(proto, contact)
    # set other info
    ident.certificates = []
    ident.date = time.strftime('%b %d, %Y')
    ident.postage = "1"
    ident.revision = "0"
    # update software version number
    version_number = bpio.ReadTextFile(settings.VersionNumberFile()).strip()
    repo, location = misc.ReadRepoLocation()
    ident.version = (version_number.strip() + ' ' + repo.strip() + ' ' +
                     bpio.osinfo().strip()).strip()
    # build a version info
    vernum = bpio.ReadTextFile(settings.VersionNumberFile())
    repo, location = misc.ReadRepoLocation()
    ident.version = (vernum.strip() + ' ' + repo.strip() + ' ' +
                     bpio.osinfo().strip()).strip()
    # put my public key in my identity
    ident.publickey = key.MyPublicKey()
    # generate signature
    ident.sign()
    # validate new identity
    if not ident.Valid():
        lg.warn('generated identity is not valid !!!')
    return ident
Exemple #40
0
def run(ip='192.168.42.1', port=502):
    StartTcpServer(context, identity=identity(), address=(ip, port))
Exemple #41
0
        rr = client.read_input_registers(0, IR_NUM)
        context[SLAVE_ID].store['i'] = ModbusSequentialDataBlock(
            0, [
                0,
            ] + rr.registers[:IR_NUM])
        print context[SLAVE_ID].store['i'].values
    except:
        log.warn('Cannot read IR')
    log.info('Copied from modbus server #1')


# Override ModbusSlaveContext to hook our function
class myModbusSlaveContext(ModbusSlaveContext):
    def setValues(self, fx, address, values):
        super(myModbusSlaveContext, self).setValues(fx, address, values)
        log.warn('Someone set values! %s, %s, %s', str(fx), str(address),
                 str(values))


# Initialize ModBus Context
store = myModbusSlaveContext(di=ModbusSequentialDataBlock(0, [0] * DI_NUM),
                             co=ModbusSequentialDataBlock(0, [0] * CO_NUM),
                             hr=ModbusSequentialDataBlock(0, [0] * HR_NUM),
                             ir=ModbusSequentialDataBlock(0, [0] * IR_NUM))
context = ModbusServerContext(slaves=store, single=True)

# Start loop
loop = LoopingCall(f=copy_modbus_source, a=(context, ))
loop.start(TIME_TO_COPY, now=True)
StartTcpServer(context, identity=identity(), address=('192.168.42.2', 502))
Exemple #42
0
 def get(identity_val=None):
     key = BingoIdentityCache.key_for_identity(identity(identity_val))
     return CacheLayers.get(
         key, lambda: BingoIdentityCache.load_from_datastore(identity_val))