text stringlengths 18 773k |
|---|
def formfield(self, **kwargs):
"""
:returns: A :class:`~osm_field.forms.OSMFormField` with a
:class:`~osm_field.widgets.OSMWidget`.
"""
widget_kwargs = {
'lat_field': self.latitude_field_name,
'lon_field': self.longitude_field_name,
}
... |
def latitude_field_name(self):
"""
The name of the related :class:`LatitudeField`.
"""
if self._lat_field_name is None:
self._lat_field_name = self.name + '_lat'
return self._lat_field_name |
def longitude_field_name(self):
"""
The name of the related :class:`LongitudeField`.
"""
if self._lon_field_name is None:
self._lon_field_name = self.name + '_lon'
return self._lon_field_name |
def update_dependency_kinds(apps, schema_editor):
"""Update historical dependency kinds as they may be wrong."""
DataDependency = apps.get_model('flow', 'DataDependency')
for dependency in DataDependency.objects.all():
# Assume dependency is of subprocess kind.
dependency.kind = 'subprocess'... |
def escape(self, value):
"""Escape given value."""
value = soft_unicode(value)
if self._engine._escape is None: # pylint: disable=protected-access
return value
return self._engine._escape(value) |
def _wrap_jinja_filter(self, function):
"""Propagate exceptions as undefined values filter."""
def wrapper(*args, **kwargs):
"""Filter wrapper."""
try:
return function(*args, **kwargs)
except Exception: # pylint: disable=broad-except
r... |
def _register_custom_filters(self):
"""Register any custom filter modules."""
custom_filters = self.settings.get('CUSTOM_FILTERS', [])
if not isinstance(custom_filters, list):
raise KeyError("`CUSTOM_FILTERS` setting must be a list.")
for filter_module_name in custom_filters... |
def _evaluation_context(self, escape, safe_wrapper):
"""Configure the evaluation context."""
self._escape = escape
self._safe_wrapper = safe_wrapper
try:
yield
finally:
self._escape = None
self._safe_wrapper = None |
def evaluate_block(self, template, context=None, escape=None, safe_wrapper=None):
"""Evaluate a template block."""
if context is None:
context = {}
try:
with self._evaluation_context(escape, safe_wrapper):
template = self._environment.from_string(template... |
def evaluate_inline(self, expression, context=None, escape=None, safe_wrapper=None):
"""Evaluate an inline expression."""
if context is None:
context = {}
try:
with self._evaluation_context(escape, safe_wrapper):
compiled = self._environment.compile_expre... |
def update_module_file(redbaron_tree, module_path, show_diff=False, dry_run=False):
"""Set show_diff to False to overwrite module_path with a new file generated from
``redbaron_tree``.
Returns True if tree is different from source.
"""
with tempfile.NamedTemporaryFile() as tmp_file:
tmp_fi... |
def find_repo_root_by_path(path):
"""Given a path to an item in a git repository, find the root of the repository."""
repo = git.Repo(path, search_parent_directories=True)
repo_path = repo.git.rev_parse('--show-toplevel')
logging.info('Repository: {}'.format(repo_path))
return repo_path |
def _format_value(self, operation, key, indent):
"""A value that exists in the operation but has value None is displayed.
A value that does not exist in the operation is left out entirely. The value
name in the operation must match the value name in the template, but the
location does n... |
def add_cors_headers(response, request):
"""Add Cross-Origin Resource Sharing (CORS) headers to response.
- ``method_list`` is a list of HTTP methods that are allowed for the endpoint that
was called. It should not include "OPTIONS", which is included automatically
since it's allowed for all endpoi... |
def run_process(self, slug, inputs):
"""Run a new process from a running process."""
def export_files(value):
"""Export input files of spawned process."""
if isinstance(value, str) and os.path.isfile(value):
# TODO: Use the protocol to export files and get the
... |
def info(self, *args):
"""Log informational message."""
report = resolwe_runtime_utils.info(' '.join([str(x) for x in args]))
# TODO: Use the protocol to report progress.
print(report) |
def get_data_id_by_slug(self, slug):
"""Find data object ID for given slug.
This method queries the Resolwe API and requires network access.
"""
resolwe_host = os.environ.get('RESOLWE_HOST_URL')
url = urllib.parse.urljoin(resolwe_host, '/api/data?slug={}&fields=id'.format(slug))... |
def requirements(self):
"""Process requirements."""
class dotdict(dict): # pylint: disable=invalid-name
"""Dot notation access to dictionary attributes."""
def __getattr__(self, attr):
value = self.get(attr)
return dotdict(value) if isinstance(va... |
def start(self, inputs):
"""Start the process.
:param inputs: An instance of `Inputs` describing the process inputs
:return: An instance of `Outputs` describing the process outputs
"""
self.logger.info("Process is starting")
outputs = Outputs(self._meta.outputs)
... |
def discover_process(self, path):
"""Perform process discovery in given path.
This method will be called during process registration and
should return a list of dictionaries with discovered process
schemas.
"""
if not path.lower().endswith('.py'):
return []
... |
def evaluate(self, data):
"""Evaluate the code needed to compute a given Data object."""
return 'PYTHONPATH="{runtime}" python3 -u -m resolwe.process {program} --slug {slug} --inputs {inputs}'.format(
runtime=PYTHON_RUNTIME_VOLUME,
program=PYTHON_PROGRAM_VOLUME,
slug=... |
def prepare_runtime(self, runtime_dir, data):
"""Prepare runtime directory."""
# Copy over Python process runtime (resolwe.process).
import resolwe.process as runtime_package
src_dir = os.path.dirname(inspect.getsourcefile(runtime_package))
dest_package_dir = os.path.join(runtim... |
def get_subject_with_local_validation(jwt_bu64, cert_obj):
"""Validate the JWT and return the subject it contains.
- The JWT is validated by checking that it was signed with a CN certificate.
- The returned subject can be trusted for authz and authn operations.
- Possible validation errors include:
... |
def get_subject_with_remote_validation(jwt_bu64, base_url):
"""Same as get_subject_with_local_validation() except that the signing certificate
is automatically downloaded from the CN.
- Additional possible validations errors:
- The certificate could not be retrieved from the root CN.
"""
ce... |
def get_subject_with_file_validation(jwt_bu64, cert_path):
"""Same as get_subject_with_local_validation() except that the signing certificate
is read from a local PEM file."""
cert_obj = d1_common.cert.x509.deserialize_pem_file(cert_path)
return get_subject_with_local_validation(jwt_bu64, cert_obj) |
def get_subject_without_validation(jwt_bu64):
"""Extract subject from the JWT without validating the JWT.
- The extracted subject cannot be trusted for authn or authz.
Args:
jwt_bu64: bytes
JWT, encoded using a a URL safe flavor of Base64.
Returns:
str: The subject contained in th... |
def get_jwt_dict(jwt_bu64):
"""Parse Base64 encoded JWT and return as a dict.
- JWTs contain a set of values serialized to a JSON dict. This decodes the JWT and
returns it as a dict containing Unicode strings.
- In addition, a SHA1 hash is added to the dict for convenience.
Args:
jwt_bu64:... |
def validate_and_decode(jwt_bu64, cert_obj):
"""Validate the JWT and return as a dict.
- JWTs contain a set of values serialized to a JSON dict. This decodes the JWT and
returns it as a dict.
Args:
jwt_bu64: bytes
The JWT encoded using a a URL safe flavor of Base64.
cert_obj: cr... |
def log_jwt_dict_info(log, msg_str, jwt_dict):
"""Dump JWT to log.
Args:
log: Logger
Logger to which to write the message.
msg_str: str
A message to write to the log before the JWT values.
jwt_dict: dict
JWT containing values to log.
Returns:
None
"""... |
def ts_to_str(jwt_dict):
"""Convert timestamps in JWT to human readable dates.
Args:
jwt_dict: dict
JWT with some keys containing timestamps.
Returns:
dict: Copy of input dict where timestamps have been replaced with human readable
dates.
"""
d = ts_to_dt(jwt_dict)
f... |
def ts_to_dt(jwt_dict):
"""Convert timestamps in JWT to datetime objects.
Args:
jwt_dict: dict
JWT with some keys containing timestamps.
Returns:
dict: Copy of input dict where timestamps have been replaced with
datetime.datetime() objects.
"""
d = jwt_dict.copy()
fo... |
def encode_bu64(b):
"""Encode bytes to a URL safe flavor of Base64 used by JWTs.
- Reverse of decode_bu64().
Args:
b: bytes
Bytes to Base64 encode.
Returns:
bytes: URL safe Base64 encoded version of input.
"""
s = base64.standard_b64encode(b)
s = s.rstrip('=')
s =... |
def decode_bu64(b):
"""Encode bytes to a URL safe flavor of Base64 used by JWTs.
- Reverse of encode_bu64().
Args:
b: bytes
URL safe Base64 encoded bytes to encode.
Returns:
bytes: Decoded bytes.
"""
s = b
s = s.replace(b'-', b'+')
s = s.replace(b'_', b'/')
p ... |
def evaluate(self, data):
"""Evaluate the code needed to compute a given Data object."""
try:
inputs = copy.deepcopy(data.input)
hydrate_input_references(inputs, data.process.input_schema)
hydrate_input_uploads(inputs, data.process.input_schema)
# Include... |
def _escape(self, value):
"""Escape given value unless it is safe."""
if isinstance(value, SafeString):
return value
return shellescape.quote(value) |
def open_sciobj_file_by_pid_ctx(pid, write=False):
"""Open the file containing the Science Object bytes of ``pid`` in the default
location within the tree of the local SciObj store.
If ``write`` is True, the file is opened for writing and any missing directories are
created. Return the file handle and ... |
def open_sciobj_file_by_path_ctx(abs_path, write=False):
"""Open the file containing the Science Object bytes at the custom location
``abs_path`` in the local filesystem.
If ``write`` is True, the file is opened for writing and any missing directores are
created. Return the file handle and file_url wit... |
def open_sciobj_file_by_pid(pid, write=False):
"""Open the file containing the Science Object bytes at the custom location
``abs_path`` in the local filesystem for read."""
abs_path = get_abs_sciobj_file_path_by_pid(pid)
if write:
d1_common.utils.filesystem.create_missing_directories_for_file(ab... |
def open_sciobj_file_by_path(abs_path, write=False):
"""Open a SciObj file for read or write. If opened for write, create any missing
directories. For a SciObj stored in the default SciObj store, the path includes the
PID hash based directory levels.
This is the only method in GMN that opens SciObj fil... |
def get_rel_sciobj_file_path(pid):
"""Get the relative local path to the file holding an object's bytes.
- The path is relative to settings.OBJECT_STORE_PATH
- There is a one-to-one mapping between pid and path
- The path is based on a SHA1 hash. It's now possible to craft SHA1 collisions, but
it... |
def get_abs_sciobj_file_path_by_url(file_url):
"""Get the absolute path to the file holding an object's bytes.
- ``file_url`` is an absolute or relative file:// url as stored in the DB.
"""
assert_sciobj_store_exists()
m = re.match(r'file://(.*?)/(.*)', file_url, re.IGNORECASE)
if m.group(1) =... |
def get_gmn_version(base_url):
"""Return the version currently running on a GMN instance.
(is_gmn, version_or_error)
"""
home_url = d1_common.url.joinPathElements(base_url, 'home')
try:
response = requests.get(home_url, verify=False)
except requests.exceptions.ConnectionError as e:
... |
def extract_subjects(subject_info_xml, primary_str):
"""Extract a set of authenticated subjects from a DataONE SubjectInfo.
- See subject_info_tree for details.
Args:
subject_info_xml : str
A SubjectInfo XML document.
primary_str : str
A DataONE subject, typically ... |
def deserialize_subject_info(subject_info_xml):
"""Deserialize SubjectInfo XML doc to native object.
Args:
subject_info_xml: str
SubjectInfo XML doc
Returns:
SubjectInfo PyXB object
"""
try:
return d1_common.xml.deserialize(subject_info_xml)
except ValueErr... |
def gen_subject_info_tree(subject_info_pyxb, authn_subj, include_duplicates=False):
"""Convert the flat, self referential lists in the SubjectInfo to a tree structure.
Args:
subject_info_pyxb: SubjectInfo PyXB object
authn_subj: str
The authenticated subject that becomes the root s... |
def _trim_tree(state):
"""Trim empty leaf nodes from the tree.
- To simplify the tree conversion, empty nodes are added before it is known if they
will contain items that connect back to the authenticated subject. If there are
no connections, the nodes remain empty, which causes them to be removed ... |
def add_child(self, label_str, type_str):
"""Add a child node."""
child_node = SubjectInfoNode(label_str, type_str)
child_node.parent = self
self.child_list.append(child_node)
return child_node |
def get_path_str(self, sep=os.path.sep, type_str=None):
"""Get path from root to this node.
Args:
sep: str
One or more characters to insert between each element in the path.
Defaults to "/" on Unix and "\" on Windows.
type_str:
SU... |
def get_leaf_node_path_list(self, sep=os.path.sep, type_str=None):
"""Get paths for all leaf nodes for the tree rooted at this node.
Args:
sep: str
One or more characters to insert between each element in the path.
Defaults to "/" on Unix and "\" on Windows.
... |
def get_path_list(self, type_str=None):
"""Get list of the labels of the nodes leading up to this node from the root.
Args:
type_str:
SUBJECT_NODE_TAG, TYPE_NODE_TAG or None. If set, only include
information from nodes of that type.
Returns:
... |
def get_label_set(self, type_str=None):
"""Get a set of label_str for the tree rooted at this node.
Args:
type_str:
SUBJECT_NODE_TAG, TYPE_NODE_TAG or None. If set, only include
information from nodes of that type.
Returns:
set: The label... |
def start_task_type(self, task_type_str, total_task_count):
"""Call when about to start processing a new type of task, typically just before
entering a loop that processes many task of the given type.
Args:
task_type_str (str):
The name of the task, used as a dict ke... |
def end_task_type(self, task_type_str):
"""Call when processing of all tasks of the given type is completed, typically
just after exiting a loop that processes many tasks of the given type.
Progress messages logged at intervals will typically not include the final entry
which shows that... |
def start_task(self, task_type_str, current_task_index=None):
"""Call when processing is about to start on a single task of the given task
type, typically at the top inside of the loop that processes the tasks.
Args:
task_type_str (str):
The name of the task, used as... |
def event(self, event_name):
"""Register an event that occurred during processing of a task of the given
type.
Args: event_name: str A name for a type of events. Events of the
same type are displayed as a single entry and a total count of
occurences.
... |
def get_permissible_wcs(classname, f):
r"""For some classes (in particular $\Delta F=1$), only a subset of Wilson
coefficients exist in WET-3 and WET-4. Therefore, depending on the number
of flavours `f`, the dimensionality of the ADM has to be reduced."""
# these are the problematic sectors
classes... |
def admeig(classname, f, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau):
"""Compute the eigenvalues and eigenvectors for a QCD anomalous dimension
matrix that is defined in `adm.adm_s_X` where X is the name of the sector.
Supports memoization. Output analogous to `np.linalg.eig`."""
args = f, m_u, m_d, m_s... |
def getUs(classname, eta_s, f, alpha_s, alpha_e, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau):
"""Get the QCD evolution matrix."""
w, v = admeig(classname, f, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau)
b0s = 11 - 2 * f / 3
a = w / (2 * b0s)
return v @ np.diag(eta_s**a) @ np.linalg.inv(v) |
def getUe(classname, eta_s, f, alpha_s, alpha_e, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau):
"""Get the QCD evolution matrix."""
args = f, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau
A = getattr(adm, 'adm_e_' + classname)(*args)
perm_keys = get_permissible_wcs(classname, f)
if perm_keys != 'all':
... |
def run_sector(sector, C_in, eta_s, f, p_in, p_out, qed_order=1, qcd_order=1):
r"""Solve the WET RGE for a specific sector.
Parameters:
- sector: sector of interest
- C_in: dictionary of Wilson coefficients
- eta_s: ratio of $\alpha_s$ at input and output scale
- f: number of active quark flav... |
def _merge_region_trees(self, dst_tree, src_tree, pid):
"""Merge conflicts occur if a folder in one tree is a file in the other.
As the files are PIDs, this can only happen if a PID matches one of the
geographical areas that the dataset covers and should be very rare. In such
conflicts,... |
def _get_region_tree_item_and_unconsumed_path(
self, region_tree, path, parent_key=''
):
"""Return the region_tree item specified by path. An item can be a a folder
(represented by a dictionary) or a PID (represented by None).
This function is also used for determining which section... |
def save(self, **kwargs):
"""Override save method to catch handled errors and repackage them as 400 errors."""
try:
return super().save(**kwargs)
except SlugError as error:
raise ParseError(error) |
def get_api_major_by_base_url(base_url, *client_arg_list, **client_arg_dict):
"""Read the Node document from a node and return an int containing the latest D1 API
version supported by the node.
The Node document can always be reached through the v1 API and will list services
for v1 and any later APIs v... |
def delete_unused_subjects():
"""Delete any unused subjects from the database.
This is not strictly required as any unused subjects will automatically be reused if
needed in the future.
"""
# This causes Django to create a single join (check with query.query)
query = d1_gmn.app.models.Subject.... |
def extract_subject_from_dn(cert_obj):
"""Serialize a DN to a DataONE subject string.
Args:
cert_obj: cryptography.Certificate
Returns:
str:
Primary subject extracted from the certificate DN.
The certificate DN (DistinguishedName) is a sequence of RDNs
(RelativeDistinguishedNa... |
def create_d1_dn_subject(common_name_str):
"""Create the DN Subject for certificate that will be used in a DataONE environment.
The DN is formatted into a DataONE subject, which is used in authentication,
authorization and event tracking.
Args:
common_name_str: str
DataONE uses sim... |
def generate_csr(private_key_bytes, subject_name, fqdn_list):
"""Generate a Certificate Signing Request (CSR).
Args:
private_key_bytes: bytes
Private key with which the CSR will be signed.
subject_name: str
Certificate Subject Name
fqdn_list:
List o... |
def deserialize_pem(cert_pem):
"""Deserialize PEM (Base64) encoded X.509 v3 certificate.
Args:
cert_pem: str or bytes
PEM (Base64) encoded X.509 v3 certificate
Returns:
cert_obj: cryptography.Certificate
"""
if isinstance(cert_pem, str):
cert_pem = cert_pem.encode("utf... |
def serialize_cert_to_pem(cert_obj):
"""Serialize certificate to PEM.
The certificate can be also be a Certificate Signing Request (CSR).
Args:
cert_obj: cryptography.Certificate
Returns:
bytes: PEM encoded certificate
"""
return cert_obj.public_bytes(
encoding=cryptograp... |
def extract_subject_info_extension(cert_obj):
"""Extract DataONE SubjectInfo XML doc from certificate.
Certificates issued by DataONE may include an embedded XML doc containing
additional information about the subject specified in the certificate DN. If
present, the doc is stored as an extension with a... |
def download_as_der(
base_url=d1_common.const.URL_DATAONE_ROOT,
timeout_sec=d1_common.const.DEFAULT_HTTP_TIMEOUT,
):
"""Download public certificate from a TLS/SSL web server as DER encoded ``bytes``.
If the certificate is being downloaded in order to troubleshoot validation issues,
the download its... |
def download_as_pem(
base_url=d1_common.const.URL_DATAONE_ROOT,
timeout_sec=d1_common.const.DEFAULT_HTTP_TIMEOUT,
):
"""Download public certificate from a TLS/SSL web server as PEM encoded string.
Also see download_as_der().
Args:
base_url : str
A full URL to a DataONE service en... |
def download_as_obj(
base_url=d1_common.const.URL_DATAONE_ROOT,
timeout_sec=d1_common.const.DEFAULT_HTTP_TIMEOUT,
):
"""Download public certificate from a TLS/SSL web server as Certificate object.
Also see download_as_der().
Args:
base_url : str
A full URL to a DataONE service en... |
def decode_der(cert_der):
"""Decode cert DER string to Certificate object.
Args:
cert_der : Certificate as a DER encoded string
Returns:
cryptography.Certificate()
"""
return cryptography.x509.load_der_x509_certificate(
data=cert_der, backend=cryptography.hazmat.backends.defau... |
def disable_cert_validation():
"""Context manager to temporarily disable certificate validation in the standard SSL
library.
Note: This should not be used in production code but is sometimes useful for
troubleshooting certificate validation issues.
By design, the standard SSL library does not prov... |
def extract_issuer_ca_cert_url(cert_obj):
"""Extract issuer CA certificate URL from certificate.
Certificates may include a URL where the root certificate for the CA which was used
for signing the certificate can be downloaded. This function returns the URL if
present.
The primary use for this is ... |
def serialize_private_key_to_pem(private_key, passphrase_bytes=None):
"""Serialize private key to PEM.
Args:
private_key:
passphrase_bytes:
Returns:
bytes: PEM encoded private key
"""
return private_key.private_bytes(
encoding=cryptography.hazmat.primitives.serialization... |
def generate_private_key(key_size=2048):
"""Generate a private key"""
return cryptography.hazmat.primitives.asymmetric.rsa.generate_private_key(
public_exponent=65537,
key_size=key_size,
backend=cryptography.hazmat.backends.default_backend(),
) |
def get_public_key_pem(cert_obj):
"""Extract public key from certificate as PEM encoded PKCS#1.
Args:
cert_obj: cryptography.Certificate
Returns:
bytes: PEM encoded PKCS#1 public key.
"""
return cert_obj.public_key().public_bytes(
encoding=cryptography.hazmat.primitives.serial... |
def load_csr(pem_path):
"""Load CSR from PEM encoded file"""
with open(pem_path, "rb") as f:
return cryptography.x509.load_pem_x509_csr(
data=f.read(), backend=cryptography.hazmat.backends.default_backend()
) |
def load_private_key(pem_path, passphrase_bytes=None):
"""Load private key from PEM encoded file"""
with open(pem_path, "rb") as f:
return cryptography.hazmat.primitives.serialization.load_pem_private_key(
data=f.read(),
password=passphrase_bytes,
backend=cryptography... |
def serialize_cert_to_der(cert_obj):
"""Serialize certificate to DER.
Args:
cert_obj: cryptography.Certificate
Returns:
bytes: DER encoded certificate
"""
return cert_obj.public_bytes(
cryptography.hazmat.primitives.serialization.Encoding.DER
) |
def log_cert_info(logger, msg_str, cert_obj):
"""Dump basic certificate values to the log.
Args:
logger: Logger
Logger to which to write the certificate values.
msg_str: str
A message to write to the log before the certificate values.
cert_obj: cryptography.Certificate
... |
def get_extension_by_name(cert_obj, extension_name):
"""Get a standard certificate extension by attribute name.
Args:
cert_obj: cryptography.Certificate
Certificate containing a standard extension.
extension_name : str
Extension name. E.g., 'SUBJECT_DIRECTORY_ATTRIBUTES'.
Retu... |
def _get_val_list(obj, path_list, reverse=False):
"""Extract values from nested objects by attribute names.
Objects contain attributes which are named references to objects. This will descend
down a tree of nested objects, starting at the given object, following the given
path.
Args:
obj: ob... |
def _get_val_str(obj, path_list=None, reverse=False):
"""Extract values from nested objects by attribute names and concatenate their
string representations.
Args:
obj: object
Any type of object
path_list: list
Attribute names
reverse: bool
Reverse the list of val... |
def _JMS_to_Bern_I(C, qq):
"""From JMS to BernI basis (= traditional SUSY basis in this case)
for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'cu'"""
if qq in ['sb', 'db', 'ds']:
dd = 'dd'
ij = tuple(dflav[q] for q in qq)
elif qq == 'cu':
dd = 'uu'
ij =... |
def _Bern_to_JMS_I(C, qq):
"""From Bern to JMS basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'cu'"""
if qq in ['sb', 'db', 'ds']:
dd = 'dd'
ij = '{}{}'.format(dflav[qq[0]] + 1, dflav[qq[1]] + 1)
elif qq == 'cu':
dd = 'uu'
ij = '{}{}'.format(uflav[qq... |
def _BernI_to_Flavio_I(C, qq):
"""From BernI to FlavioI basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'uc'"""
qqf = qq[::-1] # flavio uses "bs" instead of "sb" etc.
if qq in ['sb', 'db', 'ds', 'cu']:
return {
'CVLL_' + 2*qqf: C["1" + 2*qq],
'CSLL_'... |
def _FlavioI_to_Bern_I(C, qq):
"""From FlavioI to BernI basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'uc'"""
qqb = qq[::-1] # flavio uses "bs" instead of "sb" etc.
if qq in ['bs', 'bd', 'sd', 'uc']:
return {
'1' + 2*qqb: C["CVLL_" + 2*qq],
'2' + 2... |
def _BernI_to_FormFlavor_I(C, qq):
"""From BernI to FormFlavorI basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'uc'"""
qqf = qq[::-1] # FormFlavour uses "bs" instead of "sb" etc.
if qq in ['sb', 'db', 'ds']:
return {
'CVLL_' + 2*qqf: C["1" + 2*qq],
'... |
def _JMS_to_Bern_II(C, udlnu):
"""From JMS to BernII basis for charged current process semileptonic
operators. `udlnu` should be of the form 'udl_enu_tau', 'cbl_munu_e' etc."""
u = uflav[udlnu[0]]
d = dflav[udlnu[1]]
l = lflav[udlnu[4:udlnu.find('n')]]
lp = lflav[udlnu[udlnu.find('_',5)+1:len(ud... |
def _Bern_to_JMS_II(C, udlnu):
"""From BernII to JMS basis for charged current process semileptonic
operators. `udlnu` should be of the form 'udl_enu_tau', 'cbl_munu_e' etc."""
u = uflav[udlnu[0]]
d = dflav[udlnu[1]]
l = lflav[udlnu[4:udlnu.find('n')]]
lp = lflav[udlnu[udlnu.find('_',5)+1:len(ud... |
def _BernII_to_Flavio_II(C, udlnu, parameters):
"""From BernII to FlavioII basis
for charged current process semileptonic operators.
`udlnu` should be of the form 'udl_enu_tau', 'cbl_munu_e' etc."""
p = parameters
u = uflav[udlnu[0]]
d = dflav[udlnu[1]]
l = lflav[udlnu[4:udlnu.find('n')]]
... |
def _Fierz_to_JMS_III_IV_V(Fqqqq, qqqq):
"""From 4-quark Fierz to JMS basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc."""
F = Fqqqq.copy()
#case dduu
classIII = ['sbuc', 'sbcu', 'dbuc', 'dbcu', 'dsuc', 'dscu']
classVdduu = ['sbuu' , 'dbuu', 'dsuu', 'sbcc'... |
def _JMS_to_Fierz_III_IV_V(C, qqqq):
"""From JMS to 4-quark Fierz basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc."""
#case dduu
classIII = ['sbuc', 'sbcu', 'dbuc', 'dbcu', 'dsuc', 'dscu']
classVdduu = ['sbuu' , 'dbuu', 'dsuu', 'sbcc' , 'dbcc', 'dscc']
if... |
def _Fierz_to_Bern_III_IV_V(Fqqqq, qqqq):
"""From Fierz to 4-quark Bern basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc."""
# 2nd != 4th, color-octet redundant
if qqqq in ['sbss', 'dbdd', 'dbds', 'sbsd', 'bsbd', 'dsdd']:
return {
'1' + qqqq : -Fqq... |
def _Bern_to_Fierz_III_IV_V(C, qqqq):
"""From Bern to 4-quark Fierz basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc."""
# 2nd != 4th, color-octet redundant
if qqqq in ['sbss', 'dbdd', 'dbds', 'sbsd', 'bsbd', 'dsdd']:
return {
'F' + qqqq + ... |
def _Fierz_to_EOS_V(Fsbuu,Fsbdd,Fsbcc,Fsbss,Fsbbb,parameters):
p = parameters
V = ckmutil.ckm.ckm_tree(p["Vus"], p["Vub"], p["Vcb"], p["delta"])
Vtb = V[2,2]
Vts = V[2,1]
"""From Fierz to the EOS basis for b -> s transitions.
The arguments are dictionaries of the corresponding Fierz bases """
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.