Skip to content

Commit 4eb9445

Browse files
Rename Latexise to Latexize, so the library has one spelling (#840) (#842)
Stringize and Latexise do the same kind of thing, are declared next to each other and are overridden per node in the same files -- one American, one British. Everything else public is -ize: Stringize, Factorize, Serialize, Deserialize. Renamed across every surface the name reaches: the method and its 61 overrides, ILatexiseable, the string extension, MathS.Latex's parameter, the native entry point entity_latexise, the C++ Entity::Latexise, the F# latexise, and the notebook extension. No forwarding member is left behind. Sources/Samples/SampleNet5 keeps the old name deliberately: it compiles against PackageReference AngouriMath 1.3.0, not against this source. MathS.Quantum.Factorise keeps its spelling; renaming it to Factorize would give the library two unrelated public Factorize methods. It needs a distinguishing name instead, which is #843. Also corrects a claim in BREAKING-CHANGES.md that nothing parses LaTeX, and regenerates the PublicApi.txt baseline that #841 introduced.
1 parent 0820a2f commit 4eb9445

38 files changed

Lines changed: 332 additions & 292 deletions

AGENTS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ printed with `if` came back as a product with `if` read as an undeclared variabl
9292
usual notation is not in the grammar, print the function call the parser does have.
9393
`StringizeRoundTripTest` is where that is enforced; add to it when you add a node.
9494

95-
**`Latexise` has a round trip too, and it is enforced in someone else's repository.**
95+
**`Latexize` has a round trip too, and it is enforced in someone else's repository.**
9696
[CSharpMath.Evaluation](https://github.com/verybadcat/CSharpMath/blob/master/CSharpMath.Evaluation/Evaluation.cs)
9797
reads LaTeX back into an `Entity`, and says so in its own source: *"CSharpMath must handle all LaTeX
98-
coming from AngouriMath or a bug is present!"* So a change to what `Latexise` emits — a new node, a
98+
coming from AngouriMath or a bug is present!"* So a change to what `Latexize` emits — a new node, a
9999
different command, a changed bracketing — can break a downstream project, and no test here will say
100100
so.
101101

102102
That is weaker than `Stringize`'s contract, not stronger. `StringizeRoundTripTest` fails in this
103103
repository the moment the printed form stops parsing; the LaTeX contract fails as a bug report from
104-
someone else, months later. When you change `Latexise` output, check it against CSharpMath and open
104+
someone else, months later. When you change `Latexize` output, check it against CSharpMath and open
105105
a PR there as well ([#822](https://github.com/asc-community/AngouriMath/issues/822)).
106106

107107
The syntax the parser accepts is written down in
@@ -217,7 +217,7 @@ the *basis* is, and it is made differently on purpose:
217217

218218
| | basis | why |
219219
|---|---|---|
220-
| quantum | `Entity`-backed | the state is then an ordinary expression, so `Simplify`, `Substitute`, `Latexise` and the rest work on it without anything being taught about quantum |
220+
| quantum | `Entity`-backed | the state is then an ordinary expression, so `Simplify`, `Substitute`, `Latexize` and the rest work on it without anything being taught about quantum |
221221
| polynomials, series | a generic `TBasis` struct | exponent vectors never enter the expression tree, and the internal layers stay allocation-free and type-safe |
222222

223223
One generic spine, instantiated twice. That is less tidy than picking a single answer, and the

BREAKING-CHANGES.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ read first.
5252
| loud | `floor(x)`, `ceil(x)`, `ceiling(x)` | `UnrecognizedFunctionParseException` | the functions |
5353
| loud | `round(x)`, `min(a, b)`, `max(a, b)`, `gcd(a, b)` | `UnrecognizedFunctionParseException` | the functions |
5454
| loud | 28 members deprecated since 1.x | obsolete but present | removed |
55+
| loud | `Latexise`, `ILatexiseable`, `entity_latexise` | the British spelling | `Latexize`, `ILatexizeable`, `entity_latexize` |
5556
| loud | the target frameworks | `net7.0;netstandard2.0` | `netstandard2.0;net8.0;net10.0` |
5657
| **silent** | `abs(x) = c` for a negative `c` | a set of non-solutions | the empty set |
5758

@@ -118,6 +119,42 @@ right answer. Code written against the old names was wrong in the same way.
118119
[#632](https://github.com/asc-community/AngouriMath/issues/632), PR
119120
[#664](https://github.com/asc-community/AngouriMath/pull/664).
120121

122+
### `Latexise` is now `Latexize`
123+
124+
The library serialises a node to text two ways, and spelled them in two languages:
125+
126+
| | was | is |
127+
|---|---|---|
128+
| the method | `Latexise()` | `Latexize()` |
129+
| the interface | `ILatexiseable` | `ILatexizeable` |
130+
| the string extension | `"x + 1".Latexise()` | `"x + 1".Latexize()` |
131+
| the C# helper | `MathS.Latex(ILatexiseable)` | `MathS.Latex(ILatexizeable)` |
132+
| the native entry point | `entity_latexise` | `entity_latexize` |
133+
| the C++ method | `Entity::Latexise()` | `Entity::Latexize()` |
134+
| the F# function | `latexise` | `latexize` |
135+
136+
Everything else in the public surface is `-ize``Stringize`, `Factorize`, `Serialize`,
137+
`Deserialize` — so `Latexise` and its interface were the only members a caller had to remember the
138+
other spelling for. `Stringize` and `Latexise` do the same kind of thing and sit next to each other
139+
in every file that has either, which is what made the split spelling costly rather than merely
140+
untidy.
141+
142+
**What breaks.** Every call, every override, and every implementation of the interface. There is no
143+
forwarding member: this release is the one that removed 28 members that accumulated as forwarders,
144+
so adding a permanent one here would undo that on the same day. The compiler reports each site, and
145+
the fix is mechanical.
146+
147+
`MathS.Quantum.Factorise` keeps its spelling for now. Renaming it to `Factorize` would give the
148+
library two public `Factorize` methods doing unrelated things — expression factoring on `Entity`,
149+
tensor factorisation on a quantum state — which is a worse outcome than the inconsistency. It wants
150+
a distinguishing name rather than a spelling change, and that is not decided here.
151+
152+
**Downstream.** [`CSharpMath.Evaluation`](https://github.com/verybadcat/CSharpMath) reads LaTeX
153+
produced here back into an `Entity` and calls this method. It is unaffected until it moves to 2.0,
154+
at which point it needs the new name.
155+
156+
[#840](https://github.com/asc-community/AngouriMath/issues/840).
157+
121158
---
122159

123160
## Parsing
@@ -312,7 +349,10 @@ This one is worth reading twice if you parse printed output, because the misread
312349
ordinary number: every root of a trigonometric equation prints through this path, and
313350
`cos(x)^2 + sin(x) = 0` returns roots that are exact as entities and were not as text.
314351

315-
`Latexise` is under no such obligation, since nothing parses LaTeX, and is unaffected.
352+
`Latexize` is unaffected by this change. Its output is under a weaker obligation, not none:
353+
nothing in this repository parses LaTeX back, but [`CSharpMath.Evaluation`](https://github.com/verybadcat/CSharpMath)
354+
does, so a change to what it emits can break a downstream project with no test here to say so
355+
([#822](https://github.com/asc-community/AngouriMath/issues/822)).
316356

317357
The syntax the parser accepts is now written down in
318358
[`Sources/AngouriMath/Docs/Usage/Syntax.md`](Sources/AngouriMath/Docs/Usage/Syntax.md).

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ Console.WriteLine("x^2 + x + a".SolveEquation("x"));
264264
Under developing now and forever (always available)
265265
```cs
266266
Entity expr = "(sin(x)^2 - sin(x) + a)(b - x)((-3) * x + 2 + 3 * x ^ 2 + (x + (-3)) * x ^ 3)";
267-
Console.WriteLine(expr.SolveEquation("x").Latexise());
267+
Console.WriteLine(expr.SolveEquation("x").Latexize());
268268
```
269269
<img src="https://render.githubusercontent.com/render/math?math=\left\{-\left(-\arcsin\left(\frac{1-\sqrt{1-4\times a}}{2}\right)-2\times \pi\times n_{1}\right),-\left(-\pi--\arcsin\left(\frac{1-\sqrt{1-4\times a}}{2}\right)-2\times \pi\times n_{1}\right),-\left(-\arcsin\left(\frac{1%2B\sqrt{1-4\times a}}{2}\right)-2\times \pi\times n_{1}\right),-\left(-\pi--\arcsin\left(\frac{1%2B\sqrt{1-4\times a}}{2}\right)-2\times \pi\times n_{1}\right),\frac{-b}{-1},-i,i,1,2\right\}">
270270

@@ -297,7 +297,7 @@ var system = MathS.Equations(
297297
"cos(x2 + 1)^2 + 3y",
298298
"y * (-1) + 4cos(x2 + 1)"
299299
);
300-
Console.WriteLine(system.Latexise());
300+
Console.WriteLine(system.Latexize());
301301
var solutions = system.Solve("x", "y");
302302
Console.WriteLine(solutions);
303303
```
@@ -334,10 +334,10 @@ WriteLine("x^2 + a x".Integrate("x").InnerSimplified);
334334

335335
There are four types of sets:
336336
```cs
337-
WriteLine("{ 1, 2 }".Latexise());
338-
WriteLine("[3; +oo)".Latexise());
339-
WriteLine("RR".Latexise());
340-
WriteLine("{ x : x^8 + a x < 0 }".Latexise());
337+
WriteLine("{ 1, 2 }".Latexize());
338+
WriteLine("[3; +oo)".Latexize());
339+
WriteLine("RR".Latexize());
340+
WriteLine("{ x : x^8 + a x < 0 }".Latexize());
341341
```
342342

343343
<img src="https://render.githubusercontent.com/render/math?math=\left\{ 1, 2 \right\}">
@@ -347,9 +347,9 @@ WriteLine("{ x : x^8 + a x < 0 }".Latexise());
347347

348348
And there operators:
349349
```cs
350-
WriteLine(@"A \/ B".Latexise());
351-
WriteLine(@"A /\ B".Latexise());
352-
WriteLine(@"A \ B".Latexise());
350+
WriteLine(@"A \/ B".Latexize());
351+
WriteLine(@"A /\ B".Latexize());
352+
WriteLine(@"A \ B".Latexize());
353353
```
354354

355355
<img src="https://render.githubusercontent.com/render/math?math=A\cup B">
@@ -363,7 +363,7 @@ WriteLine(@"A \ B".Latexise());
363363
You can build LaTeX with AngouriMath:
364364
```cs
365365
var expr = "x ^ y + sqrt(x) + integral(sqrt(x) / a, x, 1) + derive(sqrt(x) / a, x, 1) + limit(sqrt(x) / a, x, +oo)";
366-
Console.WriteLine(expr.Latexise());
366+
Console.WriteLine(expr.Latexize());
367367
>>> {x}^{y}+\sqrt{x}+\int \left[\frac{\sqrt{x}}{a}\right] dx+\frac{d\left[\frac{\sqrt{x}}{a}\right]}{dx}+\lim_{x\to \infty } \left[\frac{\sqrt{x}}{a}\right]
368368
```
369369
<img src="https://render.githubusercontent.com/render/math?math={x}^{y}%2B\sqrt{x}%2B\int\left[\frac{\sqrt{x}}{a}\right]dx%2B\frac{d\left[\frac{\sqrt{x}}{a}\right]}{dx}%2B\lim_{x\to\infty}\left[\frac{\sqrt{x}}{a}\right]">

Sources/AngouriMath/Convenience/AngouriMathExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public static Complex ToNumber(this NumericsComplex complex)
279279
/// Builds a LaTeX code from an expression
280280
/// </summary>
281281
/// <returns>A <see cref="string"/> which can be rendered into pretty output</returns>
282-
public static string Latexise(this string str) => str.ToEntity().Latexise();
282+
public static string Latexize(this string str) => str.ToEntity().Latexize();
283283

284284
/// <summary>
285285
/// Compiles an expression into a special compiled code that runs via

Sources/AngouriMath/Convenience/MathS.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3162,7 +3162,7 @@ public static IEnumerable<Entity> TaylorTerms(Entity expr, params (Variable expr
31623162
/// var inCyrillic = Var("Абаваола");
31633163
/// </code>
31643164
/// Underscore "_" allows indexing. Greek letter names (e. g.
3165-
/// "alpha") will be latexised as Greek letter (but other than that,
3165+
/// "alpha") will be latexized as Greek letter (but other than that,
31663166
/// will appear as "alpha" in other places).
31673167
/// </example>
31683168
public static Variable Var(string name) => name;
@@ -3184,7 +3184,7 @@ public static IEnumerable<Entity> TaylorTerms(Entity expr, params (Variable expr
31843184
/// var inCyrillic = Var("Абаваола");
31853185
/// </code>
31863186
/// Underscore "_" allows indexing. Greek letter names (e. g.
3187-
/// "alpha") will be latexised as Greek letter (but other than that,
3187+
/// "alpha") will be latexized as Greek letter (but other than that,
31883188
/// will appear as "alpha" in other places).
31893189
/// </example>
31903190
public static (Variable, Variable) Var(string name1, string name2) => (Var(name1), Var(name2));
@@ -3206,7 +3206,7 @@ public static IEnumerable<Entity> TaylorTerms(Entity expr, params (Variable expr
32063206
/// var inCyrillic = Var("Абаваола");
32073207
/// </code>
32083208
/// Underscore "_" allows indexing. Greek letter names (e. g.
3209-
/// "alpha") will be latexised as Greek letter (but other than that,
3209+
/// "alpha") will be latexized as Greek letter (but other than that,
32103210
/// will appear as "alpha" in other places).
32113211
/// </example>
32123212
public static (Variable, Variable, Variable) Var(string name1, string name2, string name3)
@@ -3231,7 +3231,7 @@ public static (Variable, Variable, Variable) Var(string name1, string name2, str
32313231
/// var inCyrillic = Var("Абаваола");
32323232
/// </code>
32333233
/// Underscore "_" allows indexing. Greek letter names (e. g.
3234-
/// "alpha") will be latexised as Greek letter (but other than that,
3234+
/// "alpha") will be latexized as Greek letter (but other than that,
32353235
/// will appear as "alpha" in other places).
32363236
/// </example>
32373237
public static (Variable, Variable, Variable, Variable) Var(string name1, string name2, string name3, string name4)
@@ -3256,7 +3256,7 @@ public static (Variable, Variable, Variable, Variable) Var(string name1, string
32563256
/// var inCyrillic = Var("Абаваола");
32573257
/// </code>
32583258
/// Underscore "_" allows indexing. Greek letter names (e. g.
3259-
/// "alpha") will be latexised as Greek letter (but other than that,
3259+
/// "alpha") will be latexized as Greek letter (but other than that,
32603260
/// will appear as "alpha" in other places).
32613261
/// </example>
32623262
public static (Variable, Variable, Variable, Variable, Variable) Var(string name1, string name2, string name3, string name4, string name5)
@@ -3984,7 +3984,7 @@ public static ParsingResult Parse(string source)
39843984
/// <returns>
39853985
/// The <a href="https://en.wikipedia.org/wiki/LaTeX">LaTeX</a> representation of the argument
39863986
/// </returns>
3987-
/// <param name="latexiseable">
3987+
/// <param name="latexizeable">
39883988
/// Any element (<see cref="Entity"/>, <see cref="Set"/>, etc.) that can be represented in LaTeX
39893989
/// </param>
39903990
/// <example>
@@ -4008,7 +4008,7 @@ public static ParsingResult Parse(string source)
40084008
/// \frac{a}{{b}^{\lim_{x\to \infty } \left[\sin\left(x\right)-\frac{{e}^{y}+{e}^{-y}}{2}\right]}}
40094009
/// </code>
40104010
/// </example>
4011-
public static string Latex(ILatexiseable latexiseable) => latexiseable.Latexise();
4011+
public static string Latex(ILatexizeable latexizeable) => latexizeable.Latexize();
40124012

40134013
/// <summary>
40144014
/// <para>All operations for <see cref="Number"/> and its derived classes are available from here.</para>

Sources/AngouriMath/Core/Entity/Entity.Definition.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ internal enum Priority
7070
///
7171
/// Entity expr = "sqrt(a) + integral(sin(x), x)";
7272
/// Console.WriteLine(expr);
73-
/// Console.WriteLine(expr.Latexise());
73+
/// Console.WriteLine(expr.Latexize());
7474
/// Entity expr2 = "a / b ^ limit(sin(x) - cosh(y), x, +oo)";
7575
/// Console.WriteLine(expr2);
76-
/// Console.WriteLine(expr2.Latexise());
76+
/// Console.WriteLine(expr2.Latexize());
7777
/// </code>
7878
/// Prints
7979
/// <code>
@@ -83,13 +83,13 @@ internal enum Priority
8383
/// \frac{a}{{b}^{\lim_{x\to \infty } \left[\sin\left(x\right)-\frac{{e}^{y}+{e}^{-y}}{2}\right]}}
8484
/// </code>
8585
/// </example>
86-
public interface ILatexiseable
86+
public interface ILatexizeable
8787
{
8888
/// <summary>
8989
/// Converts the object to the LaTeX format
9090
/// That is, a string that can be later displayed and rendered as LaTeX
9191
/// </summary>
92-
public string Latexise();
92+
public string Latexize();
9393
}
9494
}
9595

@@ -101,7 +101,7 @@ namespace AngouriMath
101101
/// Every node, expression, or number is an <see cref="Entity"/>.
102102
/// However, you cannot create an instance of this class, look for the nested classes instead.
103103
/// </summary>
104-
public abstract partial record Entity : ILatexiseable
104+
public abstract partial record Entity : ILatexizeable
105105
{
106106
/// <summary>
107107
/// Returns the array of the direct children. Will be

Sources/AngouriMath/Core/EquationSystem.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ namespace AngouriMath.Core
1717
/// It is a system of arbitrary equations, not only those linear. However,
1818
/// it is not a system of <see cref="Statement"/>s.
1919
/// </summary>
20-
public sealed class EquationSystem : ILatexiseable
20+
public sealed class EquationSystem : ILatexizeable
2121
{
2222
private readonly IEnumerable<Entity> equations;
2323

2424
/// <summary>
2525
/// The equations you pass should not have an <see cref="MathS.Equality"/> node.
26-
/// After having created a system of equations, you may solve or latexise it.
26+
/// After having created a system of equations, you may solve or latexize it.
2727
/// </summary>
2828
/// <param name="equations">
2929
/// Any <see cref="IEnumerable{T}"/> parameter, such as <see cref="List{T}"/> or <see cref="System.Array"/>.
@@ -40,7 +40,7 @@ public sealed class EquationSystem : ILatexiseable
4040

4141
/// <summary>
4242
/// The equations you pass should not have an <see cref="MathS.Equality"/> node.
43-
/// After having created a system of equations, you may solve or latexise it.
43+
/// After having created a system of equations, you may solve or latexize it.
4444
/// </summary>
4545
/// <param name="equations">
4646
/// An <see cref="System.Array"/>
@@ -73,19 +73,19 @@ public sealed class EquationSystem : ILatexiseable
7373
public Matrix? Solve(params Variable[] vars) => EquationSolver.SolveSystem(equations, vars);
7474

7575
/// <returns>
76-
/// Latexised version of the system. It adds
76+
/// Latexized version of the system. It adds
7777
/// zero equality to all the provided expressions
7878
/// </returns>
79-
public string Latexise()
79+
public string Latexize()
8080
{
8181
using var enumerator = equations.GetEnumerator();
8282
if (!enumerator.MoveNext())
8383
return string.Empty;
84-
var firstEquation = enumerator.Current.Latexise() + " = 0";
84+
var firstEquation = enumerator.Current.Latexize() + " = 0";
8585
if (!enumerator.MoveNext())
8686
return firstEquation;
8787
var sb = new StringBuilder(@"\begin{cases}").Append(firstEquation);
88-
do sb.Append(@"\\").Append(enumerator.Current.Latexise()).Append(" = 0");
88+
do sb.Append(@"\\").Append(enumerator.Current.Latexize()).Append(" = 0");
8989
while (enumerator.MoveNext());
9090
sb.Append(@"\end{cases}");
9191
return sb.ToString();

Sources/AngouriMath/Docs/Contributing/AddingNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
/// 3. A few essential methods
3131
/// a. InnerEval and InnerSimplify (<see cref="AngouriMath.Entity.Sinf.InnerEval"/> for numerical and <see cref="AngouriMath.Entity.Andf.InnerEval"/> for boolean)
3232
/// b. Stringize (<see cref="AngouriMath.Entity.Sinf.Stringize"/>) (and tests to CircleTest.cs)
33-
/// c. Latexise (<see cref="AngouriMath.Entity.Sinf.Latexise"/>) (and tests to LatexTest.cs)
33+
/// c. Latexize (<see cref="AngouriMath.Entity.Sinf.Latexize"/>) (and tests to LatexTest.cs)
3434
/// d. Limit computation (<see cref="AngouriMath.Entity.Sinf.ComputeLimitDivideEtImpera"/>) (and tests to LimitTest.cs)
3535
/// e. Hash for sorting (<see cref="AngouriMath.Entity.Sinf.SortHashName"/>)
3636
/// f. Default domain <see cref="AngouriMath.Entity.Sinf.Codomain"/>

Sources/AngouriMath/Docs/Usage/Syntax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ form would silently come back as something else.
1616
**LaTeX output has a round trip too, and it is checked in someone else's repository.**
1717
[CSharpMath.Evaluation](https://github.com/verybadcat/CSharpMath/blob/master/CSharpMath.Evaluation/Evaluation.cs)
1818
reads LaTeX back into an `Entity` and says so in its own source — *"CSharpMath must handle all
19-
LaTeX coming from AngouriMath or a bug is present!"* — so `Latexise` is free to use `\frac`,
19+
LaTeX coming from AngouriMath or a bug is present!"* — so `Latexize` is free to use `\frac`,
2020
`\bmod` and the rest, but changing what it emits can break a downstream project and no test here
2121
will say so ([#822](https://github.com/asc-community/AngouriMath/issues/822)).
2222

Sources/AngouriMath/Functions/Continuous/Solvers/EquationSolver/AnalyticalEquationSolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace AngouriMath
1717
{
18-
partial record Entity : ILatexiseable
18+
partial record Entity : ILatexizeable
1919
{
2020
/// <summary>
2121
/// Attempt to find analytical roots of a custom equation.

0 commit comments

Comments
 (0)