Comments (4)
Hi;
Thank you for your interest, and, please, note that standard rules of politeness apply here ;)
In short: It is not possible to use latex syntax in python(/sympy). In some cases (e.g. matplotlib plot titles and legends), it is possible to render in math mode "$\pi$". We could build a wrapper in pyphs that would basically escapes every backslashes when necessary, but it is not a priority.
I don't understand why you "need" latex symbols.
If you are looking for fancy printing in python interpreter, you can use this sympy module, or simply the capabilities of sympy regarding pretty printing of maths:
>>> import sympy
>>> sympy.init_printing() # activate sympy pretty printing
>>> pi = sympy.symbols('pi_1') # notice there is no backslash
>>> pi # display nicely most latex symbols
π₁
I you want LaTeX commands for symbols in the generated LaTeX files, I suggest that (i) you use standard names for symbols in pyphs (e.g. "pi_i"), and (ii) make a query/replace in the generated LaTeX file to get the proper command (e.g. search "pi_i" => replace by "\pi_i").
Sorry, no solution out of the box, but this a standard python/sympy/pyphs behavior, not an issue.
I close, and you can open a thread in the mailing list to ask other pyphs users.
from pyphs.
Hi Antoine, Hi Victor,
as mentioned by Antoine, Sympy handles (under the hood) many latex symbols, including greek letters. For instance
xk, k = core.symbols([ '\\xi_i','k' ])
can simply be changed to
xk, k = core.symbols([ 'xi_i','k' ])
and the xk python variable will be represented by the appropriate
Best regards
from pyphs.
Hi Antoine, Hi Fabrice
Thank you for your answers! You solved my problems :)
from pyphs.
Hi!
@FabricioS The rendering of symbols in the latex report generated by PyPHS is controlled in the symbol_names
function (line 14 in pyphs/pyphs/misc/latex/tools.py):
def symbol_names(core):
sn = {}
for var in [r'x', 'dx', r'w', r'u', r'y', r'cy', r'p', r'o', r'g', r'z_symbols']:
for symb in geteval(core, var):
string = str(symb)
lab = string[1:]
sn.update({symb: string[0]+r'_{\mathrm{'+lab+r'}}'})
for symb in core.subs.keys():
string = str(symb)
lab = string[1:]
sn.update({symb: string[0]+r'_{\mathrm{'+lab+r'}}'})
return sn
In short, the (nowhere written) rule is: the first character of the symbol's string is the variable, the remaining part is the variable label: the symbol "xstiff" will be rendered as
@WetzelVictor you can redesign the function symbol_names
to your needs, and submit it as a pull request if you think it's worth it.
I admit we could do a lot regarding the rendering of PyPHS structures, but again this is not a priority.
All the best;
Antoine
from pyphs.
Related Issues (20)
- Python doesn't raise errors if the C++ compilation fails HOT 2
- Debug module for NL solver convergence issue
- Unfold the evaluation of implicit function in NL solver
- Complexity of FAUST code is to high for more than 2 NL components
- Externalize the modules for LATEX/JUCE/FAUST code generation HOT 2
- Discarding linear part of a quadratic Hamiltonian HOT 5
- Account for linear part of Hamiltonian of linear components in latex rendering system HOT 1
- matvecprod ShapeError in Typical use HOT 3
- minor warnings related to manifest HOT 2
- Rhodes Example: TypeError: can't convert expression to float HOT 2
- Memory issues for huge number of samples HOT 7
- Add rotary mechanical elements to PyPHS HOT 3
- Improve time to plot data HOT 2
- Issue when installing PyPHS HOT 3
- redefinition of symbols are not allowed HOT 3
- 'NodeView' object has no attribute 'index' HOT 5
- AssertionError: flux-controlled edge xBSC1 is effort-controlled I don't understand HOT 2
- Is it possible to define a state feedback control (u = k*x) for the simulation? HOT 4
- Eigen stack allocation limit
- C++ code feature: CMakeLists.txt template HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyphs.