Skip to content

Public 'collection from in-memory cells' (collect.from_cells / Batch.from_cells) #787

Description

@jepegit

Problem

collect_summaries / collect_cycles are exactly what an app wants, but they only
accept a batch exposing .cells ({label: CellpyCell}) and .journal.pages
(a polars frame with filename / group / sub_group / group_label /
label / selected). There is no public way to build that from a set of
already-loaded CellpyCell objects (e.g. cells a GUI is holding in memory, some
loaded from raw files, some from .cellpy files).

I had to reverse-engineer the contract and duck-type a shim. Two things only
surfaced at runtime:

  • collect_summaries also reads batch.journal.name (undocumented; AttributeError
    if missing).
  • pages must be polars (.iter_rows(named=True), .columns), and the
    filename key must match the batch.cells keys.

Suggestion

A supported constructor, e.g.:

collection = cellpy.collect.from_cells(
    cells,                        # list or {label: CellpyCell}
    groups={label: 1, ...},       # optional
    selected={label: True, ...},  # optional
)
# or Batch.from_cells(...)

This is probably the single biggest enabler for GUIs / notebooks that manage cells
in memory rather than from a journal on disk.


Found while building cellpy-simple-gui on cellpy 2.1.0.post1. Full write-up with all items: CELLPY_PAINPOINTS.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementv2cellpy v2 work - PRs should target the master branch

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions