Construct the DAG pattern (representing the I-equivalence class) for
        a given DAG. This is the "inverse" to pdag_to_dag.
348810
def model_to_pdag(model):
        

        if not isinstance(model, DAG):
            raise TypeError("model: Expected DAG instance, " +
                            "got type {model_type}".format(model_type=type(model)))

        skel, separating_sets = ConstraintBasedEstimator.build_skeleton(
                                    model.nodes(),
                                    model.get_independencies())
        pdag = ConstraintBasedEstimator.skeleton_to_pdag(skel, separating_sets)

        return pdag
332876
@SuppressWarnings("unchecked")
    public static <A extends AggregateRoot<I>, I> Class<I> resolveAggregateIdClass(Class<A> aggregateRootClass) {
        checkNotNull(aggregateRootClass, "aggregateRootClass should not be null");
        return (Class<I>) resolveGenerics(AggregateRoot.class, aggregateRootClass)[0];
    }
1198905
def pattern_convert(grammar, raw_node_info):
    """"""
    type, value, context, children = raw_node_info
    if children or type in grammar.number2symbol:
        return pytree.Node(type, children, context=context)
    else:
        return pytree.Leaf(type, value, context=context)
79980
def construct(key_data, algorithm=None):
    

    # Allow for pulling the algorithm off of the passed in jwk.
    if not algorithm and isinstance(key_data, dict):
        algorithm = key_data.get('alg', None)

    if not algorithm:
        raise JWKError('Unable to find a algorithm for key: %s' % key_data)

    key_class = get_key(algorithm)
    if not key_class:
        raise JWKError('Unable to find a algorithm for key: %s' % key_data)
    return key_class(key_data, algorithm)
644030
def _create_inverse_maps(self):
        ''''''

        # We have already determined that the inverse maps are well-defined (the normal maps are injective). The inverse maps will be partial maps in general.

        self.atom_to_rosetta_sequence_maps = {}
        for chain_id, sequence_map in self.rosetta_to_atom_sequence_maps.iteritems():
            s = SequenceMap()
            for k, v, substitution_match in sequence_map:
                s.add(v, k, substitution_match)
            self.atom_to_rosetta_sequence_maps[chain_id] = s

        self.seqres_to_atom_sequence_maps = {}
        for chain_id, sequence_map in self.atom_to_seqres_sequence_maps.iteritems():
            s = SequenceMap()
            for k, v, substitution_match in sequence_map:
                s.add(v, k, substitution_match)
            self.seqres_to_atom_sequence_maps[chain_id] = s

        # This map uses PDB chain IDs as PDB chains may map to zero or one UniParc IDs whereas UniParc IDs may map to many PDB chains
        self.uniparc_to_seqres_sequence_maps = {}
        for chain_id, sequence_map in self.seqres_to_uniparc_sequence_maps.iteritems():
            s = UniParcPDBSequenceMap()
            for k, v, substitution_match in sequence_map:
                s.add(v, k, substitution_match)
            self.uniparc_to_seqres_sequence_maps[chain_id] = s
1101136
@Override
	public Pattern constructPattern()
	{
		Pattern p = new Pattern(SmallMoleculeReference.class, "SMR");
		p.add(new Size(
			new PathConstraint("SmallMoleculeReference/entityReferenceOf/participantOf:Conversion"),
			50, Size.Type.GREATER_OR_EQUAL), "SMR");
		return p;
	}
611396
def split_dae_alg(eqs: SYM, dx: SYM) -> Dict[str, SYM]:
    """"""
    dae = []
    alg = []
    for eq in ca.vertsplit(eqs):
        if ca.depends_on(eq, dx):
            dae.append(eq)
        else:
            alg.append(eq)
    return {
        'dae': ca.vertcat(*dae),
        'alg': ca.vertcat(*alg)
    }
992185
@Override
  public boolean equivalent(PMap<K, V> that, BiPredicate<V, V> equivalence) {
    return equivalent(
        !this.isEmpty() ? this : null, !that.isEmpty() ? (HamtPMap<K, V>) that : null, equivalence);
  }
1195604
def make_pattern( patt, flags=0 ):
    
    # print('input',len(patt))
    patt_letters = utf8.get_letters( patt )
    patt_out = list()
    idx = 0
    # print('output',len(patt_letters))
    patt = [None,None]
    prev = None
    LEN_PATT = len(patt_letters)
    while( idx < LEN_PATT ):
        if utf8.istamil( patt_letters[idx] ) and ( prev == '-' or ((idx+1) < LEN_PATT and patt_letters[idx+1] == u'-') ):
            if (idx+1) < LEN_PATT and patt_letters[idx+1] == u'-':
                patt[0] = patt_letters[idx]
                idx = idx + 2
                prev = "-"
            elif prev == '-':
                patt[1] = patt_letters[idx]
                patt_out.extend( expand_tamil( patt[0], patt[1]) )
                idx = idx + 1
                prev = patt_letters[idx]
            continue
        patt_out.extend( patt_letters[idx] )
        prev = patt_letters[idx]
        idx = idx + 1
    opattern = u"".join( patt_out )
    compile_regexp = re.compile( opattern, flags )        
    return (compile_regexp,opattern)
1214695
def get_chain_mapping(self, pdb_name1, pdb_name2):
        ''''''
        raise Exception('Implement. Map pdb_namex to its equivalence class, call get_representative_chain_mapping, and something something.')
        pprint.pprint(self.chain_mapping)

        d = {}
        for pdb1_chain_id, matched_chain_list in self.chain_mapping[(pdb_name1, pdb_name2)].iteritems():
            d[pdb1_chain_id] = matched_chain_list.get_related_chains_ids(pdb_name2)
        return d
244740
public Graph<AttributeOccurrence>[] createIDP(Graph<AttributeOccurrence>[] dp) {
        Graph<AttributeOccurrence>[] idp;
        Graph<AttributeOccurrence>[] idpClosure;
        boolean[] touched;
        int p;
        int q;
        AttributeOccurrence left;
        AttributeOccurrence right;
        int symbol;
        int ofs;
        boolean modified;
        AttributeOccurrence newLeft;
        AttributeOccurrence newRight;
        EdgeIterator<AttributeOccurrence> iter;

        idp = new Graph[dp.length];
        idpClosure = new Graph[dp.length];
        touched = new boolean[dp.length];
        for (p = 0; p < idp.length; p++) {
            idp[p] = new Graph<AttributeOccurrence>();
            idp[p].addGraph(dp[p]);
            idpClosure[p] = new Graph<AttributeOccurrence>();
            idpClosure[p].addGraph(dp[p]);
            idpClosure[p].closureHere();
            touched[p] = true;
        }

        do {
            modified = false;
            for (q = 0; q < idp.length; q++) {
                if (touched[q]) {
                    touched[q] = false;
                    iter = idpClosure[q].edges();
                    while (iter.step()) {
                        left = iter.left();
                        right = iter.right();
                        if (left.sameSymbolOccurrence(right)) {
                            for (p = 0; p < idp.length; p++) {
                                for (ofs = 0; ofs <= grammar.getLength(p); ofs++) {
                                    symbol = semantics.getGrammar().getSymbol(p, ofs);
                                    if (symbol == left.attr.symbol) {
                                        newLeft = new AttributeOccurrence(left.attr, ofs - 1);
                                        newRight = new AttributeOccurrence(right.attr, ofs - 1);
                                        if (idp[p].addEdge(newLeft, newRight)) {
                                            idpClosure[p].addEdge(newLeft, newRight);
                                            idpClosure[p].closureHere();
                                            touched[p] = true;
                                            modified = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } while (modified);
        return idp;
    }
1058727
protected Pattern[] queryDetectionPattern(final Pattern... pattern) {
        if (pattern == null) {
            throw new IllegalArgumentException();
        } // end of if

        // ---

        if (this.queryDetection == null) {
            return pattern;
        } // end of if

        // ---

        final Pattern[] patterns = 
            new Pattern[this.queryDetection.length + pattern.length];

        System.arraycopy(this.queryDetection, 0, 
                         patterns, 0, 
                         this.queryDetection.length);

        int i = this.queryDetection.length;

        for (final Pattern p : pattern) {
            patterns[i++] = p;
        } // end of for

        return patterns;
    }
1181606
def from_gtp(gtpc):
    """"""
    gtpc = gtpc.upper()
    if gtpc == 'PASS':
        return None
    col = _GTP_COLUMNS.index(gtpc[0])
    row_from_bottom = int(gtpc[1:])
    return go.N - row_from_bottom, col
187307
def inverse(x, p, errorOnFail=False):
    
    # Check types
    assertType(x, BigInt)

    # There are a number of ways in RELIC to compute this inverse, but
    # for simplicity, we'll use the extended GCD algorithm because it 
    # involves less type conversions. On the initial development platform
    # Lehmer's algorithm was the most performant: we call it directly.
    gcd = BigInt()
    inv = BigInt()

    # bn_gcd_ext(c, d, e, a, b) computes: c = a*d + b*e
    # We take x=a. b=p, and expect: c = 1 = gcd(x,p), d = 1/x, and e is unused.
    librelic.bn_gcd_ext_lehme(byref(gcd), byref(inv), None, byref(x), byref(p))

    # Check that GCD == 1 
    if gcd != 1:
        if errorOnFail:
            raise Exception("Cannot find an inverse. gcd(x,p) == {}, but we need gcd(x,p) == 1 to find an inverse.".
                format(long(gcd)))
        else:
            return None

    return inv
1348062
void radbg(final int ido, final int ip, final int l1, final int idl1, final double in[], final int in_off, final double out[], final int out_off, final int offset) {
		int idij, ipph, j2, ic, jc, lc, is;
		double dc2, ai1, ai2, ar1, ar2, ds2, w1r, w1i;
		int nbd;
		double dcp, arg, dsp, ar1h, ar2h;
		int iw1 = offset;

		arg = TWO_PI / (double) ip;
		dcp = Math.cos(arg);
		dsp = Math.sin(arg);
		nbd = (ido - 1) / 2;
		ipph = (ip + 1) / 2;
		int idx0 = ip * ido;
		if (ido >= l1) {
			for (int k = 0; k < l1; k++) {
				int idx1 = k * ido;
				int idx2 = k * idx0;
				for (int i = 0; i < ido; i++) {
					out[out_off + i + idx1] = in[in_off + i + idx2];
				}
			}
		} else {
			for (int i = 0; i < ido; i++) {
				int idx1 = out_off + i;
				int idx2 = in_off + i;
				for (int k = 0; k < l1; k++) {
					out[idx1 + k * ido] = in[idx2 + k * idx0];
				}
			}
		}
		int iidx0 = in_off + ido - 1;
		for (int j = 1; j < ipph; j++) {
			jc = ip - j;
			j2 = 2 * j;
			int idx1 = j * l1 * ido;
			int idx2 = jc * l1 * ido;
			int idx3 = j2 * ido;
			for (int k = 0; k < l1; k++) {
				int idx4 = k * ido;
				int idx5 = idx4 * ip;
				int iidx1 = iidx0 + idx3 + idx5 - ido;
				int iidx2 = in_off + idx3 + idx5;
				double i1r = in[iidx1];
				double i2r = in[iidx2];

				out[out_off + idx4 + idx1] = i1r + i1r;
				out[out_off + idx4 + idx2] = i2r + i2r;
			}
		}

		if (ido != 1) {
			if (nbd >= l1) {
				for (int j = 1; j < ipph; j++) {
					jc = ip - j;
					int idx1 = j * l1 * ido;
					int idx2 = jc * l1 * ido;
					int idx3 = 2 * j * ido;
					for (int k = 0; k < l1; k++) {
						int idx4 = k * ido + idx1;
						int idx5 = k * ido + idx2;
						int idx6 = k * ip * ido + idx3;
						for (int i = 2; i < ido; i += 2) {
							ic = ido - i;
							int idx7 = out_off + i;
							int idx8 = in_off + ic;
							int idx9 = in_off + i;
							int oidx1 = idx7 + idx4;
							int oidx2 = idx7 + idx5;
							int iidx1 = idx9 + idx6;
							int iidx2 = idx8 + idx6 - ido;
							double a1i = in[iidx1 - 1];
							double a1r = in[iidx1];
							double a2i = in[iidx2 - 1];
							double a2r = in[iidx2];

							out[oidx1 - 1] = a1i + a2i;
							out[oidx2 - 1] = a1i - a2i;
							out[oidx1] = a1r - a2r;
							out[oidx2] = a1r + a2r;
						}
					}
				}
			} else {
				for (int j = 1; j < ipph; j++) {
					jc = ip - j;
					int idx1 = j * l1 * ido;
					int idx2 = jc * l1 * ido;
					int idx3 = 2 * j * ido;
					for (int i = 2; i < ido; i += 2) {
						ic = ido - i;
						int idx7 = out_off + i;
						int idx8 = in_off + ic;
						int idx9 = in_off + i;
						for (int k = 0; k < l1; k++) {
							int idx4 = k * ido + idx1;
							int idx5 = k * ido + idx2;
							int idx6 = k * ip * ido + idx3;
							int oidx1 = idx7 + idx4;
							int oidx2 = idx7 + idx5;
							int iidx1 = idx9 + idx6;
							int iidx2 = idx8 + idx6 - ido;
							double a1i = in[iidx1 - 1];
							double a1r = in[iidx1];
							double a2i = in[iidx2 - 1];
							double a2r = in[iidx2];

							out[oidx1 - 1] = a1i + a2i;
							out[oidx2 - 1] = a1i - a2i;
							out[oidx1] = a1r - a2r;
							out[oidx2] = a1r + a2r;
						}
					}
				}
			}
		}

		ar1 = 1;
		ai1 = 0;
		int idx01 = (ip - 1) * idl1;
		for (int l = 1; l < ipph; l++) {
			lc = ip - l;
			ar1h = dcp * ar1 - dsp * ai1;
			ai1 = dcp * ai1 + dsp * ar1;
			ar1 = ar1h;
			int idx1 = l * idl1;
			int idx2 = lc * idl1;
			for (int ik = 0; ik < idl1; ik++) {
				int idx3 = in_off + ik;
				int idx4 = out_off + ik;
				in[idx3 + idx1] = out[idx4] + ar1 * out[idx4 + idl1];
				in[idx3 + idx2] = ai1 * out[idx4 + idx01];
			}
			dc2 = ar1;
			ds2 = ai1;
			ar2 = ar1;
			ai2 = ai1;
			for (int j = 2; j < ipph; j++) {
				jc = ip - j;
				ar2h = dc2 * ar2 - ds2 * ai2;
				ai2 = dc2 * ai2 + ds2 * ar2;
				ar2 = ar2h;
				int idx5 = j * idl1;
				int idx6 = jc * idl1;
				for (int ik = 0; ik < idl1; ik++) {
					int idx7 = in_off + ik;
					int idx8 = out_off + ik;
					in[idx7 + idx1] += ar2 * out[idx8 + idx5];
					in[idx7 + idx2] += ai2 * out[idx8 + idx6];
				}
			}
		}
		for (int j = 1; j < ipph; j++) {
			int idx1 = j * idl1;
			for (int ik = 0; ik < idl1; ik++) {
				int idx2 = out_off + ik;
				out[idx2] += out[idx2 + idx1];
			}
		}
		for (int j = 1; j < ipph; j++) {
			jc = ip - j;
			int idx1 = j * l1 * ido;
			int idx2 = jc * l1 * ido;
			for (int k = 0; k < l1; k++) {
				int idx3 = k * ido;
				int oidx1 = out_off + idx3;
				int iidx1 = in_off + idx3 + idx1;
				int iidx2 = in_off + idx3 + idx2;
				double i1r = in[iidx1];
				double i2r = in[iidx2];

				out[oidx1 + idx1] = i1r - i2r;
				out[oidx1 + idx2] = i1r + i2r;
			}
		}

		if (ido == 1)
			return;
		if (nbd >= l1) {
			for (int j = 1; j < ipph; j++) {
				jc = ip - j;
				int idx1 = j * l1 * ido;
				int idx2 = jc * l1 * ido;
				for (int k = 0; k < l1; k++) {
					int idx3 = k * ido;
					for (int i = 2; i < ido; i += 2) {
						int idx4 = out_off + i;
						int idx5 = in_off + i;
						int oidx1 = idx4 + idx3 + idx1;
						int oidx2 = idx4 + idx3 + idx2;
						int iidx1 = idx5 + idx3 + idx1;
						int iidx2 = idx5 + idx3 + idx2;
						double i1i = in[iidx1 - 1];
						double i1r = in[iidx1];
						double i2i = in[iidx2 - 1];
						double i2r = in[iidx2];

						out[oidx1 - 1] = i1i - i2r;
						out[oidx2 - 1] = i1i + i2r;
						out[oidx1] = i1r + i2i;
						out[oidx2] = i1r - i2i;
					}
				}
			}
		} else {
			for (int j = 1; j < ipph; j++) {
				jc = ip - j;
				int idx1 = j * l1 * ido;
				int idx2 = jc * l1 * ido;
				for (int i = 2; i < ido; i += 2) {
					int idx4 = out_off + i;
					int idx5 = in_off + i;
					for (int k = 0; k < l1; k++) {
						int idx3 = k * ido;
						int oidx1 = idx4 + idx3 + idx1;
						int oidx2 = idx4 + idx3 + idx2;
						int iidx1 = idx5 + idx3 + idx1;
						int iidx2 = idx5 + idx3 + idx2;
						double i1i = in[iidx1 - 1];
						double i1r = in[iidx1];
						double i2i = in[iidx2 - 1];
						double i2r = in[iidx2];

						out[oidx1 - 1] = i1i - i2r;
						out[oidx2 - 1] = i1i + i2r;
						out[oidx1] = i1r + i2i;
						out[oidx2] = i1r - i2i;
					}
				}
			}
		}
		System.arraycopy(out, out_off, in, in_off, idl1);
		for (int j = 1; j < ip; j++) {
			int idx1 = j * l1 * ido;
			for (int k = 0; k < l1; k++) {
				int idx2 = k * ido + idx1;
				in[in_off + idx2] = out[out_off + idx2];
			}
		}
		if (nbd <= l1) {
			is = -ido;
			for (int j = 1; j < ip; j++) {
				is += ido;
				idij = is - 1;
				int idx1 = j * l1 * ido;
				for (int i = 2; i < ido; i += 2) {
					idij += 2;
					int idx2 = idij + iw1;
					w1r = wtable_r[idx2 - 1];
					w1i = wtable_r[idx2];
					int idx4 = in_off + i;
					int idx5 = out_off + i;
					for (int k = 0; k < l1; k++) {
						int idx3 = k * ido + idx1;
						int iidx1 = idx4 + idx3;
						int oidx1 = idx5 + idx3;
						double o1i = out[oidx1 - 1];
						double o1r = out[oidx1];

						in[iidx1 - 1] = w1r * o1i - w1i * o1r;
						in[iidx1] = w1r * o1r + w1i * o1i;
					}
				}
			}
		} else {
			is = -ido;
			for (int j = 1; j < ip; j++) {
				is += ido;
				int idx1 = j * l1 * ido;
				for (int k = 0; k < l1; k++) {
					idij = is - 1;
					int idx3 = k * ido + idx1;
					for (int i = 2; i < ido; i += 2) {
						idij += 2;
						int idx2 = idij + iw1;
						w1r = wtable_r[idx2 - 1];
						w1i = wtable_r[idx2];
						int idx4 = in_off + i;
						int idx5 = out_off + i;
						int iidx1 = idx4 + idx3;
						int oidx1 = idx5 + idx3;
						double o1i = out[oidx1 - 1];
						double o1r = out[oidx1];

						in[iidx1 - 1] = w1r * o1i - w1i * o1r;
						in[iidx1] = w1r * o1r + w1i * o1i;

					}
				}
			}
		}
	}
219731
def convert_block_tridiag_to_banded(H_diag, H_upper_diag, lower=True):
    
    T, D, _ = H_diag.shape
    assert H_diag.ndim == 3 and H_diag.shape[2] == D
    assert H_upper_diag.shape == (T - 1, D, D)
    H_lower_diag = np.swapaxes(H_upper_diag, -2, -1)

    ab = np.zeros((2 * D, T * D))

    # Fill in blocks along the diagonal
    for d in range(D):
        # Get indices of (-d)-th diagonal of H_diag
        i = np.arange(d, D)
        j = np.arange(0, D - d)
        h = np.column_stack((H_diag[:, i, j], np.zeros((T, d))))
        ab[d] = h.ravel()

    # Fill in lower left corner of blocks below the diagonal
    for d in range(0, D):
        # Get indices of (-d)-th diagonal of H_diag
        i = np.arange(d, D)
        j = np.arange(0, D - d)
        h = np.column_stack((H_lower_diag[:, i, j], np.zeros((T - 1, d))))
        ab[D + d, :D * (T - 1)] = h.ravel()

    # Fill in upper corner of blocks below the diagonal
    for d in range(1, D):
        # Get indices of (+d)-th diagonal of H_lower_diag
        i = np.arange(0, D - d)
        j = np.arange(d, D)
        h = np.column_stack((np.zeros((T - 1, d)), H_lower_diag[:, i, j]))
        ab[D - d, :D * (T - 1)] += h.ravel()

    return ab if lower else transpose_lower_banded_matrix(ab)
905988
public static Class<?>[] getAggregateIdClasses(Class<? extends AggregateRoot<?>>[] aggregateRootClasses) {
        checkNotNull(aggregateRootClasses, "aggregateRootClasses should not be null");
        Class<?>[] result = new Class<?>[aggregateRootClasses.length];
        for (int i = 0; i < aggregateRootClasses.length; i++) {
            result[i] = resolveGenerics(AggregateRoot.class, aggregateRootClasses[i])[0];
        }
        return result;
    }