idx int64 0 251k | question stringlengths 53 3.53k | target stringlengths 5 1.23k | len_question int64 20 893 | len_target int64 3 238 |
|---|---|---|---|---|
246,800 | def tisbod ( ref , body , et ) : ref = stypes . stringToCharP ( ref ) body = ctypes . c_int ( body ) et = ctypes . c_double ( et ) retmatrix = stypes . emptyDoubleMatrix ( x = 6 , y = 6 ) libspice . tisbod_c ( ref , body , et , retmatrix ) return stypes . cMatrixToNumpy ( retmatrix ) | Return a 6x6 matrix that transforms states in inertial coordinates to states in body - equator - and - prime - meridian coordinates . | 101 | 29 |
246,801 | def tkvrsn ( item ) : item = stypes . stringToCharP ( item ) return stypes . toPythonString ( libspice . tkvrsn_c ( item ) ) | Given an item such as the Toolkit or an entry point name return the latest version string . | 45 | 19 |
246,802 | def tparse ( instring , lenout = _default_len_out ) : errmsg = stypes . stringToCharP ( lenout ) lenout = ctypes . c_int ( lenout ) instring = stypes . stringToCharP ( instring ) sp2000 = ctypes . c_double ( ) libspice . tparse_c ( instring , lenout , ctypes . byref ( sp2000 ) , errmsg ) return sp2000 . value , stypes . toPythonString ( errmsg ) | Parse a time string and return seconds past the J2000 epoch on a formal calendar . | 114 | 18 |
246,803 | def tpictr ( sample , lenout = _default_len_out , lenerr = _default_len_out ) : sample = stypes . stringToCharP ( sample ) pictur = stypes . stringToCharP ( lenout ) errmsg = stypes . stringToCharP ( lenerr ) lenout = ctypes . c_int ( lenout ) lenerr = ctypes . c_int ( lenerr ) ok = ctypes . c_int ( ) libspice . tpictr_c ( sample , lenout , lenerr , pictur , ctypes . byref ( ok ) , errmsg ) return stypes . toPythonString ( pictur ) , ok . value , stypes . toPythonString ( errmsg ) | Given a sample time string create a time format picture suitable for use by the routine timout . | 168 | 19 |
246,804 | def trcdep ( ) : depth = ctypes . c_int ( ) libspice . trcdep_c ( ctypes . byref ( depth ) ) return depth . value | Return the number of modules in the traceback representation . | 40 | 11 |
246,805 | def trcnam ( index , namlen = _default_len_out ) : index = ctypes . c_int ( index ) name = stypes . stringToCharP ( namlen ) namlen = ctypes . c_int ( namlen ) libspice . trcnam_c ( index , namlen , name ) return stypes . toPythonString ( name ) | Return the name of the module having the specified position in the trace representation . The first module to check in is at index 0 . | 87 | 26 |
246,806 | def twovec ( axdef , indexa , plndef , indexp ) : axdef = stypes . toDoubleVector ( axdef ) indexa = ctypes . c_int ( indexa ) plndef = stypes . toDoubleVector ( plndef ) indexp = ctypes . c_int ( indexp ) mout = stypes . emptyDoubleMatrix ( ) libspice . twovec_c ( axdef , indexa , plndef , indexp , mout ) return stypes . cMatrixToNumpy ( mout ) | Find the transformation to the right - handed frame having a given vector as a specified axis and having a second given vector lying in a specified coordinate plane . | 123 | 30 |
246,807 | def txtopn ( fname ) : fnameP = stypes . stringToCharP ( fname ) unit_out = ctypes . c_int ( ) fname_len = ctypes . c_int ( len ( fname ) ) libspice . txtopn_ ( fnameP , ctypes . byref ( unit_out ) , fname_len ) return unit_out . value | Internal undocumented command for opening a new text file for subsequent write access . | 91 | 14 |
246,808 | def ucase ( inchar , lenout = None ) : if lenout is None : lenout = len ( inchar ) + 1 inchar = stypes . stringToCharP ( inchar ) outchar = stypes . stringToCharP ( " " * lenout ) lenout = ctypes . c_int ( lenout ) libspice . ucase_c ( inchar , lenout , outchar ) return stypes . toPythonString ( outchar ) | Convert the characters in a string to uppercase . | 102 | 12 |
246,809 | def ucrss ( v1 , v2 ) : v1 = stypes . toDoubleVector ( v1 ) v2 = stypes . toDoubleVector ( v2 ) vout = stypes . emptyDoubleVector ( 3 ) libspice . ucrss_c ( v1 , v2 , vout ) return stypes . cVectorToPython ( vout ) | Compute the normalized cross product of two 3 - vectors . | 81 | 12 |
246,810 | def uddc ( udfunc , x , dx ) : x = ctypes . c_double ( x ) dx = ctypes . c_double ( dx ) isdescr = ctypes . c_int ( ) libspice . uddc_c ( udfunc , x , dx , ctypes . byref ( isdescr ) ) return bool ( isdescr . value ) | SPICE private routine intended solely for the support of SPICE routines . Users should not call this routine directly due to the volatile nature of this routine . | 86 | 30 |
246,811 | def uddf ( udfunc , x , dx ) : x = ctypes . c_double ( x ) dx = ctypes . c_double ( dx ) deriv = ctypes . c_double ( ) libspice . uddf_c ( udfunc , x , dx , ctypes . byref ( deriv ) ) return deriv . value | Routine to calculate the first derivative of a caller - specified function using a three - point estimation . | 77 | 20 |
246,812 | def udf ( x ) : x = ctypes . c_double ( x ) value = ctypes . c_double ( ) libspice . udf_c ( x , ctypes . byref ( value ) ) return value . value | No - op routine for with an argument signature matching udfuns . Allways returns 0 . 0 . | 52 | 21 |
246,813 | def unitim ( epoch , insys , outsys ) : epoch = ctypes . c_double ( epoch ) insys = stypes . stringToCharP ( insys ) outsys = stypes . stringToCharP ( outsys ) return libspice . unitim_c ( epoch , insys , outsys ) | Transform time from one uniform scale to another . The uniform time scales are TAI TDT TDB ET JED JDTDB JDTDT . | 70 | 30 |
246,814 | def unload ( filename ) : if isinstance ( filename , list ) : for f in filename : libspice . unload_c ( stypes . stringToCharP ( f ) ) return filename = stypes . stringToCharP ( filename ) libspice . unload_c ( filename ) | Unload a SPICE kernel . | 65 | 7 |
246,815 | def unorm ( v1 ) : v1 = stypes . toDoubleVector ( v1 ) vout = stypes . emptyDoubleVector ( 3 ) vmag = ctypes . c_double ( ) libspice . unorm_c ( v1 , vout , ctypes . byref ( vmag ) ) return stypes . cVectorToPython ( vout ) , vmag . value | Normalize a double precision 3 - vector and return its magnitude . | 86 | 13 |
246,816 | def unormg ( v1 , ndim ) : v1 = stypes . toDoubleVector ( v1 ) vout = stypes . emptyDoubleVector ( ndim ) vmag = ctypes . c_double ( ) ndim = ctypes . c_int ( ndim ) libspice . unormg_c ( v1 , ndim , vout , ctypes . byref ( vmag ) ) return stypes . cVectorToPython ( vout ) , vmag . value | Normalize a double precision vector of arbitrary dimension and return its magnitude . | 108 | 14 |
246,817 | def utc2et ( utcstr ) : utcstr = stypes . stringToCharP ( utcstr ) et = ctypes . c_double ( ) libspice . utc2et_c ( utcstr , ctypes . byref ( et ) ) return et . value | Convert an input time from Calendar or Julian Date format UTC to ephemeris seconds past J2000 . | 65 | 21 |
246,818 | def valid ( insize , n , inset ) : assert isinstance ( inset , stypes . SpiceCell ) insize = ctypes . c_int ( insize ) n = ctypes . c_int ( n ) libspice . valid_c ( insize , n , inset ) return inset | Create a valid CSPICE set from a CSPICE Cell of any data type . | 68 | 18 |
246,819 | def vcrss ( v1 , v2 ) : v1 = stypes . toDoubleVector ( v1 ) v2 = stypes . toDoubleVector ( v2 ) vout = stypes . emptyDoubleVector ( 3 ) libspice . vcrss_c ( v1 , v2 , vout ) return stypes . cVectorToPython ( vout ) | Compute the cross product of two 3 - dimensional vectors . | 81 | 12 |
246,820 | def vdist ( v1 , v2 ) : v1 = stypes . toDoubleVector ( v1 ) v2 = stypes . toDoubleVector ( v2 ) return libspice . vdist_c ( v1 , v2 ) | Return the distance between two three - dimensional vectors . | 53 | 10 |
246,821 | def vdistg ( v1 , v2 , ndim ) : v1 = stypes . toDoubleVector ( v1 ) v2 = stypes . toDoubleVector ( v2 ) ndim = ctypes . c_int ( ndim ) return libspice . vdistg_c ( v1 , v2 , ndim ) | Return the distance between two vectors of arbitrary dimension . | 74 | 10 |
246,822 | def vdot ( v1 , v2 ) : v1 = stypes . toDoubleVector ( v1 ) v2 = stypes . toDoubleVector ( v2 ) return libspice . vdot_c ( v1 , v2 ) | Compute the dot product of two double precision 3 - dimensional vectors . | 53 | 14 |
246,823 | def vdotg ( v1 , v2 , ndim ) : v1 = stypes . toDoubleVector ( v1 ) v2 = stypes . toDoubleVector ( v2 ) ndim = ctypes . c_int ( ndim ) return libspice . vdotg_c ( v1 , v2 , ndim ) | Compute the dot product of two double precision vectors of arbitrary dimension . | 74 | 14 |
246,824 | def vequ ( v1 ) : v1 = stypes . toDoubleVector ( v1 ) vout = stypes . emptyDoubleVector ( 3 ) libspice . vequ_c ( v1 , vout ) return stypes . cVectorToPython ( vout ) | Make one double precision 3 - dimensional vector equal to another . | 60 | 12 |
246,825 | def vequg ( v1 , ndim ) : v1 = stypes . toDoubleVector ( v1 ) vout = stypes . emptyDoubleVector ( ndim ) ndim = ctypes . c_int ( ndim ) libspice . vequg_c ( v1 , ndim , vout ) return stypes . cVectorToPython ( vout ) | Make one double precision vector of arbitrary dimension equal to another . | 82 | 12 |
246,826 | def vhat ( v1 ) : v1 = stypes . toDoubleVector ( v1 ) vout = stypes . emptyDoubleVector ( 3 ) libspice . vhat_c ( v1 , vout ) return stypes . cVectorToPython ( vout ) | Find the unit vector along a double precision 3 - dimensional vector . | 60 | 13 |
246,827 | def vhatg ( v1 , ndim ) : v1 = stypes . toDoubleVector ( v1 ) vout = stypes . emptyDoubleVector ( ndim ) ndim = ctypes . c_int ( ndim ) libspice . vhatg_c ( v1 , ndim , vout ) return stypes . cVectorToPython ( vout ) | Find the unit vector along a double precision vector of arbitrary dimension . | 82 | 13 |
246,828 | def vlcom ( a , v1 , b , v2 ) : v1 = stypes . toDoubleVector ( v1 ) v2 = stypes . toDoubleVector ( v2 ) sumv = stypes . emptyDoubleVector ( 3 ) a = ctypes . c_double ( a ) b = ctypes . c_double ( b ) libspice . vlcom_c ( a , v1 , b , v2 , sumv ) return stypes . cVectorToPython ( sumv ) | Compute a vector linear combination of two double precision 3 - dimensional vectors . | 111 | 15 |
246,829 | def vlcomg ( n , a , v1 , b , v2 ) : v1 = stypes . toDoubleVector ( v1 ) v2 = stypes . toDoubleVector ( v2 ) sumv = stypes . emptyDoubleVector ( n ) a = ctypes . c_double ( a ) b = ctypes . c_double ( b ) n = ctypes . c_int ( n ) libspice . vlcomg_c ( n , a , v1 , b , v2 , sumv ) return stypes . cVectorToPython ( sumv ) | Compute a vector linear combination of two double precision vectors of arbitrary dimension . | 128 | 15 |
246,830 | def vminug ( vin , ndim ) : vin = stypes . toDoubleVector ( vin ) vout = stypes . emptyDoubleVector ( ndim ) ndim = ctypes . c_int ( ndim ) libspice . vminug_c ( vin , ndim , vout ) return stypes . cVectorToPython ( vout ) | Negate a double precision vector of arbitrary dimension . | 82 | 10 |
246,831 | def vminus ( vin ) : vin = stypes . toDoubleVector ( vin ) vout = stypes . emptyDoubleVector ( 3 ) libspice . vminus_c ( vin , vout ) return stypes . cVectorToPython ( vout ) | Negate a double precision 3 - dimensional vector . | 60 | 10 |
246,832 | def vnormg ( v , ndim ) : v = stypes . toDoubleVector ( v ) ndim = ctypes . c_int ( ndim ) return libspice . vnormg_c ( v , ndim ) | Compute the magnitude of a double precision vector of arbitrary dimension . | 51 | 13 |
246,833 | def vpack ( x , y , z ) : x = ctypes . c_double ( x ) y = ctypes . c_double ( y ) z = ctypes . c_double ( z ) vout = stypes . emptyDoubleVector ( 3 ) libspice . vpack_c ( x , y , z , vout ) return stypes . cVectorToPython ( vout ) | Pack three scalar components into a vector . | 86 | 9 |
246,834 | def vperp ( a , b ) : a = stypes . toDoubleVector ( a ) b = stypes . toDoubleVector ( b ) vout = stypes . emptyDoubleVector ( 3 ) libspice . vperp_c ( a , b , vout ) return stypes . cVectorToPython ( vout ) | Find the component of a vector that is perpendicular to a second vector . All vectors are 3 - dimensional . | 73 | 21 |
246,835 | def vprjp ( vin , plane ) : vin = stypes . toDoubleVector ( vin ) vout = stypes . emptyDoubleVector ( 3 ) libspice . vprjp_c ( vin , ctypes . byref ( plane ) , vout ) return stypes . cVectorToPython ( vout ) | Project a vector onto a specified plane orthogonally . | 73 | 12 |
246,836 | def vprjpi ( vin , projpl , invpl ) : vin = stypes . toDoubleVector ( vin ) vout = stypes . emptyDoubleVector ( 3 ) found = ctypes . c_int ( ) libspice . vprjpi_c ( vin , ctypes . byref ( projpl ) , ctypes . byref ( invpl ) , vout , ctypes . byref ( found ) ) return stypes . cVectorToPython ( vout ) , bool ( found . value ) | Find the vector in a specified plane that maps to a specified vector in another plane under orthogonal projection . | 118 | 22 |
246,837 | def vproj ( a , b ) : a = stypes . toDoubleVector ( a ) b = stypes . toDoubleVector ( b ) vout = stypes . emptyDoubleVector ( 3 ) libspice . vproj_c ( a , b , vout ) return stypes . cVectorToPython ( vout ) | Find the projection of one vector onto another vector . | 73 | 10 |
246,838 | def vrel ( v1 , v2 ) : v1 = stypes . toDoubleVector ( v1 ) v2 = stypes . toDoubleVector ( v2 ) return libspice . vrel_c ( v1 , v2 ) | Return the relative difference between two 3 - dimensional vectors . | 53 | 11 |
246,839 | def vrelg ( v1 , v2 , ndim ) : v1 = stypes . toDoubleVector ( v1 ) v2 = stypes . toDoubleVector ( v2 ) ndim = ctypes . c_int ( ndim ) return libspice . vrelg_c ( v1 , v2 , ndim ) | Return the relative difference between two vectors of general dimension . | 74 | 11 |
246,840 | def vrotv ( v , axis , theta ) : v = stypes . toDoubleVector ( v ) axis = stypes . toDoubleVector ( axis ) theta = ctypes . c_double ( theta ) r = stypes . emptyDoubleVector ( 3 ) libspice . vrotv_c ( v , axis , theta , r ) return stypes . cVectorToPython ( r ) | Rotate a vector about a specified axis vector by a specified angle and return the rotated vector . | 89 | 19 |
246,841 | def vscl ( s , v1 ) : s = ctypes . c_double ( s ) v1 = stypes . toDoubleVector ( v1 ) vout = stypes . emptyDoubleVector ( 3 ) libspice . vscl_c ( s , v1 , vout ) return stypes . cVectorToPython ( vout ) | Multiply a scalar and a 3 - dimensional double precision vector . | 75 | 15 |
246,842 | def vsclg ( s , v1 , ndim ) : s = ctypes . c_double ( s ) v1 = stypes . toDoubleVector ( v1 ) vout = stypes . emptyDoubleVector ( ndim ) ndim = ctypes . c_int ( ndim ) libspice . vsclg_c ( s , v1 , ndim , vout ) return stypes . cVectorToPython ( vout ) | Multiply a scalar and a double precision vector of arbitrary dimension . | 97 | 15 |
246,843 | def vsep ( v1 , v2 ) : v1 = stypes . toDoubleVector ( v1 ) v2 = stypes . toDoubleVector ( v2 ) return libspice . vsep_c ( v1 , v2 ) | Find the separation angle in radians between two double precision 3 - dimensional vectors . This angle is defined as zero if either vector is zero . | 55 | 28 |
246,844 | def vsepg ( v1 , v2 , ndim ) : v1 = stypes . toDoubleVector ( v1 ) v2 = stypes . toDoubleVector ( v2 ) ndim = ctypes . c_int ( ndim ) return libspice . vsepg_c ( v1 , v2 , ndim ) | Find the separation angle in radians between two double precision vectors of arbitrary dimension . This angle is defined as zero if either vector is zero . | 74 | 28 |
246,845 | def vsub ( v1 , v2 ) : v1 = stypes . toDoubleVector ( v1 ) v2 = stypes . toDoubleVector ( v2 ) vout = stypes . emptyDoubleVector ( 3 ) libspice . vsub_c ( v1 , v2 , vout ) return stypes . cVectorToPython ( vout ) | Compute the difference between two 3 - dimensional double precision vectors . | 79 | 13 |
246,846 | def vsubg ( v1 , v2 , ndim ) : v1 = stypes . toDoubleVector ( v1 ) v2 = stypes . toDoubleVector ( v2 ) vout = stypes . emptyDoubleVector ( ndim ) ndim = ctypes . c_int ( ndim ) libspice . vsubg_c ( v1 , v2 , ndim , vout ) return stypes . cVectorToPython ( vout ) | Compute the difference between two double precision vectors of arbitrary dimension . | 101 | 13 |
246,847 | def vtmv ( v1 , matrix , v2 ) : v1 = stypes . toDoubleVector ( v1 ) matrix = stypes . toDoubleMatrix ( matrix ) v2 = stypes . toDoubleVector ( v2 ) return libspice . vtmv_c ( v1 , matrix , v2 ) | Multiply the transpose of a 3 - dimensional column vector a 3x3 matrix and a 3 - dimensional column vector . | 70 | 26 |
246,848 | def vtmvg ( v1 , matrix , v2 , nrow , ncol ) : v1 = stypes . toDoubleVector ( v1 ) matrix = stypes . toDoubleMatrix ( matrix ) v2 = stypes . toDoubleVector ( v2 ) nrow = ctypes . c_int ( nrow ) ncol = ctypes . c_int ( ncol ) return libspice . vtmvg_c ( v1 , matrix , v2 , nrow , ncol ) | Multiply the transpose of a n - dimensional column vector a nxm matrix and a m - dimensional column vector . | 108 | 26 |
246,849 | def vupack ( v ) : v1 = stypes . toDoubleVector ( v ) x = ctypes . c_double ( ) y = ctypes . c_double ( ) z = ctypes . c_double ( ) libspice . vupack_c ( v1 , ctypes . byref ( x ) , ctypes . byref ( y ) , ctypes . byref ( z ) ) return x . value , y . value , z . value | Unpack three scalar components from a vector . | 102 | 10 |
246,850 | def vzero ( v ) : v = stypes . toDoubleVector ( v ) return bool ( libspice . vzero_c ( v ) ) | Indicate whether a 3 - vector is the zero vector . | 33 | 12 |
246,851 | def vzerog ( v , ndim ) : v = stypes . toDoubleVector ( v ) ndim = ctypes . c_int ( ndim ) return bool ( libspice . vzerog_c ( v , ndim ) ) | Indicate whether a general - dimensional vector is the zero vector . | 54 | 13 |
246,852 | def wncomd ( left , right , window ) : assert isinstance ( window , stypes . SpiceCell ) assert window . dtype == 1 left = ctypes . c_double ( left ) right = ctypes . c_double ( right ) result = stypes . SpiceCell . double ( window . size ) libspice . wncomd_c ( left , right , ctypes . byref ( window ) , result ) return result | Determine the complement of a double precision window with respect to a specified interval . | 96 | 17 |
246,853 | def wncond ( left , right , window ) : assert isinstance ( window , stypes . SpiceCell ) assert window . dtype == 1 left = ctypes . c_double ( left ) right = ctypes . c_double ( right ) libspice . wncond_c ( left , right , ctypes . byref ( window ) ) return window | Contract each of the intervals of a double precision window . | 78 | 11 |
246,854 | def wndifd ( a , b ) : assert isinstance ( a , stypes . SpiceCell ) assert isinstance ( b , stypes . SpiceCell ) assert a . dtype == 1 assert b . dtype == 1 c = stypes . SpiceCell . double ( a . size + b . size ) libspice . wndifd_c ( ctypes . byref ( a ) , ctypes . byref ( b ) , ctypes . byref ( c ) ) return c | Place the difference of two double precision windows into a third window . | 107 | 13 |
246,855 | def wnelmd ( point , window ) : assert isinstance ( window , stypes . SpiceCell ) assert window . dtype == 1 point = ctypes . c_double ( point ) return bool ( libspice . wnelmd_c ( point , ctypes . byref ( window ) ) ) | Determine whether a point is an element of a double precision window . | 65 | 15 |
246,856 | def wnexpd ( left , right , window ) : assert isinstance ( window , stypes . SpiceCell ) assert window . dtype == 1 left = ctypes . c_double ( left ) right = ctypes . c_double ( right ) libspice . wnexpd_c ( left , right , ctypes . byref ( window ) ) return window | Expand each of the intervals of a double precision window . | 78 | 12 |
246,857 | def wnextd ( side , window ) : assert isinstance ( window , stypes . SpiceCell ) assert window . dtype == 1 assert side == 'L' or side == 'R' side = ctypes . c_char ( side . encode ( encoding = 'UTF-8' ) ) libspice . wnextd_c ( side , ctypes . byref ( window ) ) return window | Extract the left or right endpoints from a double precision window . | 86 | 14 |
246,858 | def wnfetd ( window , n ) : assert isinstance ( window , stypes . SpiceCell ) assert window . dtype == 1 n = ctypes . c_int ( n ) left = ctypes . c_double ( ) right = ctypes . c_double ( ) libspice . wnfetd_c ( ctypes . byref ( window ) , n , ctypes . byref ( left ) , ctypes . byref ( right ) ) return left . value , right . value | Fetch a particular interval from a double precision window . | 109 | 11 |
246,859 | def wnfild ( small , window ) : assert isinstance ( window , stypes . SpiceCell ) assert window . dtype == 1 small = ctypes . c_double ( small ) libspice . wnfild_c ( small , ctypes . byref ( window ) ) return window | Fill small gaps between adjacent intervals of a double precision window . | 65 | 12 |
246,860 | def wnincd ( left , right , window ) : assert isinstance ( window , stypes . SpiceCell ) assert window . dtype == 1 left = ctypes . c_double ( left ) right = ctypes . c_double ( right ) return bool ( libspice . wnincd_c ( left , right , ctypes . byref ( window ) ) ) | Determine whether an interval is included in a double precision window . | 82 | 14 |
246,861 | def wninsd ( left , right , window ) : assert isinstance ( window , stypes . SpiceCell ) assert window . dtype == 1 left = ctypes . c_double ( left ) right = ctypes . c_double ( right ) libspice . wninsd_c ( left , right , ctypes . byref ( window ) ) | Insert an interval into a double precision window . | 78 | 9 |
246,862 | def wnintd ( a , b ) : assert isinstance ( a , stypes . SpiceCell ) assert b . dtype == 1 assert isinstance ( b , stypes . SpiceCell ) assert a . dtype == 1 c = stypes . SpiceCell . double ( b . size + a . size ) libspice . wnintd_c ( ctypes . byref ( a ) , ctypes . byref ( b ) , ctypes . byref ( c ) ) return c | Place the intersection of two double precision windows into a third window . | 107 | 13 |
246,863 | def wnreld ( a , op , b ) : assert isinstance ( a , stypes . SpiceCell ) assert b . dtype == 1 assert isinstance ( b , stypes . SpiceCell ) assert a . dtype == 1 assert isinstance ( op , str ) op = stypes . stringToCharP ( op . encode ( encoding = 'UTF-8' ) ) return bool ( libspice . wnreld_c ( ctypes . byref ( a ) , op , ctypes . byref ( b ) ) ) | Compare two double precision windows . | 117 | 6 |
246,864 | def wnsumd ( window ) : assert isinstance ( window , stypes . SpiceCell ) assert window . dtype == 1 meas = ctypes . c_double ( ) avg = ctypes . c_double ( ) stddev = ctypes . c_double ( ) shortest = ctypes . c_int ( ) longest = ctypes . c_int ( ) libspice . wnsumd_c ( ctypes . byref ( window ) , ctypes . byref ( meas ) , ctypes . byref ( avg ) , ctypes . byref ( stddev ) , ctypes . byref ( shortest ) , ctypes . byref ( longest ) ) return meas . value , avg . value , stddev . value , shortest . value , longest . value | Summarize the contents of a double precision window . | 169 | 11 |
246,865 | def wnunid ( a , b ) : assert isinstance ( a , stypes . SpiceCell ) assert b . dtype == 1 assert isinstance ( b , stypes . SpiceCell ) assert a . dtype == 1 c = stypes . SpiceCell . double ( b . size + a . size ) libspice . wnunid_c ( ctypes . byref ( a ) , ctypes . byref ( b ) , ctypes . byref ( c ) ) return c | Place the union of two double precision windows into a third window . | 107 | 13 |
246,866 | def wnvald ( insize , n , window ) : assert isinstance ( window , stypes . SpiceCell ) assert window . dtype == 1 insize = ctypes . c_int ( insize ) n = ctypes . c_int ( n ) libspice . wnvald_c ( insize , n , ctypes . byref ( window ) ) return window | Form a valid double precision window from the contents of a window array . | 82 | 14 |
246,867 | def writln ( line , unit ) : lineP = stypes . stringToCharP ( line ) unit = ctypes . c_int ( unit ) line_len = ctypes . c_int ( len ( line ) ) libspice . writln_ ( lineP , ctypes . byref ( unit ) , line_len ) | Internal undocumented command for writing a text line to a logical unit | 73 | 12 |
246,868 | def xfmsta ( input_state , input_coord_sys , output_coord_sys , body ) : input_state = stypes . toDoubleVector ( input_state ) input_coord_sys = stypes . stringToCharP ( input_coord_sys ) output_coord_sys = stypes . stringToCharP ( output_coord_sys ) body = stypes . stringToCharP ( body ) output_state = stypes . emptyDoubleVector ( 6 ) libspice . xfmsta_c ( input_state , input_coord_sys , output_coord_sys , body , output_state ) return stypes . cVectorToPython ( output_state ) | Transform a state between coordinate systems . | 149 | 7 |
246,869 | def xpose ( m ) : m = stypes . toDoubleMatrix ( m ) mout = stypes . emptyDoubleMatrix ( x = 3 , y = 3 ) libspice . xpose_c ( m , mout ) return stypes . cMatrixToNumpy ( mout ) | Transpose a 3x3 matrix | 63 | 7 |
246,870 | def xpose6 ( m ) : m = stypes . toDoubleMatrix ( m ) mout = stypes . emptyDoubleMatrix ( x = 6 , y = 6 ) libspice . xpose6_c ( m , mout ) return stypes . cMatrixToNumpy ( mout ) | Transpose a 6x6 matrix | 65 | 7 |
246,871 | def xposeg ( matrix , nrow , ncol ) : matrix = stypes . toDoubleMatrix ( matrix ) mout = stypes . emptyDoubleMatrix ( x = ncol , y = nrow ) ncol = ctypes . c_int ( ncol ) nrow = ctypes . c_int ( nrow ) libspice . xposeg_c ( matrix , nrow , ncol , mout ) return stypes . cMatrixToNumpy ( mout ) | Transpose a matrix of arbitrary size in place the matrix need not be square . | 105 | 16 |
246,872 | def CallUDFUNS ( f , x ) : value = c_double ( ) f ( x , byref ( value ) ) return value . value | We are given a UDF CFUNCTYPE and want to call it in python | 33 | 18 |
246,873 | def updateD_G ( self , x ) : self . precompute ( x ) g = zeros ( len ( x ) ) Ai = zeros ( self . A . shape [ 0 ] ) for i in range ( len ( g ) ) : Ai = self . A [ : , i ] g [ i ] = ( self . E * ( dot ( self . AD , outer ( self . R [ : , i ] , Ai ) ) + dot ( outer ( Ai , self . R [ i , : ] ) , self . ADt ) ) ) . sum ( ) return - 2 * g | Compute Gradient for update of D | 128 | 8 |
246,874 | def updateD_H ( self , x ) : self . precompute ( x ) H = zeros ( ( len ( x ) , len ( x ) ) ) Ai = zeros ( self . A . shape [ 0 ] ) Aj = zeros ( Ai . shape ) for i in range ( len ( x ) ) : Ai = self . A [ : , i ] ti = dot ( self . AD , outer ( self . R [ : , i ] , Ai ) ) + dot ( outer ( Ai , self . R [ i , : ] ) , self . ADt ) for j in range ( i , len ( x ) ) : Aj = self . A [ : , j ] tj = outer ( Ai , Aj ) H [ i , j ] = ( self . E * ( self . R [ i , j ] * tj + self . R [ j , i ] * tj . T ) - ti * ( dot ( self . AD , outer ( self . R [ : , j ] , Aj ) ) + dot ( outer ( Aj , self . R [ j , : ] ) , self . ADt ) ) ) . sum ( ) H [ j , i ] = H [ i , j ] H *= - 2 e = eigvals ( H ) . min ( ) H = H + ( eye ( H . shape [ 0 ] ) * e ) return H | Compute Hessian for update of D | 296 | 8 |
246,875 | def is_sequence ( obj ) : try : from collections import Sequence except ImportError : from operator import isSequenceType return isSequenceType ( obj ) else : return isinstance ( obj , Sequence ) | Helper function to determine sequences across Python 2 . x and 3 . x | 43 | 14 |
246,876 | def is_number ( obj ) : try : from numbers import Number except ImportError : from operator import isNumberType return isNumberType ( obj ) else : return isinstance ( obj , Number ) | Helper function to determine numbers across Python 2 . x and 3 . x | 41 | 14 |
246,877 | def func_attr ( f , attr ) : if hasattr ( f , 'func_%s' % attr ) : return getattr ( f , 'func_%s' % attr ) elif hasattr ( f , '__%s__' % attr ) : return getattr ( f , '__%s__' % attr ) else : raise ValueError ( 'Object %s has no attr' % ( str ( f ) , attr ) ) | Helper function to get the attribute of a function like name code defaults across Python 2 . x and 3 . x | 104 | 22 |
246,878 | def from_to_without ( frm , to , without , step = 1 , skip = 1 , reverse = False , separate = False ) : if reverse : frm , to = ( to - 1 ) , ( frm - 1 ) step *= - 1 skip *= - 1 a = list ( range ( frm , without , step ) ) b = list ( range ( without + skip , to , step ) ) if separate : return a , b else : return a + b | Helper function to create ranges with missing entries | 103 | 8 |
246,879 | def unfold ( self , mode ) : sz = array ( self . shape ) N = len ( sz ) order = ( [ mode ] , from_to_without ( N - 1 , - 1 , mode , step = - 1 , skip = - 1 ) ) newsz = ( sz [ order [ 0 ] ] [ 0 ] , prod ( sz [ order [ 1 ] ] ) ) arr = self . transpose ( axes = ( order [ 0 ] + order [ 1 ] ) ) arr = arr . reshape ( newsz ) return unfolded_dtensor ( arr , mode , self . shape ) | Unfolds a dense tensor in mode n . | 130 | 11 |
246,880 | def accum ( subs , vals , func = np . sum , issorted = False , with_subs = False ) : # sort accmap for ediff if not sorted if not issorted : sidx = lexsort ( subs , axis = 0 ) subs = [ sub [ sidx ] for sub in subs ] vals = vals [ sidx ] idx = np . where ( np . diff ( subs ) . any ( axis = 0 ) ) [ 0 ] + 1 idx = np . concatenate ( ( [ 0 ] , idx , [ subs [ 0 ] . shape [ 0 ] ] ) ) # create values array nvals = np . zeros ( len ( idx ) - 1 ) for i in range ( len ( idx ) - 1 ) : nvals [ i ] = func ( vals [ idx [ i ] : idx [ i + 1 ] ] ) # return results if with_subs : return nvals , tuple ( sub [ idx [ : - 1 ] ] for sub in subs ) else : return nvals | NumPy implementation for Matlab s accumarray | 224 | 9 |
246,881 | def hooi ( X , rank , * * kwargs ) : # init options ainit = kwargs . pop ( 'init' , __DEF_INIT ) maxIter = kwargs . pop ( 'maxIter' , __DEF_MAXITER ) conv = kwargs . pop ( 'conv' , __DEF_CONV ) dtype = kwargs . pop ( 'dtype' , X . dtype ) if not len ( kwargs ) == 0 : raise ValueError ( 'Unknown keywords (%s)' % ( kwargs . keys ( ) ) ) ndims = X . ndim if is_number ( rank ) : rank = rank * ones ( ndims ) normX = norm ( X ) U = __init ( ainit , X , ndims , rank , dtype ) fit = 0 exectimes = [ ] for itr in range ( maxIter ) : tic = time . clock ( ) fitold = fit for n in range ( ndims ) : Utilde = ttm ( X , U , n , transp = True , without = True ) U [ n ] = nvecs ( Utilde , n , rank [ n ] ) # compute core tensor to get fit core = ttm ( Utilde , U , n , transp = True ) # since factors are orthonormal, compute fit on core tensor normresidual = sqrt ( normX ** 2 - norm ( core ) ** 2 ) # fraction explained by model fit = 1 - ( normresidual / normX ) fitchange = abs ( fitold - fit ) exectimes . append ( time . clock ( ) - tic ) _log . debug ( '[%3d] fit: %.5f | delta: %7.1e | secs: %.5f' % ( itr , fit , fitchange , exectimes [ - 1 ] ) ) if itr > 1 and fitchange < conv : break return core , U | Compute Tucker decomposition of a tensor using Higher - Order Orthogonal Iterations . | 434 | 19 |
246,882 | def uttkrp ( self , U , mode ) : N = self . ndim if mode == 1 : R = U [ 1 ] . shape [ 1 ] else : R = U [ 0 ] . shape [ 1 ] W = np . tile ( self . lmbda , 1 , R ) for i in range ( mode ) + range ( mode + 1 , N ) : W = W * dot ( self . U [ i ] . T , U [ i ] ) return dot ( self . U [ mode ] , W ) | Unfolded tensor times Khatri - Rao product for Kruskal tensors | 113 | 18 |
246,883 | def norm ( self ) : N = len ( self . shape ) coef = outer ( self . lmbda , self . lmbda ) for i in range ( N ) : coef = coef * dot ( self . U [ i ] . T , self . U [ i ] ) return np . sqrt ( coef . sum ( ) ) | Efficient computation of the Frobenius norm for ktensors | 76 | 14 |
246,884 | def innerprod ( self , X ) : N = len ( self . shape ) R = len ( self . lmbda ) res = 0 for r in range ( R ) : vecs = [ ] for n in range ( N ) : vecs . append ( self . U [ n ] [ : , r ] ) res += self . lmbda [ r ] * X . ttv ( tuple ( vecs ) ) return res | Efficient computation of the inner product of a ktensor with another tensor | 93 | 16 |
246,885 | def toarray ( self ) : A = dot ( self . lmbda , khatrirao ( tuple ( self . U ) ) . T ) return A . reshape ( self . shape ) | Converts a ktensor into a dense multidimensional ndarray | 42 | 15 |
246,886 | def fromarray ( A ) : subs = np . nonzero ( A ) vals = A [ subs ] return sptensor ( subs , vals , shape = A . shape , dtype = A . dtype ) | Create a sptensor from a dense numpy array | 47 | 11 |
246,887 | def _ttm_me_compute ( self , V , edims , sdims , transp ) : shapeY = np . copy ( self . shape ) # Determine size of Y for n in np . union1d ( edims , sdims ) : shapeY [ n ] = V [ n ] . shape [ 1 ] if transp else V [ n ] . shape [ 0 ] # Allocate Y (final result) and v (vectors for elementwise computations) Y = zeros ( shapeY ) shapeY = array ( shapeY ) v = [ None for _ in range ( len ( edims ) ) ] for i in range ( np . prod ( shapeY [ edims ] ) ) : rsubs = unravel_index ( shapeY [ edims ] , i ) | Assume Y = T x_i V_i for i = 1 ... n can fit into memory | 171 | 21 |
246,888 | def transpose ( self , axes = None ) : if axes is None : raise NotImplementedError ( 'Sparse tensor transposition without axes argument is not supported' ) nsubs = tuple ( [ self . subs [ idx ] for idx in axes ] ) nshape = [ self . shape [ idx ] for idx in axes ] return sptensor ( nsubs , self . vals , nshape ) | Compute transpose of sparse tensors . | 93 | 9 |
246,889 | def concatenate ( self , tpl , axis = None ) : if axis is None : raise NotImplementedError ( 'Sparse tensor concatenation without axis argument is not supported' ) T = self for i in range ( 1 , len ( tpl ) ) : T = _single_concatenate ( T , tpl [ i ] , axis = axis ) return T | Concatenates sparse tensors . | 84 | 8 |
246,890 | def fold ( self ) : nsubs = zeros ( ( len ( self . data ) , len ( self . ten_shape ) ) , dtype = np . int ) if len ( self . rdims ) > 0 : nidx = unravel_index ( self . row , self . ten_shape [ self . rdims ] ) for i in range ( len ( self . rdims ) ) : nsubs [ : , self . rdims [ i ] ] = nidx [ i ] if len ( self . cdims ) > 0 : nidx = unravel_index ( self . col , self . ten_shape [ self . cdims ] ) for i in range ( len ( self . cdims ) ) : nsubs [ : , self . cdims [ i ] ] = nidx [ i ] nsubs = [ z . flatten ( ) for z in hsplit ( nsubs , len ( self . ten_shape ) ) ] return sptensor ( tuple ( nsubs ) , self . data , self . ten_shape ) | Recreate original tensor by folding unfolded_sptensor according toc ten_shape . | 235 | 20 |
246,891 | def _updateA ( X , A , R , P , Z , lmbdaA , orthogonalize ) : n , rank = A . shape F = zeros ( ( n , rank ) , dtype = A . dtype ) E = zeros ( ( rank , rank ) , dtype = A . dtype ) AtA = dot ( A . T , A ) for i in range ( len ( X ) ) : F += X [ i ] . dot ( dot ( A , R [ i ] . T ) ) + X [ i ] . T . dot ( dot ( A , R [ i ] ) ) E += dot ( R [ i ] , dot ( AtA , R [ i ] . T ) ) + dot ( R [ i ] . T , dot ( AtA , R [ i ] ) ) # regularization I = lmbdaA * eye ( rank , dtype = A . dtype ) # attributes for i in range ( len ( Z ) ) : F += P [ i ] . dot ( Z [ i ] . T ) E += dot ( Z [ i ] , Z [ i ] . T ) # finally compute update for A A = solve ( I + E . T , F . T ) . T return orth ( A ) if orthogonalize else A | Update step for A | 278 | 4 |
246,892 | def _compute_fval ( X , A , R , P , Z , lmbdaA , lmbdaR , lmbdaZ , normX ) : f = lmbdaA * norm ( A ) ** 2 for i in range ( len ( X ) ) : ARAt = dot ( A , dot ( R [ i ] , A . T ) ) f += ( norm ( X [ i ] - ARAt ) ** 2 ) / normX [ i ] + lmbdaR * norm ( R [ i ] ) ** 2 return f | Compute fit for full slices | 119 | 6 |
246,893 | def als ( X , rank , * * kwargs ) : # init options ainit = kwargs . pop ( 'init' , _DEF_INIT ) maxiter = kwargs . pop ( 'max_iter' , _DEF_MAXITER ) fit_method = kwargs . pop ( 'fit_method' , _DEF_FIT_METHOD ) conv = kwargs . pop ( 'conv' , _DEF_CONV ) dtype = kwargs . pop ( 'dtype' , _DEF_TYPE ) if not len ( kwargs ) == 0 : raise ValueError ( 'Unknown keywords (%s)' % ( kwargs . keys ( ) ) ) N = X . ndim normX = norm ( X ) U = _init ( ainit , X , N , rank , dtype ) fit = 0 exectimes = [ ] for itr in range ( maxiter ) : tic = time . clock ( ) fitold = fit for n in range ( N ) : Unew = X . uttkrp ( U , n ) Y = ones ( ( rank , rank ) , dtype = dtype ) for i in ( list ( range ( n ) ) + list ( range ( n + 1 , N ) ) ) : Y = Y * dot ( U [ i ] . T , U [ i ] ) Unew = Unew . dot ( pinv ( Y ) ) # Normalize if itr == 0 : lmbda = sqrt ( ( Unew ** 2 ) . sum ( axis = 0 ) ) else : lmbda = Unew . max ( axis = 0 ) lmbda [ lmbda < 1 ] = 1 U [ n ] = Unew / lmbda P = ktensor ( U , lmbda ) if fit_method == 'full' : normresidual = normX ** 2 + P . norm ( ) ** 2 - 2 * P . innerprod ( X ) fit = 1 - ( normresidual / normX ** 2 ) else : fit = itr fitchange = abs ( fitold - fit ) exectimes . append ( time . clock ( ) - tic ) _log . debug ( '[%3d] fit: %.5f | delta: %7.1e | secs: %.5f' % ( itr , fit , fitchange , exectimes [ - 1 ] ) ) if itr > 0 and fitchange < conv : break return P , fit , itr , array ( exectimes ) | Alternating least - sqaures algorithm to compute the CP decomposition . | 552 | 15 |
246,894 | def _init ( init , X , N , rank , dtype ) : Uinit = [ None for _ in range ( N ) ] if isinstance ( init , list ) : Uinit = init elif init == 'random' : for n in range ( 1 , N ) : Uinit [ n ] = array ( rand ( X . shape [ n ] , rank ) , dtype = dtype ) elif init == 'nvecs' : for n in range ( 1 , N ) : Uinit [ n ] = array ( nvecs ( X , n , rank ) , dtype = dtype ) else : raise 'Unknown option (init=%s)' % str ( init ) return Uinit | Initialization for CP models | 151 | 5 |
246,895 | def nvecs ( X , n , rank , do_flipsign = True , dtype = np . float ) : Xn = X . unfold ( n ) if issparse_mat ( Xn ) : Xn = csr_matrix ( Xn , dtype = dtype ) Y = Xn . dot ( Xn . T ) _ , U = eigsh ( Y , rank , which = 'LM' ) else : Y = Xn . dot ( Xn . T ) N = Y . shape [ 0 ] _ , U = eigh ( Y , eigvals = ( N - rank , N - 1 ) ) #_, U = eigsh(Y, rank, which='LM') # reverse order of eigenvectors such that eigenvalues are decreasing U = array ( U [ : , : : - 1 ] ) # flip sign if do_flipsign : U = flipsign ( U ) return U | Eigendecomposition of mode - n unfolding of a tensor | 204 | 15 |
246,896 | def flipsign ( U ) : midx = abs ( U ) . argmax ( axis = 0 ) for i in range ( U . shape [ 1 ] ) : if U [ midx [ i ] , i ] < 0 : U [ : , i ] = - U [ : , i ] return U | Flip sign of factor matrices such that largest magnitude element will be positive | 65 | 15 |
246,897 | def khatrirao ( A , reverse = False ) : if not isinstance ( A , tuple ) : raise ValueError ( 'A must be a tuple of array likes' ) N = A [ 0 ] . shape [ 1 ] M = 1 for i in range ( len ( A ) ) : if A [ i ] . ndim != 2 : raise ValueError ( 'A must be a tuple of matrices (A[%d].ndim = %d)' % ( i , A [ i ] . ndim ) ) elif N != A [ i ] . shape [ 1 ] : raise ValueError ( 'All matrices must have same number of columns' ) M *= A [ i ] . shape [ 0 ] matorder = arange ( len ( A ) ) if reverse : matorder = matorder [ : : - 1 ] # preallocate P = np . zeros ( ( M , N ) , dtype = A [ 0 ] . dtype ) for n in range ( N ) : ab = A [ matorder [ 0 ] ] [ : , n ] for j in range ( 1 , len ( matorder ) ) : ab = np . kron ( ab , A [ matorder [ j ] ] [ : , n ] ) P [ : , n ] = ab return P | Compute the columnwise Khatri - Rao product . | 277 | 12 |
246,898 | def teneye ( dim , order ) : I = zeros ( dim ** order ) for f in range ( dim ) : idd = f for i in range ( 1 , order ) : idd = idd + dim ** ( i - 1 ) * ( f - 1 ) I [ idd ] = 1 return I . reshape ( ones ( order ) * dim ) | Create tensor with superdiagonal all one rest zeros | 80 | 12 |
246,899 | def ttm ( self , V , mode = None , transp = False , without = False ) : if mode is None : mode = range ( self . ndim ) if isinstance ( V , np . ndarray ) : Y = self . _ttm_compute ( V , mode , transp ) elif is_sequence ( V ) : dims , vidx = check_multiplication_dims ( mode , self . ndim , len ( V ) , vidx = True , without = without ) Y = self . _ttm_compute ( V [ vidx [ 0 ] ] , dims [ 0 ] , transp ) for i in xrange ( 1 , len ( dims ) ) : Y = Y . _ttm_compute ( V [ vidx [ i ] ] , dims [ i ] , transp ) return Y | Tensor times matrix product | 190 | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.