Comments (6)
I was wondering whether other projects rely on this mixin idea or not, and yep, it's common! Great, I didn't think of this possibility.
Some examples:
EasyReprMixin
byhangtwenty
- More mixins in
textblob
We could also use reprlib
, which I have just discovered. Man, the standard library is vast. From the docs:
The reprlib module provides a means for producing object representations with limits on the size of the resulting strings. This is used in the Python debugger and may be useful in other contexts as well.
from openff-evaluator.
This will be automatically handled once #226 is closed as pydantic
provides this for free by default.
from openff-evaluator.
Thanks for the fantastic feedback!
Because I've always developed, ran and stepped through all of my code and examples directly in an IDE (currently PyCharm) I've never really used the str
and repr
representations because the debugger gives a full object hierarchy - so this need and use for them is great to know about!
Absolutely a PR would be most welcome to fix up the many instances I've missed! I wonder if we could just use a simple mix-in with an implementation similar to your ComputeResourcesRepr
to automate this cleanly in the bulk of cases (at least, those that implement __getstate__
which should be most)?
from openff-evaluator.
I wonder if we could just use a simple mix-in with an implementation similar to your ComputeResourcesRepr to automate this cleanly in the bulk of cases?
Given that .__getstate__()
is implemented the same way across all involved instances (returns a dict with string-representable keys and values), I'd say that yes, a Representable
class only implementing __str__
and __repr__
for mixins would be enough. It could even check for the existence of __getstate__
and throw a warning otherwise, maybe?
edit: The mixin would have to define abstract methods for required definitions in the children classes.
from openff-evaluator.
I was wondering whether other projects rely on this mixin idea or not, and yep, it's common! Great, I didn't think of this possibility.
Some examples:
EasyReprMixin
byhangtwenty
- More mixins in
textblob
We could also use
reprlib
, which I have just discovered. Man, the standard library is vast. From the docs:The reprlib module provides a means for producing object representations with limits on the size of the resulting strings. This is used in the Python debugger and may be useful in other contexts as well.
That's good to hear! And it sounds like this should be pretty simple to add in which is great!
from openff-evaluator.
I have just found about __qualname__
, which might be what we need here instead of manually concatenating __module__
, __class__.__name__
etc.
from openff-evaluator.
Related Issues (20)
- Random halting of estimations (experiments/solvent2.nc) HOT 5
- Solvation free energy calculations failing HOT 10
- Loosen MDTraj constraint HOT 3
- tutorial data and script are outdated HOT 1
- unit bug forcebalance 1.9.4 + evaluator 0.4.1 + toolkit 0.11.4 in tutorial04 HOT 5
- Virtual sites missing from gradient calculations HOT 8
- Remove modules depending on Yank
- OpenMM 8 causing test failures HOT 2
- Star imports misconfigured HOT 1
- Unit-related AttributeError on code which previously worked HOT 6
- FilterBySmirks does not work with isotopes HOT 6
- Remove use of `pkg_resources`
- Pandas 2 breaks things HOT 3
- Tutorial01 HOT 5
- OE_LICENSE HOT 3
- unit HOT 16
- Pint removed upcast_types = [] from pint.compat HOT 3
- openff-evaluator conda installation problems HOT 3
- Update calls to Simulation.MinimizeEnergy to provide tolerance as force, not energy HOT 4
- tutorial04 - No module named 'forcebalance' HOT 1
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 openff-evaluator.