diff --git a/.launchpadlib/api.launchpad.net/cache/api.launchpad.net,devel,~deadsnakes,+archive,ubuntu,ppa,ws.op=getSigningKeyData-application,json,c76e9ed0b661c7fa5da42e8fb2da319e b/.launchpadlib/api.launchpad.net/cache/api.launchpad.net,devel,~deadsnakes,+archive,ubuntu,ppa,ws.op=getSigningKeyData-application,json,c76e9ed0b661c7fa5da42e8fb2da319e new file mode 100644 index 0000000000000000000000000000000000000000..23822351289a692e295aa0aa0b409249a892c630 --- /dev/null +++ b/.launchpadlib/api.launchpad.net/cache/api.launchpad.net,devel,~deadsnakes,+archive,ubuntu,ppa,ws.op=getSigningKeyData-application,json,c76e9ed0b661c7fa5da42e8fb2da319e @@ -0,0 +1,22 @@ +status: 200 +date: Mon, 05 Feb 2024 23:25:35 GMT +server: gunicorn +x-powered-by: Zope (www.zope.org), Python (www.python.org) +content-security-policy: frame-ancestors 'self'; +content-type: application/json +strict-transport-security: max-age=15552000 +vary: Accept,Accept-Encoding +x-content-type-options: nosniff +x-frame-options: SAMEORIGIN +x-launchpad-revision: 9643586c585856148a18782148972ae9c1179d06 +x-lazr-notifications: [] +x-xss-protection: 1; mode=block +x-vcs-revision: 9643586c585856148a18782148972ae9c1179d06 +x-request-id: 452e0c68-aa99-4bb4-abc3-237c7bb39fae +content-length: 1641 +-content-encoding: gzip +content-location: https://api.launchpad.net/devel/~deadsnakes/+archive/ubuntu/ppa?ws.op=getSigningKeyData +-varied-accept: application/json +-varied-accept-encoding: gzip, deflate + +"-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBFl8fYEBEADQmGZ6pDrwY9iH9DVlwNwTOvOZ7q7lHXPl/TLfMs1tckMc/D9a\nhsdBN9VWtMmo+RySvhkIe8X15r65TFs2HE8ft6j2e/4K472pObM1hB+ajiU/wYX2\nSyq7DBlNm6YMP5/SyQzRxqis4Ja1uUjW4Q5/Csdf5In8uMzXj5D1P7qOiP2aNa0E\nr3w6PXWRTuTihWZOsHv8npyVYDBRR6gEZbd3r86snI/7o8Bfmad3KjbxL7aOdNMw\nAqQFaNKl7Y+UJpv1CNFIf+twcOoC0se1SrsVJlAH9HNHM7XGQsPUwpNvQlcmvr+t\n1vVS2m72lk3gyShDuJpi1TifGw+DoTqu54U0k+0sZm4pnQVeiizNkefU2UqOoGlt\n4oiG9nIhSX04xRlGes3Ya0OjNI5b1xbcYoR+r0c3odI+UCw3VSZtKDX/xlH1o/82\nb8ouXeE7LA1i4DvGNj4VSvoxv4ggIznxMf+PkWXWKwRGsbAAXF52rr4FUaeaKoIU\nDkJqHXAxrB3PQslZ+ZgBEukkQZF76NkqRqP1E7FXzZZMo2eEL7vtnhSzUlanOf42\nECBoWHVoZQaRFMNbGpqlg9aWedHGyetMStS3nH1sqanr+i4I8VR/UH+ilarPTW3T\nE0apWlsH8+N3IKbRx2wgrRZNoQEuyVtvyewDFYShJB3Zxt7VCy67vKAl1QARAQAB\ntBxMYXVuY2hwYWQgUFBBIGZvciBkZWFkc25ha2VziQI4BBMBAgAiBQJZfH2BAhsD\nBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRC6aTI2anVXdvwhD/4oI3yckeKn\n9aJNNTJsyw4ydMkIAOdG+jbZsYv/rN73UVQF1RA8HC71SDmbd0Nu80koBOX+USuL\nvvhoMIsARlD5dLx5f/zaQcYWJm/BtsMF/eZ4s1xsenwW6PpXd8FpaTn1qtg/8+O9\n99R4uSetAhhyf1vSRb/8U0sgSQd38mpZZFq352UuVisXnmCThj621loQubYJ3lwU\nLSLs8wmgo4XIYH7UgdavV9dfplPh0M19RHQL3wTyQP2KRNRq1rG7/n1XzUwDyqY6\neMVhdVhvnxAGztvdFCySVzBRr/rCw6quhcYQwBqdqaXhz63np+4mlUNfd8Eu+Vas\nb/tbteF/pDu0yeFMpK4X09Cwn2kYYCpq4XujijW+iRWb4MO3G8LLi8oBAHP/k0CM\n/QvSRbbG8JDQkQDH37Efm8iE/EttJTixjKAIfyugmvEHfcrnxaMoBioa6h6McQrM\nvI8bJirxorJzOVF4kY7xXvMYwjzaDC8G0fTA8SzQRaShksR3USXZjz8vS6tZ+YNa\nmRHPoZ3Ua0bz4t2aCcu/fknVGsXcNBazNIK9WF2665Ut/b7lDbojXsUZ3PpuqOoe\nGQL9LRj7nmCI6ugoKkNp8ZXcGJ8BGw37Wep2ztyzDohXp6f/4mGgy2KYV9R4S8D5\nyBDUU6BS7Su5nhQMStfdfr4FffLmnvFC9w==\n=7hFk\n-----END PGP PUBLIC KEY BLOCK-----\n" \ No newline at end of file diff --git a/.local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/sympy.js b/.local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/sympy.js new file mode 100644 index 0000000000000000000000000000000000000000..f00b61258cd7f78937e0eab87faf71e3f2282913 --- /dev/null +++ b/.local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/sympy.js @@ -0,0 +1,750 @@ +define([ + "require", + "./sympy_functions", + "./sympy_assumptions", +], function (requirejs, sympy_functions, sympy_assumptions) { + return { + 'name' : 'SymPy', + 'sub-menu' : [ + { + 'name' : 'Setup', + 'snippet' : [ + 'from __future__ import print_function, division', + 'from sympy import *', + 'a, s, t, u, v, w, x, y, z = symbols("a, s, t, u, v, w, x, y, z")', + 'k, m, n = symbols("k, m, n", integer=True)', + 'f, g, h = symbols("f, g, h", cls=Function)', + 'init_printing()', + ], + }, + { + 'name' : 'Documentation', + 'external-link' : 'http://docs.sympy.org/latest/index.html', + }, + '---', + { + 'name' : 'Constants', + 'sub-menu' : [ + { + 'name' : '1', + 'snippet' : ['S(1)',], //'S.One',], + }, + // { + // 'name' : '0', + // 'snippet' : ['S.Zero',], + // }, + // { + // 'name' : '-1', + // 'snippet' : ['S.NegativeOne',], + // }, + { + 'name' : '1/2', + 'snippet' : ['S(1)/2',], //'S.Half',], + }, + { + 'name' : 'Rational numbers', + 'snippet' : ['Rational(3, 7)',], + }, + '---', + { + 'name' : 'Base of natural logarithm, \\(e\\)', + 'snippet' : ['E',], + }, + { + 'name' : 'Unit imaginary number, \\(i\\)', + 'snippet' : ['I',], + }, + { + 'name' : 'Geometric constant, \\(\\pi\\)', + 'snippet' : ['pi',], + }, + { + 'name' : 'Golden ratio, \\(\\phi\\)', + 'snippet' : ['GoldenRatio',], + }, + { + 'name' : 'Euler-Mascheroni constant, \\(\\gamma\\)', + 'snippet' : ['EulerGamma',], + }, + { + 'name' : 'Catalan\'s constant, \\(K\\)', + 'snippet' : ['Catalan',], + }, + '---', + { + 'name' : 'Infinity, \\(\\infty\\)', + 'snippet' : ['oo',], // 'S.Infinity' + }, + // { + // 'name' : 'Negative infinity, \\(-\\infty\\)', + // 'snippet' : ['S.NegativeInfinity',], + // }, + { + 'name' : 'Complex infinity, \\(\\tilde{\\infty}\\)', + 'snippet' : ['zoo'], //'S.ComplexInfinity',], + }, + { + 'name' : 'NaN', + 'snippet' : ['nan',], // 'S.NaN' + }, + ], + }, + sympy_functions, + { + 'name' : 'Calculus', + 'sub-menu' : [ + { + 'name' : 'Differentiate once', + 'snippet' : [ + 'expr = exp(x**2)', + 'deriv = diff(expr, x)', + ], + }, + { + 'name' : 'Differentiate multiple times', + 'snippet' : [ + 'expr = x**4', + 'deriv = diff(expr, x, 3)', + ], + }, + { + 'name' : 'Mixed partial derivatives', + 'snippet' : [ + 'expr = exp(x*y*z)', + 'deriv = diff(expr, x, y, 2, z, 4)', + ], + }, + { + 'name' : 'Finite differences', + 'snippet' : [ + 'dx0, dx1 = symbols("dx0, dx1")', + 'formula = as_finite_diff(f(x).diff(x), [x-dx0, x, x+dx1])', + ], + }, + '---', + { + 'name' : 'Indefinite integral', + 'snippet' : [ + 'integral = integrate(cos(x), x)', + ], + }, + { + 'name' : 'Definite integral', + 'snippet' : [ + 'integral = integrate(exp(-x), (x, 0, oo))', + ], + }, + { + 'name' : 'Double integral', + 'snippet' : [ + 'integral = integrate(exp(-x**2-y**2), (x, -oo, oo), (y, -oo, oo))', + ], + }, + '---', + { + 'name' : 'Limits', + 'snippet' : [ + 'lim = limit(sin(x)/x, x, 0, "+")', + ], + }, + { + 'name' : 'Series expansion', + 'snippet' : [ + 'expr = exp(sin(x))', + 'ser = series(expr, x, 0, 6)', + ], + }, + { + 'name' : 'Series expansion, removing order term', + 'snippet' : [ + 'expr = exp(sin(x))', + 'ser = series(expr, x, 0, 6).removeO()', + ], + }, + { + 'name' : 'Summations', + 'snippet' : [ + 'ell_min,ell,ell_max = symbols("ell_min,ell,ell_max", integer=True)', + 'summ = summation((2*ell + 1), (ell, ell_min, ell_max))', + ], + }, + ], + }, + + { + 'name' : 'Solvers', + 'sub-menu' : [ + { + 'name' : 'Solve for one variable', + 'snippet' : [ + 'expr = x**4 - 4*x**3 + 2*x**2 - x', + 'eqn = Eq(expr, 0)', + 'soln = solve(eqn, x)', + ], + }, + { + 'name' : 'Solve for two variables', + 'snippet' : [ + 'eqns = Eq(x + y, 4), Eq(x*y, 3)', + 'soln = solve(eqns, [x,y])', + ], + }, + { + 'name' : 'Solve differential equation', + 'snippet' : [ + 'expr = f(x).diff(x, x) + 9*f(x)', + "eqn = Eq(expr, 1) # f''(x) + 9f(x) = 1", + 'soln = dsolve(eqn, f(x))', + ], + }, + ], + }, + { + 'name' : 'Manipulating expressions', + 'sub-menu' : [ + { + 'name' : 'Simplify', + 'snippet' : [ + 'expr = (x**3 + x**2 - x - 1)/(x**2 + 2*x + 1)', + 'expr = simplify(expr)', + ], + }, + { + 'name' : 'Refine, using assumptions', + // 'snippet' : [ + // 'expr = exp(pi*I*2*x)', + // 'assumption = Q.integer(x) & Q.integer(y)', + // 'expr = refine(expr, assumption)', + // ], + 'sub-menu' : [ + { + 'name' : 'Refine', + 'snippet' : [ + 'expr = exp(pi*I*2*(x+y))', + 'assumption = Q.integer(x) & Q.integer(y)', + 'expr = refine(expr, assumption)', + ], + }, + { + 'name' : 'Refine in context manager', + 'snippet' : [ + 'expr = exp(pi*I*2*(x+y))', + 'with assuming(Q.integer(x) & Q.integer(y)):', + ' expr = refine(expr)', + ], + }, + sympy_assumptions, + ], + }, + { + 'name' : 'Expansion', + 'sub-menu' : [ + { + 'name' : 'Expand basic expressions', + 'snippet' : [ + 'expr = (x + 2)*(x - 3)', + 'expr = expand(expr)', + ], + }, + '---', + { + 'name' : 'Expand, including complex parts', + 'snippet' : [ + 'expr = cos(x)', + 'expr = expand(expr, complex=True)', + ], + }, + { + 'name' : 'Expand, including functions', + 'snippet' : [ + 'expr = gamma(x+3)', + 'expr = expand(expr, func=True)', + ], + }, + { + 'name' : 'Expand, including trig', + 'snippet' : [ + 'expr = sin(x+y)*(x+y)', + 'expr = expand(expr, trig=True)', + ], + }, + '---', + { + 'name' : 'Expand only real and imaginary parts', + 'snippet' : [ + 'expand_complex(x)', + ], + }, + { + 'name' : 'Expand only functions', + 'snippet' : [ + 'expr = gamma(x + 2)', + 'expr = expand_func(expr)', + ], + }, + { + 'name' : 'Expand only hypergeometric functions', + 'snippet' : [ + 'expr = hyper([1,1], [1,], z) + gamma(z)', + 'expr = hyperexpand(expr)', + ], + }, + { + 'name' : 'Expand only logarithms', + 'snippet' : [ + 'a, b = symbols("a, b", positive=True)', + 'expr = log(a**2*b)', + 'expr = expand_log(expr)', + ], + }, + { + 'name' : 'Expand only multiplication over addition', + 'snippet' : [ + 'expr = y*(x + z)', + 'expr = expand_mul(expr)', + ], + }, + { + 'name' : 'Expand only multinomials', + 'snippet' : [ + 'expr = (x + y + z)**3', + 'expr = expand_multinomial(expr)', + ], + }, + { + 'name' : 'Expand only powers of multiplied bases', + 'snippet' : [ + 'a, b = symbols("a, b", positive=True)', + 'expr = (a*b)**z', + 'expr = expand_power_base(expr)', + ], + }, + { + 'name' : 'Expand only addition in exponents', + 'snippet' : [ + 'expr = x**(y + 2)', + 'expr = expand_power_exp(expr)', + ], + }, + { + 'name' : 'Expand only trig', + 'snippet' : [ + 'expr = sin(x+y)*(x+y)', + 'expr = expand_trig(expr)', + ], + }, + ], + }, + { + 'name' : 'Collect terms', + 'sub-menu' : [ + { + 'name' : 'Collect as coefficients of one factor', + 'snippet' : [ + 'expr = y*x**2 + z*x**2 + t*x - 2*x + 3', + 'expr = collect(expr, x)', + ], + }, + { + 'name' : 'Collect as coefficients of multiple factors', + 'snippet' : [ + 'expr = x**2 + y*x**2 + x*y + y + z*y', + 'expr = collect(expr, [x, y])', + ], + }, + { + 'name' : 'Collect with respect to wild card', + 'snippet' : [ + 'w = Wild("w")', + 'expr = z*x**y - t*z**y', + 'expr = collect(expr, w**y)', + ], + }, + { + 'name' : 'Collect and apply function to each coefficient', + 'snippet' : [ + 'expr = expand((x + y + 1)**3)', + 'expr = collect(expr, x, factor)', + ], + }, + { + 'name' : 'Recursively collect', + 'snippet' : [ + 'expr = (x**2*y + x*y + x + y)/(x*y + z*y)', + 'expr = rcollect(expr, y)', + ], + }, + { + 'name' : 'Collect constants', + 'snippet' : [ + 'expr = sqrt(3)*x + sqrt(7)*x + sqrt(3) + sqrt(7)', + 'expr = collect_const(expr)', + ], + }, + ], + }, + { + 'name' : 'Substitutions and replacements', + 'sub-menu' : [ + { + 'name' : 'Substitute one subexpression for another', + 'snippet' : [ + 'expr = 1 + x*y', + 'expr = expr.subs(x, pi)', + ], + }, + { + 'name' : 'Substitute multiple subexpressions successively', + 'snippet' : [ + 'expr = (x+y)/y', + 'substitutions = [(x+y, y), (y, x+y)]', + 'expr = expr.subs(substitutions)', + ], + }, + { + 'name' : 'Substitute multiple subexpressions simultaneously', + 'snippet' : [ + 'expr = (x+y)/y', + 'substitutions = [(x+y, y), (y, x+y)]', + 'expr = expr.subs(substitutions, simultaneous=True)', + ], + }, + '---', + { + 'name' : 'Replace one object with another', + 'snippet' : [ + 'expr = 1 + x*y', + 'expr = expr.replace(x, pi)', + ], + }, + { + 'name' : 'Replace one object with some function of its arguments', + 'snippet' : [ + 'expr = log(sin(x)) + tan(sin(x**2))', + 'expr = expr.replace(sin, lambda arg: sin(2*arg))', + ], + }, + { + 'name' : 'Replace a pattern with an object', + 'snippet' : [ + '# Note: `exclude=` specifies that the Wild cannot match any item in the list', + 'a, b = symbols("a, b", cls=Wild, exclude=[x,y])', + 'expr = 2*x + y + z', + 'wild = a*x + b', + 'replacement = b - a', + '# Note: `exact=True` demands that all Wilds have nonzero matches', + 'expr = expr.replace(wild, replacement, exact=True)', + ], + }, + { + 'name' : 'Replace a pattern with some function of that object', + 'snippet' : [ + 'a = symbols("a", cls=Wild, exclude=[])', + 'expr = log(sin(x)) + tan(sin(x**2))', + 'expr.replace(sin(a), lambda a: sin(2*a))', + ], + }, + { + 'name' : 'Replace anything with some function of that thing', + 'snippet' : [ + 'g = 2*sin(x**3)', + 'g.replace(lambda expr: expr.is_Function, lambda expr: expr**2)', + ], + }, + '---', + { + 'name' : 'Replace exact subexpressions', + 'snippet' : [ + 'expr = x**2 + x**4', + 'replacements = {x**2: y}', + 'expr = expr.xreplace(replacements)', + ], + }, + // { + // 'name' : 'rewrite', + // 'snippet' : [ + // 'expr = tan(x)', + // 'expr = expr.rewrite(sin)', + // ], + // }, + ], + }, + { + 'name' : 'Evaluation', + 'sub-menu' : [ + { + 'name' : 'Evaluate numerically to arbitrary precision', + 'snippet' : [ + 'expr = x * sqrt(8)', + 'precision = 50', + 'val = N(expr, precision, subs={x:2.4})', + ], + }, + { + 'name' : 'Evaluate numerically to python float', + 'snippet' : [ + 'expr = x * sqrt(8)', + 'val = float(expr.subs([(x, 2.4)]))', + ], + }, + { + 'name' : 'Create numpy function for efficient evaluation', + 'snippet' : [ + 'import numpy', + 'a = numpy.arange(10)', + 'expr = sin(x)', + 'f = lambdify(x, expr, "numpy")', + 'vals = f(a)', + ], + }, + ], + }, + '---', + { + 'name' : 'Polynomials', + 'sub-menu' : [ + { + 'name' : 'Factor polynomial over rationals', + 'snippet' : [ + 'expr = x**3 - x**2 + x - 1', + 'expr = factor(expr)', + ], + }, + { + 'name' : 'Collect common powers of a term', + 'snippet' : [ + 'expr = x*y + x - 3 + 2*x**2 - z*x**2 + x**3', + 'expr = collect(expr, x)', + ], + }, + { + 'name' : 'Extract coefficient of a term', + 'snippet' : [ + 'expr = 3+2*x+4*x**2', + 'expr = expr.coeff(x**2)', + ], + }, + ], + }, + { + 'name' : 'Rational functions', + 'sub-menu' : [ + { + 'name' : 'Cancel', + 'snippet' : [ + 'expr = (x**2 + 2*x + 1)/(x**2 + x)', + 'expr = cancel(expr)', + ], + }, + { + 'name' : 'Decompose into partial fractions', + 'snippet' : [ + 'expr = (4*x**3 + 21*x**2 + 10*x + 12)/(x**4 + 5*x**3 + 5*x**2 + 4*x)', + 'expr = apart(expr)', + ], + }, + { + 'name' : 'Join over common denominator', + 'snippet' : [ + 'expr = 1/x + 1/y', + 'expr = ratsimp(expr)', + ], + }, + { + 'name' : 'Remove square roots from denominator', + 'snippet' : [ + 'expr = 1/(1+I)', + 'expr = radsimp(expr)', + ], + }, + ], + }, + { + 'name' : 'Powers', + 'sub-menu' : [ + { + 'name' : 'Important caveats', + 'external-link' : 'http://docs.sympy.org/dev/tutorial/simplification.html#powers' + }, + '---', + // { + // 'name' : 'Setup for these snippets', + // 'snippet' : [ + // 'x, y = symbols("x, y", positive=True)', + // 'a, b = symbols("a, b", real=True)', + // 'z, t, c = symbols("z, t, c")', + // ], + // }, + { + 'name' : 'Simplify powers for general arguments', + 'snippet' : [ + 'powsimp(x**y * x**z)', + ], + }, + { + 'name' : 'Simplify powers, forcing assumptions', + 'snippet' : [ + 'powsimp(x**y * x**z, force=True)', + ], + }, + { + 'name' : 'Expand powers by exponent for general arguments', + 'snippet' : [ + 'expand_power_exp(x**(y + z))', + ], + }, + { + 'name' : 'Expand powers of multiplied bases, forcing assumptions', + 'snippet' : [ + 'expand_power_base((x*y)**z, force=True)', + ], + }, + { + 'name' : 'Collect exponents on powers for general arguments', + 'snippet' : [ + 'powdenest((x**y)**z)', + ], + }, + { + 'name' : 'Collect exponents on powers, forcing assumptions', + 'snippet' : [ + 'powdenest((x**y)**z, force=True)', + ], + }, + { + 'name' : 'Collect exponents on powers, forcing assumptions and polar simplifications', + 'snippet' : [ + 'powdenest((z**a)**b, force=True, polar=True)', + ], + }, + { + 'name' : 'Denest square-roots', + 'snippet' : [ + 'sqrtdenest(sqrt(5 + 2*sqrt(6)))', + ], + }, + ], + }, + { + 'name' : 'Exponentials and Logarithms', + 'sub-menu' : [ + { + 'name' : 'Important caveats', + 'external-link' : 'http://docs.sympy.org/dev/tutorial/simplification.html#exponentials-and-logarithms' + }, + '---', + // { + // 'name' : 'Setup for these snippets', + // 'snippet' : [ + // 'x, y = symbols("x, y", positive=True)', + // 'n = symbols("n", real=True)', + // ], + // }, + { + 'name' : 'Combine exponentials', + 'snippet' : [ + 'powsimp(exp(y) * exp(z))', + ], + }, + { + 'name' : 'Expand logarithms for general arguments', + 'snippet' : [ + 'expand_log(log(x*y))', + ], + }, + { + 'name' : 'Expand logarithms, forcing assumptions', + 'snippet' : [ + 'expand_log(log(z**2), force=True)', + ], + }, + { + 'name' : 'Combine logarithms for general arguments', + 'snippet' : [ + 'logcombine(log(x) + z*log(y))', + ], + }, + { + 'name' : 'Combine logarithms, forcing assumptions', + 'snippet' : [ + 'logcombine(log(x) + z*log(y))', + ], + }, + { + 'name' : 'Simplification, possibly to trig functions', + 'snippet' : [ + 'exptrigsimp(exp(z) + exp(-z))', + ], + }, + ], + }, + { + 'name' : 'Trigonometric functions', + 'sub-menu' : [ + { + 'name' : 'Expansion', + 'snippet' : [ + 'expr = sin(x + y)', + 'expr = expand(expr, trig=True)', + ], + }, + { + 'name' : 'Simplification', + 'snippet' : [ + 'expr = sin(x)**4 - 2*cos(x)**2*sin(x)**2 + cos(x)**4', + 'expr = trigsimp(expr)', + ], + }, + { + 'name' : 'Simplification, possibly to exponentials', + 'snippet' : [ + 'expr = cosh(z) - sinh(z)', + 'expr = exptrigsimp(expr)', + ], + }, + ], + }, + { + 'name' : 'Miscellaneous', + 'sub-menu' : [ + { + 'name' : 'Simplify factorials', + 'snippet' : [ + 'expr = factorial(n)/factorial(n - 3)', + 'expr = combsimp(expr)', + ], + }, + { + 'name' : 'Simplify binomials', + 'snippet' : [ + 'expr = binomial(n+1, k+1)/binomial(n, k)', + 'expr = combsimp(expr)', + ], + }, + { + 'name' : 'Simplify numerical expressions to exact values', + 'snippet' : [ + 'nsimplify(4.0/(1+sqrt(5.0)), constants=[GoldenRatio,])', + ], + }, + { + 'name' : 'Expand gamma functions', + 'snippet' : [ + 'expr = gamma(z+3)', + 'expr = expand_func(expr)', + ], + }, + { + 'name' : 'Simplify Bessel functions', + 'snippet' : [ + 'expr = besselj(x, z*polar_lift(-1))', + 'expr = besselsimp(expr)', + ], + }, + ], + }, + ], + }, + ], + }; +}); diff --git a/.local/share/jupyter/nbextensions/toc2/toc2.js b/.local/share/jupyter/nbextensions/toc2/toc2.js new file mode 100644 index 0000000000000000000000000000000000000000..719fd4cc30490c28c19aea816a5eaf2f8ba9bc1b --- /dev/null +++ b/.local/share/jupyter/nbextensions/toc2/toc2.js @@ -0,0 +1,826 @@ +(requirejs.specified('base/js/namespace') ? define : function(deps, callback) { + "use strict"; + // if here, the Jupyter namespace hasn't been specified to be loaded. + // This means that we're probably embedded in a page, so we need to make + // our definition with a specific module name + return define('nbextensions/toc2/toc2', deps, callback); +})(['jquery', 'require'], function($, requirejs) { + "use strict"; + + var IPython; + var events; + var liveNotebook = false; + var all_headers = $("#notebook").find(":header"); + + // default values for system-wide configurable parameters + var default_cfg = { + colors: { + hover_highlight: '#DAA520', + selected_highlight: '#FFD700', + running_highlight: '#FF0000', + wrapper_background: '#FFFFFF', + sidebar_border: '#EEEEEE', + navigate_text: '#333333', + navigate_num: '#000000', + on_scroll: '#2447f0', + }, + collapse_to_match_collapsible_headings: false, + markTocItemOnScroll: true, + moveMenuLeft: true, + navigate_menu: true, + threshold: 4, + widenNotebook: false, + }; + // default values for per-notebook configurable parameters + var metadata_settings = { + nav_menu: {}, + number_sections: true, + sideBar: true, + skip_h1_title: false, + base_numbering: 1, + title_cell: 'Table of Contents', + title_sidebar: 'Contents', + toc_cell: false, + toc_position: {}, + toc_section_display: true, + toc_window_display: false, + }; + $.extend(true, default_cfg, metadata_settings); + + /** + * Read our config from server config & notebook metadata + * This function should only be called when both: + * 1. the notebook (and its metadata) has fully loaded + * AND + * 2. Jupyter.notebook.config.loaded has resolved + */ + var read_config = function () { + var cfg = default_cfg; + + if (!liveNotebook) { + return cfg; + } + + // config may be specified at system level or at document level. + // first, update defaults with config loaded from server + $.extend(true, cfg, IPython.notebook.config.data.toc2); + // ensure notebook metadata has toc object, cache old values + var md = IPython.notebook.metadata.toc || {}; + // reset notebook metadata to remove old values + IPython.notebook.metadata.toc = {}; + // then update cfg with any found in current notebook metadata + // and save in nb metadata (then can be modified per document) + Object.keys(metadata_settings).forEach(function (key) { + cfg[key] = IPython.notebook.metadata.toc[key] = (md.hasOwnProperty(key) ? md : cfg)[key]; + }); + return cfg; + }; + + // globally-used status variables: + var rendering_toc_cell = false; + // toc_position default also serves as the defaults for a non-live notebook + var toc_position = {height: 'calc(100% - 180px)', width: '20%', left: '10px', top: '150px'}; + + try { + // this will work in a live notebook because nbextensions & custom.js + // are loaded by/after notebook.js, which requires base/js/namespace + IPython = requirejs('base/js/namespace'); + events = requirejs('base/js/events'); + liveNotebook = true; + } catch (err) { + // We *are* theoretically in a non-live notebook + console.log('[toc2] working in non-live notebook'); //, err); + // in non-live notebook, there's no event structure, so we make our own + if (window.events === undefined) { + var Events = function() {}; + window.events = $([new Events()]); + } + events = window.events; + } + var Jupyter = IPython; + + var setMd = function(key, value) { + if (liveNotebook) { + var md = IPython.notebook.metadata.toc; + if (md === undefined) { + md = IPython.notebook.metadata.toc = {}; + } + var old_val = md[key]; + md[key] = value; + if (typeof _ !== undefined ? !_.isEqual(value, old_val) : old_val != value) { + IPython.notebook.set_dirty(); + } + } + return value; + }; + + function incr_lbl(ary, h_idx) { //increment heading label w/ h_idx (zero based) + ary[h_idx]++; + for (var j = h_idx + 1; j < ary.length; j++) { + ary[j] = 0; + } + return ary.slice(0, h_idx + 1); + } + + function removeMathJaxPreview(elt) { + elt.children('.anchor-link, .toc-mod-link').remove(); + elt.find("script[type='math/tex']").each( + function(i, e) { + $(e).replaceWith('$' + $(e).text() + '$') + }) + elt.find("span.MathJax_Preview").remove() + elt.find("span.MathJax").remove() + return elt + } + + var callback_toc_link_click = function(evt) { + // workaround for https://github.com/jupyter/notebook/issues/699 + setTimeout(function() { + $.ajax() + }, 100); + evt.preventDefault(); + // Each time a link is clicked in the toc, save the current position and target in the history + var currentSection = $('#toc .highlight_on_scroll a').data('tocModifiedId') + if (window.history.state != null){ + if (window.history.state.back != currentSection) { + window.history.pushState({'back':currentSection},"",'') + } + } + var trg_id = $(evt.currentTarget).attr('data-toc-modified-id'); + window.history.pushState({'back':trg_id},"",''); + window.history.lastjump = trg_id; + + // use native scrollIntoView method with semi-unique id + // ! browser native click does't follow links on all browsers + document.getElementById(trg_id).scrollIntoView(true) + if (liveNotebook) { + // use native document method as jquery won't cope with characters + // like . in an id + var cell = $(document.getElementById(trg_id)).closest('.cell').data('cell'); + Jupyter.notebook.select(Jupyter.notebook.find_cell_index(cell)); + highlight_toc_item("toc_link_click", { + cell: cell + }); + } + }; + + // + window.addEventListener('popstate', + function(e) { + if (e.state != null && e.state.back != null) { + var back_id = e.state.back; + document.getElementById(back_id).scrollIntoView(true) + if (liveNotebook) { + var cell = $(document.getElementById(back_id)).closest('.cell').data('cell'); + Jupyter.notebook.select(Jupyter.notebook.find_cell_index(cell)); + highlight_toc_item("toc_link_click", { + cell: cell + }); + } + } + }); + + var make_link = function(h, toc_mod_id) { + var a = $('') + .attr({ + 'href': h.find('.anchor-link').attr('href'), + 'data-toc-modified-id': toc_mod_id, + }); + // get the text *excluding* the link text, whatever it may be + var hclone = h.clone(); + hclone = removeMathJaxPreview(hclone); + a.html(hclone.html()); + a.on('click', callback_toc_link_click); + return a; + }; + + function highlight_toc_item(evt, data) { + var c = $(data.cell.element); + if (c.length < 1) { + return; + } + var trg_id = c.find('.toc-mod-link').attr('id') || + c.prevAll().find('.toc-mod-link').eq(-1).attr('id'); + var highlighted_item = $(); + if (trg_id !== undefined) { + highlighted_item = $('.toc a').filter(function(idx, elt) { + return $(elt).attr('data-toc-modified-id') === trg_id; + }); + } + if (evt.type === 'execute') { + // remove the selected class and add execute class + // if the cell is selected again, it will be highligted as selected+running + highlighted_item.removeClass('toc-item-highlight-select').addClass('toc-item-highlight-execute'); + } else { + $('.toc .toc-item-highlight-select').removeClass('toc-item-highlight-select'); + highlighted_item.addClass('toc-item-highlight-select'); + } + } + + var create_navigate_menu = function(cfg, callback) { + $('#kernel_menu').parent().after('