<commit_before># -*- coding: utf-8 -*-

import numpy as np
import sympy as sy
from sympy.mpmath import mp

from pyfr.bases.base import BaseBasis, lambdify_mpf
from pyfr.quadrules import BaseLineQuadRule, BaseTriQuadRule, get_quadrule
from pyfr.syutil import lagrange_basis
from pyfr.util import lazyprop


def _bary_to_cart(b, tverts):
    return [sum(bj*ej for bj, ej in zip(b, t)) for t in zip(*tverts)]


class TriBasis(BaseBasis):
    name = 'tri'
    ndims = 2

    def __init__(self, *args, **kwargs):
        super(TriBasis, self).__init__(*args, **kwargs)

        if self.nspts:
            # Solve nspts = n*(n+1)/2 for n to get the shape point order
            self._nsptsord = (sy.sqrt(8*self.nspts + 1) - 1) / 2

            if not self._nsptsord.is_Number:
                raise ValueError('Invalid number of shape points')

    @classmethod
    def std_ele(cls, sptord):
        esqr = get_quadrule(BaseLineQuadRule, 'equi-spaced', sptord + 1)
        sele = [(p, q)
                for i, q in enumerate(esqr.points)
                for p in esqr.points[:(sptord + 1 - i)]]

        return np.array(sele, dtype=np.object)

    def _orthonormal_basis(self, ptsord):
        p, q = self._dims
        a, b = 2*(1 + p)/(1 - q) - 1, q

        # Construct an orthonormal basis within a standard triangle
        db = []
        for i in xrange(ptsord):
            tmp = sy.sqrt(2)*sy.jacobi_normalized(i, 0, 0, a)*(1 - b)**i
            tmp = tmp.ratsimp()

            for j in xrange(ptsord - i):
                poly = sy.expand(tmp*sy.jacobi_normalized(j, 2*i + 1, 0, b))
                db.append(poly.evalf(mp.dps))

        return db

    def _nodal_basis(self, pts, ptsord):
        # Obtain an orthonormal basis
        ob = self._orthonormal_basis(ptsord)

        p, q = self._dims

        # Evaluate each basis function at each point
        V = self._eval_lbasis_at(lambdify_mpf(self._dims, ob), pts)

        # Invert this matrix to obtain the expansion coefficients
        Vinv = mp.matrix(V.T)**-1

        # Each nodal basis function is a linear combination of<commit_msg>Remove some unused variables in the triangle basis.<commit_after># -*- coding: utf-8 -*-

import numpy as np
import sympy as sy
from sympy.mpmath import mp

from pyfr.bases.base import BaseBasis, lambdify_mpf
from pyfr.quadrules import BaseLineQuadRule, BaseTriQuadRule, get_quadrule
from pyfr.syutil import lagrange_basis
from pyfr.util import lazyprop


def _bary_to_cart(b, tverts):
    return [sum(bj*ej for bj, ej in zip(b, t)) for t in zip(*tverts)]


class TriBasis(BaseBasis):
    name = 'tri'
    ndims = 2

    def __init__(self, *args, **kwargs):
        super(TriBasis, self).__init__(*args, **kwargs)

        if self.nspts:
            # Solve nspts = n*(n+1)/2 for n to get the shape point order
            self._nsptsord = (sy.sqrt(8*self.nspts + 1) - 1) / 2

            if not self._nsptsord.is_Number:
                raise ValueError('Invalid number of shape points')

    @classmethod
    def std_ele(cls, sptord):
        esqr = get_quadrule(BaseLineQuadRule, 'equi-spaced', sptord + 1)
        sele = [(p, q)
                for i, q in enumerate(esqr.points)
                for p in esqr.points[:(sptord + 1 - i)]]

        return np.array(sele, dtype=np.object)

    def _orthonormal_basis(self, ptsord):
        p, q = self._dims
        a, b = 2*(1 + p)/(1 - q) - 1, q

        # Construct an orthonormal basis within a standard triangle
        db = []
        for i in xrange(ptsord):
            tmp = sy.sqrt(2)*sy.jacobi_normalized(i, 0, 0, a)*(1 - b)**i
            tmp = tmp.ratsimp()

            for j in xrange(ptsord - i):
                poly = sy.expand(tmp*sy.jacobi_normalized(j, 2*i + 1, 0, b))
                db.append(poly.evalf(mp.dps))

        return db

    def _nodal_basis(self, pts, ptsord):
        # Obtain an orthonormal basis
        ob = self._orthonormal_basis(ptsord)

        # Evaluate each basis function at each point
        V = self._eval_lbasis_at(lambdify_mpf(self._dims, ob), pts)

        # Invert this matrix to obtain the expansion coefficients
        Vinv = mp.matrix(V.T)**-1

        # Each nodal basis function is a linear combination of
{'fraction_non_alphanumeric': 0.10945273631840796, 'fraction_numerical': 0.010424070125562663, 'mean_word_length': 2.2804972804972805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4081340', 'n_tokens_mistral': 1508, 'n_tokens_neox': 1411, 'n_words': 415}