mirror of
				https://github.com/Telecominfraproject/oopt-gnpy.git
				synced 2025-11-03 19:47:46 +00:00 
			
		
		
		
	tests: prefer pandas.read_csv over numpy.genfromtext
Change-Id: Icc9618afc4cad0c7a07f3a785c99b6b438e0c6cc
This commit is contained in:
		
				
					committed by
					
						
						Jan Kundrát
					
				
			
			
				
	
			
			
			
						parent
						
							eb2363a3d4
						
					
				
				
					commit
					4ea0180caf
				
			@@ -9,10 +9,11 @@ are tested.
 | 
				
			|||||||
from pathlib import Path
 | 
					from pathlib import Path
 | 
				
			||||||
from pandas import read_csv
 | 
					from pandas import read_csv
 | 
				
			||||||
from numpy.testing import assert_allclose
 | 
					from numpy.testing import assert_allclose
 | 
				
			||||||
from numpy import array, genfromtxt
 | 
					from numpy import array
 | 
				
			||||||
import pytest
 | 
					import pytest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from gnpy.core.info import create_input_spectral_information, create_arbitrary_spectral_information, Pref, ReferenceCarrier
 | 
					from gnpy.core.info import create_input_spectral_information, create_arbitrary_spectral_information, Pref, \
 | 
				
			||||||
 | 
					    ReferenceCarrier
 | 
				
			||||||
from gnpy.core.elements import Fiber, RamanFiber
 | 
					from gnpy.core.elements import Fiber, RamanFiber
 | 
				
			||||||
from gnpy.core.parameters import SimParams
 | 
					from gnpy.core.parameters import SimParams
 | 
				
			||||||
from gnpy.tools.json_io import load_json
 | 
					from gnpy.tools.json_io import load_json
 | 
				
			||||||
@@ -118,18 +119,18 @@ def test_fiber_lumped_losses_srs(set_sim_params):
 | 
				
			|||||||
    stimulated_raman_scattering = RamanSolver.calculate_stimulated_raman_scattering(
 | 
					    stimulated_raman_scattering = RamanSolver.calculate_stimulated_raman_scattering(
 | 
				
			||||||
        spectral_info_input, fiber)
 | 
					        spectral_info_input, fiber)
 | 
				
			||||||
    power_profile = stimulated_raman_scattering.power_profile
 | 
					    power_profile = stimulated_raman_scattering.power_profile
 | 
				
			||||||
    expected_power_profile = genfromtxt(TEST_DIR / 'data' / 'test_lumped_losses_fiber_no_pumps.csv', delimiter=',')
 | 
					    expected_power_profile = read_csv(TEST_DIR / 'data' / 'test_lumped_losses_fiber_no_pumps.csv', header=None)
 | 
				
			||||||
    assert_allclose(power_profile, expected_power_profile, rtol=1e-3)
 | 
					    assert_allclose(power_profile, expected_power_profile, rtol=1e-3)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # with Raman pumps
 | 
					    # with Raman pumps
 | 
				
			||||||
    expected_power_profile = genfromtxt(TEST_DIR / 'data' / 'test_lumped_losses_raman_fiber.csv', delimiter=',')
 | 
					    expected_power_profile = read_csv(TEST_DIR / 'data' / 'test_lumped_losses_raman_fiber.csv', header=None)
 | 
				
			||||||
    stimulated_raman_scattering = RamanSolver.calculate_stimulated_raman_scattering(
 | 
					    stimulated_raman_scattering = RamanSolver.calculate_stimulated_raman_scattering(
 | 
				
			||||||
        spectral_info_input, raman_fiber)
 | 
					        spectral_info_input, raman_fiber)
 | 
				
			||||||
    power_profile = stimulated_raman_scattering.power_profile
 | 
					    power_profile = stimulated_raman_scattering.power_profile
 | 
				
			||||||
    assert_allclose(power_profile, expected_power_profile, rtol=1e-3)
 | 
					    assert_allclose(power_profile, expected_power_profile, rtol=1e-3)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # without Stimulated Raman Scattering
 | 
					    # without Stimulated Raman Scattering
 | 
				
			||||||
    expected_power_profile = genfromtxt(TEST_DIR / 'data' / 'test_lumped_losses_fiber_no_raman.csv', delimiter=',')
 | 
					    expected_power_profile = read_csv(TEST_DIR / 'data' / 'test_lumped_losses_fiber_no_raman.csv', header=None)
 | 
				
			||||||
    stimulated_raman_scattering = RamanSolver.calculate_attenuation_profile(spectral_info_input, fiber)
 | 
					    stimulated_raman_scattering = RamanSolver.calculate_attenuation_profile(spectral_info_input, fiber)
 | 
				
			||||||
    power_profile = stimulated_raman_scattering.power_profile
 | 
					    power_profile = stimulated_raman_scattering.power_profile
 | 
				
			||||||
    assert_allclose(power_profile, expected_power_profile, rtol=1e-3)
 | 
					    assert_allclose(power_profile, expected_power_profile, rtol=1e-3)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user