deed936ca0bfa5998af0225fab99c47bd2bc4b6d,mathics/builtin/linalg.py,Eigenvalues,apply,#Eigenvalues#Any#Any#,715

Before Change


        if matrix.cols != matrix.rows or matrix.cols == 0:
            return evaluation.message("Eigenvalues", "matsq", m)
        eigenvalues = matrix.eigenvals().items()
        try:
            eigenvalues = sorted(eigenvalues,
                                 key=lambda v_c: (abs(v_c[0]), -v_c[0]), 
                                 reverse=True)
        // Try to sort the results as complex numbers
        except TypeError:
            try:
                eigenvalues = sorted(eigenvalues,
                                     key=lambda v_c: -abs(v_c[0]))
            // Don"t sort the results at all
            except TypeError:
                pass

        return from_sympy([v for (v, c) in eigenvalues for _ in range(c)])


class Eigensystem(Builtin):

After Change


        // Sort the eigenvalues in an arbitrary yet deterministic order
        else:
            eigenvalues = [(from_sympy(v), c) for (v, c) in eigenvalues]
            eigenvalues.sort(key=lambda v: v[0].get_sort_key())

            eigenvalues = [v for (v, c) in eigenvalues for _ in range(c)]

        return Expression("List", *eigenvalues)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: mathics/Mathics
Commit Name: deed936ca0bfa5998af0225fab99c47bd2bc4b6d
Time: 2020-09-06
Author: pablo-escobar@riseup.net
File Name: mathics/builtin/linalg.py
Class Name: Eigenvalues
Method Name: apply


Project Name: nilmtk/nilmtk
Commit Name: 72f3f5bf50ed2d91cdcfbe2cf47120a2df8883cd
Time: 2014-11-26
Author: jack-list@xlk.org.uk
File Name: nilmtk/elecmeter.py
Class Name: ElecMeter
Method Name: _get_stat_from_cache_or_compute


Project Name: mathics/Mathics
Commit Name: d6e00edb6b5e23c0aafc7b169f7517fe39da0fd6
Time: 2020-09-06
Author: pablo-escobar@riseup.net
File Name: mathics/builtin/linalg.py
Class Name: Eigenvectors
Method Name: apply