Best Python code snippet using pyresttest_python
test_realizeNTF_ct.py
Source:test_realizeNTF_ct.py
1# -*- coding: utf-8 -*-2# test_realizeNTF_ct.py3# This module provides the tests for the realizeNTF_ct function.4# Copyright 2014 Giuseppe Venturini5# This file is part of python-deltasigma.6#7# python-deltasigma is a 1:1 Python replacement of Richard Schreier's 8# MATLAB delta sigma toolbox (aka "delsigma"), upon which it is heavily based.9# The delta sigma toolbox is (c) 2009, Richard Schreier.10#11# python-deltasigma is distributed in the hope that it will be useful,12# but WITHOUT ANY WARRANTY; without even the implied warranty of13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14# LICENSE file for the licensing terms.15"""This module provides the test class for the realizeNTF_ct() function.16"""17import unittest18import numpy as np19import deltasigma as ds20from nose.tools import raises21class TestRealizeNTF_CT(unittest.TestCase):22 """Test class for realizeNTF_ct()"""23 def setUp(self):24 # FB NRTZ 0 delay tdac default25 self.ntf = (np.array([1., 1.]), np.array([0., 0.]), 1)26 self.ABCDc_ref1 = np.array(((0, 0, 1, -1),27 (1, 0, 0, -1.5),28 (0, 1, 0, 0)), dtype=np.float)29 self.tdac2_ref1 = np.array(((-1, -1),30 (0, 1)))31 # FB NRTZ 0 delay tdac in short list form32 self.ABCDc_ref2 = np.array(((0, 0, 1, -1),33 (1, 0, 0, -1.5),34 (0, 1, 0, 0)), dtype=np.float)35 self.tdac2_ref2 = np.array(((-1, -1),36 (0, 1)))37 # FB multi-timing DAC38 self.ntf3 = (np.array([1., 1., 1]), np.array([0., 0., 0]), 1)39 self.tdac3 = [[1, 2], [1, 2], [[0.5, 1], [1, 1.5]], []]40 self.ABCDc_ref3 = np.array(((0., 0., 0., 1., -1., 0., 0., 0.),41 (1., 0., 0., 0., 0., -3., 0., 0.),42 (0., 1., 0., 0., 0., 0., -6., -2.6667),43 (0., 0., 1., 0., 0., 0., 0., 0.)))44 self.tdac2_ref3 = np.array(((-1., -1.),45 (1., 2.),46 (1., 2.),47 (0.5, 1.),48 (1., 1.5)))49 # test for FF50 self.ABCDc_ref4 = np.array([[0., 0., 1., -1.],51 [1., 0., 0., 0.],52 [ 1.5, 1., 0., 0.]])53 self.tdac2_ref4 = np.array([[-1., -1.], [ 0., 1.]])54 # test for FF - NRZ DAC pulse delayed by .555 self.ABCDc_ref5 = np.array([[0., 0., 1., -1.],56 [1., 0., 0., 0.],57 [2., 1., 0., -0.8750]])58 self.tdac2_ref5 = np.array([[-1., -1.], [ 0.5, 1.5]])59 def test_realizeNTF_ct_1(self):60 """Test function for realizeNTF_ct() 1/15"""61 ABCDc, tdac2 = ds.realizeNTF_ct(self.ntf, 'FB')62 self.assertTrue(np.allclose(ABCDc, self.ABCDc_ref1, atol=1e-8,63 rtol=1e-5))64 self.assertTrue(np.allclose(tdac2, self.tdac2_ref1, atol=1e-8,65 rtol=1e-5))66 def test_realizeNTF_ct_2(self):67 """Test function for realizeNTF_ct() 2/15"""68 ABCDc, tdac2 = ds.realizeNTF_ct(self.ntf, 'FB', tdac=[0, 1])69 self.assertTrue(np.allclose(ABCDc, self.ABCDc_ref2, atol=1e-8,70 rtol=1e-5))71 self.assertTrue(np.allclose(tdac2, self.tdac2_ref2, atol=1e-8,72 rtol=1e-5))73 def test_realizeNTF_ct_3(self):74 """Test function for realizeNTF_ct() 3/15"""75 ABCDc, tdac2 = ds.realizeNTF_ct(self.ntf3, 'FB', self.tdac3)76 self.assertTrue(np.allclose(ABCDc, self.ABCDc_ref3, atol=1e-8,77 rtol=1e-4))78 self.assertTrue(np.allclose(tdac2, self.tdac2_ref3, atol=1e-8,79 rtol=1e-4))80 def test_realizeNTF_ct_4(self):81 """Test function for realizeNTF_ct() 4/15"""82 ABCDc, tdac2 = ds.realizeNTF_ct(self.ntf, 'FF')83 self.assertTrue(np.allclose(ABCDc, self.ABCDc_ref4, atol=1e-8,84 rtol=1e-4))85 self.assertTrue(np.allclose(tdac2, self.tdac2_ref4, atol=1e-8,86 rtol=1e-4))87 def test_realizeNTF_ct_5(self):88 """Test function for realizeNTF_ct() 5/15"""89 ABCDc, tdac2 = ds.realizeNTF_ct(self.ntf, 'FF', tdac=[.5, 1.5])90 self.assertTrue(np.allclose(ABCDc, self.ABCDc_ref5, atol=1e-8,91 rtol=1e-4))92 self.assertTrue(np.allclose(tdac2, self.tdac2_ref5, atol=1e-8,93 rtol=1e-4))94 @raises(ValueError)95 def test_realizeNTF_ct_6(self):96 """Test function for realizeNTF_ct() 6/15"""97 ABCDc, tdac2 = ds.realizeNTF_ct(self.ntf, 'DUMMY', tdac=[.5, 1.5])98 @raises(ValueError)99 def test_realizeNTF_ct_7(self):100 """Test function for realizeNTF_ct() 7/15"""101 ABCDc, tdac2 = ds.realizeNTF_ct(self.ntf, 'FF', tdac=[.5, 1.5, 3.])102 @raises(ValueError)103 def test_realizeNTF_ct_8(self):104 """Test function for realizeNTF_ct() 8/15"""105 tdac= [[-1, -1], [.5, 1.5], [.5, .8], [0.1, 2.]]106 ABCDc, tdac2 = ds.realizeNTF_ct(self.ntf3, 'FB', tdac)107 @raises(ValueError)108 def test_realizeNTF_ct_9(self):109 """Test function for realizeNTF_ct() 9/15"""110 ABCDc, tdac2 = ds.realizeNTF_ct(self.ntf3, 'FF', self.tdac3)111 def test_realizeNTF_ct_10(self):112 """Test function for realizeNTF_ct() 10/15"""113 ABCDc, tdac2 = ds.realizeNTF_ct(self.ntf, 'FB', method='NTF')114 self.assertTrue(np.allclose(ABCDc, self.ABCDc_ref1, atol=1e-8,115 rtol=1e-5))116 self.assertTrue(np.allclose(tdac2, self.tdac2_ref1, atol=1e-8,117 rtol=1e-5))118 def test_realizeNTF_ct_11(self):119 """Test function for realizeNTF_ct() 11/15"""120 ABCDc, tdac2 = ds.realizeNTF_ct(self.ntf, 'FB', tdac=[0, 1], method='NTF')121 self.assertTrue(np.allclose(ABCDc, self.ABCDc_ref2, atol=1e-8,122 rtol=1e-5))123 self.assertTrue(np.allclose(tdac2, self.tdac2_ref2, atol=1e-8,124 rtol=1e-5))125 def test_realizeNTF_ct_12(self):126 """Test function for realizeNTF_ct() 12/15"""127 ABCDc, tdac2 = ds.realizeNTF_ct(self.ntf3, 'FB', self.tdac3, method='NTF')128 self.assertTrue(np.allclose(ABCDc, self.ABCDc_ref3, atol=1e-8,129 rtol=1e-4))130 self.assertTrue(np.allclose(tdac2, self.tdac2_ref3, atol=1e-8,131 rtol=1e-4))132 def test_realizeNTF_ct_13(self):133 """Test function for realizeNTF_ct() 13/15"""134 ABCDc, tdac2 = ds.realizeNTF_ct(self.ntf, 'FF', method='NTF')135 self.assertTrue(np.allclose(ABCDc, self.ABCDc_ref4, atol=1e-8,136 rtol=1e-4))137 self.assertTrue(np.allclose(tdac2, self.tdac2_ref4, atol=1e-8,138 rtol=1e-4))139 def test_realizeNTF_ct_14(self):140 """Test function for realizeNTF_ct() 14/15"""141 ABCDc, tdac2 = ds.realizeNTF_ct(self.ntf, 'FF', tdac=[.5, 1.5],142 method='NTF')143 self.assertTrue(np.allclose(ABCDc, self.ABCDc_ref5, atol=1e-8,144 rtol=1e-4))145 self.assertTrue(np.allclose(tdac2, self.tdac2_ref5, atol=1e-8,146 rtol=1e-4))147 @raises(ValueError)148 def test_realizeNTF_ct_15(self):149 """Test function for realizeNTF_ct() 15/15"""...
multi_process_cal.py
Source:multi_process_cal.py
1import sys2import os3BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))4sys.path.append(BASE_DIR)5from multiprocessing.pool import Pool6# =========1D7from factor.cal_factor.cal_factor_realize.basis import basis_cal8from factor.cal_factor.cal_factor_realize.big_factor import big_factor_cal9from factor.cal_factor.cal_factor_realize.liquidity import liquidity_cal10from factor.cal_factor.cal_factor_realize.momentum import momentum_cal11# from factor.cal_factor.cal_factor_realize.money_flow import money_flow_cal12# from factor.cal_factor.cal_factor_realize.others_factor import others_factor_cal13# from factor.cal_factor.cal_factor_realize.pca_factor import pca_factor_cal14# from factor.cal_factor.cal_factor_realize.rtn_factor import rtn_factor_cal15# from factor.cal_factor.cal_factor_realize.rtn_moment import rtn_moment_cal16# from factor.cal_factor.cal_factor_realize.singular_vol import singular_vol_cal17from factor.cal_factor.cal_factor_realize.updown_factor import updown_factor_cal18# from factor.cal_factor.cal_factor_realize.vol_amt_split import vol_amt_split_cal19from factor.cal_factor.cal_factor_realize.vol_price import vol_price_cal20# =========5D21# from factor.cal_factor.cal_factor_realize.basis import _basis_cal22# from factor.cal_factor.cal_factor_realize.big_factor import _big_factor_cal23# from factor.cal_factor.cal_factor_realize.liquidity import _liquidity_cal24# from factor.cal_factor.cal_factor_realize.momentum import _momentum_cal25#26# from factor.cal_factor.cal_factor_realize.money_flow import _money_flow_cal27# from factor.cal_factor.cal_factor_realize.others_factor import _others_factor_cal28# from factor.cal_factor.cal_factor_realize.pca_factor import _pca_factor_cal29# from factor.cal_factor.cal_factor_realize.rtn_moment import _rtn_moment_cal30#31# from factor.cal_factor.cal_factor_realize.singular_vol import _singular_vol_cal32# from factor.cal_factor.cal_factor_realize.updown_factor import _updown_factor_cal33# from factor.cal_factor.cal_factor_realize.vol_amt_split import _vol_amt_split_cal34# from factor.cal_factor.cal_factor_realize.vol_price import _vol_price_cal35# =========1H36if __name__ == '__main__':37 pool = Pool(processes=4)38 # pool.apply_async(basis_cal, ('2011-01-01', '2021-02-28'))39 # pool.apply_async(big_factor_cal, ('2011-01-04', '2021-02-28'))40 # pool.apply_async(liquidity_cal, ('2011-01-04', '2021-02-28'))41 # pool.apply_async(momentum_cal, ('2011-01-04', '2021-02-28'))42 pool.close()...
test_realize.py
Source:test_realize.py
1#2# CAMP3#4# Copyright (C) 2017 -- 2019 SINTEF Digital5# All rights reserved.6#7# This software may be modified and distributed under the terms8# of the MIT license. See the LICENSE file for details.9#10from unittest import TestCase11from camp.commands import Command, Realize12class DefaultValuesAreCorrect(TestCase):13 def test_given_no_working_directory(self):14 command_line = "realize -o output"15 command = Command.extract_from(command_line.split())16 self.assertIsInstance(command, Realize)17 self.assertEqual(command.working_directory,18 Realize.DEFAULT_WORKING_DIRECTORY)19 def test_given_no_output_directory(self):20 command_line = "realize -d workspace"21 command = Command.extract_from(command_line.split())22 self.assertIsInstance(command, Realize)23 self.assertEqual(command.output_directory,24 Realize.DEFAULT_OUTPUT_DIRECTORY)25class ShortOptionsAreAccepted(TestCase):26 def test_given_working_directory(self):27 command_line = "realize -d my/test/directory"28 command = Command.extract_from(command_line.split())29 self.assertIsInstance(command, Realize)30 self.assertEqual(command.working_directory,31 "my/test/directory")32 def test_given_an_output_directory(self):33 command_line = "realize -o output"34 command = Command.extract_from(command_line.split())35 self.assertIsInstance(command, Realize)36 self.assertEqual(command.output_directory,37 "output")38class LongOptionsAreAccepted(TestCase):39 def test_given_working_directory(self):40 command_line = "realize --directory my/test/directory"41 command = Command.extract_from(command_line.split())42 self.assertIsInstance(command, Realize)43 self.assertEqual(command.working_directory,44 "my/test/directory")45 def test_given_all_configurations(self):46 command_line = "realize --output output"47 command = Command.extract_from(command_line.split())48 self.assertIsInstance(command, Realize)49 self.assertEqual(command.output_directory,...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!