How to use _get_profile method in prospector

Best Python code snippet using prospector_python

test_flatsym.py

Source:test_flatsym.py Github

copy

Full Screen

...71 @classmethod72 def tearDownClass(cls):73 plt.close('all')74 def test_get_symmetry(self):75 prof = self.img._get_profile('x', 'auto')76 # varian77 for method in ('varian', 'point difference'):78 symmetry, lt_edge, rt_edge, max_idx = self.img._get_symmetry(prof, method)79 self.assertAlmostEqual(symmetry, 3.08, delta=0.01)80 self.assertAlmostEqual(lt_edge, 393, delta=3)81 self.assertAlmostEqual(rt_edge, 681, delta=3)82 self.assertAlmostEqual(max_idx, 429, delta=3)83 # elekta84 for method in ('elekta', 'pdq-iec'):85 symmetry, lt_edge, rt_edge, max_idx = self.img._get_symmetry(prof, method)86 self.assertAlmostEqual(symmetry, 103.11, delta=0.05)87 def test_convert_position(self):88 input_pos = 'auto'89 out_pos = self.img._convert_position(input_pos, 'both')90 self.assertEqual(out_pos[0], 366)91 self.assertEqual(out_pos[1], 537)92 out_pos = self.img._convert_position(input_pos, 'x')93 self.assertEqual(out_pos[0], 366)94 input_pos = (300, 0.6)95 out_pos = self.img._convert_position(input_pos, 'both')96 self.assertEqual(out_pos[0], 300)97 self.assertEqual(out_pos[1], 614)98 input_pos = 0.699 out_pos = self.img._convert_position(input_pos, 'y')100 self.assertEqual(out_pos[0], 614)101 self.assertRaises(ValueError, self.img._convert_position, (300, 400, 0.5), 'both')102 self.assertRaises(ValueError, self.img._convert_position, (300, 400), 'x')103 self.assertRaises(ValueError, self.img._convert_position, (300, 400), 'notaplane')104 def test_parse_position(self):105 position = 30106 int_input = self.img._parse_position(position, 'x')107 self.assertEqual(int_input, position)108 float_pos = 0.4109 fl_input = self.img._parse_position(float_pos, 'i')110 self.assertAlmostEqual(fl_input, float_pos*self.img.image.shape[1], delta=1)111 fl_input = self.img._parse_position(float_pos, 'x')112 self.assertAlmostEqual(fl_input, float_pos * self.img.image.shape[0], delta=1)113 self.assertRaises(ValueError, self.img._parse_position, position, 'both')114 # self.assertRaises(ValueError, self.img._parse_position, 1.1, 'x')115 def test_get_profile(self):116 """Test various inputs for _get_profile()."""117 b = BeamImage()118 self.assertRaises(AttributeError, b._get_profile, 'x', 'auto')119 # test output type120 self.assertIsInstance(self.img._get_profile('x', 'auto'), SingleProfile)121 # test axes122 for axis in ('crossplane', 'cross', 'x', 'inplane', 'in'):123 self.img._get_profile(axis, 'auto')124 # self.assertRaises(ValueError, self.img._get_profile, 'notaplane', 'auto')125 # make sure extraction is along correct axis126 size_xplane = 1024127 prof = self.img._get_profile('x', 'auto')128 self.assertEqual(prof.values.size, size_xplane)129 size_yplane = 768130 prof = self.img._get_profile('in', 'auto')131 self.assertEqual(prof.values.size, size_yplane)132 def test_check_position_bounds(self):133 # test positions134 for pos in (100, 500, 0.5):135 self.img._check_position_inbounds(pos, 'x')136 self.assertRaises(IndexError, self.img._check_position_inbounds, 1100, 'x')137 self.assertRaises(IndexError, self.img._check_position_inbounds, 800, 'i')138 def test_get_flatness(self):139 prof = self.img._get_profile('x', 'auto')140 # varian141 for method in ('varian', 'VoM80', 'siemens'):142 flatness, dmax, dmin, lt_edge, rt_edge = self.img._get_flatness(prof, method)143 self.assertAlmostEqual(flatness, 1.91, delta=0.01)144 self.assertAlmostEqual(dmax, 58533, delta=20)145 self.assertAlmostEqual(dmin, 56335, delta=20)146 self.assertAlmostEqual(lt_edge, 393, delta=3)147 self.assertAlmostEqual(rt_edge, 681, delta=3)148 # elekta149 for method in ('elekta', 'IEC'):150 flatness, dmax, dmin, lt_edge, rt_edge = self.img._get_flatness(prof, method)151 self.assertAlmostEqual(flatness, 103.9, delta=0.05)152 def test_plot_annotation(self):153 fig, ax = plt.subplots()...

Full Screen

Full Screen

profile_input_validation.py

Source:profile_input_validation.py Github

copy

Full Screen

...85 """86 raise NotImplementedError(87 "create_profile needs to be implemented in a sub class."88 )89 def _get_profile(self, user):90 if not hasattr(self, "profile"):91 self.profile = self.create_profile(user)92 return self.profile93 def _execute_query(self, user_gql_client, profile_input):94 # Ensure Profile has been created95 self._get_profile(user_gql_client.user)96 return super()._execute_query(user_gql_client, profile_input)97 @pytest.mark.parametrize("invalid_email", [None, "", "not-an-email"])98 def test_updating_to_invalid_email_address_causes_an_invalid_email_format_error(99 self, invalid_email, user_gql_client100 ):101 profile = self._get_profile(user_gql_client.user)102 email = EmailFactory(profile=profile, primary=False)103 profile_input = {104 "updateEmails": [105 {106 "id": to_global_id(type="EmailNode", id=email.id),107 "email": invalid_email,108 }109 ],110 }111 executed = self._execute_query(user_gql_client, profile_input)112 assert_match_error_code(executed, "INVALID_EMAIL_FORMAT")113 def test_updating_phone_number_with_empty_phone_number_causes_a_validation_error(114 self, user_gql_client, empty_string_value115 ):116 profile = self._get_profile(user_gql_client.user)117 phone = PhoneFactory(profile=profile)118 profile_input = {119 "updatePhones": [120 {121 "id": to_global_id(type="PhoneNode", id=phone.id),122 "phone": empty_string_value,123 }124 ],125 }126 executed = self._execute_query(user_gql_client, profile_input)127 assert_match_error_code(executed, "VALIDATION_ERROR")128 @pytest.mark.parametrize("field_name", ["address", "postal_code", "city"])129 def test_updating_address_field_with_too_long_value_causes_a_validation_error(130 self, field_name, user_gql_client131 ):132 profile = self._get_profile(user_gql_client.user)133 address = AddressFactory(profile=profile)134 profile_input = {135 "updateAddresses": [136 {137 "id": to_global_id(type="AddressNode", id=address.id),138 to_graphql_name(field_name): "x" * 130,139 }140 ]141 }142 executed = self._execute_query(user_gql_client, profile_input)143 assert_match_error_code(executed, "VALIDATION_ERROR")144 @pytest.mark.parametrize("country_code", ["X", "fi", "VR", "Finland"])145 def test_updating_address_with_invalid_country_code_value_causes_a_validation_error(146 self, country_code, user_gql_client147 ):148 profile = self._get_profile(user_gql_client.user)149 address = AddressFactory(profile=profile)150 profile_input = {151 "updateAddresses": [152 {153 "id": to_global_id(type="AddressNode", id=address.id),154 "countryCode": country_code,155 }156 ]157 }158 executed = self._execute_query(user_gql_client, profile_input)...

Full Screen

Full Screen

profile.py

Source:profile.py Github

copy

Full Screen

...14 def plot_xlabel(self):15 return "r/kpc"16 def plot_ylabel(self):17 return r"$\rho/M_{\odot}\,kpc^{-3}$", r"$M/M_{\odot}$"18 def _get_profile(self, halo, maxrad):19 import pynbody20 delta = self.plot_xdelta()21 nbins = int(maxrad / delta)22 maxrad = delta * nbins23 pro = pynbody.analysis.profile.Profile(halo, type='lin', ndim=3,24 min=0, max=maxrad, nbins=nbins)25 rho_a = pro['density']26 mass_a = pro['mass_enc']27 rho_a = rho_a.view(np.ndarray)28 mass_a = mass_a.view(np.ndarray)29 return rho_a, mass_a30 @centred_calculation31 def calculate(self, data, existing_properties):32 dm_a, dm_b = self._get_profile(data.dm, existing_properties["max_radius"])33 return dm_a, dm_b34class BaryonicHaloDensityProfile(HaloDensityProfile):35 names = "gas_density_profile", "gas_mass_profile", "star_density_profile", "star_mass_profile"36 @centred_calculation37 def calculate(self, data, existing_properties):38 gas_a, gas_b = self._get_profile(data.gas, existing_properties["max_radius"])39 star_a, star_b = self._get_profile(data.star, existing_properties["max_radius"])...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run prospector automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful