-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dict-like interface isn't looking good! #102
Comments
I was just about to make a separate issue for this, but I'll roll it into this one. I have been thinking about this issue a bit and this is the solution I've come up with: Method 1: e.g. We can set an order by using This can be used in a number of ways:
Plus we can set once and then treat our tensor as a normal tensor for a while:
Or maybe something like:
Method 2: We abuse slicing notation and allow: Example: Both these methods can be used together, although there's some question as to certain minor details of how this would work, e.g. what should the behaviour of If you want to have a play around, I have a basic implementation here: |
@EndingCredits |
I was't really commenting on your suggestion, just rolling the discussion into one thread. Also, looks fine to me |
@EndingCredits it is much better when linter/compiler warns you about this, instead of at run-time. |
Thanks for the suggestions, this is helpful and I hear the two different approaches. I agree the dict construction approach is a bit heavyweight. particularly in loops. I need to look into whether that is actually a problem though from a memory standpoint. I see why the x.batch approach is appealing in a an editor (if you somehow declare the names). However [x.batch == 1] seems like a strange way to do constant time indexing, unless you see that being lazy somehow. |
@srush for that you might have x.batch[1] as well, and anyway it's no worse than x[{"batch": 1}] . |
Memory-wise I imagine the overhead of constructing dicts is negligible compared to the actual tensor operations, unless somehow a tensor itself is being copied. More importantly, the current way of doing thing is just very clunky, and a bit unintuitive. I feel any of the methods above would be a big improvement to usability. |
It doesn't look well, no IDE hints, and constructs a new dict every time.
Would you consider pandas-like interface instead?
x[x.batch==1]
andx[x.batch>=1 && x.batch<4]
syntax looks much better and allows for IDE hints.x.batch[1]
andx.batch[1:4]
also can be used for this specific case -- that would be amazing!The text was updated successfully, but these errors were encountered: