Comments (3)
I think methods are particularly nice for method chaining, which I find very convenient.
I have different and general opinion that having duplicate methods and functions everywhere, are not a good idea.
It duplicates the code, makes the code more longer, and also causes the documentation to be duplicated and outdated.
Because of the reasons above, I think that they have obvious cons than some pros of method chaining,
so I'm not conclusive that we should have code standards that enforces that.
The reason expand
and Expr.expand
was there, for instance, was some code style of some authors written SymPy even before I started maintaining, so it was not a code standard now anyway. We don't necessarily reject someone to introduce more things like that, however, we don't necessarily reject someone not to add expand_...
and not Expr.expand_...
.
However, we have to to keep such mirroring of expand
and Expr.expand
, (or simplify
and Expr.simplify
) that were done before as is at least for maintaninance and backward compatiblity.
expand_power_exp() is only a function?
expand_power_exp
, implemented, is just a expand
with some options pre configured.
Lines 3062 to 3086 in 9d13061
So I don't think that it is very difficult for you to configure Expr.expand
like that in your application.
I am not sure if we need to add more things like expand_power_exp
in the future because they are just expand
with some trivial options anyway.
from sympy.
I will note that expand_power_exp()
is perhaps not considered a simplification function. Perhaps I should have titled this "Why aren't all manipulation functions also methods?"
from sympy.
Thank you for your response @sylee957. I appreciate your points about duplication. I suppose I would be happiest with everything being a method instead of a function due to my preference for method chaining. This preference is a result of my Mathematica past, in which I wrote nearly everything in a pipe-like paradigm (expr -> func -> func -> ... -> func -> output), which I think is very natural for symbolic manipulation.
I wonder if there is a clean way to have a function mirror a method (or vice versa), such as in the following example:
class Expr:
def __repr__(self):
return "Expression"
def action(self):
print("action method on self")
def action(expr):
print(f"action function on {expr} just calls action method:")
return expr.action()
expr = Expr()
expr.action()
action(expr)
Perhaps this type of paradigm could be used to clean up the existing code and maintain legacy functions or methods if you want to go with just one or the other for future routines. I think it would be helpful to know which direction future development will head, so when I'm using SymPy I can "trust" that the function or the method will be there instead of guessing (as I often do now). I believe that, for now, most routines are at least functions, sometimes methods. Although I prefer the opposite, I can get on board if that's the vision you have for the project. Thanks!
from sympy.
Related Issues (20)
- `parse_latex` seems not to work well on complex latex expression.
- sympy.floor returns wrong result HOT 4
- `expand_power_exp()` Has No Effect In Cases For Which It Should HOT 3
- Simplifying symbolic relations with sympy.Max HOT 1
- solving systems of trigonometric functions
- allow bottom_up (and other traversals) to work with Python tuple and list HOT 2
- Adding other solvers to solveset
- Plotting with xlim sufficiently far from origin creates Image size too large
- Relational simplification limitation HOT 2
- Relational simplification isn't necessarily simplification of its arguments
- inverse_laplace_transform result depends on formatting of S-domain function
- suboptimal equals checking of tan(2*x) HOT 3
- Two docstring style guides HOT 7
- make TR4 do something
- Constraint solver not used for auxiliary equations in KanesMethod
- Questions about Copilot + Open Source Software Hierarchy HOT 2
- WedgeProduct giving wrong output HOT 5
- Lambdify doesn't recognize derivative symbol if cse is enabled HOT 11
- x.subs(1/x,y) behavior differs when x is symbol and when x is a function HOT 3
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 sympy.