nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: josdejong/mathjs
Pull request #324 (2015-04-15 12:03:38)

Fix bug that was introduced by the restructuring of the LaTeX code
This fixes an exception caused by symbols with indices. ( including a test that covers this case )


Patch:
diff --git a/HISTORY.md b/HISTORY.md
index 77dc5957b..aa5b20ba8 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -1,11 +1,6 @@
 # History
 
 
-## not yet released, version 1.5.3-SNAPSHOT
-
-- Improvements in `toTex`. Thanks @FSMaxB.
-
-
 ## 2015-04-09, version 1.5.2
 
 - Fixed #313: parsed functions did not handle recursive calls correctly.
diff --git a/lib/function/probability/gamma.js b/lib/function/probability/gamma.js
index e54e10a05..87d771464 100644
--- a/lib/function/probability/gamma.js
+++ b/lib/function/probability/gamma.js
@@ -33,7 +33,7 @@ module.exports = function (math, config) {
    *
    *    combinations, factorial, permutations
    *
-   * @param {Number | Array | Matrix | Boolean | null} n   A real or complex number
+   * @param {Number | Array | Matrix | Boolean | null} n   An integer number
    * @return {Number | Array | Matrix}    The gamma of `n`
    */
   math.gamma = function gamma (n) {
diff --git a/lib/util/latex.js b/lib/util/latex.js
index cb28b380e..ee5ab09b9 100644
--- a/lib/util/latex.js
+++ b/lib/util/latex.js
@@ -320,8 +320,8 @@ exports.toSymbol = function (name) {
   else if (name.indexOf('_') !== -1) {
     //symbol with index (eg. alpha_1)
     var index = name.indexOf('_');
-    return '{' + toSymbol(name.substring(0, index)) + '}_{'
-      + toSymbol(name.substring(index + 1)) + '}';
+    return '{' + exports.toSymbol(name.substring(0, index)) + '}_{'
+      + exports.toSymbol(name.substring(index + 1)) + '}';
   }
   return '\\mathrm{' + name + '}';
 };


Test patch:
diff --git a/test/util/latex.test.js b/test/util/latex.test.js
new file mode 100644
index 000000000..feddfb61f
--- /dev/null
+++ b/test/util/latex.test.js
@@ -0,0 +1,8 @@
+var assert = require('assert'),
+    latex = require('../../lib/util/latex');
+
+describe('util.latex', function() {
+  it('should convert symbols with indices', function () {
+    assert.equal(latex.toSymbol('alpha_1'), '{{\\alpha}}_{\\mathrm{1}}');
+  });
+});