Comments (4)
It's a bit problematic to override __eq__
, because of the in
keyword.
If I do:
a = iquib(3)
b = [a]
5 in b
I'll receive True
- list_contains
is a method implemented in C that must return a boolean, and it simply calls __eq__
over and over for its elements with the given argument (in our case 5).
We could do some nasty stuff and forcefully override list's contain method, but as we spoke previously this is essentially different from the overriding we do today- Python purposefully does not allow this. I suggest we use a helper method here.
For reference, the C method:
static int list_contains(PyListObject *a, PyObject *el)
{
Py_ssize_t i;
int cmp;
for (i = 0, cmp = 0 ; cmp == 0 && i < Py_SIZE(a); ++i)
cmp = PyObject_RichCompareBool(el, PyList_GET_ITEM(a, i), Py_EQ);
return cmp;
}
from quibbler.
ok. so no overriding of eq
so, if the user wants to do Q==3
they will do something like:
q(lambda x: x==3, Q)
right? or is there a simpler syntax?
from quibbler.
We could add a simpler syntax if you'd like- maybe qe(Q, 3)
or something of the like (maybe Q.equals(3)
)? Wdyt?
from quibbler.
i'm not sure which one is best. and i trust that you know better the python-way of thinking
in general, there are already several functions that we decided not to override, including eq, len, str, ...
so we need some generic way
what I did in Matlab is taking all the problematic-to-overload functions and provide their quib-implementation with a new name starting quib...
for example, I couldn't overload size(), numel(), isempty() because Matlab expects them to return real values, so I offered new functions quibsize(), quibnumel(), quibisempty()
maybe we can do something like that?
note also that right now q(...) is interpreted as a graphic quib (evaluates immediately), so we need some alternative when we would like to apply a user function as a non-graphical functional quib
from quibbler.
Related Issues (20)
- error in override viewer with path HOT 1
- shift-enter does not propagate to next cell after execution of cells with quib viewers HOT 2
- wrong override HOT 1
- error in save/load HOT 3
- labext new override is replaced at OLD rather than NEW position HOT 1
- bug in transpositional_translation HOT 1
- add Quibbler support for pandas.DataFrame
- bug in assignments within quib-creation jupyter cell HOT 1
- install.py fails HOT 3
- bug in transpositional inverter of array with ragged list HOT 1
- labext: assignment within quib creation cell is ignored
- add Quibbler support for ipywidgets HOT 1
- add Quibbler support for plotly
- grey out Undo/Redo buttons HOT 1
- `UnicodeDecodeError` when installing on windows machine using the install.py script
- Flask warning: "This is a development server"
- install.py fails installing labext HOT 1
- No support for google colab HOT 6
- Cannot initialize quibbler. HOT 7
- add Quibbler support for bokeh HOT 2
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 quibbler.