question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make the MultiBlock API saner

See original GitHub issue

This is just to track our discussion in https://github.com/pyvista/pyvista/pull/1482#discussion_r664009578:

This is a pretty confused API 😦

  1. blocks.keys() is a thing, and instantiating from a list comes up with string keys, so it looks like a dict.
  2. Iterating over the container, however, yields values, which is not like a dict.
  3. There’s no blocks.values() nor blocks.items()
  4. 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:open
  • Created 2 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
MatthewFlammcommented, Jul 19, 2022

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.

1reaction
adeakcommented, Jul 19, 2022

I know you probably just mean get/setitem here, but multi.keys() and iter(multi) behaviour will need thought too.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found