JISX0510:2004 (p.45) for details.
511720
static void makeTypeInfoBits(ErrorCorrectionLevel ecLevel, int maskPattern, BitArray bits)
      throws WriterException {
    if (!QRCode.isValidMaskPattern(maskPattern)) {
      throw new WriterException("Invalid mask pattern");
    }
    int typeInfo = (ecLevel.getBits() << 3) | maskPattern;
    bits.appendBits(typeInfo, 5);

    int bchCode = calculateBCHCode(typeInfo, TYPE_INFO_POLY);
    bits.appendBits(bchCode, 10);

    BitArray maskBits = new BitArray();
    maskBits.appendBits(TYPE_INFO_MASK_PATTERN, 15);
    bits.xor(maskBits);

    if (bits.getSize() != 15) {  // Just in case.
      throw new WriterException("should not happen but we got: " + bits.getSize());
    }
  }
1143423
private void _nonsymetricOrthes ()
  {
    // This is derived from the Algol procedures orthes and ortran,
    // by Martin and Wilkinson, Handbook for Auto. Comp.,
    // Vol.ii-Linear Algebra, and the corresponding
    // Fortran subroutines in EISPACK.

    final int low = 0;
    final int high = m_nDim - 1;

    for (int m = low + 1; m <= high - 1; m++)
    {
      // Scale column.
      double scale = 0.0;
      for (int i = m; i <= high; i++)
        scale += MathHelper.abs (m_aHessenBerg[i][m - 1]);
      if (scale != 0.0)
      {
        // Compute Householder transformation.
        double h = 0.0;
        for (int i = high; i >= m; i--)
        {
          m_aOrt[i] = m_aHessenBerg[i][m - 1] / scale;
          h += m_aOrt[i] * m_aOrt[i];
        }
        double g = Math.sqrt (h);
        if (m_aOrt[m] > 0)
        {
          g = -g;
        }
        h -= m_aOrt[m] * g;
        m_aOrt[m] = m_aOrt[m] - g;

        // Apply Householder similarity transformation
        // H = (I-u*u'/h)*H*(I-u*u')/h)

        for (int j = m; j < m_nDim; j++)
        {
          double f = 0.0;
          for (int i = high; i >= m; i--)
          {
            f += m_aOrt[i] * m_aHessenBerg[i][j];
          }
          f /= h;
          for (int i = m; i <= high; i++)
          {
            m_aHessenBerg[i][j] -= f * m_aOrt[i];
          }
        }

        for (int i = 0; i <= high; i++)
        {
          double f = 0.0;
          for (int j = high; j >= m; j--)
          {
            f += m_aOrt[j] * m_aHessenBerg[i][j];
          }
          f /= h;
          for (int j = m; j <= high; j++)
          {
            m_aHessenBerg[i][j] -= f * m_aOrt[j];
          }
        }
        m_aOrt[m] = scale * m_aOrt[m];
        m_aHessenBerg[m][m - 1] = scale * g;
      }
    }

    // Accumulate transformations (Algol's ortran).
    for (int i = 0; i < m_nDim; i++)
    {
      final double [] aRow = m_aEigenVector[i];
      for (int j = 0; j < m_nDim; j++)
      {
        aRow[j] = (i == j ? 1d : 0d);
      }
    }

    for (int m = high - 1; m >= low + 1; m--)
    {
      if (m_aHessenBerg[m][m - 1] != 0.0)
      {
        for (int i = m + 1; i <= high; i++)
        {
          m_aOrt[i] = m_aHessenBerg[i][m - 1];
        }
        for (int j = m; j <= high; j++)
        {
          double g = 0.0;
          for (int i = m; i <= high; i++)
          {
            g += m_aOrt[i] * m_aEigenVector[i][j];
          }
          // Double division avoids possible underflow
          g = (g / m_aOrt[m]) / m_aHessenBerg[m][m - 1];
          for (int i = m; i <= high; i++)
          {
            m_aEigenVector[i][j] += g * m_aOrt[i];
          }
        }
      }
    }
  }
861307
def part_specs(self, part):
        '''
        
        '''
        result = self._e.parts_match(
            queries=[{'mpn_or_sku': part}],
            exact_only=True,
            show_mpn=True,
            show_manufacturer=True,
            show_octopart_url=True,
            show_short_description=True,
            show_specs=True,
            show_category_uids=True,
            show_external_links=True,
            show_reference_designs=True,
            show_cad_models=True,
            show_datasheets=True,
            include_specs=True,
            include_category_uids=True,
            include_external_links=True,
            include_reference_designs=True,
            include_cad_models=True,
            include_datasheets=True
        )
        if result[1][0]['hits'] == 0:
            print("No result")
            return ReturnValues.NO_RESULTS

        result = result[1][0]['items'][0]
        print("Showing specs for '{}':".format(result['mpn']))
        print(" → Manufacturer:      {}".format(result['manufacturer']['name']))
        print("  → Specifications:    ")
        for k,v in result['specs'].items():
            name = v['metadata']['name'] if v['metadata']['name'] else k
            min_value = v['min_value'] if v['min_value'] else ''
            max_value = v['max_value'] if v['max_value'] else ''
            unit = ' ({})'.format(v['metadata']['unit']['name']) if v['metadata']['unit'] else ''
            value = ','.join(v['value']) if len(v['value']) > 0 else ''

            if value and not (min_value or max_value):
                print("    → {:20}: {}{}".format(name, value, unit))
            elif value and min_value and max_value:
                print("    → {:20}: {}{} (min: {}, max: {})".format(name, value, unit, min_value, max_value))
            elif not value and min_value and max_value:
                print("    → {:20}:{} min: {}, max: {}".format(name, unit, min_value, max_value))
            elif not value and min_value and not max_value:
                print("    → {:20}:{} min: {}".format(name, unit, min_value))
            elif not value and not min_value and max_value:
                print("    → {:20}:{} max: {}".format(name, unit, max_value))

        print(" → URI:               {}".format(result['octopart_url']))
        if result['external_links']['evalkit_url'] \
                or result['external_links']['freesample_url'] \
                or result['external_links']['product_url']:
            print("  → External Links")
            if result['external_links']['evalkit_url']:
                print("    → Evaluation kit: {}".format(result['external_links']['evalkit_url']))
            if result['external_links']['freesample_url']:
                print("    → Free Sample: {}".format(result['external_links']['freesample_url']))
            if result['external_links']['product_url']:
                print("    → Product URI: {}".format(result['external_links']['product_url']))
        if len(result['datasheets']) > 0:
            print("  → Datasheets")
            for datasheet in result['datasheets']:
                print("    → URL:      {}".format(datasheet['url']))
                if datasheet['metadata']:
                    print("      → Updated:  {}".format(datasheet['metadata']['last_updated']))
                    print("      → Nb Pages: {}".format(datasheet['metadata']['num_pages']))
        if len(result['reference_designs']) > 0:
            print("  → Reference designs: ")
        if len(result['cad_models']) > 0:
            print("  → CAD Models:        ")
        return ReturnValues.OK
1264041
def get_summary_dict(self, print_subelectrodes=True):
        

        d = {}
        framework_comp = Composition({k: v
                                      for k, v in self._composition.items()
                                      if k.symbol != self.working_ion.symbol})

        d["framework"] = framework_comp.to_data_dict
        d["framework_pretty"] = framework_comp.reduced_formula
        d["average_voltage"] = self.get_average_voltage()
        d["max_voltage"] = self.max_voltage
        d["min_voltage"] = self.min_voltage
        d["max_delta_volume"] = self.max_delta_volume
        d["max_instability"] = 0
        d["max_voltage_step"] = self.max_voltage_step
        d["nsteps"] = self.num_steps
        d["capacity_grav"] = self.get_capacity_grav()
        d["capacity_vol"] = self.get_capacity_vol()
        d["energy_grav"] = self.get_specific_energy()
        d["energy_vol"] = self.get_energy_density()
        d["working_ion"] = self.working_ion.symbol
        d["reactions"] = []
        d["reactant_compositions"] = []
        comps = []
        frac = []
        for pair in self._vpairs:
            rxn = pair.rxn
            frac.append(pair.frac_charge)
            frac.append(pair.frac_discharge)
            d["reactions"].append(str(rxn))
            for i in range(len(rxn.coeffs)):
                if abs(rxn.coeffs[i]) > 1e-5 and rxn.all_comp[i] not in comps:
                    comps.append(rxn.all_comp[i])
                if abs(rxn.coeffs[i]) > 1e-5 and \
                        rxn.all_comp[i].reduced_formula != d["working_ion"]:
                    reduced_comp = rxn.all_comp[i].reduced_composition
                    comp_dict = reduced_comp.as_dict()
                    d["reactant_compositions"].append(comp_dict)
        d["fracA_charge"] = min(frac)
        d["fracA_discharge"] = max(frac)
        d["nsteps"] = self.num_steps
        if print_subelectrodes:
            f_dict = lambda c: c.get_summary_dict(print_subelectrodes=False)
            d["adj_pairs"] = map(f_dict,
                                 self.get_sub_electrodes(adjacent_only=True))
            d["all_pairs"] = map(f_dict,
                                 self.get_sub_electrodes(adjacent_only=False))
        return d
657218
PolyMeshDetail mergePolyMeshDetails(Context ctx, PolyMeshDetail[] meshes, int nmeshes) {
        PolyMeshDetail mesh = new PolyMeshDetail();

        ctx.startTimer("MERGE_POLYMESHDETAIL");

        int maxVerts = 0;
        int maxTris = 0;
        int maxMeshes = 0;

        for (int i = 0; i < nmeshes; ++i) {
            if (meshes[i] == null) {
                continue;
            }
            maxVerts += meshes[i].nverts;
            maxTris += meshes[i].ntris;
            maxMeshes += meshes[i].nmeshes;
        }

        mesh.nmeshes = 0;
        mesh.meshes = new int[maxMeshes * 4];
        mesh.ntris = 0;
        mesh.tris = new int[maxTris * 4];
        mesh.nverts = 0;
        mesh.verts = new float[maxVerts * 3];

        // Merge datas.
        for (int i = 0; i < nmeshes; ++i) {
            PolyMeshDetail dm = meshes[i];
            if (dm == null) {
                continue;
            }
            for (int j = 0; j < dm.nmeshes; ++j) {
                int dst = mesh.nmeshes * 4;
                int src = j * 4;
                mesh.meshes[dst + 0] = mesh.nverts + dm.meshes[src + 0];
                mesh.meshes[dst + 1] = dm.meshes[src + 1];
                mesh.meshes[dst + 2] = mesh.ntris + dm.meshes[src + 2];
                mesh.meshes[dst + 3] = dm.meshes[src + 3];
                mesh.nmeshes++;
            }

            for (int k = 0; k < dm.nverts; ++k) {
                RecastVectors.copy(mesh.verts, mesh.nverts * 3, dm.verts, k * 3);
                mesh.nverts++;
            }
            for (int k = 0; k < dm.ntris; ++k) {
                mesh.tris[mesh.ntris * 4 + 0] = dm.tris[k * 4 + 0];
                mesh.tris[mesh.ntris * 4 + 1] = dm.tris[k * 4 + 1];
                mesh.tris[mesh.ntris * 4 + 2] = dm.tris[k * 4 + 2];
                mesh.tris[mesh.ntris * 4 + 3] = dm.tris[k * 4 + 3];
                mesh.ntris++;
            }
        }
        ctx.stopTimer("MERGE_POLYMESHDETAIL");
        return mesh;
    }
1205722
def _t1_summary(self,x):
        
        # set decimal places
        if isinstance(self._decimals,int):
            n = self._decimals
        elif isinstance(self._decimals,dict):
            try:
                n = self._decimals[x.name]
            except:
                n = 1
        else:
            n = 1
            warnings.warn('The decimals arg must be an int or dict. Defaulting to {} d.p.'.format(n))

        if x.name in self._nonnormal:
            f = '{{:.{}f}} [{{:.{}f}},{{:.{}f}}]'.format(n,n,n)
            return f.format(np.nanmedian(x.values),
                np.nanpercentile(x.values,25), np.nanpercentile(x.values,75))
        else:
            f = '{{:.{}f}} ({{:.{}f}})'.format(n,n)
            return f.format(np.nanmean(x.values),
                np.nanstd(x.values,ddof=self._ddof))
18124
def description(self, platform, key):
        """"""
        patterns = self._dict_dscr.get(platform, None)
        description = patterns.get(key, None)
        return description
487271
def ic45(msg):
    
    d = hex2bin(data(msg))
    if d[9] == '0':
        return None

    ic = bin2int(d[10:12])
    return ic
836551
def j0_2(a=1):
    """

    def lhs(x):
        return np.exp(-a*x)

    def rhs(b):
        return 1/np.sqrt(b**2 + a**2)

    return Ghosh('j0', lhs, rhs)
844865
def J(self):
        '''
        
        '''
        result = self.dr_wrt(self.x, profiler=self.profiler).copy()
        if self.profiler:
            self.profiler.harvest()
        return np.atleast_2d(result) if not sp.issparse(result) else result
610643
def log_joint(self, x):
        
        T, D = self.T, self.D_latent
        assert x.shape == (T, D)

        # prior log p(x) -- quadratic terms
        J_diag, J_upper_diag = self.sparse_J_prior
        lp = -0.5 * np.sum(x * symm_block_tridiag_matmul(J_diag, J_upper_diag, x))

        # prior log p(x) -- linear terms
        _, h_init, log_Z_init = self.info_init_params
        _, _, _, h1, h2, log_Z_dyn = self.info_dynamics_params
        lp += x[0].dot(h_init)
        lp += np.sum(x[:-1] * h1)
        lp += np.sum(x[1:] * h2)

        # prior log p(x) -- normalization constants
        lp += log_Z_init
        lp += np.sum(log_Z_dyn)

        # likelihood log p(y | x)
        lp += self.log_conditional_likelihood(x)

        return lp
1283703
def conpair_general_stats_table(self):
        

        headers = {}
        headers['concordance_concordance'] = {
            'title': 'Concordance',
            'max': 100,
            'min': 0,
            'suffix': '%',
            'format': '{:,.2f}',
            'scale': 'RdYlGn'
        }
        headers['contamination_normal'] = {
            'title': 'N Contamination',
            'description': 'Normal sample contamination level',
            'max': 100,
            'min': 0,
            'suffix': '%',
            'format': '{:,.3f}',
            'scale': 'RdYlBu-rev'
        }
        headers['contamination_tumor'] = {
            'title': 'T Contamination',
            'description': 'Tumor sample contamination level',
            'max': 100,
            'min': 0,
            'suffix': '%',
            'format': '{:,.3f}',
            'scale': 'RdYlBu-rev'
        }
        self.general_stats_addcols(self.conpair_data, headers)
316722
function jdnToEthiopic(jdn, era = JD_EPOCH_OFFSET_AMETE_MIHRET) {
  const r = mod((jdn - era), 1461);
  const n = mod(r, 365) + 365 * Math.floor(r / 1460);

  const year = 4 * Math.floor((jdn - era) / 1461) + Math.floor(r / 365) - Math.floor(r / 1460);
  const month = Math.floor(n / 30) + 1;
  const day = mod(n, 30) + 1;

  return { year, month, day };
}
1119940
def info(self):
        
        names = []
        types = []
        sizes = []
        names.append('WIDGET')
        types.append('-')
        s = 0
        sizes.append(s)
        names.append('METADATA')
        types.append('-')
        s = 0
        for obj in self._rel().values():
            s += getsizeof(obj)
        sizes.append(s)
        for name, obj in self._data().items():
            names.append(name[1:] if name.startswith('_') else name)
            types.append('.'.join((obj.__module__, obj.__class__.__name__)))
            if isinstance(obj, pd.Series):
                sizes.append(obj.memory_usage())
            else:
                sizes.append(obj.memory_usage().sum())
        inf = pd.DataFrame.from_dict({'object': names, 'type': types, 'size': sizes})
        inf.set_index('object', inplace=True)
        return inf.sort_index()
256049
def compute_lp_mhb2000(jc)
      return ((  1287104.79305   + \
              (129596581.0481    + \
              (       -0.5532    + \
              (        0.000136  + \
              (       -0.00001149) \
              * jc) * jc) * jc) * jc) % Const::TURNAS) * Const::AS2R
    rescue => e
      raise
    end
324471
def _xy_idx(self):
        

        yidx, xidx = np.indices(self._data.shape)
        return xidx[~self.mask].ravel(), yidx[~self.mask].ravel()
225549
def C(self):
        '''
        
        '''
        return Point(self.maxX, self.maxY, self.origin.z)