repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
oscarlazoarjona/fast
fast/atomic_structure.py
calculate_gamma_matrix
def calculate_gamma_matrix(magnetic_states, Omega=1, einsteinA=None, numeric=True): ur"""Calculate the matrix of decay between states. This function calculates the matrix :math:`\gamma_{ij}` of decay rates between states :math:`|i\rangle` and :math:`|j\rangle` (in the units s...
python
def calculate_gamma_matrix(magnetic_states, Omega=1, einsteinA=None, numeric=True): ur"""Calculate the matrix of decay between states. This function calculates the matrix :math:`\gamma_{ij}` of decay rates between states :math:`|i\rangle` and :math:`|j\rangle` (in the units s...
[ "def", "calculate_gamma_matrix", "(", "magnetic_states", ",", "Omega", "=", "1", ",", "einsteinA", "=", "None", ",", "numeric", "=", "True", ")", ":", "Ne", "=", "len", "(", "magnetic_states", ")", "fine_states", "=", "[", "]", "fine_map", "=", "{", "}",...
ur"""Calculate the matrix of decay between states. This function calculates the matrix :math:`\gamma_{ij}` of decay rates between states :math:`|i\rangle` and :math:`|j\rangle` (in the units specified by the Omega argument). >>> import numpy as np >>> g = State("Rb", 87, 5, 0, 1/Integer(2)) >>...
[ "ur", "Calculate", "the", "matrix", "of", "decay", "between", "states", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/atomic_structure.py#L1489-L1709
oscarlazoarjona/fast
fast/atomic_structure.py
reduced_matrix_element
def reduced_matrix_element(fine_statei, fine_statej, convention=1): r"""Return the reduced matrix element of the position operator in Bohr\ radii. We have two available conventions for this 1.- [Racah]_ and [Edmonds74]_ .. math:: \langle \gamma_i, J_i, M_i| \hat{T}^k_q| \gamma_j, J_j, M_j...
python
def reduced_matrix_element(fine_statei, fine_statej, convention=1): r"""Return the reduced matrix element of the position operator in Bohr\ radii. We have two available conventions for this 1.- [Racah]_ and [Edmonds74]_ .. math:: \langle \gamma_i, J_i, M_i| \hat{T}^k_q| \gamma_j, J_j, M_j...
[ "def", "reduced_matrix_element", "(", "fine_statei", ",", "fine_statej", ",", "convention", "=", "1", ")", ":", "if", "fine_statei", "==", "fine_statej", ":", "return", "0.0", "t", "=", "Transition", "(", "fine_statei", ",", "fine_statej", ")", "einsteinAij", ...
r"""Return the reduced matrix element of the position operator in Bohr\ radii. We have two available conventions for this 1.- [Racah]_ and [Edmonds74]_ .. math:: \langle \gamma_i, J_i, M_i| \hat{T}^k_q| \gamma_j, J_j, M_j\rangle \ = (-1)^{J_i-M_i} \ \left(\begin{matrix}J_i & k...
[ "r", "Return", "the", "reduced", "matrix", "element", "of", "the", "position", "operator", "in", "Bohr", "\\", "radii", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/atomic_structure.py#L1712-L1810
oscarlazoarjona/fast
fast/atomic_structure.py
calculate_reduced_matrix_elements
def calculate_reduced_matrix_elements(fine_states, convention=1): r"""Calculate the reduced matrix elements for a list of fine states. This function calculates the reduced matrix elments .. math:: \langle N,L,J||T^1(r)||N',L',J'\rangle given a list of fine states. We calculate the reduce...
python
def calculate_reduced_matrix_elements(fine_states, convention=1): r"""Calculate the reduced matrix elements for a list of fine states. This function calculates the reduced matrix elments .. math:: \langle N,L,J||T^1(r)||N',L',J'\rangle given a list of fine states. We calculate the reduce...
[ "def", "calculate_reduced_matrix_elements", "(", "fine_states", ",", "convention", "=", "1", ")", ":", "reduced_matrix_elements", "=", "[", "[", "reduced_matrix_element", "(", "ei", ",", "ej", ",", "convention", "=", "convention", ")", "for", "ej", "in", "fine_s...
r"""Calculate the reduced matrix elements for a list of fine states. This function calculates the reduced matrix elments .. math:: \langle N,L,J||T^1(r)||N',L',J'\rangle given a list of fine states. We calculate the reduced matrix elements found in [SteckRb87]_ for the \ D1 and D2 lines ...
[ "r", "Calculate", "the", "reduced", "matrix", "elements", "for", "a", "list", "of", "fine", "states", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/atomic_structure.py#L1813-L1841
oscarlazoarjona/fast
fast/atomic_structure.py
matrix_element
def matrix_element(ji, fi, mi, jj, fj, mj, II, reduced_matrix_element, q=None, numeric=True, convention=1): r"""Calculate a matrix element of the electric dipole (in the helicity basis). We calculate the matrix element for the cyclical transition of the D2 line in ...
python
def matrix_element(ji, fi, mi, jj, fj, mj, II, reduced_matrix_element, q=None, numeric=True, convention=1): r"""Calculate a matrix element of the electric dipole (in the helicity basis). We calculate the matrix element for the cyclical transition of the D2 line in ...
[ "def", "matrix_element", "(", "ji", ",", "fi", ",", "mi", ",", "jj", ",", "fj", ",", "mj", ",", "II", ",", "reduced_matrix_element", ",", "q", "=", "None", ",", "numeric", "=", "True", ",", "convention", "=", "1", ")", ":", "if", "q", "is", "None...
r"""Calculate a matrix element of the electric dipole (in the helicity basis). We calculate the matrix element for the cyclical transition of the D2 line in Rb 87. >>> from sympy import symbols >>> red = symbols("r", positive=True) >>> half = 1/Integer(2) >>> II = 3*half >>> matrix_ele...
[ "r", "Calculate", "a", "matrix", "element", "of", "the", "electric", "dipole", "(", "in", "the", "helicity", "basis", ")", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/atomic_structure.py#L1844-L1891
oscarlazoarjona/fast
fast/atomic_structure.py
calculate_r_matrices
def calculate_r_matrices(fine_states, reduced_matrix_elements, q=None, numeric=True, convention=1): ur"""Calculate the matrix elements of the electric dipole (in the helicity basis). We calculate all matrix elements for the D2 line in Rb 87. >>> from sympy import symbols, ppri...
python
def calculate_r_matrices(fine_states, reduced_matrix_elements, q=None, numeric=True, convention=1): ur"""Calculate the matrix elements of the electric dipole (in the helicity basis). We calculate all matrix elements for the D2 line in Rb 87. >>> from sympy import symbols, ppri...
[ "def", "calculate_r_matrices", "(", "fine_states", ",", "reduced_matrix_elements", ",", "q", "=", "None", ",", "numeric", "=", "True", ",", "convention", "=", "1", ")", ":", "magnetic_states", "=", "make_list_of_states", "(", "fine_states", ",", "'magnetic'", ",...
ur"""Calculate the matrix elements of the electric dipole (in the helicity basis). We calculate all matrix elements for the D2 line in Rb 87. >>> from sympy import symbols, pprint >>> red = symbols("r", positive=True) >>> reduced_matrix_elements = [[0, -red], [red, 0]] >>> g = State("Rb", 87, ...
[ "ur", "Calculate", "the", "matrix", "elements", "of", "the", "electric", "dipole", "(", "in", "the", "helicity", "basis", ")", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/atomic_structure.py#L1894-L2127
oscarlazoarjona/fast
fast/atomic_structure.py
calculate_matrices
def calculate_matrices(states, Omega=1): r"""Calculate the matrices omega_ij, gamma_ij, r_pij. This function calculates the matrices omega_ij, gamma_ij and r_pij given a list of atomic states. The states can be arbitrarily in their fine, hyperfine or magnetic detail. """ # We check that all sta...
python
def calculate_matrices(states, Omega=1): r"""Calculate the matrices omega_ij, gamma_ij, r_pij. This function calculates the matrices omega_ij, gamma_ij and r_pij given a list of atomic states. The states can be arbitrarily in their fine, hyperfine or magnetic detail. """ # We check that all sta...
[ "def", "calculate_matrices", "(", "states", ",", "Omega", "=", "1", ")", ":", "# We check that all states belong to the same element and the same isotope.", "iso", "=", "states", "[", "0", "]", ".", "isotope", "element", "=", "states", "[", "0", "]", ".", "element...
r"""Calculate the matrices omega_ij, gamma_ij, r_pij. This function calculates the matrices omega_ij, gamma_ij and r_pij given a list of atomic states. The states can be arbitrarily in their fine, hyperfine or magnetic detail.
[ "r", "Calculate", "the", "matrices", "omega_ij", "gamma_ij", "r_pij", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/atomic_structure.py#L2130-L2173
oscarlazoarjona/fast
fast/atomic_structure.py
vapour_density
def vapour_density(Temperature, element, isotope=None): r"""This function returns the density in a rubidium or cesium vapour in kg/m^-3. It receives as input the temperature in Kelvins, the name of the element, and optionally the isotope. If no isotope is specified, the density of a vapour with the natu...
python
def vapour_density(Temperature, element, isotope=None): r"""This function returns the density in a rubidium or cesium vapour in kg/m^-3. It receives as input the temperature in Kelvins, the name of the element, and optionally the isotope. If no isotope is specified, the density of a vapour with the natu...
[ "def", "vapour_density", "(", "Temperature", ",", "element", ",", "isotope", "=", "None", ")", ":", "atom", "=", "Atom", "(", "element", ",", "isotope", ")", "if", "atom", ".", "isotope", "is", "None", ":", "rho", "=", "0.0", "for", "iso", "in", "ato...
r"""This function returns the density in a rubidium or cesium vapour in kg/m^-3. It receives as input the temperature in Kelvins, the name of the element, and optionally the isotope. If no isotope is specified, the density of a vapour with the natural abundances will be returned. This is calculated...
[ "r", "This", "function", "returns", "the", "density", "in", "a", "rubidium", "or", "cesium", "vapour", "in", "kg", "/", "m^", "-", "3", ".", "It", "receives", "as", "input", "the", "temperature", "in", "Kelvins", "the", "name", "of", "the", "element", ...
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/atomic_structure.py#L2514-L2543
oscarlazoarjona/fast
fast/atomic_structure.py
doppler_width
def doppler_width(transition, Temperature): r"""Return the Doppler width of a transition at a given temperature (in angular frequency). The usual Doppler FWHM of the rubidium D2 line (in MHz). >>> g = State("Rb", 87, 5, 0, 1/Integer(2), 2) >>> e = State("Rb", 87, 5, 1, 3/Integer(2)) >>> t = Tr...
python
def doppler_width(transition, Temperature): r"""Return the Doppler width of a transition at a given temperature (in angular frequency). The usual Doppler FWHM of the rubidium D2 line (in MHz). >>> g = State("Rb", 87, 5, 0, 1/Integer(2), 2) >>> e = State("Rb", 87, 5, 1, 3/Integer(2)) >>> t = Tr...
[ "def", "doppler_width", "(", "transition", ",", "Temperature", ")", ":", "atom", "=", "Atom", "(", "transition", ".", "e1", ".", "element", ",", "transition", ".", "e1", ".", "isotope", ")", "m", "=", "atom", ".", "mass", "omega", "=", "transition", "....
r"""Return the Doppler width of a transition at a given temperature (in angular frequency). The usual Doppler FWHM of the rubidium D2 line (in MHz). >>> g = State("Rb", 87, 5, 0, 1/Integer(2), 2) >>> e = State("Rb", 87, 5, 1, 3/Integer(2)) >>> t = Transition(e, g) >>> omega = doppler_width(t, ...
[ "r", "Return", "the", "Doppler", "width", "of", "a", "transition", "at", "a", "given", "temperature", "(", "in", "angular", "frequency", ")", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/atomic_structure.py#L2640-L2657
oscarlazoarjona/fast
fast/atomic_structure.py
thermal_state
def thermal_state(omega_level, T, return_diagonal=False): r"""Return a thermal state for a given set of levels. INPUT: - ``omega_level`` - The angular frequencies of each state. - ``T`` - The temperature of the ensemble (in Kelvin). - ``return_diagonal`` - Whether to return only the populations...
python
def thermal_state(omega_level, T, return_diagonal=False): r"""Return a thermal state for a given set of levels. INPUT: - ``omega_level`` - The angular frequencies of each state. - ``T`` - The temperature of the ensemble (in Kelvin). - ``return_diagonal`` - Whether to return only the populations...
[ "def", "thermal_state", "(", "omega_level", ",", "T", ",", "return_diagonal", "=", "False", ")", ":", "Ne", "=", "len", "(", "omega_level", ")", "E", "=", "np", ".", "array", "(", "[", "hbar", "*", "omega_level", "[", "i", "]", "for", "i", "in", "r...
r"""Return a thermal state for a given set of levels. INPUT: - ``omega_level`` - The angular frequencies of each state. - ``T`` - The temperature of the ensemble (in Kelvin). - ``return_diagonal`` - Whether to return only the populations. >>> ground = State("Rb", 85, 5, 0, 1/Integer(2)) >>...
[ "r", "Return", "a", "thermal", "state", "for", "a", "given", "set", "of", "levels", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/atomic_structure.py#L2660-L2685
oscarlazoarjona/fast
fast/atomic_structure.py
Atom.transitions
def transitions(self, omega_min=None, omega_max=None): r"""Find all allowed transitions. This function finds all allowed transitions (by electric-dipole selection rules) in the atom. >>> atom=Atom("Rb",85) >>> transitions=atom.transitions() >>> print(len(transitions)) ...
python
def transitions(self, omega_min=None, omega_max=None): r"""Find all allowed transitions. This function finds all allowed transitions (by electric-dipole selection rules) in the atom. >>> atom=Atom("Rb",85) >>> transitions=atom.transitions() >>> print(len(transitions)) ...
[ "def", "transitions", "(", "self", ",", "omega_min", "=", "None", ",", "omega_max", "=", "None", ")", ":", "states", "=", "self", ".", "states", "(", ")", "transitions", "=", "states", "transitions", "=", "[", "]", "for", "i", "in", "range", "(", "le...
r"""Find all allowed transitions. This function finds all allowed transitions (by electric-dipole selection rules) in the atom. >>> atom=Atom("Rb",85) >>> transitions=atom.transitions() >>> print(len(transitions)) 270 Arguments omega_min and omega_max can be us...
[ "r", "Find", "all", "allowed", "transitions", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/atomic_structure.py#L348-L395
oscarlazoarjona/fast
fast/inhomo.py
fast_doppler_terms
def fast_doppler_terms(v, detuning_knob, k, omega_level, xi, theta, unfolding, axes=["x", "y", "z"], matrix_form=False, file_name=None, return_code=False): r"""Return a fast function that returns the Doppler terms. >>> from sympy import Matri...
python
def fast_doppler_terms(v, detuning_knob, k, omega_level, xi, theta, unfolding, axes=["x", "y", "z"], matrix_form=False, file_name=None, return_code=False): r"""Return a fast function that returns the Doppler terms. >>> from sympy import Matri...
[ "def", "fast_doppler_terms", "(", "v", ",", "detuning_knob", ",", "k", ",", "omega_level", ",", "xi", ",", "theta", ",", "unfolding", ",", "axes", "=", "[", "\"x\"", ",", "\"y\"", ",", "\"z\"", "]", ",", "matrix_form", "=", "False", ",", "file_name", "...
r"""Return a fast function that returns the Doppler terms. >>> from sympy import Matrix, symbols >>> from scipy.constants import physical_constants >>> from fast import PlaneWave >>> from fast.bloch import phase_transformation >>> Ne = 2 >>> Nl = 1 >>> unfolding = Unfolding(Ne, True, True, ...
[ "r", "Return", "a", "fast", "function", "that", "returns", "the", "Doppler", "terms", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/inhomo.py#L241-L439
oscarlazoarjona/fast
fast/inhomo.py
fast_maxwell_boltzmann
def fast_maxwell_boltzmann(mass, file_name=None, return_code=False): r"""Return a function that returns values of a Maxwell-Boltzmann distribution. >>> from fast import Atom >>> mass = Atom("Rb", 87).mass >>> f = fast_maxwell_boltzmann(mass) >>> print f(0, 273.15+20) ...
python
def fast_maxwell_boltzmann(mass, file_name=None, return_code=False): r"""Return a function that returns values of a Maxwell-Boltzmann distribution. >>> from fast import Atom >>> mass = Atom("Rb", 87).mass >>> f = fast_maxwell_boltzmann(mass) >>> print f(0, 273.15+20) ...
[ "def", "fast_maxwell_boltzmann", "(", "mass", ",", "file_name", "=", "None", ",", "return_code", "=", "False", ")", ":", "# We get the mass of the atom.", "code", "=", "\"\"", "code", "=", "\"def maxwell_boltzmann(v, T):\\n\"", "code", "+=", "' r\"\"\"A fast calculat...
r"""Return a function that returns values of a Maxwell-Boltzmann distribution. >>> from fast import Atom >>> mass = Atom("Rb", 87).mass >>> f = fast_maxwell_boltzmann(mass) >>> print f(0, 273.15+20) 0.00238221482739 >>> import numpy as np >>> v = np.linspace(-600, 600, 101) >>> dis...
[ "r", "Return", "a", "function", "that", "returns", "values", "of", "a", "Maxwell", "-", "Boltzmann", "distribution", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/inhomo.py#L442-L496
oscarlazoarjona/fast
fast/inhomo.py
fast_inhomo_bloch_equations
def fast_inhomo_bloch_equations(Ep, epsilonp, detuning_knob, T, gamma, omega_level, rm, xi, theta, unfolding, inhomogeneity, matrix_form=False, file_name=None, return_code=False): r"""Return a fast function that returns ...
python
def fast_inhomo_bloch_equations(Ep, epsilonp, detuning_knob, T, gamma, omega_level, rm, xi, theta, unfolding, inhomogeneity, matrix_form=False, file_name=None, return_code=False): r"""Return a fast function that returns ...
[ "def", "fast_inhomo_bloch_equations", "(", "Ep", ",", "epsilonp", ",", "detuning_knob", ",", "T", ",", "gamma", ",", "omega_level", ",", "rm", ",", "xi", ",", "theta", ",", "unfolding", ",", "inhomogeneity", ",", "matrix_form", "=", "False", ",", "file_name"...
r"""Return a fast function that returns the numeric right-hand sides of \ inhomogeneous Bloch equations. We test a basic two-level system. >>> import numpy as np >>> from scipy.constants import physical_constants >>> from sympy import Matrix, symbols >>> from fast.electric_field import electri...
[ "r", "Return", "a", "fast", "function", "that", "returns", "the", "numeric", "right", "-", "hand", "sides", "of", "\\", "inhomogeneous", "Bloch", "equations", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/inhomo.py#L499-L709
oscarlazoarjona/fast
fast/inhomo.py
fast_inhomo_sweep_time_evolution
def fast_inhomo_sweep_time_evolution(Ep, epsilonp, gamma, omega_level, rm, xi, theta, inhomogeneity, semi_analytic=True, file_name=None, return_code=False): r"""Return ...
python
def fast_inhomo_sweep_time_evolution(Ep, epsilonp, gamma, omega_level, rm, xi, theta, inhomogeneity, semi_analytic=True, file_name=None, return_code=False): r"""Return ...
[ "def", "fast_inhomo_sweep_time_evolution", "(", "Ep", ",", "epsilonp", ",", "gamma", ",", "omega_level", ",", "rm", ",", "xi", ",", "theta", ",", "inhomogeneity", ",", "semi_analytic", "=", "True", ",", "file_name", "=", "None", ",", "return_code", "=", "Fal...
r"""Return a spectrum of time evolutions of the density matrix. We test a basic two-level system. >>> from fast.bloch import phase_transformation >>> from fast import PlaneWave, electric_field_amplitude_top, Atom >>> Ne = 2 >>> Nl = 1 >>> a0 = physical_constants["Bohr radius"][0] >>> rm = ...
[ "r", "Return", "a", "spectrum", "of", "time", "evolutions", "of", "the", "density", "matrix", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/inhomo.py#L985-L1129
oscarlazoarjona/fast
fast/inhomo.py
Inhomogeneity.average
def average(self, rho): r"""Return the average density matrix of an inhomogeneous ensemble.""" def marginal(f, rho): remaining = len(f.shape) if remaining == 0: return rho rho = sum([f[i]*rho[i] for i in range(rho.shape[0])]) f = np.sum(f, ...
python
def average(self, rho): r"""Return the average density matrix of an inhomogeneous ensemble.""" def marginal(f, rho): remaining = len(f.shape) if remaining == 0: return rho rho = sum([f[i]*rho[i] for i in range(rho.shape[0])]) f = np.sum(f, ...
[ "def", "average", "(", "self", ",", "rho", ")", ":", "def", "marginal", "(", "f", ",", "rho", ")", ":", "remaining", "=", "len", "(", "f", ".", "shape", ")", "if", "remaining", "==", "0", ":", "return", "rho", "rho", "=", "sum", "(", "[", "f", ...
r"""Return the average density matrix of an inhomogeneous ensemble.
[ "r", "Return", "the", "average", "density", "matrix", "of", "an", "inhomogeneous", "ensemble", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/inhomo.py#L104-L114
oscarlazoarjona/fast
fast/inhomo.py
DopplerBroadening.reset
def reset(self, T): r"""Recalculate the doppler broadening for a given temperature.""" self.__init__(self.shape, self.stds, T, self.mass, self.detuning_knob, self.k, self.omega_level, self.xi, self.theta, self.unfolding, self.axes, ...
python
def reset(self, T): r"""Recalculate the doppler broadening for a given temperature.""" self.__init__(self.shape, self.stds, T, self.mass, self.detuning_knob, self.k, self.omega_level, self.xi, self.theta, self.unfolding, self.axes, ...
[ "def", "reset", "(", "self", ",", "T", ")", ":", "self", ".", "__init__", "(", "self", ".", "shape", ",", "self", ".", "stds", ",", "T", ",", "self", ".", "mass", ",", "self", ".", "detuning_knob", ",", "self", ".", "k", ",", "self", ".", "omeg...
r"""Recalculate the doppler broadening for a given temperature.
[ "r", "Recalculate", "the", "doppler", "broadening", "for", "a", "given", "temperature", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/inhomo.py#L232-L238
tdsmith/ijroi
ijroi/ijroi.py
read_roi
def read_roi(fileobj): ''' points = read_roi(fileobj) Read ImageJ's ROI format. Points are returned in a nx2 array. Each row is in [row, column] -- that is, (y,x) -- order. ''' # This is based on: # http://rsbweb.nih.gov/ij/developer/source/ij/io/RoiDecoder.java.html # http://rsbweb.nih...
python
def read_roi(fileobj): ''' points = read_roi(fileobj) Read ImageJ's ROI format. Points are returned in a nx2 array. Each row is in [row, column] -- that is, (y,x) -- order. ''' # This is based on: # http://rsbweb.nih.gov/ij/developer/source/ij/io/RoiDecoder.java.html # http://rsbweb.nih...
[ "def", "read_roi", "(", "fileobj", ")", ":", "# This is based on:", "# http://rsbweb.nih.gov/ij/developer/source/ij/io/RoiDecoder.java.html", "# http://rsbweb.nih.gov/ij/developer/source/ij/io/RoiEncoder.java.html", "SPLINE_FIT", "=", "1", "DOUBLE_HEADED", "=", "2", "OUTLINE", "=", ...
points = read_roi(fileobj) Read ImageJ's ROI format. Points are returned in a nx2 array. Each row is in [row, column] -- that is, (y,x) -- order.
[ "points", "=", "read_roi", "(", "fileobj", ")" ]
train
https://github.com/tdsmith/ijroi/blob/611a220286788ff1447d79343da51cb2bb69a984/ijroi/ijroi.py#L11-L139
oscarlazoarjona/fast
fast/angular_momentum.py
perm_j
def perm_j(j1, j2): r"""Calculate the allowed total angular momenta. >>> from sympy import Integer >>> L = 1 >>> S = 1/Integer(2) >>> perm_j(L, S) [1/2, 3/2] """ jmin = abs(j1-j2) jmax = j1+j2 return [jmin + i for i in range(jmax-jmin+1)]
python
def perm_j(j1, j2): r"""Calculate the allowed total angular momenta. >>> from sympy import Integer >>> L = 1 >>> S = 1/Integer(2) >>> perm_j(L, S) [1/2, 3/2] """ jmin = abs(j1-j2) jmax = j1+j2 return [jmin + i for i in range(jmax-jmin+1)]
[ "def", "perm_j", "(", "j1", ",", "j2", ")", ":", "jmin", "=", "abs", "(", "j1", "-", "j2", ")", "jmax", "=", "j1", "+", "j2", "return", "[", "jmin", "+", "i", "for", "i", "in", "range", "(", "jmax", "-", "jmin", "+", "1", ")", "]" ]
r"""Calculate the allowed total angular momenta. >>> from sympy import Integer >>> L = 1 >>> S = 1/Integer(2) >>> perm_j(L, S) [1/2, 3/2]
[ "r", "Calculate", "the", "allowed", "total", "angular", "momenta", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/angular_momentum.py#L31-L43
oscarlazoarjona/fast
fast/angular_momentum.py
coupling_matrix_2j
def coupling_matrix_2j(j1, j2): ur"""For angular momenta $j_1, j_2$ the unitary transformation from the \ uncoupled basis into the $j = j_1 \oplus j_2$ coupled basis. >>> from sympy import Integer, pprint >>> L = 0 >>> S = 1/Integer(2) >>> pprint(coupling_matrix_2j(L, S)) ⎑1 0⎀ ⎒ βŽ₯ ...
python
def coupling_matrix_2j(j1, j2): ur"""For angular momenta $j_1, j_2$ the unitary transformation from the \ uncoupled basis into the $j = j_1 \oplus j_2$ coupled basis. >>> from sympy import Integer, pprint >>> L = 0 >>> S = 1/Integer(2) >>> pprint(coupling_matrix_2j(L, S)) ⎑1 0⎀ ⎒ βŽ₯ ...
[ "def", "coupling_matrix_2j", "(", "j1", ",", "j2", ")", ":", "# We calculate the quantum numbers for the uncoupled basis.", "M1", "=", "[", "-", "j1", "+", "i", "for", "i", "in", "range", "(", "2", "*", "j1", "+", "1", ")", "]", "M2", "=", "[", "-", "j...
ur"""For angular momenta $j_1, j_2$ the unitary transformation from the \ uncoupled basis into the $j = j_1 \oplus j_2$ coupled basis. >>> from sympy import Integer, pprint >>> L = 0 >>> S = 1/Integer(2) >>> pprint(coupling_matrix_2j(L, S)) ⎑1 0⎀ ⎒ βŽ₯ ⎣0 1⎦ >>> L = 1 >>> S ...
[ "ur", "For", "angular", "momenta", "$j_1", "j_2$", "the", "unitary", "transformation", "from", "the", "\\", "uncoupled", "basis", "into", "the", "$j", "=", "j_1", "\\", "oplus", "j_2$", "coupled", "basis", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/angular_momentum.py#L61-L113
oscarlazoarjona/fast
fast/angular_momentum.py
coupling_matrix_3j
def coupling_matrix_3j(j1, j2, j3): ur"""For angular momenta $j_1, j_2, j_3$ the unitary transformation from the \ uncoupled basis into the $j = (j_1 \oplus j_2)\oplus j_3$ coupled basis. >>> from sympy import Integer, pprint >>> L = 0 >>> S = 1/Integer(2) >>> II = 3/Integer(2) >>> pprint(c...
python
def coupling_matrix_3j(j1, j2, j3): ur"""For angular momenta $j_1, j_2, j_3$ the unitary transformation from the \ uncoupled basis into the $j = (j_1 \oplus j_2)\oplus j_3$ coupled basis. >>> from sympy import Integer, pprint >>> L = 0 >>> S = 1/Integer(2) >>> II = 3/Integer(2) >>> pprint(c...
[ "def", "coupling_matrix_3j", "(", "j1", ",", "j2", ",", "j3", ")", ":", "idj3", "=", "eye", "(", "2", "*", "j3", "+", "1", ")", "Jper", "=", "perm_j", "(", "j1", ",", "j2", ")", "U_Jj3_list", "=", "[", "coupling_matrix_2j", "(", "J", ",", "j3", ...
ur"""For angular momenta $j_1, j_2, j_3$ the unitary transformation from the \ uncoupled basis into the $j = (j_1 \oplus j_2)\oplus j_3$ coupled basis. >>> from sympy import Integer, pprint >>> L = 0 >>> S = 1/Integer(2) >>> II = 3/Integer(2) >>> pprint(coupling_matrix_3j(L, S, II)) ⎑ ...
[ "ur", "For", "angular", "momenta", "$j_1", "j_2", "j_3$", "the", "unitary", "transformation", "from", "the", "\\", "uncoupled", "basis", "into", "the", "$j", "=", "(", "j_1", "\\", "oplus", "j_2", ")", "\\", "oplus", "j_3$", "coupled", "basis", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/angular_momentum.py#L116-L166
oscarlazoarjona/fast
fast/angular_momentum.py
angular_momentum_matrix
def angular_momentum_matrix(J, ind="z"): ur"""Return the angular momentum operator matrix (divided by hbar) for a\ given J angular momentum. INPUT: - ``ind`` - A string ("x", "y", "z", "all") indicating which direction \ to calculate, or to return them all as :math:`(J_x, J_y, J_z)`. OUTPUT:...
python
def angular_momentum_matrix(J, ind="z"): ur"""Return the angular momentum operator matrix (divided by hbar) for a\ given J angular momentum. INPUT: - ``ind`` - A string ("x", "y", "z", "all") indicating which direction \ to calculate, or to return them all as :math:`(J_x, J_y, J_z)`. OUTPUT:...
[ "def", "angular_momentum_matrix", "(", "J", ",", "ind", "=", "\"z\"", ")", ":", "MJ", "=", "[", "-", "J", "+", "i", "for", "i", "in", "range", "(", "2", "*", "J", "+", "1", ")", "]", "if", "ind", "==", "\"x\"", ":", "JX", "=", "Matrix", "(", ...
ur"""Return the angular momentum operator matrix (divided by hbar) for a\ given J angular momentum. INPUT: - ``ind`` - A string ("x", "y", "z", "all") indicating which direction \ to calculate, or to return them all as :math:`(J_x, J_y, J_z)`. OUTPUT: - matrix forms of angular momentum oper...
[ "ur", "Return", "the", "angular", "momentum", "operator", "matrix", "(", "divided", "by", "hbar", ")", "for", "a", "\\", "given", "J", "angular", "momentum", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/angular_momentum.py#L169-L233
oscarlazoarjona/fast
fast/angular_momentum.py
orbital_spin_nuclear_matrices
def orbital_spin_nuclear_matrices(L, S, II, ind="z"): ur"""Return the matrix representation of the orbita, electron-spin, and \ nuclear-spin angular momentum operators \ :math:`\hat{\vec{L}}, \hat{\vec{L}}, \hat{\vec{L}}` in the coupled basis \ :math:`[|J, -J\rangle, \cdot, |J, J\rangle]`. INPUT: ...
python
def orbital_spin_nuclear_matrices(L, S, II, ind="z"): ur"""Return the matrix representation of the orbita, electron-spin, and \ nuclear-spin angular momentum operators \ :math:`\hat{\vec{L}}, \hat{\vec{L}}, \hat{\vec{L}}` in the coupled basis \ :math:`[|J, -J\rangle, \cdot, |J, J\rangle]`. INPUT: ...
[ "def", "orbital_spin_nuclear_matrices", "(", "L", ",", "S", ",", "II", ",", "ind", "=", "\"z\"", ")", ":", "if", "ind", "==", "\"all\"", ":", "LSIx", "=", "orbital_spin_nuclear_matrices", "(", "L", ",", "S", ",", "II", ",", "\"x\"", ")", "LSIy", "=", ...
ur"""Return the matrix representation of the orbita, electron-spin, and \ nuclear-spin angular momentum operators \ :math:`\hat{\vec{L}}, \hat{\vec{L}}, \hat{\vec{L}}` in the coupled basis \ :math:`[|J, -J\rangle, \cdot, |J, J\rangle]`. INPUT: - ``ind`` - A string ("x", "y", "z", "all") indicatin...
[ "ur", "Return", "the", "matrix", "representation", "of", "the", "orbita", "electron", "-", "spin", "and", "\\", "nuclear", "-", "spin", "angular", "momentum", "operators", "\\", ":", "math", ":", "\\", "hat", "{", "\\", "vec", "{", "L", "}}", "\\", "ha...
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/angular_momentum.py#L236-L362
oscarlazoarjona/fast
fast/angular_momentum.py
spherical_tensor
def spherical_tensor(Ji, Jj, K, Q): ur"""Return a matrix representation of the spherical tensor with quantum numbers $J_i, J_j, K, Q$. >>> from sympy import pprint >>> pprint(spherical_tensor(1, 1, 1, 0)) ⎑-√2 ⎀ βŽ’β”€β”€β”€β”€ 0 0 βŽ₯ ⎒ 2 βŽ₯ ⎒ βŽ₯ ⎒ 0 0 0 βŽ₯ ⎒ ...
python
def spherical_tensor(Ji, Jj, K, Q): ur"""Return a matrix representation of the spherical tensor with quantum numbers $J_i, J_j, K, Q$. >>> from sympy import pprint >>> pprint(spherical_tensor(1, 1, 1, 0)) ⎑-√2 ⎀ βŽ’β”€β”€β”€β”€ 0 0 βŽ₯ ⎒ 2 βŽ₯ ⎒ βŽ₯ ⎒ 0 0 0 βŽ₯ ⎒ ...
[ "def", "spherical_tensor", "(", "Ji", ",", "Jj", ",", "K", ",", "Q", ")", ":", "keti", "=", "{", "(", "Ji", ",", "Mi", ")", ":", "Matrix", "(", "[", "KroneckerDelta", "(", "i", ",", "j", ")", "for", "j", "in", "range", "(", "2", "*", "Ji", ...
ur"""Return a matrix representation of the spherical tensor with quantum numbers $J_i, J_j, K, Q$. >>> from sympy import pprint >>> pprint(spherical_tensor(1, 1, 1, 0)) ⎑-√2 ⎀ βŽ’β”€β”€β”€β”€ 0 0 βŽ₯ ⎒ 2 βŽ₯ ⎒ βŽ₯ ⎒ 0 0 0 βŽ₯ ⎒ βŽ₯ ⎒ √2βŽ₯ ⎒ 0 0...
[ "ur", "Return", "a", "matrix", "representation", "of", "the", "spherical", "tensor", "with", "quantum", "numbers", "$J_i", "J_j", "K", "Q$", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/angular_momentum.py#L365-L416
oscarlazoarjona/fast
fast/angular_momentum.py
wigner_d_small
def wigner_d_small(J, beta): u"""Return the small Wigner d matrix for angular momentum J. We use the general formula from [Edmonds74]_, equation 4.1.15. Some examples form [Edmonds74]_: >>> from sympy import Integer, symbols, pi >>> half = 1/Integer(2) >>> beta = symbols("beta", real=True) ...
python
def wigner_d_small(J, beta): u"""Return the small Wigner d matrix for angular momentum J. We use the general formula from [Edmonds74]_, equation 4.1.15. Some examples form [Edmonds74]_: >>> from sympy import Integer, symbols, pi >>> half = 1/Integer(2) >>> beta = symbols("beta", real=True) ...
[ "def", "wigner_d_small", "(", "J", ",", "beta", ")", ":", "def", "prod", "(", "x", ")", ":", "p", "=", "1", "for", "i", ",", "xi", "in", "enumerate", "(", "x", ")", ":", "p", "=", "p", "*", "xi", "return", "p", "M", "=", "[", "J", "-", "i...
u"""Return the small Wigner d matrix for angular momentum J. We use the general formula from [Edmonds74]_, equation 4.1.15. Some examples form [Edmonds74]_: >>> from sympy import Integer, symbols, pi >>> half = 1/Integer(2) >>> beta = symbols("beta", real=True) >>> wigner_d_small(half, beta) ...
[ "u", "Return", "the", "small", "Wigner", "d", "matrix", "for", "angular", "momentum", "J", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/angular_momentum.py#L419-L507
oscarlazoarjona/fast
fast/angular_momentum.py
wigner_d
def wigner_d(J, alpha, beta, gamma): u"""Return the Wigner D matrix for angular momentum J. We use the general formula from [Edmonds74]_, equation 4.1.12. The simplest possible example: >>> from sympy import Integer, symbols, pprint >>> half = 1/Integer(2) >>> alpha, beta, gamma = symbols("al...
python
def wigner_d(J, alpha, beta, gamma): u"""Return the Wigner D matrix for angular momentum J. We use the general formula from [Edmonds74]_, equation 4.1.12. The simplest possible example: >>> from sympy import Integer, symbols, pprint >>> half = 1/Integer(2) >>> alpha, beta, gamma = symbols("al...
[ "def", "wigner_d", "(", "J", ",", "alpha", ",", "beta", ",", "gamma", ")", ":", "d", "=", "wigner_d_small", "(", "J", ",", "beta", ")", "M", "=", "[", "J", "-", "i", "for", "i", "in", "range", "(", "2", "*", "J", "+", "1", ")", "]", "D", ...
u"""Return the Wigner D matrix for angular momentum J. We use the general formula from [Edmonds74]_, equation 4.1.12. The simplest possible example: >>> from sympy import Integer, symbols, pprint >>> half = 1/Integer(2) >>> alpha, beta, gamma = symbols("alpha, beta, gamma", real=True) >>> ppr...
[ "u", "Return", "the", "Wigner", "D", "matrix", "for", "angular", "momentum", "J", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/angular_momentum.py#L510-L538
oscarlazoarjona/fast
fast/angular_momentum.py
density_matrix_rotation
def density_matrix_rotation(J_values, alpha, beta, gamma): r"""Return a block-wise diagonal Wigner D matrix for that rotates a density matrix of an ensemble of particles in definite total angular momentum states given by J_values. >>> from sympy import Integer, pi >>> half = 1/Integer(2) >>> J_...
python
def density_matrix_rotation(J_values, alpha, beta, gamma): r"""Return a block-wise diagonal Wigner D matrix for that rotates a density matrix of an ensemble of particles in definite total angular momentum states given by J_values. >>> from sympy import Integer, pi >>> half = 1/Integer(2) >>> J_...
[ "def", "density_matrix_rotation", "(", "J_values", ",", "alpha", ",", "beta", ",", "gamma", ")", ":", "size", "=", "sum", "(", "[", "2", "*", "J", "+", "1", "for", "J", "in", "J_values", "]", ")", "D", "=", "zeros", "(", "size", ",", "size", ")",...
r"""Return a block-wise diagonal Wigner D matrix for that rotates a density matrix of an ensemble of particles in definite total angular momentum states given by J_values. >>> from sympy import Integer, pi >>> half = 1/Integer(2) >>> J_values = [2*half, 0] >>> density_matrix_rotation(J_values, ...
[ "r", "Return", "a", "block", "-", "wise", "diagonal", "Wigner", "D", "matrix", "for", "that", "rotates", "a", "density", "matrix", "of", "an", "ensemble", "of", "particles", "in", "definite", "total", "angular", "momentum", "states", "given", "by", "J_values...
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/angular_momentum.py#L541-L567
alexwlchan/specktre
src/specktre/tilings.py
generate_unit_squares
def generate_unit_squares(image_width, image_height): """Generate coordinates for a tiling of unit squares.""" # Iterate over the required rows and cells. The for loops (x, y) # give the coordinates of the top left-hand corner of each square: # # (x, y) +-----+ (x + 1, y) # | ...
python
def generate_unit_squares(image_width, image_height): """Generate coordinates for a tiling of unit squares.""" # Iterate over the required rows and cells. The for loops (x, y) # give the coordinates of the top left-hand corner of each square: # # (x, y) +-----+ (x + 1, y) # | ...
[ "def", "generate_unit_squares", "(", "image_width", ",", "image_height", ")", ":", "# Iterate over the required rows and cells. The for loops (x, y)", "# give the coordinates of the top left-hand corner of each square:", "#", "# (x, y) +-----+ (x + 1, y)", "# | |", "#...
Generate coordinates for a tiling of unit squares.
[ "Generate", "coordinates", "for", "a", "tiling", "of", "unit", "squares", "." ]
train
https://github.com/alexwlchan/specktre/blob/dcdd0d5486e5c3f612f64221b2e0dbc6fb7adafc/src/specktre/tilings.py#L23-L36
alexwlchan/specktre
src/specktre/tilings.py
generate_unit_triangles
def generate_unit_triangles(image_width, image_height): """Generate coordinates for a tiling of unit triangles.""" # Our triangles lie with one side parallel to the x-axis. Let s be # the length of one side, and h the height of the triangle. # # The for loops (x, y) gives the coordinates of the top...
python
def generate_unit_triangles(image_width, image_height): """Generate coordinates for a tiling of unit triangles.""" # Our triangles lie with one side parallel to the x-axis. Let s be # the length of one side, and h the height of the triangle. # # The for loops (x, y) gives the coordinates of the top...
[ "def", "generate_unit_triangles", "(", "image_width", ",", "image_height", ")", ":", "# Our triangles lie with one side parallel to the x-axis. Let s be", "# the length of one side, and h the height of the triangle.", "#", "# The for loops (x, y) gives the coordinates of the top left-hand cor...
Generate coordinates for a tiling of unit triangles.
[ "Generate", "coordinates", "for", "a", "tiling", "of", "unit", "triangles", "." ]
train
https://github.com/alexwlchan/specktre/blob/dcdd0d5486e5c3f612f64221b2e0dbc6fb7adafc/src/specktre/tilings.py#L44-L76
hammerlab/stancache
stancache/config.py
restore_default_settings
def restore_default_settings(): """ Restore settings to default values. """ global __DEFAULTS __DEFAULTS.CACHE_DIR = defaults.CACHE_DIR __DEFAULTS.SET_SEED = defaults.SET_SEED __DEFAULTS.SEED = defaults.SEED logging.info('Settings reverted to their default values.')
python
def restore_default_settings(): """ Restore settings to default values. """ global __DEFAULTS __DEFAULTS.CACHE_DIR = defaults.CACHE_DIR __DEFAULTS.SET_SEED = defaults.SET_SEED __DEFAULTS.SEED = defaults.SEED logging.info('Settings reverted to their default values.')
[ "def", "restore_default_settings", "(", ")", ":", "global", "__DEFAULTS", "__DEFAULTS", ".", "CACHE_DIR", "=", "defaults", ".", "CACHE_DIR", "__DEFAULTS", ".", "SET_SEED", "=", "defaults", ".", "SET_SEED", "__DEFAULTS", ".", "SEED", "=", "defaults", ".", "SEED",...
Restore settings to default values.
[ "Restore", "settings", "to", "default", "values", "." ]
train
https://github.com/hammerlab/stancache/blob/22f2548731d0960c14c0d41f4f64e418d3f22e4c/stancache/config.py#L19-L26
hammerlab/stancache
stancache/config.py
load_config
def load_config(config_file='~/.stancache.ini'): """ Load config file into default settings """ if not os.path.exists(config_file): logging.warning('Config file does not exist: {}. Using default settings.'.format(config_file)) return ## get user-level config in *.ini format config = ...
python
def load_config(config_file='~/.stancache.ini'): """ Load config file into default settings """ if not os.path.exists(config_file): logging.warning('Config file does not exist: {}. Using default settings.'.format(config_file)) return ## get user-level config in *.ini format config = ...
[ "def", "load_config", "(", "config_file", "=", "'~/.stancache.ini'", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "config_file", ")", ":", "logging", ".", "warning", "(", "'Config file does not exist: {}. Using default settings.'", ".", "format", ...
Load config file into default settings
[ "Load", "config", "file", "into", "default", "settings" ]
train
https://github.com/hammerlab/stancache/blob/22f2548731d0960c14c0d41f4f64e418d3f22e4c/stancache/config.py#L29-L42
deployed/django-emailtemplates
emailtemplates/shortcuts.py
send_email
def send_email(name, ctx_dict, send_to=None, subject=u'Subject', **kwargs): """ Shortcut function for EmailFromTemplate class @return: None """ eft = EmailFromTemplate(name=name) eft.subject = subject eft.context = ctx_dict eft.get_object() eft.render_message() eft.send_email(s...
python
def send_email(name, ctx_dict, send_to=None, subject=u'Subject', **kwargs): """ Shortcut function for EmailFromTemplate class @return: None """ eft = EmailFromTemplate(name=name) eft.subject = subject eft.context = ctx_dict eft.get_object() eft.render_message() eft.send_email(s...
[ "def", "send_email", "(", "name", ",", "ctx_dict", ",", "send_to", "=", "None", ",", "subject", "=", "u'Subject'", ",", "*", "*", "kwargs", ")", ":", "eft", "=", "EmailFromTemplate", "(", "name", "=", "name", ")", "eft", ".", "subject", "=", "subject",...
Shortcut function for EmailFromTemplate class @return: None
[ "Shortcut", "function", "for", "EmailFromTemplate", "class" ]
train
https://github.com/deployed/django-emailtemplates/blob/0e95139989dbcf7e624153ddcd7b5b66b48eb6eb/emailtemplates/shortcuts.py#L5-L17
abn/cafeteria
cafeteria/logging/__init__.py
LoggingManager.set_level
def set_level(cls, level): """ :raises: ValueError """ level = ( level if not is_str(level) else int(LOGGING_LEVELS.get(level.upper(), level)) ) for handler in root.handlers: handler.setLevel(level) root.setLevel(l...
python
def set_level(cls, level): """ :raises: ValueError """ level = ( level if not is_str(level) else int(LOGGING_LEVELS.get(level.upper(), level)) ) for handler in root.handlers: handler.setLevel(level) root.setLevel(l...
[ "def", "set_level", "(", "cls", ",", "level", ")", ":", "level", "=", "(", "level", "if", "not", "is_str", "(", "level", ")", "else", "int", "(", "LOGGING_LEVELS", ".", "get", "(", "level", ".", "upper", "(", ")", ",", "level", ")", ")", ")", "fo...
:raises: ValueError
[ ":", "raises", ":", "ValueError" ]
train
https://github.com/abn/cafeteria/blob/0a2efb0529484d6da08568f4364daff77f734dfd/cafeteria/logging/__init__.py#L17-L30
abn/cafeteria
cafeteria/logging/__init__.py
LoggingManager.load_config
def load_config(cls, configfile="logging.yaml"): """ :raises: ValueError """ configfile = getenv(cls.CONFIGFILE_ENV_KEY, configfile) if isfile(configfile): with open(configfile, "r") as cf: # noinspection PyBroadException try: ...
python
def load_config(cls, configfile="logging.yaml"): """ :raises: ValueError """ configfile = getenv(cls.CONFIGFILE_ENV_KEY, configfile) if isfile(configfile): with open(configfile, "r") as cf: # noinspection PyBroadException try: ...
[ "def", "load_config", "(", "cls", ",", "configfile", "=", "\"logging.yaml\"", ")", ":", "configfile", "=", "getenv", "(", "cls", ".", "CONFIGFILE_ENV_KEY", ",", "configfile", ")", "if", "isfile", "(", "configfile", ")", ":", "with", "open", "(", "configfile"...
:raises: ValueError
[ ":", "raises", ":", "ValueError" ]
train
https://github.com/abn/cafeteria/blob/0a2efb0529484d6da08568f4364daff77f734dfd/cafeteria/logging/__init__.py#L33-L48
daddyd/dewiki
dewiki/parser.py
Parser.__parse
def __parse(self, string=''): ''' Parse a string to remove and replace all wiki markup tags ''' self.string = string self.string = self.wiki_re.sub('', self.string) # search for lists self.listmatch = re.search('^(\*+)', self.string) if self.listmatch: ...
python
def __parse(self, string=''): ''' Parse a string to remove and replace all wiki markup tags ''' self.string = string self.string = self.wiki_re.sub('', self.string) # search for lists self.listmatch = re.search('^(\*+)', self.string) if self.listmatch: ...
[ "def", "__parse", "(", "self", ",", "string", "=", "''", ")", ":", "self", ".", "string", "=", "string", "self", ".", "string", "=", "self", ".", "wiki_re", ".", "sub", "(", "''", ",", "self", ".", "string", ")", "# search for lists", "self", ".", ...
Parse a string to remove and replace all wiki markup tags
[ "Parse", "a", "string", "to", "remove", "and", "replace", "all", "wiki", "markup", "tags" ]
train
https://github.com/daddyd/dewiki/blob/84214bb9537326e036fa65e70d7a9ce7c6659c26/dewiki/parser.py#L32-L43
daddyd/dewiki
dewiki/parser.py
Parser.parse_string
def parse_string(self, string=''): ''' Parse a string object to de-wikified text ''' self.strings = string.splitlines(1) self.strings = [self.__parse(line) for line in self.strings] return ''.join(self.strings)
python
def parse_string(self, string=''): ''' Parse a string object to de-wikified text ''' self.strings = string.splitlines(1) self.strings = [self.__parse(line) for line in self.strings] return ''.join(self.strings)
[ "def", "parse_string", "(", "self", ",", "string", "=", "''", ")", ":", "self", ".", "strings", "=", "string", ".", "splitlines", "(", "1", ")", "self", ".", "strings", "=", "[", "self", ".", "__parse", "(", "line", ")", "for", "line", "in", "self"...
Parse a string object to de-wikified text
[ "Parse", "a", "string", "object", "to", "de", "-", "wikified", "text" ]
train
https://github.com/daddyd/dewiki/blob/84214bb9537326e036fa65e70d7a9ce7c6659c26/dewiki/parser.py#L45-L51
oscarlazoarjona/fast
fast/evolution.py
run_evolution
def run_evolution(path,name,E0,laser_frequencies, N_iter,dt,N_states, spectrum_of_laser=None,N_delta=None,frequency_step=None,frequency_end=None, rho0=None,print_steps=False, integrate=False, save_systems=False,save_eigenvalues=False,rk4=False,use_netcdf=True): """This function runs the Runge-Kutta me...
python
def run_evolution(path,name,E0,laser_frequencies, N_iter,dt,N_states, spectrum_of_laser=None,N_delta=None,frequency_step=None,frequency_end=None, rho0=None,print_steps=False, integrate=False, save_systems=False,save_eigenvalues=False,rk4=False,use_netcdf=True): """This function runs the Runge-Kutta me...
[ "def", "run_evolution", "(", "path", ",", "name", ",", "E0", ",", "laser_frequencies", ",", "N_iter", ",", "dt", ",", "N_states", ",", "spectrum_of_laser", "=", "None", ",", "N_delta", "=", "None", ",", "frequency_step", "=", "None", ",", "frequency_end", ...
This function runs the Runge-Kutta method compiled in path+name...
[ "This", "function", "runs", "the", "Runge", "-", "Kutta", "method", "compiled", "in", "path", "+", "name", "..." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/evolution.py#L477-L558
oscarlazoarjona/fast
fast/evolution.py
characteristic_times
def characteristic_times(path,name,Omega=1): r'''This function can be called after calling ``run_diagonalization`` if the option ``save_eigenvalues`` is set to ``True``. It will return the oscillation periods, and the shortest and half lives. The results are lists ordered as: ``[detunings, oscillation_periods_1, osci...
python
def characteristic_times(path,name,Omega=1): r'''This function can be called after calling ``run_diagonalization`` if the option ``save_eigenvalues`` is set to ``True``. It will return the oscillation periods, and the shortest and half lives. The results are lists ordered as: ``[detunings, oscillation_periods_1, osci...
[ "def", "characteristic_times", "(", "path", ",", "name", ",", "Omega", "=", "1", ")", ":", "re", ",", "im", "=", "get_eigenvalues", "(", "path", ",", "name", ")", "log12", "=", "log", "(", "0.5", ")", "Nr", "=", "len", "(", "re", "[", "0", "]", ...
r'''This function can be called after calling ``run_diagonalization`` if the option ``save_eigenvalues`` is set to ``True``. It will return the oscillation periods, and the shortest and half lives. The results are lists ordered as: ``[detunings, oscillation_periods_1, oscillation_periods_N**2-1, half_lives_1, half_liv...
[ "r", "This", "function", "can", "be", "called", "after", "calling", "run_diagonalization", "if", "the", "option", "save_eigenvalues", "is", "set", "to", "True", ".", "It", "will", "return", "the", "oscillation", "periods", "and", "the", "shortest", "and", "hal...
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/evolution.py#L569-L595
oscarlazoarjona/fast
fast/evolution.py
analyze_eigenvalues
def analyze_eigenvalues(path,name,Ne): r'''This function can be called after calling ``run_diagonalization`` if the option ``save_eigenvalues`` is set to ``True``. It will return the shortest and longest oscillation period, and the shortest and longest half life. The results are lists ordered as: ``[detunings, shorte...
python
def analyze_eigenvalues(path,name,Ne): r'''This function can be called after calling ``run_diagonalization`` if the option ``save_eigenvalues`` is set to ``True``. It will return the shortest and longest oscillation period, and the shortest and longest half life. The results are lists ordered as: ``[detunings, shorte...
[ "def", "analyze_eigenvalues", "(", "path", ",", "name", ",", "Ne", ")", ":", "times", "=", "characteristic_times", "(", "path", ",", "name", ")", "min_osci", "=", "min", "(", "[", "min", "(", "times", "[", "1", "+", "i", "]", ")", "for", "i", "in",...
r'''This function can be called after calling ``run_diagonalization`` if the option ``save_eigenvalues`` is set to ``True``. It will return the shortest and longest oscillation period, and the shortest and longest half life. The results are lists ordered as: ``[detunings, shortest_oscillations, longest_oscillations, s...
[ "r", "This", "function", "can", "be", "called", "after", "calling", "run_diagonalization", "if", "the", "option", "save_eigenvalues", "is", "set", "to", "True", ".", "It", "will", "return", "the", "shortest", "and", "longest", "oscillation", "period", "and", "...
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/evolution.py#L597-L616
oscarlazoarjona/fast
build/lib/fast/electric_field.py
electric_field_amplitude_intensity
def electric_field_amplitude_intensity(s0,Omega=1.0e6): '''This function returns the value of E0 (the amplitude of the electric field) at a given saturation parameter s0=I/I0, where I0=2.50399 mW/cm^2 is the saturation intensity of the D2 line of Rubidium for linearly polarized light.''' e0=hbar*Omega/(e*a0) #T...
python
def electric_field_amplitude_intensity(s0,Omega=1.0e6): '''This function returns the value of E0 (the amplitude of the electric field) at a given saturation parameter s0=I/I0, where I0=2.50399 mW/cm^2 is the saturation intensity of the D2 line of Rubidium for linearly polarized light.''' e0=hbar*Omega/(e*a0) #T...
[ "def", "electric_field_amplitude_intensity", "(", "s0", ",", "Omega", "=", "1.0e6", ")", ":", "e0", "=", "hbar", "*", "Omega", "/", "(", "e", "*", "a0", ")", "#This is the electric field scale.\r", "I0", "=", "2.50399", "#mW/cm^2\r", "I0", "=", "1.668894511028...
This function returns the value of E0 (the amplitude of the electric field) at a given saturation parameter s0=I/I0, where I0=2.50399 mW/cm^2 is the saturation intensity of the D2 line of Rubidium for linearly polarized light.
[ "This", "function", "returns", "the", "value", "of", "E0", "(", "the", "amplitude", "of", "the", "electric", "field", ")", "at", "a", "given", "saturation", "parameter", "s0", "=", "I", "/", "I0", "where", "I0", "=", "2", ".", "50399", "mW", "/", "cm...
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/build/lib/fast/electric_field.py#L374-L393
tilde-lab/tilde
tilde/parsers/__init__.py
Output.get_checksum
def get_checksum(self): ''' Retrieve unique hash in a cross-platform manner: this is how calculation identity is determined ''' if self._checksum: return self._checksum if not self._filename: raise RuntimeError('Source calc file is required in ord...
python
def get_checksum(self): ''' Retrieve unique hash in a cross-platform manner: this is how calculation identity is determined ''' if self._checksum: return self._checksum if not self._filename: raise RuntimeError('Source calc file is required in ord...
[ "def", "get_checksum", "(", "self", ")", ":", "if", "self", ".", "_checksum", ":", "return", "self", ".", "_checksum", "if", "not", "self", ".", "_filename", ":", "raise", "RuntimeError", "(", "'Source calc file is required in order to properly save the data!'", ")"...
Retrieve unique hash in a cross-platform manner: this is how calculation identity is determined
[ "Retrieve", "unique", "hash", "in", "a", "cross", "-", "platform", "manner", ":", "this", "is", "how", "calculation", "identity", "is", "determined" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/parsers/__init__.py#L145-L179
tilde-lab/tilde
tilde/core/symmetry.py
SymmetryFinder.refine_cell
def refine_cell(self, tilde_obj): ''' NB only used for perovskite_tilting app ''' try: lattice, positions, numbers = spg.refine_cell(tilde_obj['structures'][-1], symprec=self.accuracy, angle_tolerance=self.angle_tolerance) except Exception as ex: self.error = 'Symmetr...
python
def refine_cell(self, tilde_obj): ''' NB only used for perovskite_tilting app ''' try: lattice, positions, numbers = spg.refine_cell(tilde_obj['structures'][-1], symprec=self.accuracy, angle_tolerance=self.angle_tolerance) except Exception as ex: self.error = 'Symmetr...
[ "def", "refine_cell", "(", "self", ",", "tilde_obj", ")", ":", "try", ":", "lattice", ",", "positions", ",", "numbers", "=", "spg", ".", "refine_cell", "(", "tilde_obj", "[", "'structures'", "]", "[", "-", "1", "]", ",", "symprec", "=", "self", ".", ...
NB only used for perovskite_tilting app
[ "NB", "only", "used", "for", "perovskite_tilting", "app" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/symmetry.py#L36-L46
myth/pepper8
pepper8/parser.py
Parser.parse
def parse(self): """ Reads all lines from the current data source and yields each FileResult objects """ if self.data is None: raise ValueError('No input data provided, unable to parse') for line in self.data: parts = line.strip().split() try...
python
def parse(self): """ Reads all lines from the current data source and yields each FileResult objects """ if self.data is None: raise ValueError('No input data provided, unable to parse') for line in self.data: parts = line.strip().split() try...
[ "def", "parse", "(", "self", ")", ":", "if", "self", ".", "data", "is", "None", ":", "raise", "ValueError", "(", "'No input data provided, unable to parse'", ")", "for", "line", "in", "self", ".", "data", ":", "parts", "=", "line", ".", "strip", "(", ")"...
Reads all lines from the current data source and yields each FileResult objects
[ "Reads", "all", "lines", "from", "the", "current", "data", "source", "and", "yields", "each", "FileResult", "objects" ]
train
https://github.com/myth/pepper8/blob/98ffed4089241d8d3c1048995bc6777a2f3abdda/pepper8/parser.py#L26-L57
rshipp/python-dshield
dshield.py
_get
def _get(function, return_format=None): """Get and return data from the API. :returns: A str, list, or dict, depending on the input values and API data. """ if return_format: return requests.get(''.join([__BASE_URL, function, return_format])).text return requests.get(''.join([__BASE_URL, fu...
python
def _get(function, return_format=None): """Get and return data from the API. :returns: A str, list, or dict, depending on the input values and API data. """ if return_format: return requests.get(''.join([__BASE_URL, function, return_format])).text return requests.get(''.join([__BASE_URL, fu...
[ "def", "_get", "(", "function", ",", "return_format", "=", "None", ")", ":", "if", "return_format", ":", "return", "requests", ".", "get", "(", "''", ".", "join", "(", "[", "__BASE_URL", ",", "function", ",", "return_format", "]", ")", ")", ".", "text"...
Get and return data from the API. :returns: A str, list, or dict, depending on the input values and API data.
[ "Get", "and", "return", "data", "from", "the", "API", "." ]
train
https://github.com/rshipp/python-dshield/blob/1b003d0dfac0bc2ee8b86ca5f1a44b765b8cc6e0/dshield.py#L20-L27
rshipp/python-dshield
dshield.py
backscatter
def backscatter(date=None, rows=None, return_format=None): """Returns possible backscatter data. This report only includes "syn ack" data and is summarized by source port. :param date: optional string (in Y-M-D format) or datetime.date() object :param rows: optional number of rows returned (default 10...
python
def backscatter(date=None, rows=None, return_format=None): """Returns possible backscatter data. This report only includes "syn ack" data and is summarized by source port. :param date: optional string (in Y-M-D format) or datetime.date() object :param rows: optional number of rows returned (default 10...
[ "def", "backscatter", "(", "date", "=", "None", ",", "rows", "=", "None", ",", "return_format", "=", "None", ")", ":", "uri", "=", "'backscatter'", "if", "date", ":", "try", ":", "uri", "=", "'/'", ".", "join", "(", "[", "uri", ",", "date", ".", ...
Returns possible backscatter data. This report only includes "syn ack" data and is summarized by source port. :param date: optional string (in Y-M-D format) or datetime.date() object :param rows: optional number of rows returned (default 1000) :returns: list -- backscatter data.
[ "Returns", "possible", "backscatter", "data", "." ]
train
https://github.com/rshipp/python-dshield/blob/1b003d0dfac0bc2ee8b86ca5f1a44b765b8cc6e0/dshield.py#L30-L47
rshipp/python-dshield
dshield.py
ip
def ip(ip_address, return_format=None): """Returns a summary of the information our database holds for a particular IP address (similar to /ipinfo.html). In the returned data: Count: (also reports or records) total number of packets blocked from this IP. Attacks: (also targets) number of uniqu...
python
def ip(ip_address, return_format=None): """Returns a summary of the information our database holds for a particular IP address (similar to /ipinfo.html). In the returned data: Count: (also reports or records) total number of packets blocked from this IP. Attacks: (also targets) number of uniqu...
[ "def", "ip", "(", "ip_address", ",", "return_format", "=", "None", ")", ":", "response", "=", "_get", "(", "'ip/{address}'", ".", "format", "(", "address", "=", "ip_address", ")", ",", "return_format", ")", "if", "'bad IP address'", "in", "str", "(", "resp...
Returns a summary of the information our database holds for a particular IP address (similar to /ipinfo.html). In the returned data: Count: (also reports or records) total number of packets blocked from this IP. Attacks: (also targets) number of unique destination IP addresses for these packet...
[ "Returns", "a", "summary", "of", "the", "information", "our", "database", "holds", "for", "a", "particular", "IP", "address", "(", "similar", "to", "/", "ipinfo", ".", "html", ")", "." ]
train
https://github.com/rshipp/python-dshield/blob/1b003d0dfac0bc2ee8b86ca5f1a44b765b8cc6e0/dshield.py#L57-L74
rshipp/python-dshield
dshield.py
port
def port(port_number, return_format=None): """Summary information about a particular port. In the returned data: Records: Total number of records for a given date. Targets: Number of unique destination IP addresses. Sources: Number of unique originating IPs. :param port_number: a string or in...
python
def port(port_number, return_format=None): """Summary information about a particular port. In the returned data: Records: Total number of records for a given date. Targets: Number of unique destination IP addresses. Sources: Number of unique originating IPs. :param port_number: a string or in...
[ "def", "port", "(", "port_number", ",", "return_format", "=", "None", ")", ":", "response", "=", "_get", "(", "'port/{number}'", ".", "format", "(", "number", "=", "port_number", ")", ",", "return_format", ")", "if", "'bad port number'", "in", "str", "(", ...
Summary information about a particular port. In the returned data: Records: Total number of records for a given date. Targets: Number of unique destination IP addresses. Sources: Number of unique originating IPs. :param port_number: a string or integer port number
[ "Summary", "information", "about", "a", "particular", "port", "." ]
train
https://github.com/rshipp/python-dshield/blob/1b003d0dfac0bc2ee8b86ca5f1a44b765b8cc6e0/dshield.py#L76-L91
rshipp/python-dshield
dshield.py
portdate
def portdate(port_number, date=None, return_format=None): """Information about a particular port at a particular date. If the date is ommited, today's date is used. :param port_number: a string or integer port number :param date: an optional string in 'Y-M-D' format or datetime.date() object """ ...
python
def portdate(port_number, date=None, return_format=None): """Information about a particular port at a particular date. If the date is ommited, today's date is used. :param port_number: a string or integer port number :param date: an optional string in 'Y-M-D' format or datetime.date() object """ ...
[ "def", "portdate", "(", "port_number", ",", "date", "=", "None", ",", "return_format", "=", "None", ")", ":", "uri", "=", "'portdate/{number}'", ".", "format", "(", "number", "=", "port_number", ")", "if", "date", ":", "try", ":", "uri", "=", "'/'", "....
Information about a particular port at a particular date. If the date is ommited, today's date is used. :param port_number: a string or integer port number :param date: an optional string in 'Y-M-D' format or datetime.date() object
[ "Information", "about", "a", "particular", "port", "at", "a", "particular", "date", "." ]
train
https://github.com/rshipp/python-dshield/blob/1b003d0dfac0bc2ee8b86ca5f1a44b765b8cc6e0/dshield.py#L93-L111
rshipp/python-dshield
dshield.py
topports
def topports(sort_by='records', limit=10, date=None, return_format=None): """Information about top ports for a particular date with return limit. :param sort_by: one of 'records', 'targets', 'sources' :param limit: number of records to be returned :param date: an optional string in 'Y-M-D' format or da...
python
def topports(sort_by='records', limit=10, date=None, return_format=None): """Information about top ports for a particular date with return limit. :param sort_by: one of 'records', 'targets', 'sources' :param limit: number of records to be returned :param date: an optional string in 'Y-M-D' format or da...
[ "def", "topports", "(", "sort_by", "=", "'records'", ",", "limit", "=", "10", ",", "date", "=", "None", ",", "return_format", "=", "None", ")", ":", "uri", "=", "'/'", ".", "join", "(", "[", "'topports'", ",", "sort_by", ",", "str", "(", "limit", "...
Information about top ports for a particular date with return limit. :param sort_by: one of 'records', 'targets', 'sources' :param limit: number of records to be returned :param date: an optional string in 'Y-M-D' format or datetime.date() object
[ "Information", "about", "top", "ports", "for", "a", "particular", "date", "with", "return", "limit", "." ]
train
https://github.com/rshipp/python-dshield/blob/1b003d0dfac0bc2ee8b86ca5f1a44b765b8cc6e0/dshield.py#L113-L126
rshipp/python-dshield
dshield.py
porthistory
def porthistory(port_number, start_date=None, end_date=None, return_format=None): """Returns port data for a range of dates. In the return data: Records: Total number of records for a given date range. Targets: Number of unique destination IP addresses. Sources: Number of unique originating IPs. ...
python
def porthistory(port_number, start_date=None, end_date=None, return_format=None): """Returns port data for a range of dates. In the return data: Records: Total number of records for a given date range. Targets: Number of unique destination IP addresses. Sources: Number of unique originating IPs. ...
[ "def", "porthistory", "(", "port_number", ",", "start_date", "=", "None", ",", "end_date", "=", "None", ",", "return_format", "=", "None", ")", ":", "uri", "=", "'porthistory/{port}'", ".", "format", "(", "port", "=", "port_number", ")", "if", "not", "star...
Returns port data for a range of dates. In the return data: Records: Total number of records for a given date range. Targets: Number of unique destination IP addresses. Sources: Number of unique originating IPs. :param port_number: a valid port number (required) :param start_date: string or d...
[ "Returns", "port", "data", "for", "a", "range", "of", "dates", "." ]
train
https://github.com/rshipp/python-dshield/blob/1b003d0dfac0bc2ee8b86ca5f1a44b765b8cc6e0/dshield.py#L159-L191
rshipp/python-dshield
dshield.py
asnum
def asnum(number, limit=None, return_format=None): """Returns a summary of the information our database holds for a particular ASNUM (similar to /asdetailsascii.html) with return limit. :param limit: number of records to be returned (max 2000) """ uri = 'asnum/{number}'.format(number=number) if...
python
def asnum(number, limit=None, return_format=None): """Returns a summary of the information our database holds for a particular ASNUM (similar to /asdetailsascii.html) with return limit. :param limit: number of records to be returned (max 2000) """ uri = 'asnum/{number}'.format(number=number) if...
[ "def", "asnum", "(", "number", ",", "limit", "=", "None", ",", "return_format", "=", "None", ")", ":", "uri", "=", "'asnum/{number}'", ".", "format", "(", "number", "=", "number", ")", "if", "limit", ":", "uri", "=", "'/'", ".", "join", "(", "[", "...
Returns a summary of the information our database holds for a particular ASNUM (similar to /asdetailsascii.html) with return limit. :param limit: number of records to be returned (max 2000)
[ "Returns", "a", "summary", "of", "the", "information", "our", "database", "holds", "for", "a", "particular", "ASNUM", "(", "similar", "to", "/", "asdetailsascii", ".", "html", ")", "with", "return", "limit", "." ]
train
https://github.com/rshipp/python-dshield/blob/1b003d0dfac0bc2ee8b86ca5f1a44b765b8cc6e0/dshield.py#L193-L202
rshipp/python-dshield
dshield.py
dailysummary
def dailysummary(start_date=None, end_date=None, return_format=None): """Returns daily summary totals of targets, attacks and sources. Limit to 30 days at a time. (Query 2002-01-01 to present) In the return data: Sources: Distinct source IP addresses the packets originate from. Targets: Distinct t...
python
def dailysummary(start_date=None, end_date=None, return_format=None): """Returns daily summary totals of targets, attacks and sources. Limit to 30 days at a time. (Query 2002-01-01 to present) In the return data: Sources: Distinct source IP addresses the packets originate from. Targets: Distinct t...
[ "def", "dailysummary", "(", "start_date", "=", "None", ",", "end_date", "=", "None", ",", "return_format", "=", "None", ")", ":", "uri", "=", "'dailysummary'", "if", "not", "start_date", ":", "# default today", "start_date", "=", "datetime", ".", "datetime", ...
Returns daily summary totals of targets, attacks and sources. Limit to 30 days at a time. (Query 2002-01-01 to present) In the return data: Sources: Distinct source IP addresses the packets originate from. Targets: Distinct target IP addresses the packets were sent to. Reports: Number of packets r...
[ "Returns", "daily", "summary", "totals", "of", "targets", "attacks", "and", "sources", ".", "Limit", "to", "30", "days", "at", "a", "time", ".", "(", "Query", "2002", "-", "01", "-", "01", "to", "present", ")" ]
train
https://github.com/rshipp/python-dshield/blob/1b003d0dfac0bc2ee8b86ca5f1a44b765b8cc6e0/dshield.py#L204-L232
rshipp/python-dshield
dshield.py
daily404summary
def daily404summary(date, return_format=None): """Returns daily summary information of submitted 404 Error Page Information. :param date: string or datetime.date() (required) """ uri = 'daily404summary' if date: try: uri = '/'.join([uri, date.strftime("%Y-%m-%d")]) e...
python
def daily404summary(date, return_format=None): """Returns daily summary information of submitted 404 Error Page Information. :param date: string or datetime.date() (required) """ uri = 'daily404summary' if date: try: uri = '/'.join([uri, date.strftime("%Y-%m-%d")]) e...
[ "def", "daily404summary", "(", "date", ",", "return_format", "=", "None", ")", ":", "uri", "=", "'daily404summary'", "if", "date", ":", "try", ":", "uri", "=", "'/'", ".", "join", "(", "[", "uri", ",", "date", ".", "strftime", "(", "\"%Y-%m-%d\"", ")",...
Returns daily summary information of submitted 404 Error Page Information. :param date: string or datetime.date() (required)
[ "Returns", "daily", "summary", "information", "of", "submitted", "404", "Error", "Page", "Information", "." ]
train
https://github.com/rshipp/python-dshield/blob/1b003d0dfac0bc2ee8b86ca5f1a44b765b8cc6e0/dshield.py#L234-L246
rshipp/python-dshield
dshield.py
daily404detail
def daily404detail(date, limit=None, return_format=None): """Returns detail information of submitted 404 Error Page Information. :param date: string or datetime.date() (required) :param limit: string or int, limit for number of returned items """ uri = 'daily404detail' if date: try: ...
python
def daily404detail(date, limit=None, return_format=None): """Returns detail information of submitted 404 Error Page Information. :param date: string or datetime.date() (required) :param limit: string or int, limit for number of returned items """ uri = 'daily404detail' if date: try: ...
[ "def", "daily404detail", "(", "date", ",", "limit", "=", "None", ",", "return_format", "=", "None", ")", ":", "uri", "=", "'daily404detail'", "if", "date", ":", "try", ":", "uri", "=", "'/'", ".", "join", "(", "[", "uri", ",", "date", ".", "strftime"...
Returns detail information of submitted 404 Error Page Information. :param date: string or datetime.date() (required) :param limit: string or int, limit for number of returned items
[ "Returns", "detail", "information", "of", "submitted", "404", "Error", "Page", "Information", "." ]
train
https://github.com/rshipp/python-dshield/blob/1b003d0dfac0bc2ee8b86ca5f1a44b765b8cc6e0/dshield.py#L248-L262
rshipp/python-dshield
dshield.py
glossary
def glossary(term=None, return_format=None): """List of glossary terms and definitions. :param term: a whole or parital word to "search" in the API """ uri = 'glossary' if term: uri = '/'.join([uri, term]) return _get(uri, return_format)
python
def glossary(term=None, return_format=None): """List of glossary terms and definitions. :param term: a whole or parital word to "search" in the API """ uri = 'glossary' if term: uri = '/'.join([uri, term]) return _get(uri, return_format)
[ "def", "glossary", "(", "term", "=", "None", ",", "return_format", "=", "None", ")", ":", "uri", "=", "'glossary'", "if", "term", ":", "uri", "=", "'/'", ".", "join", "(", "[", "uri", ",", "term", "]", ")", "return", "_get", "(", "uri", ",", "ret...
List of glossary terms and definitions. :param term: a whole or parital word to "search" in the API
[ "List", "of", "glossary", "terms", "and", "definitions", "." ]
train
https://github.com/rshipp/python-dshield/blob/1b003d0dfac0bc2ee8b86ca5f1a44b765b8cc6e0/dshield.py#L264-L272
rshipp/python-dshield
dshield.py
webhoneypotsummary
def webhoneypotsummary(date, return_format=None): """API data for `Webhoneypot: Web Server Log Project <https://dshield.org/webhoneypot/>`_. :param date: string or datetime.date() (required) """ uri = 'webhoneypotsummary' try: uri = '/'.join([uri, date.strftime("%Y-%m-%d")]) except ...
python
def webhoneypotsummary(date, return_format=None): """API data for `Webhoneypot: Web Server Log Project <https://dshield.org/webhoneypot/>`_. :param date: string or datetime.date() (required) """ uri = 'webhoneypotsummary' try: uri = '/'.join([uri, date.strftime("%Y-%m-%d")]) except ...
[ "def", "webhoneypotsummary", "(", "date", ",", "return_format", "=", "None", ")", ":", "uri", "=", "'webhoneypotsummary'", "try", ":", "uri", "=", "'/'", ".", "join", "(", "[", "uri", ",", "date", ".", "strftime", "(", "\"%Y-%m-%d\"", ")", "]", ")", "e...
API data for `Webhoneypot: Web Server Log Project <https://dshield.org/webhoneypot/>`_. :param date: string or datetime.date() (required)
[ "API", "data", "for", "Webhoneypot", ":", "Web", "Server", "Log", "Project", "<https", ":", "//", "dshield", ".", "org", "/", "webhoneypot", "/", ">", "_", "." ]
train
https://github.com/rshipp/python-dshield/blob/1b003d0dfac0bc2ee8b86ca5f1a44b765b8cc6e0/dshield.py#L274-L285
rshipp/python-dshield
dshield.py
webhoneypotbytype
def webhoneypotbytype(date, return_format=None): """API data for `Webhoneypot: Attack By Type <https://isc.sans.edu/webhoneypot/types.html>`_. We currently use a set of regular expressions to determine the type of attack used to attack the honeypot. Output is the top 30 attacks for the last month. ...
python
def webhoneypotbytype(date, return_format=None): """API data for `Webhoneypot: Attack By Type <https://isc.sans.edu/webhoneypot/types.html>`_. We currently use a set of regular expressions to determine the type of attack used to attack the honeypot. Output is the top 30 attacks for the last month. ...
[ "def", "webhoneypotbytype", "(", "date", ",", "return_format", "=", "None", ")", ":", "uri", "=", "'webhoneypotbytype'", "try", ":", "uri", "=", "'/'", ".", "join", "(", "[", "uri", ",", "date", ".", "strftime", "(", "\"%Y-%m-%d\"", ")", "]", ")", "exc...
API data for `Webhoneypot: Attack By Type <https://isc.sans.edu/webhoneypot/types.html>`_. We currently use a set of regular expressions to determine the type of attack used to attack the honeypot. Output is the top 30 attacks for the last month. :param date: string or datetime.date() (required)
[ "API", "data", "for", "Webhoneypot", ":", "Attack", "By", "Type", "<https", ":", "//", "isc", ".", "sans", ".", "edu", "/", "webhoneypot", "/", "types", ".", "html", ">", "_", ".", "We", "currently", "use", "a", "set", "of", "regular", "expressions", ...
train
https://github.com/rshipp/python-dshield/blob/1b003d0dfac0bc2ee8b86ca5f1a44b765b8cc6e0/dshield.py#L287-L300
albertyw/syspath
syspath/syspath.py
_append_path
def _append_path(new_path): # type: (str) -> None """ Given a path string, append it to sys.path """ for path in sys.path: path = os.path.abspath(path) if new_path == path: return sys.path.append(new_path)
python
def _append_path(new_path): # type: (str) -> None """ Given a path string, append it to sys.path """ for path in sys.path: path = os.path.abspath(path) if new_path == path: return sys.path.append(new_path)
[ "def", "_append_path", "(", "new_path", ")", ":", "# type: (str) -> None", "for", "path", "in", "sys", ".", "path", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "if", "new_path", "==", "path", ":", "return", "sys", ".", "path"...
Given a path string, append it to sys.path
[ "Given", "a", "path", "string", "append", "it", "to", "sys", ".", "path" ]
train
https://github.com/albertyw/syspath/blob/af219aecfecb1ef3130165121dcad6d2e1a269b7/syspath/syspath.py#L6-L12
albertyw/syspath
syspath/syspath.py
_caller_path
def _caller_path(index): # type: (int) -> str """ Get the caller's file path, by the index of the stack, does not work when the caller is stdin through a CLI python """ module = None stack = inspect.stack() while not module: if index >= len(stack): raise RuntimeError("Ca...
python
def _caller_path(index): # type: (int) -> str """ Get the caller's file path, by the index of the stack, does not work when the caller is stdin through a CLI python """ module = None stack = inspect.stack() while not module: if index >= len(stack): raise RuntimeError("Ca...
[ "def", "_caller_path", "(", "index", ")", ":", "# type: (int) -> str", "module", "=", "None", "stack", "=", "inspect", ".", "stack", "(", ")", "while", "not", "module", ":", "if", "index", ">=", "len", "(", "stack", ")", ":", "raise", "RuntimeError", "("...
Get the caller's file path, by the index of the stack, does not work when the caller is stdin through a CLI python
[ "Get", "the", "caller", "s", "file", "path", "by", "the", "index", "of", "the", "stack", "does", "not", "work", "when", "the", "caller", "is", "stdin", "through", "a", "CLI", "python" ]
train
https://github.com/albertyw/syspath/blob/af219aecfecb1ef3130165121dcad6d2e1a269b7/syspath/syspath.py#L15-L30
albertyw/syspath
syspath/syspath.py
get_current_path
def get_current_path(index=2): # type: (int) -> str """ Get the caller's path to sys.path If the caller is a CLI through stdin, the current working directory is used """ try: path = _caller_path(index) except RuntimeError: path = os.getcwd() return path
python
def get_current_path(index=2): # type: (int) -> str """ Get the caller's path to sys.path If the caller is a CLI through stdin, the current working directory is used """ try: path = _caller_path(index) except RuntimeError: path = os.getcwd() return path
[ "def", "get_current_path", "(", "index", "=", "2", ")", ":", "# type: (int) -> str", "try", ":", "path", "=", "_caller_path", "(", "index", ")", "except", "RuntimeError", ":", "path", "=", "os", ".", "getcwd", "(", ")", "return", "path" ]
Get the caller's path to sys.path If the caller is a CLI through stdin, the current working directory is used
[ "Get", "the", "caller", "s", "path", "to", "sys", ".", "path", "If", "the", "caller", "is", "a", "CLI", "through", "stdin", "the", "current", "working", "directory", "is", "used" ]
train
https://github.com/albertyw/syspath/blob/af219aecfecb1ef3130165121dcad6d2e1a269b7/syspath/syspath.py#L33-L42
albertyw/syspath
syspath/syspath.py
get_git_root
def get_git_root(index=3): # type: (int) -> str """ Get the path of the git root directory of the caller's file Raises a RuntimeError if a git repository cannot be found """ path = get_current_path(index=index) while True: git_path = os.path.join(path, '.git') if os.path.isdir(g...
python
def get_git_root(index=3): # type: (int) -> str """ Get the path of the git root directory of the caller's file Raises a RuntimeError if a git repository cannot be found """ path = get_current_path(index=index) while True: git_path = os.path.join(path, '.git') if os.path.isdir(g...
[ "def", "get_git_root", "(", "index", "=", "3", ")", ":", "# type: (int) -> str", "path", "=", "get_current_path", "(", "index", "=", "index", ")", "while", "True", ":", "git_path", "=", "os", ".", "path", ".", "join", "(", "path", ",", "'.git'", ")", "...
Get the path of the git root directory of the caller's file Raises a RuntimeError if a git repository cannot be found
[ "Get", "the", "path", "of", "the", "git", "root", "directory", "of", "the", "caller", "s", "file", "Raises", "a", "RuntimeError", "if", "a", "git", "repository", "cannot", "be", "found" ]
train
https://github.com/albertyw/syspath/blob/af219aecfecb1ef3130165121dcad6d2e1a269b7/syspath/syspath.py#L55-L67
albertyw/syspath
syspath/syspath.py
get_parent_path
def get_parent_path(index=2): # type: (int) -> str """ Get the caller's parent path to sys.path If the caller is a CLI through stdin, the parent of the current working directory is used """ try: path = _caller_path(index) except RuntimeError: path = os.getcwd() path = os...
python
def get_parent_path(index=2): # type: (int) -> str """ Get the caller's parent path to sys.path If the caller is a CLI through stdin, the parent of the current working directory is used """ try: path = _caller_path(index) except RuntimeError: path = os.getcwd() path = os...
[ "def", "get_parent_path", "(", "index", "=", "2", ")", ":", "# type: (int) -> str", "try", ":", "path", "=", "_caller_path", "(", "index", ")", "except", "RuntimeError", ":", "path", "=", "os", ".", "getcwd", "(", ")", "path", "=", "os", ".", "path", "...
Get the caller's parent path to sys.path If the caller is a CLI through stdin, the parent of the current working directory is used
[ "Get", "the", "caller", "s", "parent", "path", "to", "sys", ".", "path", "If", "the", "caller", "is", "a", "CLI", "through", "stdin", "the", "parent", "of", "the", "current", "working", "directory", "is", "used" ]
train
https://github.com/albertyw/syspath/blob/af219aecfecb1ef3130165121dcad6d2e1a269b7/syspath/syspath.py#L80-L91
oscarlazoarjona/fast
build/lib/fast/rk4.py
write_rk4
def write_rk4(path,name,laser,omega,gamma,r,Lij,states=None,verbose=1): r""" This function writes the Fortran code needed to calculate the time evolution of the density matrix elements `\rho_{ij}` using the Runge-Kutta method of order 4. INPUT: - ``path`` - A string with the working directory where a...
python
def write_rk4(path,name,laser,omega,gamma,r,Lij,states=None,verbose=1): r""" This function writes the Fortran code needed to calculate the time evolution of the density matrix elements `\rho_{ij}` using the Runge-Kutta method of order 4. INPUT: - ``path`` - A string with the working directory where a...
[ "def", "write_rk4", "(", "path", ",", "name", ",", "laser", ",", "omega", ",", "gamma", ",", "r", ",", "Lij", ",", "states", "=", "None", ",", "verbose", "=", "1", ")", ":", "global", "omega_rescaled", "t0", "=", "time", "(", ")", "Ne", "=", "len...
r""" This function writes the Fortran code needed to calculate the time evolution of the density matrix elements `\rho_{ij}` using the Runge-Kutta method of order 4. INPUT: - ``path`` - A string with the working directory where all files will be stored. It must end with ``/``. - ``name`` - A stri...
[ "r", "This", "function", "writes", "the", "Fortran", "code", "needed", "to", "calculate", "the", "time", "evolution", "of", "the", "density", "matrix", "elements", "\\", "rho_", "{", "ij", "}", "using", "the", "Runge", "-", "Kutta", "method", "of", "order"...
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/build/lib/fast/rk4.py#L56-L411
oscarlazoarjona/fast
build/lib/fast/rk4.py
run_rk4
def run_rk4(path,name,E0,laser_frequencies, N_iter,dt,N_states, spectrum_of_laser=None,N_delta=None,frequency_step=None,frequency_end=None, rho0=None,print_steps=False,integrate=False, save_systems=False): """This function runs the Runge-Kutta method compiled in path+name...""" t0=time() params =str(N_...
python
def run_rk4(path,name,E0,laser_frequencies, N_iter,dt,N_states, spectrum_of_laser=None,N_delta=None,frequency_step=None,frequency_end=None, rho0=None,print_steps=False,integrate=False, save_systems=False): """This function runs the Runge-Kutta method compiled in path+name...""" t0=time() params =str(N_...
[ "def", "run_rk4", "(", "path", ",", "name", ",", "E0", ",", "laser_frequencies", ",", "N_iter", ",", "dt", ",", "N_states", ",", "spectrum_of_laser", "=", "None", ",", "N_delta", "=", "None", ",", "frequency_step", "=", "None", ",", "frequency_end", "=", ...
This function runs the Runge-Kutta method compiled in path+name...
[ "This", "function", "runs", "the", "Runge", "-", "Kutta", "method", "compiled", "in", "path", "+", "name", "..." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/build/lib/fast/rk4.py#L413-L473
deployed/django-emailtemplates
emailtemplates/email.py
EmailFromTemplate.send_email
def send_email(self, send_to, attachment_paths=None, fail_silently=True, *args, **kwargs): """ Sends email to recipient based on self object parameters. @param fail_silently: When it’s False, msg.send() will raise an smtplib.SMTPException if an error occurs. @param send_to: recipient em...
python
def send_email(self, send_to, attachment_paths=None, fail_silently=True, *args, **kwargs): """ Sends email to recipient based on self object parameters. @param fail_silently: When it’s False, msg.send() will raise an smtplib.SMTPException if an error occurs. @param send_to: recipient em...
[ "def", "send_email", "(", "self", ",", "send_to", ",", "attachment_paths", "=", "None", ",", "fail_silently", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "msg", "=", "self", ".", "get_message_object", "(", "send_to", ",", "attachmen...
Sends email to recipient based on self object parameters. @param fail_silently: When it’s False, msg.send() will raise an smtplib.SMTPException if an error occurs. @param send_to: recipient email @param args: additional args passed to EmailMessage @param kwargs: kwargs passed to EmailMe...
[ "Sends", "email", "to", "recipient", "based", "on", "self", "object", "parameters", "." ]
train
https://github.com/deployed/django-emailtemplates/blob/0e95139989dbcf7e624153ddcd7b5b66b48eb6eb/emailtemplates/email.py#L127-L148
deployed/django-emailtemplates
emailtemplates/email.py
EmailFromTemplate.send
def send(self, to, attachment_paths=None, *args, **kwargs): """This function does all the operations on eft object, that are necessary to send email. Usually one would use eft object like this: eft = EmailFromTemplate(name='sth/sth.html') eft.get_object() ...
python
def send(self, to, attachment_paths=None, *args, **kwargs): """This function does all the operations on eft object, that are necessary to send email. Usually one would use eft object like this: eft = EmailFromTemplate(name='sth/sth.html') eft.get_object() ...
[ "def", "send", "(", "self", ",", "to", ",", "attachment_paths", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "get_object", "(", ")", "self", ".", "render_message", "(", ")", "self", ".", "send_email", "(", "to", ",...
This function does all the operations on eft object, that are necessary to send email. Usually one would use eft object like this: eft = EmailFromTemplate(name='sth/sth.html') eft.get_object() eft.render_message() eft.send_email(['email@example....
[ "This", "function", "does", "all", "the", "operations", "on", "eft", "object", "that", "are", "necessary", "to", "send", "email", ".", "Usually", "one", "would", "use", "eft", "object", "like", "this", ":", "eft", "=", "EmailFromTemplate", "(", "name", "="...
train
https://github.com/deployed/django-emailtemplates/blob/0e95139989dbcf7e624153ddcd7b5b66b48eb6eb/emailtemplates/email.py#L150-L164
commontk/ctk-cli
ctk_cli/module.py
_tag
def _tag(element): """Return element.tag with xmlns stripped away.""" tag = element.tag if tag[0] == "{": uri, tag = tag[1:].split("}") return tag
python
def _tag(element): """Return element.tag with xmlns stripped away.""" tag = element.tag if tag[0] == "{": uri, tag = tag[1:].split("}") return tag
[ "def", "_tag", "(", "element", ")", ":", "tag", "=", "element", ".", "tag", "if", "tag", "[", "0", "]", "==", "\"{\"", ":", "uri", ",", "tag", "=", "tag", "[", "1", ":", "]", ".", "split", "(", "\"}\"", ")", "return", "tag" ]
Return element.tag with xmlns stripped away.
[ "Return", "element", ".", "tag", "with", "xmlns", "stripped", "away", "." ]
train
https://github.com/commontk/ctk-cli/blob/ddd8de62b586491ad6e6750133cc1f0e11f37b11/ctk_cli/module.py#L23-L28
commontk/ctk-cli
ctk_cli/module.py
_uriPrefix
def _uriPrefix(element): """Return xmlns prefix of the given element.""" i = element.tag.find('}') if i < 0: return "" return element.tag[:i+1]
python
def _uriPrefix(element): """Return xmlns prefix of the given element.""" i = element.tag.find('}') if i < 0: return "" return element.tag[:i+1]
[ "def", "_uriPrefix", "(", "element", ")", ":", "i", "=", "element", ".", "tag", ".", "find", "(", "'}'", ")", "if", "i", "<", "0", ":", "return", "\"\"", "return", "element", ".", "tag", "[", ":", "i", "+", "1", "]" ]
Return xmlns prefix of the given element.
[ "Return", "xmlns", "prefix", "of", "the", "given", "element", "." ]
train
https://github.com/commontk/ctk-cli/blob/ddd8de62b586491ad6e6750133cc1f0e11f37b11/ctk_cli/module.py#L30-L35
commontk/ctk-cli
ctk_cli/module.py
_parseElements
def _parseElements(self, elementTree, expectedTag = None): """Read REQUIRED_ELEMENTS and OPTIONAL_ELEMENTS and returns the rest of the children. Every read child element's text value will be filled into an attribute of the same name, i.e. <description>Test</description> will lead to 'Test' being as...
python
def _parseElements(self, elementTree, expectedTag = None): """Read REQUIRED_ELEMENTS and OPTIONAL_ELEMENTS and returns the rest of the children. Every read child element's text value will be filled into an attribute of the same name, i.e. <description>Test</description> will lead to 'Test' being as...
[ "def", "_parseElements", "(", "self", ",", "elementTree", ",", "expectedTag", "=", "None", ")", ":", "xmlns", "=", "_uriPrefix", "(", "elementTree", ")", "if", "expectedTag", "is", "not", "None", ":", "assert", "_tag", "(", "elementTree", ")", "==", "expec...
Read REQUIRED_ELEMENTS and OPTIONAL_ELEMENTS and returns the rest of the children. Every read child element's text value will be filled into an attribute of the same name, i.e. <description>Test</description> will lead to 'Test' being assigned to self.description. Missing REQUIRED_ELEMENTS result ...
[ "Read", "REQUIRED_ELEMENTS", "and", "OPTIONAL_ELEMENTS", "and", "returns", "the", "rest", "of", "the", "children", ".", "Every", "read", "child", "element", "s", "text", "value", "will", "be", "filled", "into", "an", "attribute", "of", "the", "same", "name", ...
train
https://github.com/commontk/ctk-cli/blob/ddd8de62b586491ad6e6750133cc1f0e11f37b11/ctk_cli/module.py#L38-L67
commontk/ctk-cli
ctk_cli/module.py
CLIModule.classifyParameters
def classifyParameters(self): """Return (arguments, options, outputs) tuple. Together, the three lists contain all parameters (recursively fetched from all parameter groups), classified into optional parameters, required ones (with an index), and simple output parameters (that w...
python
def classifyParameters(self): """Return (arguments, options, outputs) tuple. Together, the three lists contain all parameters (recursively fetched from all parameter groups), classified into optional parameters, required ones (with an index), and simple output parameters (that w...
[ "def", "classifyParameters", "(", "self", ")", ":", "arguments", "=", "[", "]", "options", "=", "[", "]", "outputs", "=", "[", "]", "for", "parameter", "in", "self", ".", "parameters", "(", ")", ":", "if", "parameter", ".", "channel", "==", "'output'",...
Return (arguments, options, outputs) tuple. Together, the three lists contain all parameters (recursively fetched from all parameter groups), classified into optional parameters, required ones (with an index), and simple output parameters (that would get written to a file using ...
[ "Return", "(", "arguments", "options", "outputs", ")", "tuple", ".", "Together", "the", "three", "lists", "contain", "all", "parameters", "(", "recursively", "fetched", "from", "all", "parameter", "groups", ")", "classified", "into", "optional", "parameters", "r...
train
https://github.com/commontk/ctk-cli/blob/ddd8de62b586491ad6e6750133cc1f0e11f37b11/ctk_cli/module.py#L134-L159
commontk/ctk-cli
ctk_cli/module.py
CLIParameter.parseValue
def parseValue(self, value): """Parse the given value and return result.""" if self.isVector(): return list(map(self._pythonType, value.split(','))) if self.typ == 'boolean': return _parseBool(value) return self._pythonType(value)
python
def parseValue(self, value): """Parse the given value and return result.""" if self.isVector(): return list(map(self._pythonType, value.split(','))) if self.typ == 'boolean': return _parseBool(value) return self._pythonType(value)
[ "def", "parseValue", "(", "self", ",", "value", ")", ":", "if", "self", ".", "isVector", "(", ")", ":", "return", "list", "(", "map", "(", "self", ".", "_pythonType", ",", "value", ".", "split", "(", "','", ")", ")", ")", "if", "self", ".", "typ"...
Parse the given value and return result.
[ "Parse", "the", "given", "value", "and", "return", "result", "." ]
train
https://github.com/commontk/ctk-cli/blob/ddd8de62b586491ad6e6750133cc1f0e11f37b11/ctk_cli/module.py#L259-L265
commontk/ctk-cli
ctk_cli/module.py
CLIParameter.defaultExtension
def defaultExtension(self): """Return default extension for this parameter type, checked against supported fileExtensions. If the default extension is not within `fileExtensions`, return the first supported extension.""" result = self.EXTERNAL_TYPES[self.typ] if not self...
python
def defaultExtension(self): """Return default extension for this parameter type, checked against supported fileExtensions. If the default extension is not within `fileExtensions`, return the first supported extension.""" result = self.EXTERNAL_TYPES[self.typ] if not self...
[ "def", "defaultExtension", "(", "self", ")", ":", "result", "=", "self", ".", "EXTERNAL_TYPES", "[", "self", ".", "typ", "]", "if", "not", "self", ".", "fileExtensions", ":", "return", "result", "if", "result", "in", "self", ".", "fileExtensions", ":", "...
Return default extension for this parameter type, checked against supported fileExtensions. If the default extension is not within `fileExtensions`, return the first supported extension.
[ "Return", "default", "extension", "for", "this", "parameter", "type", "checked", "against", "supported", "fileExtensions", ".", "If", "the", "default", "extension", "is", "not", "within", "fileExtensions", "return", "the", "first", "supported", "extension", "." ]
train
https://github.com/commontk/ctk-cli/blob/ddd8de62b586491ad6e6750133cc1f0e11f37b11/ctk_cli/module.py#L291-L301
kpdyer/libfte
fte/encoder.py
DfaEncoderObject.encode
def encode(self, X, seed=None): """Given a string ``X``, returns ``unrank(X[:n]) || X[n:]`` where ``n`` is the the maximum number of bytes that can be unranked w.r.t. the capacity of the input ``dfa`` and ``unrank`` is w.r.t. to the input ``dfa``. """ if not X: ...
python
def encode(self, X, seed=None): """Given a string ``X``, returns ``unrank(X[:n]) || X[n:]`` where ``n`` is the the maximum number of bytes that can be unranked w.r.t. the capacity of the input ``dfa`` and ``unrank`` is w.r.t. to the input ``dfa``. """ if not X: ...
[ "def", "encode", "(", "self", ",", "X", ",", "seed", "=", "None", ")", ":", "if", "not", "X", ":", "return", "''", "if", "not", "isinstance", "(", "X", ",", "str", ")", ":", "raise", "InvalidInputException", "(", "'Input must be of type string.'", ")", ...
Given a string ``X``, returns ``unrank(X[:n]) || X[n:]`` where ``n`` is the the maximum number of bytes that can be unranked w.r.t. the capacity of the input ``dfa`` and ``unrank`` is w.r.t. to the input ``dfa``.
[ "Given", "a", "string", "X", "returns", "unrank", "(", "X", "[", ":", "n", "]", ")", "||", "X", "[", "n", ":", "]", "where", "n", "is", "the", "the", "maximum", "number", "of", "bytes", "that", "can", "be", "unranked", "w", ".", "r", ".", "t", ...
train
https://github.com/kpdyer/libfte/blob/74ed6ad197b6e72d1b9709c4dbc04041e05eb9b7/fte/encoder.py#L84-L133
kpdyer/libfte
fte/encoder.py
DfaEncoderObject.decode
def decode(self, covertext): """Given an input string ``unrank(X[:n]) || X[n:]`` returns ``X``. """ if not isinstance(covertext, str): raise InvalidInputException('Input must be of type string.') insufficient = (len(covertext) < self._fixed_slice) if insufficient: ...
python
def decode(self, covertext): """Given an input string ``unrank(X[:n]) || X[n:]`` returns ``X``. """ if not isinstance(covertext, str): raise InvalidInputException('Input must be of type string.') insufficient = (len(covertext) < self._fixed_slice) if insufficient: ...
[ "def", "decode", "(", "self", ",", "covertext", ")", ":", "if", "not", "isinstance", "(", "covertext", ",", "str", ")", ":", "raise", "InvalidInputException", "(", "'Input must be of type string.'", ")", "insufficient", "=", "(", "len", "(", "covertext", ")", ...
Given an input string ``unrank(X[:n]) || X[n:]`` returns ``X``.
[ "Given", "an", "input", "string", "unrank", "(", "X", "[", ":", "n", "]", ")", "||", "X", "[", "n", ":", "]", "returns", "X", "." ]
train
https://github.com/kpdyer/libfte/blob/74ed6ad197b6e72d1b9709c4dbc04041e05eb9b7/fte/encoder.py#L135-L166
oscarlazoarjona/fast
fast/symbolic.py
define_symbol
def define_symbol(name, open_brace, comma, i, j, close_brace, variables, **kwds): r"""Define a nice symbol with matrix indices. >>> name = "rho" >>> from sympy import symbols >>> t, x, y, z = symbols("t, x, y, z", positive=True) >>> variables = [t, x, y, z] >>> open_brace = ""...
python
def define_symbol(name, open_brace, comma, i, j, close_brace, variables, **kwds): r"""Define a nice symbol with matrix indices. >>> name = "rho" >>> from sympy import symbols >>> t, x, y, z = symbols("t, x, y, z", positive=True) >>> variables = [t, x, y, z] >>> open_brace = ""...
[ "def", "define_symbol", "(", "name", ",", "open_brace", ",", "comma", ",", "i", ",", "j", ",", "close_brace", ",", "variables", ",", "*", "*", "kwds", ")", ":", "if", "variables", "is", "None", ":", "return", "Symbol", "(", "name", "+", "open_brace", ...
r"""Define a nice symbol with matrix indices. >>> name = "rho" >>> from sympy import symbols >>> t, x, y, z = symbols("t, x, y, z", positive=True) >>> variables = [t, x, y, z] >>> open_brace = "" >>> comma = "" >>> close_brace = "" >>> i = 0 >>> j = 1 >>> f = define_symbol(name,...
[ "r", "Define", "a", "nice", "symbol", "with", "matrix", "indices", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L59-L83
oscarlazoarjona/fast
fast/symbolic.py
polarization_vector
def polarization_vector(phi, theta, alpha, beta, p, numeric=False, abstract=False): """This function returns a unitary vector describing the polarization of plane waves.: INPUT: - ``phi`` - The spherical coordinates azimuthal angle of the wave vector\ k. - ``theta`` - Th...
python
def polarization_vector(phi, theta, alpha, beta, p, numeric=False, abstract=False): """This function returns a unitary vector describing the polarization of plane waves.: INPUT: - ``phi`` - The spherical coordinates azimuthal angle of the wave vector\ k. - ``theta`` - Th...
[ "def", "polarization_vector", "(", "phi", ",", "theta", ",", "alpha", ",", "beta", ",", "p", ",", "numeric", "=", "False", ",", "abstract", "=", "False", ")", ":", "if", "abstract", ":", "Nl", "=", "symbols", "(", "\"N_l\"", ",", "integer", "=", "Tru...
This function returns a unitary vector describing the polarization of plane waves.: INPUT: - ``phi`` - The spherical coordinates azimuthal angle of the wave vector\ k. - ``theta`` - The spherical coordinates polar angle of the wave vector k. - ``alpha`` - The rotation of a half-wave plate. ...
[ "This", "function", "returns", "a", "unitary", "vector", "describing", "the", "polarization", "of", "plane", "waves", ".", ":" ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L208-L297
oscarlazoarjona/fast
fast/symbolic.py
cartesian_to_helicity
def cartesian_to_helicity(vector, numeric=False): r"""This function takes vectors from the cartesian basis to the helicity basis. For instance, we can check what are the vectors of the helicity basis. >>> from sympy import pi >>> em=polarization_vector(phi=0, theta= 0, alpha=0, beta=-pi/8,p= 1) >>>...
python
def cartesian_to_helicity(vector, numeric=False): r"""This function takes vectors from the cartesian basis to the helicity basis. For instance, we can check what are the vectors of the helicity basis. >>> from sympy import pi >>> em=polarization_vector(phi=0, theta= 0, alpha=0, beta=-pi/8,p= 1) >>>...
[ "def", "cartesian_to_helicity", "(", "vector", ",", "numeric", "=", "False", ")", ":", "if", "numeric", ":", "vector", "=", "list", "(", "vector", ")", "vector", "[", "0", "]", "=", "nparray", "(", "vector", "[", "0", "]", ")", "vector", "[", "1", ...
r"""This function takes vectors from the cartesian basis to the helicity basis. For instance, we can check what are the vectors of the helicity basis. >>> from sympy import pi >>> em=polarization_vector(phi=0, theta= 0, alpha=0, beta=-pi/8,p= 1) >>> em Matrix([ [ sqrt(2)/2], [-sqrt(2)*I/2...
[ "r", "This", "function", "takes", "vectors", "from", "the", "cartesian", "basis", "to", "the", "helicity", "basis", ".", "For", "instance", "we", "can", "check", "what", "are", "the", "vectors", "of", "the", "helicity", "basis", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L300-L400
oscarlazoarjona/fast
fast/symbolic.py
define_r_components
def define_r_components(Ne, xi=None, explicitly_hermitian=False, helicity=False, real=True, p=None): r"""Define the components of the position operators. In general, these are representations of the position operators x, y, z >>> define_r_components(2) [Matrix([ [ 0, x_...
python
def define_r_components(Ne, xi=None, explicitly_hermitian=False, helicity=False, real=True, p=None): r"""Define the components of the position operators. In general, these are representations of the position operators x, y, z >>> define_r_components(2) [Matrix([ [ 0, x_...
[ "def", "define_r_components", "(", "Ne", ",", "xi", "=", "None", ",", "explicitly_hermitian", "=", "False", ",", "helicity", "=", "False", ",", "real", "=", "True", ",", "p", "=", "None", ")", ":", "frequency_sign", "=", "p", "if", "Ne", ">", "9", ":...
r"""Define the components of the position operators. In general, these are representations of the position operators x, y, z >>> define_r_components(2) [Matrix([ [ 0, x_{12}], [x_{21}, 0]]), Matrix([ [ 0, y_{12}], [y_{21}, 0]]), Matrix([ [ 0, z_{12}], [z_{21},...
[ "r", "Define", "the", "components", "of", "the", "position", "operators", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L530-L687
oscarlazoarjona/fast
fast/symbolic.py
vector_element
def vector_element(r, i, j): r"""Extract an matrix element of a vector operator. >>> r = define_r_components(2) >>> vector_element(r, 1, 0) Matrix([ [x_{21}], [y_{21}], [z_{21}]]) """ return Matrix([r[p][i, j] for p in range(3)])
python
def vector_element(r, i, j): r"""Extract an matrix element of a vector operator. >>> r = define_r_components(2) >>> vector_element(r, 1, 0) Matrix([ [x_{21}], [y_{21}], [z_{21}]]) """ return Matrix([r[p][i, j] for p in range(3)])
[ "def", "vector_element", "(", "r", ",", "i", ",", "j", ")", ":", "return", "Matrix", "(", "[", "r", "[", "p", "]", "[", "i", ",", "j", "]", "for", "p", "in", "range", "(", "3", ")", "]", ")" ]
r"""Extract an matrix element of a vector operator. >>> r = define_r_components(2) >>> vector_element(r, 1, 0) Matrix([ [x_{21}], [y_{21}], [z_{21}]])
[ "r", "Extract", "an", "matrix", "element", "of", "a", "vector", "operator", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L690-L701
oscarlazoarjona/fast
fast/symbolic.py
define_frequencies
def define_frequencies(Ne, explicitly_antisymmetric=False): u"""Define all frequencies omega_level, omega, gamma. >>> from sympy import pprint >>> pprint(define_frequencies(2), use_unicode=True) βŽ› ⎑ 0 Ο‰β‚β‚‚βŽ€ ⎑ 0 Ξ³β‚β‚‚βŽ€βŽž ⎜[ω₁, Ο‰β‚‚], ⎒ βŽ₯, ⎒ βŽ₯⎟ ⎝ βŽ£Ο‰β‚‚β‚ 0 ⎦ βŽ£Ξ³β‚‚β‚ ...
python
def define_frequencies(Ne, explicitly_antisymmetric=False): u"""Define all frequencies omega_level, omega, gamma. >>> from sympy import pprint >>> pprint(define_frequencies(2), use_unicode=True) βŽ› ⎑ 0 Ο‰β‚β‚‚βŽ€ ⎑ 0 Ξ³β‚β‚‚βŽ€βŽž ⎜[ω₁, Ο‰β‚‚], ⎒ βŽ₯, ⎒ βŽ₯⎟ ⎝ βŽ£Ο‰β‚‚β‚ 0 ⎦ βŽ£Ξ³β‚‚β‚ ...
[ "def", "define_frequencies", "(", "Ne", ",", "explicitly_antisymmetric", "=", "False", ")", ":", "omega_level", "=", "[", "Symbol", "(", "'omega_'", "+", "str", "(", "i", "+", "1", ")", ",", "real", "=", "True", ")", "for", "i", "in", "range", "(", "...
u"""Define all frequencies omega_level, omega, gamma. >>> from sympy import pprint >>> pprint(define_frequencies(2), use_unicode=True) βŽ› ⎑ 0 Ο‰β‚β‚‚βŽ€ ⎑ 0 Ξ³β‚β‚‚βŽ€βŽž ⎜[ω₁, Ο‰β‚‚], ⎒ βŽ₯, ⎒ βŽ₯⎟ ⎝ βŽ£Ο‰β‚‚β‚ 0 ⎦ βŽ£Ξ³β‚‚β‚ 0 ⎦⎠ We can make these matrices explicitly antisymmetric. ...
[ "u", "Define", "all", "frequencies", "omega_level", "omega", "gamma", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L704-L772
oscarlazoarjona/fast
fast/symbolic.py
bra
def bra(i, Ne): r"""This function returns the transpose of the i-th element of the canonical basis of a Hilbert space of dimension Ne (in the form of a row vector). >>> bra(2,4) Matrix([[0, 1, 0, 0]]) This will return an error if i is not in [1 .. Ne]: >>> bra(5,3) Traceback (most rec...
python
def bra(i, Ne): r"""This function returns the transpose of the i-th element of the canonical basis of a Hilbert space of dimension Ne (in the form of a row vector). >>> bra(2,4) Matrix([[0, 1, 0, 0]]) This will return an error if i is not in [1 .. Ne]: >>> bra(5,3) Traceback (most rec...
[ "def", "bra", "(", "i", ",", "Ne", ")", ":", "if", "i", "not", "in", "range", "(", "1", ",", "Ne", "+", "1", ")", ":", "raise", "ValueError", "(", "\"i must be in [1 .. Ne].\"", ")", "return", "Matrix", "(", "[", "KroneckerDelta", "(", "i", "-", "1...
r"""This function returns the transpose of the i-th element of the canonical basis of a Hilbert space of dimension Ne (in the form of a row vector). >>> bra(2,4) Matrix([[0, 1, 0, 0]]) This will return an error if i is not in [1 .. Ne]: >>> bra(5,3) Traceback (most recent call last): ...
[ "r", "This", "function", "returns", "the", "transpose", "of", "the", "i", "-", "th", "element", "of", "the", "canonical", "basis", "of", "a", "Hilbert", "space", "of", "dimension", "Ne", "(", "in", "the", "form", "of", "a", "row", "vector", ")", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L801-L819
oscarlazoarjona/fast
fast/symbolic.py
ket
def ket(i, Ne): r"""This function returns the i-th element of the canonical basis of a Hilbert space of dimension Ne (in the form of a column vector). >>> ket(2,4) Matrix([ [0], [1], [0], [0]]) This will return an error if i is not in [1 .. Ne]: >>> ket(5,3) Traceback (mos...
python
def ket(i, Ne): r"""This function returns the i-th element of the canonical basis of a Hilbert space of dimension Ne (in the form of a column vector). >>> ket(2,4) Matrix([ [0], [1], [0], [0]]) This will return an error if i is not in [1 .. Ne]: >>> ket(5,3) Traceback (mos...
[ "def", "ket", "(", "i", ",", "Ne", ")", ":", "if", "i", "not", "in", "range", "(", "1", ",", "Ne", "+", "1", ")", ":", "raise", "ValueError", "(", "\"i must be in [1 .. Ne].\"", ")", "return", "Matrix", "(", "[", "KroneckerDelta", "(", "i", "-", "1...
r"""This function returns the i-th element of the canonical basis of a Hilbert space of dimension Ne (in the form of a column vector). >>> ket(2,4) Matrix([ [0], [1], [0], [0]]) This will return an error if i is not in [1 .. Ne]: >>> ket(5,3) Traceback (most recent call last):...
[ "r", "This", "function", "returns", "the", "i", "-", "th", "element", "of", "the", "canonical", "basis", "of", "a", "Hilbert", "space", "of", "dimension", "Ne", "(", "in", "the", "form", "of", "a", "column", "vector", ")", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L822-L843
oscarlazoarjona/fast
fast/symbolic.py
ketbra
def ketbra(i, j, Ne): """This function returns the outer product :math:`|i><j|` where\ :math:`|i>` and :math:`|j>` are elements of the canonical basis of an\ Ne-dimensional Hilbert space (in matrix form). >>> ketbra(2, 3, 3) Matrix([ [0, 0, 0], [0, 0, 1], [0, 0, 0]]) """ return ket(i...
python
def ketbra(i, j, Ne): """This function returns the outer product :math:`|i><j|` where\ :math:`|i>` and :math:`|j>` are elements of the canonical basis of an\ Ne-dimensional Hilbert space (in matrix form). >>> ketbra(2, 3, 3) Matrix([ [0, 0, 0], [0, 0, 1], [0, 0, 0]]) """ return ket(i...
[ "def", "ketbra", "(", "i", ",", "j", ",", "Ne", ")", ":", "return", "ket", "(", "i", ",", "Ne", ")", "*", "bra", "(", "j", ",", "Ne", ")" ]
This function returns the outer product :math:`|i><j|` where\ :math:`|i>` and :math:`|j>` are elements of the canonical basis of an\ Ne-dimensional Hilbert space (in matrix form). >>> ketbra(2, 3, 3) Matrix([ [0, 0, 0], [0, 0, 1], [0, 0, 0]])
[ "This", "function", "returns", "the", "outer", "product", ":", "math", ":", "|i", ">", "<j|", "where", "\\", ":", "math", ":", "|i", ">", "and", ":", "math", ":", "|j", ">", "are", "elements", "of", "the", "canonical", "basis", "of", "an", "\\", "N...
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L846-L858
oscarlazoarjona/fast
fast/symbolic.py
sigma_operator_indices
def sigma_operator_indices(A): r"""If A is an outer-product type operator |a><b| return a, b. >>> sig = ket(2, 3)*bra(1, 3) >>> sigma_operator_indices(sig) (1, 0) >>> sigma_operator_indices(sig+sig.adjoint()) (None, None) """ Ne = A.shape[0] band = True if sum(A) != 1: ...
python
def sigma_operator_indices(A): r"""If A is an outer-product type operator |a><b| return a, b. >>> sig = ket(2, 3)*bra(1, 3) >>> sigma_operator_indices(sig) (1, 0) >>> sigma_operator_indices(sig+sig.adjoint()) (None, None) """ Ne = A.shape[0] band = True if sum(A) != 1: ...
[ "def", "sigma_operator_indices", "(", "A", ")", ":", "Ne", "=", "A", ".", "shape", "[", "0", "]", "band", "=", "True", "if", "sum", "(", "A", ")", "!=", "1", ":", "band", "=", "False", "a", "=", "None", "b", "=", "None", "for", "i", "in", "ra...
r"""If A is an outer-product type operator |a><b| return a, b. >>> sig = ket(2, 3)*bra(1, 3) >>> sigma_operator_indices(sig) (1, 0) >>> sigma_operator_indices(sig+sig.adjoint()) (None, None)
[ "r", "If", "A", "is", "an", "outer", "-", "product", "type", "operator", "|a", ">", "<b|", "return", "a", "b", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L861-L886
oscarlazoarjona/fast
fast/symbolic.py
lindblad_operator
def lindblad_operator(A, rho): r"""This function returns the action of a Lindblad operator A on a density\ matrix rho. This is defined as : .. math:: \mathcal{L}(A, \rho) = A \rho A^\dagger - (A^\dagger A \rho + \rho A^\dagger A)/2. >>> rho=define_density_matrix(3) >>> lindblad_operat...
python
def lindblad_operator(A, rho): r"""This function returns the action of a Lindblad operator A on a density\ matrix rho. This is defined as : .. math:: \mathcal{L}(A, \rho) = A \rho A^\dagger - (A^\dagger A \rho + \rho A^\dagger A)/2. >>> rho=define_density_matrix(3) >>> lindblad_operat...
[ "def", "lindblad_operator", "(", "A", ",", "rho", ")", ":", "a", ",", "b", "=", "sigma_operator_indices", "(", "A", ")", "# print(111, a, b)", "if", "a", "is", "not", "None", "and", "b", "is", "not", "None", ":", "Ne", "=", "A", ".", "shape", "[", ...
r"""This function returns the action of a Lindblad operator A on a density\ matrix rho. This is defined as : .. math:: \mathcal{L}(A, \rho) = A \rho A^\dagger - (A^\dagger A \rho + \rho A^\dagger A)/2. >>> rho=define_density_matrix(3) >>> lindblad_operator( ketbra(1,2,3) ,rho ) Matrix...
[ "r", "This", "function", "returns", "the", "action", "of", "a", "Lindblad", "operator", "A", "on", "a", "density", "\\", "matrix", "rho", ".", "This", "is", "defined", "as", ":" ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L889-L920
oscarlazoarjona/fast
fast/symbolic.py
lindblad_terms
def lindblad_terms(gamma, rho, Ne, verbose=1): u"""Return the Lindblad terms for decays gamma in matrix form. >>> from sympy import pprint >>> aux = define_frequencies(4, explicitly_antisymmetric=True) >>> omega_level, omega, gamma = aux >>> gamma = gamma.subs({gamma[2, 0]:0, gamma[3, 0]:0, gamma[3...
python
def lindblad_terms(gamma, rho, Ne, verbose=1): u"""Return the Lindblad terms for decays gamma in matrix form. >>> from sympy import pprint >>> aux = define_frequencies(4, explicitly_antisymmetric=True) >>> omega_level, omega, gamma = aux >>> gamma = gamma.subs({gamma[2, 0]:0, gamma[3, 0]:0, gamma[3...
[ "def", "lindblad_terms", "(", "gamma", ",", "rho", ",", "Ne", ",", "verbose", "=", "1", ")", ":", "# We count the necessary Lindblad operators.", "Nterms", "=", "0", "for", "i", "in", "range", "(", "Ne", ")", ":", "for", "j", "in", "range", "(", "i", "...
u"""Return the Lindblad terms for decays gamma in matrix form. >>> from sympy import pprint >>> aux = define_frequencies(4, explicitly_antisymmetric=True) >>> omega_level, omega, gamma = aux >>> gamma = gamma.subs({gamma[2, 0]:0, gamma[3, 0]:0, gamma[3, 1]:0}) >>> pprint(gamma, use_unicode=True) ...
[ "u", "Return", "the", "Lindblad", "terms", "for", "decays", "gamma", "in", "matrix", "form", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L923-L983
oscarlazoarjona/fast
fast/symbolic.py
define_rho_vector
def define_rho_vector(rho, Ne): u"""Define the vectorized density matrix. >>> from sympy import pprint >>> rho = define_density_matrix(3) >>> pprint(define_rho_vector(rho, 3), use_unicode=True) ⎑ ρ₂₂ ⎀ ⎒ βŽ₯ ⎒ ρ₃₃ βŽ₯ ⎒ βŽ₯ ⎒re(ρ₂₁)βŽ₯ ⎒ βŽ₯ ⎒re(ρ₃₁)βŽ₯ ⎒ ...
python
def define_rho_vector(rho, Ne): u"""Define the vectorized density matrix. >>> from sympy import pprint >>> rho = define_density_matrix(3) >>> pprint(define_rho_vector(rho, 3), use_unicode=True) ⎑ ρ₂₂ ⎀ ⎒ βŽ₯ ⎒ ρ₃₃ βŽ₯ ⎒ βŽ₯ ⎒re(ρ₂₁)βŽ₯ ⎒ βŽ₯ ⎒re(ρ₃₁)βŽ₯ ⎒ ...
[ "def", "define_rho_vector", "(", "rho", ",", "Ne", ")", ":", "rho_vect", "=", "[", "]", "for", "mu", "in", "range", "(", "1", ",", "Ne", "**", "2", ")", ":", "i", ",", "j", ",", "s", "=", "IJ", "(", "mu", ",", "Ne", ")", "i", "=", "i", "-...
u"""Define the vectorized density matrix. >>> from sympy import pprint >>> rho = define_density_matrix(3) >>> pprint(define_rho_vector(rho, 3), use_unicode=True) ⎑ ρ₂₂ ⎀ ⎒ βŽ₯ ⎒ ρ₃₃ βŽ₯ ⎒ βŽ₯ ⎒re(ρ₂₁)βŽ₯ ⎒ βŽ₯ ⎒re(ρ₃₁)βŽ₯ ⎒ βŽ₯ ⎒re(ρ₃₂)βŽ₯ ⎒ βŽ₯ ⎒...
[ "u", "Define", "the", "vectorized", "density", "matrix", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L1021-L1049
oscarlazoarjona/fast
fast/symbolic.py
calculate_A_b
def calculate_A_b(eqs, unfolding, verbose=0): u"""Calculate the equations in matrix form. >>> from sympy import symbols, pprint, I >>> rho = define_density_matrix(2, explicitly_hermitian=True, ... normalized=True) >>> Omega = symbols("Omega") >>> delta = symbols("de...
python
def calculate_A_b(eqs, unfolding, verbose=0): u"""Calculate the equations in matrix form. >>> from sympy import symbols, pprint, I >>> rho = define_density_matrix(2, explicitly_hermitian=True, ... normalized=True) >>> Omega = symbols("Omega") >>> delta = symbols("de...
[ "def", "calculate_A_b", "(", "eqs", ",", "unfolding", ",", "verbose", "=", "0", ")", ":", "Ne", "=", "unfolding", ".", "Ne", "Nrho", "=", "unfolding", ".", "Nrho", "lower_triangular", "=", "unfolding", ".", "lower_triangular", "rho", "=", "define_density_mat...
u"""Calculate the equations in matrix form. >>> from sympy import symbols, pprint, I >>> rho = define_density_matrix(2, explicitly_hermitian=True, ... normalized=True) >>> Omega = symbols("Omega") >>> delta = symbols("delta", real=True) >>> hbar = symbols("hbar", po...
[ "u", "Calculate", "the", "equations", "in", "matrix", "form", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L1052-L1124
oscarlazoarjona/fast
fast/symbolic.py
phase_transformation
def phase_transformation(Ne, Nl, r, Lij, omega_laser, phase): r"""Obtain a phase transformation to eliminate explicit time dependence. >>> Ne = 2 """ ph = find_phase_transformation(Ne, Nl, r, Lij) return {phase[i]: sum([ph[i][j]*omega_laser[j] for j in range(Nl)]) for i in range(Ne)}
python
def phase_transformation(Ne, Nl, r, Lij, omega_laser, phase): r"""Obtain a phase transformation to eliminate explicit time dependence. >>> Ne = 2 """ ph = find_phase_transformation(Ne, Nl, r, Lij) return {phase[i]: sum([ph[i][j]*omega_laser[j] for j in range(Nl)]) for i in range(Ne)}
[ "def", "phase_transformation", "(", "Ne", ",", "Nl", ",", "r", ",", "Lij", ",", "omega_laser", ",", "phase", ")", ":", "ph", "=", "find_phase_transformation", "(", "Ne", ",", "Nl", ",", "r", ",", "Lij", ")", "return", "{", "phase", "[", "i", "]", "...
r"""Obtain a phase transformation to eliminate explicit time dependence. >>> Ne = 2
[ "r", "Obtain", "a", "phase", "transformation", "to", "eliminate", "explicit", "time", "dependence", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L1127-L1136
oscarlazoarjona/fast
fast/symbolic.py
hamiltonian
def hamiltonian(Ep, epsilonp, detuning_knob, rm, omega_level, omega_laser, xi, RWA=True, RF=True): r"""Return symbolic Hamiltonian. >>> from sympy import zeros, pi, pprint, symbols >>> Ne = 3 >>> Nl = 2 >>> Ep, omega_laser = define_laser_variables(Nl) >>> epsilonp = [polarizatio...
python
def hamiltonian(Ep, epsilonp, detuning_knob, rm, omega_level, omega_laser, xi, RWA=True, RF=True): r"""Return symbolic Hamiltonian. >>> from sympy import zeros, pi, pprint, symbols >>> Ne = 3 >>> Nl = 2 >>> Ep, omega_laser = define_laser_variables(Nl) >>> epsilonp = [polarizatio...
[ "def", "hamiltonian", "(", "Ep", ",", "epsilonp", ",", "detuning_knob", ",", "rm", ",", "omega_level", ",", "omega_laser", ",", "xi", ",", "RWA", "=", "True", ",", "RF", "=", "True", ")", ":", "# We check what RF is.", "if", "type", "(", "RF", ")", "==...
r"""Return symbolic Hamiltonian. >>> from sympy import zeros, pi, pprint, symbols >>> Ne = 3 >>> Nl = 2 >>> Ep, omega_laser = define_laser_variables(Nl) >>> epsilonp = [polarization_vector(0, -pi/2, 0, 0, 1) for l in range(Nl)] >>> detuning_knob = symbols("delta1 delta2", real=True) >>> xi...
[ "r", "Return", "symbolic", "Hamiltonian", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L1163-L1262
oscarlazoarjona/fast
fast/symbolic.py
dot
def dot(a, b): r"""Dot product of two 3d vectors.""" if isinstance(a, Mul): a = a.expand() avect = 1 aivect = -1 for ai, fact in enumerate(a.args): if isinstance(fact, Vector3D): avect = fact aivect = ai break a...
python
def dot(a, b): r"""Dot product of two 3d vectors.""" if isinstance(a, Mul): a = a.expand() avect = 1 aivect = -1 for ai, fact in enumerate(a.args): if isinstance(fact, Vector3D): avect = fact aivect = ai break a...
[ "def", "dot", "(", "a", ",", "b", ")", ":", "if", "isinstance", "(", "a", ",", "Mul", ")", ":", "a", "=", "a", ".", "expand", "(", ")", "avect", "=", "1", "aivect", "=", "-", "1", "for", "ai", ",", "fact", "in", "enumerate", "(", "a", ".", ...
r"""Dot product of two 3d vectors.
[ "r", "Dot", "product", "of", "two", "3d", "vectors", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L1390-L1428
oscarlazoarjona/fast
fast/symbolic.py
cross
def cross(a, b): r"""Cross product of two 3d vectors.""" if isinstance(a, Mul): a = a.expand() avect = 1 aivect = -1 for ai, fact in enumerate(a.args): if isinstance(fact, Vector3D): avect = fact aivect = ai break ...
python
def cross(a, b): r"""Cross product of two 3d vectors.""" if isinstance(a, Mul): a = a.expand() avect = 1 aivect = -1 for ai, fact in enumerate(a.args): if isinstance(fact, Vector3D): avect = fact aivect = ai break ...
[ "def", "cross", "(", "a", ",", "b", ")", ":", "if", "isinstance", "(", "a", ",", "Mul", ")", ":", "a", "=", "a", ".", "expand", "(", ")", "avect", "=", "1", "aivect", "=", "-", "1", "for", "ai", ",", "fact", "in", "enumerate", "(", "a", "."...
r"""Cross product of two 3d vectors.
[ "r", "Cross", "product", "of", "two", "3d", "vectors", "." ]
train
https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L1431-L1462
tilde-lab/tilde
tilde/core/settings.py
write_settings
def write_settings(settings): ''' Saves user's settings @returns True on success @returns False on failure ''' if not os.access(DATA_DIR, os.W_OK): return False try: f = open(DATA_DIR + os.sep + SETTINGS_FILE, 'w') f.writelines(json.dumps(settings, indent=0)) f.close(...
python
def write_settings(settings): ''' Saves user's settings @returns True on success @returns False on failure ''' if not os.access(DATA_DIR, os.W_OK): return False try: f = open(DATA_DIR + os.sep + SETTINGS_FILE, 'w') f.writelines(json.dumps(settings, indent=0)) f.close(...
[ "def", "write_settings", "(", "settings", ")", ":", "if", "not", "os", ".", "access", "(", "DATA_DIR", ",", "os", ".", "W_OK", ")", ":", "return", "False", "try", ":", "f", "=", "open", "(", "DATA_DIR", "+", "os", ".", "sep", "+", "SETTINGS_FILE", ...
Saves user's settings @returns True on success @returns False on failure
[ "Saves", "user", "s", "settings" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/settings.py#L109-L124
tilde-lab/tilde
tilde/core/settings.py
get_hierarchy
def get_hierarchy(settings): ''' Gets main mapping source according to what a data classification is made Gets the hierarchy groups (only for GUI) Gets the hierarchy values ''' hierarchy, hierarchy_groups, hierarchy_values = [], [], {} hgroup_ids, enumerated_vals = {}, set() session = co...
python
def get_hierarchy(settings): ''' Gets main mapping source according to what a data classification is made Gets the hierarchy groups (only for GUI) Gets the hierarchy values ''' hierarchy, hierarchy_groups, hierarchy_values = [], [], {} hgroup_ids, enumerated_vals = {}, set() session = co...
[ "def", "get_hierarchy", "(", "settings", ")", ":", "hierarchy", ",", "hierarchy_groups", ",", "hierarchy_values", "=", "[", "]", ",", "[", "]", ",", "{", "}", "hgroup_ids", ",", "enumerated_vals", "=", "{", "}", ",", "set", "(", ")", "session", "=", "c...
Gets main mapping source according to what a data classification is made Gets the hierarchy groups (only for GUI) Gets the hierarchy values
[ "Gets", "main", "mapping", "source", "according", "to", "what", "a", "data", "classification", "is", "made", "Gets", "the", "hierarchy", "groups", "(", "only", "for", "GUI", ")", "Gets", "the", "hierarchy", "values" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/core/settings.py#L126-L177
hammerlab/stancache
stancache/utils.py
is_field_unique_by_group
def is_field_unique_by_group(df, field_col, group_col): ''' Determine if field is constant by group in df ''' def num_unique(x): return len(pd.unique(x)) num_distinct = df.groupby(group_col)[field_col].agg(num_unique) return all(num_distinct == 1)
python
def is_field_unique_by_group(df, field_col, group_col): ''' Determine if field is constant by group in df ''' def num_unique(x): return len(pd.unique(x)) num_distinct = df.groupby(group_col)[field_col].agg(num_unique) return all(num_distinct == 1)
[ "def", "is_field_unique_by_group", "(", "df", ",", "field_col", ",", "group_col", ")", ":", "def", "num_unique", "(", "x", ")", ":", "return", "len", "(", "pd", ".", "unique", "(", "x", ")", ")", "num_distinct", "=", "df", ".", "groupby", "(", "group_c...
Determine if field is constant by group in df
[ "Determine", "if", "field", "is", "constant", "by", "group", "in", "df" ]
train
https://github.com/hammerlab/stancache/blob/22f2548731d0960c14c0d41f4f64e418d3f22e4c/stancache/utils.py#L36-L42
hammerlab/stancache
stancache/utils.py
_list_files_in_path
def _list_files_in_path(path, pattern="*.stan"): """ indexes a directory of stan files returns as dictionary containing contents of files """ results = [] for dirname, subdirs, files in os.walk(path): for name in files: if fnmatch(name, pattern): results.appe...
python
def _list_files_in_path(path, pattern="*.stan"): """ indexes a directory of stan files returns as dictionary containing contents of files """ results = [] for dirname, subdirs, files in os.walk(path): for name in files: if fnmatch(name, pattern): results.appe...
[ "def", "_list_files_in_path", "(", "path", ",", "pattern", "=", "\"*.stan\"", ")", ":", "results", "=", "[", "]", "for", "dirname", ",", "subdirs", ",", "files", "in", "os", ".", "walk", "(", "path", ")", ":", "for", "name", "in", "files", ":", "if",...
indexes a directory of stan files returns as dictionary containing contents of files
[ "indexes", "a", "directory", "of", "stan", "files", "returns", "as", "dictionary", "containing", "contents", "of", "files" ]
train
https://github.com/hammerlab/stancache/blob/22f2548731d0960c14c0d41f4f64e418d3f22e4c/stancache/utils.py#L45-L56
tilde-lab/tilde
tilde/classifiers/perovskites.py
generate_random_perovskite
def generate_random_perovskite(lat=None): ''' This generates a random valid perovskite structure in ASE format. Useful for testing. Binary and organic perovskites are not considered. ''' if not lat: lat = round(random.uniform(3.5, Perovskite_tilting.OCTAHEDRON_BOND_LENGTH_LIMIT*2), 3) ...
python
def generate_random_perovskite(lat=None): ''' This generates a random valid perovskite structure in ASE format. Useful for testing. Binary and organic perovskites are not considered. ''' if not lat: lat = round(random.uniform(3.5, Perovskite_tilting.OCTAHEDRON_BOND_LENGTH_LIMIT*2), 3) ...
[ "def", "generate_random_perovskite", "(", "lat", "=", "None", ")", ":", "if", "not", "lat", ":", "lat", "=", "round", "(", "random", ".", "uniform", "(", "3.5", ",", "Perovskite_tilting", ".", "OCTAHEDRON_BOND_LENGTH_LIMIT", "*", "2", ")", ",", "3", ")", ...
This generates a random valid perovskite structure in ASE format. Useful for testing. Binary and organic perovskites are not considered.
[ "This", "generates", "a", "random", "valid", "perovskite", "structure", "in", "ASE", "format", ".", "Useful", "for", "testing", ".", "Binary", "and", "organic", "perovskites", "are", "not", "considered", "." ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/classifiers/perovskites.py#L126-L151
alexwlchan/specktre
src/specktre/cli.py
check_positive_integer
def check_positive_integer(name, value): """Check a value is a positive integer. Returns the value if so, raises ValueError otherwise. """ try: value = int(value) is_positive = (value > 0) except ValueError: raise ValueError('%s should be an integer; got %r' % (name, value)...
python
def check_positive_integer(name, value): """Check a value is a positive integer. Returns the value if so, raises ValueError otherwise. """ try: value = int(value) is_positive = (value > 0) except ValueError: raise ValueError('%s should be an integer; got %r' % (name, value)...
[ "def", "check_positive_integer", "(", "name", ",", "value", ")", ":", "try", ":", "value", "=", "int", "(", "value", ")", "is_positive", "=", "(", "value", ">", "0", ")", "except", "ValueError", ":", "raise", "ValueError", "(", "'%s should be an integer; got...
Check a value is a positive integer. Returns the value if so, raises ValueError otherwise.
[ "Check", "a", "value", "is", "a", "positive", "integer", "." ]
train
https://github.com/alexwlchan/specktre/blob/dcdd0d5486e5c3f612f64221b2e0dbc6fb7adafc/src/specktre/cli.py#L40-L55
alexwlchan/specktre
src/specktre/cli.py
check_color_input
def check_color_input(value): """Check a value is a valid colour input. Returns a parsed `RGBColor` instance if so, raises ValueError otherwise. """ value = value.lower() # Trim a leading hash if value.startswith('#'): value = value[1:] if len(value) != 6: raise ValueE...
python
def check_color_input(value): """Check a value is a valid colour input. Returns a parsed `RGBColor` instance if so, raises ValueError otherwise. """ value = value.lower() # Trim a leading hash if value.startswith('#'): value = value[1:] if len(value) != 6: raise ValueE...
[ "def", "check_color_input", "(", "value", ")", ":", "value", "=", "value", ".", "lower", "(", ")", "# Trim a leading hash", "if", "value", ".", "startswith", "(", "'#'", ")", ":", "value", "=", "value", "[", "1", ":", "]", "if", "len", "(", "value", ...
Check a value is a valid colour input. Returns a parsed `RGBColor` instance if so, raises ValueError otherwise.
[ "Check", "a", "value", "is", "a", "valid", "colour", "input", "." ]
train
https://github.com/alexwlchan/specktre/blob/dcdd0d5486e5c3f612f64221b2e0dbc6fb7adafc/src/specktre/cli.py#L58-L82
tilde-lab/tilde
tilde/apps/perovskite_tilting/perovskite_tilting.py
Perovskite_tilting.get_octahedra
def get_octahedra(self, atoms, periodicity=3): ''' Extract octahedra as lists of sequence numbers of corner atoms ''' octahedra = [] for n, i in enumerate(atoms): found = [] if i.symbol in Perovskite_Structure.B: for m, j in enumerate(self....
python
def get_octahedra(self, atoms, periodicity=3): ''' Extract octahedra as lists of sequence numbers of corner atoms ''' octahedra = [] for n, i in enumerate(atoms): found = [] if i.symbol in Perovskite_Structure.B: for m, j in enumerate(self....
[ "def", "get_octahedra", "(", "self", ",", "atoms", ",", "periodicity", "=", "3", ")", ":", "octahedra", "=", "[", "]", "for", "n", ",", "i", "in", "enumerate", "(", "atoms", ")", ":", "found", "=", "[", "]", "if", "i", ".", "symbol", "in", "Perov...
Extract octahedra as lists of sequence numbers of corner atoms
[ "Extract", "octahedra", "as", "lists", "of", "sequence", "numbers", "of", "corner", "atoms" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/apps/perovskite_tilting/perovskite_tilting.py#L141-L157
tilde-lab/tilde
tilde/apps/perovskite_tilting/perovskite_tilting.py
Perovskite_tilting.get_tiltplane
def get_tiltplane(self, sequence): ''' Extract the main tilting plane basing on Z coordinate ''' sequence = sorted(sequence, key=lambda x: self.virtual_atoms[ x ].z) in_plane = [] for i in range(0, len(sequence)-4): if abs(self.virtual_atoms[ sequence[i] ].z -...
python
def get_tiltplane(self, sequence): ''' Extract the main tilting plane basing on Z coordinate ''' sequence = sorted(sequence, key=lambda x: self.virtual_atoms[ x ].z) in_plane = [] for i in range(0, len(sequence)-4): if abs(self.virtual_atoms[ sequence[i] ].z -...
[ "def", "get_tiltplane", "(", "self", ",", "sequence", ")", ":", "sequence", "=", "sorted", "(", "sequence", ",", "key", "=", "lambda", "x", ":", "self", ".", "virtual_atoms", "[", "x", "]", ".", "z", ")", "in_plane", "=", "[", "]", "for", "i", "in"...
Extract the main tilting plane basing on Z coordinate
[ "Extract", "the", "main", "tilting", "plane", "basing", "on", "Z", "coordinate" ]
train
https://github.com/tilde-lab/tilde/blob/59841578b3503075aa85c76f9ae647b3ff92b0a3/tilde/apps/perovskite_tilting/perovskite_tilting.py#L159-L170