You will see later, that that is exactly which solution I end up with! 2014-06-10 14:06 GMT+02:00 Edward d'Auvergne <[email protected]>: > Hi Troels, > > I was wondering if you could replace: > > self.R20A_a[0][si][mi][0][:num_disp_points] = > np.array( [R20A[r20_index]] * num_disp_points, float64) > > with: > > self.R20A_a[0][si][mi][0][:num_disp_points] = R20A[r20_index] > > As self.R20A_a is already a numpy array, you can set a single value to > all parts of an array element. For example: > > """ > from numpy import zeros > > a = zeros((5, 4)) > a[1] = 1 > a[:,1] = 2 > > print(a) > """ > > The result of running this is: > > [[ 0. 2. 0. 0.] > [ 1. 2. 1. 1.] > [ 0. 2. 0. 0.] > [ 0. 2. 0. 0.] > [ 0. 2. 0. 0.]] > > You can use such logic to avoid numpy.array() in the target functions, > as that is very undesirable. > > Regards, > > Edward > > > > On 8 June 2014 22:22, <[email protected]> wrote: >> Author: tlinnet >> Date: Sun Jun 8 22:22:22 2014 >> New Revision: 23740 >> >> URL: http://svn.gna.org/viewcvs/relax?rev=23740&view=rev >> Log: >> Critical fix for the slicing of values in target function. >> >> This makes system test: Relax_disp.test_sod1wt_t25_to_cr72 pass. >> >> Task #7807 (https://gna.org/task/index.php?7807): Speed-up of dispersion >> models for Clustered analysis. >> >> Modified: >> branches/disp_spin_speed/target_functions/relax_disp.py >> >> Modified: branches/disp_spin_speed/target_functions/relax_disp.py >> URL: >> http://svn.gna.org/viewcvs/relax/branches/disp_spin_speed/target_functions/relax_disp.py?rev=23740&r1=23739&r2=23740&view=diff >> ============================================================================== >> --- branches/disp_spin_speed/target_functions/relax_disp.py (original) >> +++ branches/disp_spin_speed/target_functions/relax_disp.py Sun Jun 8 >> 22:22:22 2014 >> @@ -521,18 +521,18 @@ >> r20_index = mi + si*self.num_frq >> >> # Store r20a and r20b values per disp point. >> - self.R20A_a[0][si][mi][0] = np.array( [R20A[r20_index]] * >> self.max_num_disp_points, float64) >> - self.R20B_a[0][si][mi][0] = np.array( [R20B[r20_index]] * >> self.max_num_disp_points, float64) >> + self.R20A_a[0][si][mi][0][:num_disp_points] = np.array( >> [R20A[r20_index]] * num_disp_points, float64) >> + self.R20B_a[0][si][mi][0][:num_disp_points] = np.array( >> [R20B[r20_index]] * num_disp_points, float64) >> >> # Convert dw from ppm to rad/s. >> dw_frq = dw[si] * self.frqs[0][si][mi] >> >> # Store dw_frq per disp point. >> - self.dw_frq_a[0][si][mi][0] = np.array( [dw_frq] * >> self.max_num_disp_points, float64) >> + self.dw_frq_a[0][si][mi][0][:num_disp_points] = np.array( >> [dw_frq] * num_disp_points, float64) >> >> # Store pA and kex per disp point. >> - self.pA_a[0][si][mi][0] = np.array( [pA] * >> self.max_num_disp_points, float64) >> - self.kex_a[0][si][mi][0] = np.array( [kex] * >> self.max_num_disp_points, float64) >> + self.pA_a[0][si][mi][0][:num_disp_points] = np.array( [pA] >> * num_disp_points, float64) >> + self.kex_a[0][si][mi][0][:num_disp_points] = np.array( >> [kex] * num_disp_points, float64) >> >> ## Back calculate the R2eff values. >> r2eff_CR72(r20a=self.R20A_a, r20b=self.R20B_a, pA=self.pA_a, >> dw=self.dw_frq_a, kex=self.kex_a, cpmg_frqs=self.cpmg_frqs_a, >> back_calc=self.back_calc_a, num_points=self.num_disp_points_a) >> >> >> _______________________________________________ >> relax (http://www.nmr-relax.com) >> >> This is the relax-commits mailing list >> [email protected] >> >> To unsubscribe from this list, get a password >> reminder, or change your subscription options, >> visit the list information page at >> https://mail.gna.org/listinfo/relax-commits > > _______________________________________________ > relax (http://www.nmr-relax.com) > > This is the relax-devel mailing list > [email protected] > > To unsubscribe from this list, get a password > reminder, or change your subscription options, > visit the list information page at > https://mail.gna.org/listinfo/relax-devel
_______________________________________________ relax (http://www.nmr-relax.com) This is the relax-devel mailing list [email protected] To unsubscribe from this list, get a password reminder, or change your subscription options, visit the list information page at https://mail.gna.org/listinfo/relax-devel

