mirror of
				https://github.com/fjosw/pyerrors.git
				synced 2025-11-04 09:35:45 +01:00 
			
		
		
		
	Merge branch 'develop' into documentation
This commit is contained in:
		
				commit
				
					
						f13ddce69c
					
				
			
		
					 5 changed files with 20 additions and 56 deletions
				
			
		| 
						 | 
				
			
			@ -1,7 +1,8 @@
 | 
			
		|||
import os
 | 
			
		||||
import gzip
 | 
			
		||||
import numpy as np
 | 
			
		||||
import pyerrors as pe
 | 
			
		||||
import pyerrors.input.json as jsonio
 | 
			
		||||
import numpy as np
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_jsonio():
 | 
			
		||||
| 
						 | 
				
			
			@ -70,6 +71,15 @@ def test_jsonio():
 | 
			
		|||
 | 
			
		||||
def test_json_string_reconstruction():
 | 
			
		||||
    my_obs = pe.Obs([np.random.rand(100)], ['name'])
 | 
			
		||||
 | 
			
		||||
    json_string = pe.input.json.create_json_string(my_obs)
 | 
			
		||||
    reconstructed_obs = pe.input.json.import_json_string(json_string)
 | 
			
		||||
    assert my_obs == reconstructed_obs
 | 
			
		||||
    reconstructed_obs1 = pe.input.json.import_json_string(json_string)
 | 
			
		||||
    assert my_obs == reconstructed_obs1
 | 
			
		||||
 | 
			
		||||
    compressed_string = gzip.compress(json_string.encode('utf-8'))
 | 
			
		||||
 | 
			
		||||
    reconstructed_string = gzip.decompress(compressed_string).decode('utf-8')
 | 
			
		||||
    reconstructed_obs2 = pe.input.json.import_json_string(reconstructed_string)
 | 
			
		||||
 | 
			
		||||
    assert reconstructed_string == json_string
 | 
			
		||||
    assert my_obs == reconstructed_obs2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -300,6 +300,10 @@ def test_matrix_functions():
 | 
			
		|||
        for j in range(dim):
 | 
			
		||||
            assert tmp[j].is_zero()
 | 
			
		||||
 | 
			
		||||
    # Check eig function
 | 
			
		||||
    e2 = pe.linalg.eig(sym)
 | 
			
		||||
    assert np.all(np.sort(e) == np.sort(e2))
 | 
			
		||||
 | 
			
		||||
    # Check svd
 | 
			
		||||
    u, v, vh = pe.linalg.svd(sym)
 | 
			
		||||
    diff = sym - u @ np.diag(v) @ vh
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue