Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:16

0001 #!/usr/bin/env python
0002 #
0003 # Copyright (c) 2019 Opticks Team. All Rights Reserved.
0004 #
0005 # This file is part of Opticks
0006 # (see https://bitbucket.org/simoncblyth/opticks).
0007 #
0008 # Licensed under the Apache License, Version 2.0 (the "License"); 
0009 # you may not use this file except in compliance with the License.  
0010 # You may obtain a copy of the License at
0011 #
0012 #   http://www.apache.org/licenses/LICENSE-2.0
0013 #
0014 # Unless required by applicable law or agreed to in writing, software 
0015 # distributed under the License is distributed on an "AS IS" BASIS, 
0016 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0017 # See the License for the specific language governing permissions and 
0018 # limitations under the License.
0019 #
0020 
0021 
0022 import os, numpy as np
0023 
0024 try: 
0025     from hashlib import md5 
0026 except ImportError: 
0027     from md5 import md5 
0028 
0029 
0030 from opticks.ana.nbase import array_digest 
0031 
0032 
0033 
0034 def test_hello():
0035     s = 'hello'
0036     dig = md5()
0037     dig.update(s)
0038     print s, dig.hexdigest()
0039 
0040 
0041 def test_array_digest():
0042     """
0043     digest on the file includes the header, but array_digest 
0044     covers just the data
0045     """
0046     i = np.eye(4, dtype=np.float32)
0047     a = np.vstack([i,i,i]).reshape(-1,4,4)
0048     print array_digest(a)
0049     np.save(os.path.expandvars("$TMP/test_array_digest.npy"), a )
0050 
0051 
0052 
0053 if __name__ == '__main__':
0054     test_hello()
0055     test_array_digest()
0056 
0057 
0058 
0059 
0060 
0061