Make the MultiBlock API saner
See original GitHub issueThis is just to track our discussion in https://github.com/pyvista/pyvista/pull/1482#discussion_r664009578:
This is a pretty confused API 😦
blocks.keys()
is a thing, and instantiating from a list comes up with string keys, so it looks like a dict.- Iterating over the container, however, yields values, which is not like a dict.
- There’s no
blocks.values()
norblocks.items()
…blocks[i]
supports both keys and integer indices?!
Additionally, I’ve also noticed that MultiBlock__setitem__
does this:
import pyvista as pv
blocks = pv.MultiBlock()
blocks[3, 'name'] = pv.Sphere()
blocks.keys()
# [None, None, None, 'name']
Making a 2-tuple passed to __setitem__
act neither like a list nor like a dict is especially problematic from an API design standpoint.
I’m still not sure if we can change any of this without breaking too much downstream code, but at least we can track this future work on this issue.
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
Yona168/MultiblockAPI: Multiblock API for Spigot - GitHub
MultiblockAPI is a spigot API to allow the creation of multiblocks. Multiblocks are structures made from multiple blocks that, when together ...
Read more >Zero CORE multiblock API tutorial - ZeroNoMods
This is a tutorial on how to use the API to build multiblock machines in your own mod, in the same way I'm...
Read more >[openssl-commits] [openssl] OpenSSL_1_1_0-pre4 create
Alessandro Ghedini (19): Implement new multi-threading API GH355: Implement HKDF ... Add ASN.1 ADB callback. use saner default parameters for scrypt Make ......
Read more >Pressure Pipes - BDew
Pressure Pipes 1.2.4 · Added detailed tooltips to multiblock controllers/modules · Added Sluice (thanks CplPibald) · Updated Chinese localization ( ...
Read more >Untitled
... linux-2.6-audit-make-audit-config-immutable-in-kernel.patch ... linux-2.6-fs-ecryptfs-backport-to-crypto-hash-api.patch ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You are right, I’m focusing first on
__setitem__
/__getitem__
in this list. I wanted to start writing down the current behavior in one place. Feel free to add directly to my list or start a new list for other behaviors.I know you probably just mean get/setitem here, but
multi.keys()
anditer(multi)
behaviour will need thought too.