Skip to content

Commit

Permalink
fix: typo in run subs (#3300)
Browse files Browse the repository at this point in the history
Solves #3299 

Just making sure it wasn't my recent change.

@akshayka OR @mscolnick
  • Loading branch information
dmadisetti authored Dec 29, 2024
1 parent 0f639ad commit e97bc0c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion marimo/_runtime/dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ def _get_ancestors(
) -> set[CellId_t]:
# Get the transitive closure of parents defining unsubstituted refs
graph = self._graph
substitutions = set(kwargs.values())
substitutions = set(kwargs.keys())
unsubstituted_refs = cell_impl.refs - substitutions
parent_ids = set(
[
Expand Down
21 changes: 21 additions & 0 deletions tests/_ast/cell_data/named_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,26 @@ def h(y):
return (z,)


@app.cell
def unhashable_defined():
unhashable = {0, 1, 2}
unhashable
return (unhashable,)


@app.cell
def unhashable_override_required(unhashable):
assert unhashable == {0, 1}
unhashable
return


@app.cell
def multiple():
A = 0
B = 1
(A, B)
return (A, B)

if __name__ == "__main__":
app.run()
29 changes: 29 additions & 0 deletions tests/_ast/test_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,35 @@ def test_import() -> None:
assert g.run(x=1) == (None, {"y": 2})
assert h.run(y=2) == (3, {"z": 3})

@staticmethod
def test_unhashable_import() -> None:
from cell_data.named_cells import (
unhashable_defined,
unhashable_override_required,
)

assert unhashable_defined.name == "unhashable_defined"
assert (
unhashable_override_required.name == "unhashable_override_required"
)

assert unhashable_override_required.run(unhashable={0, 1}) == (
{0, 1},
{},
)
assert unhashable_defined.run() == (
{0, 1, 2},
{"unhashable": {0, 1, 2}},
)

@staticmethod
def test_direct_call() -> None:
from cell_data.named_cells import h, multiple, unhashable_defined

assert h(1) == 2
assert multiple() == (0, 1)
assert unhashable_defined() == {0, 1, 2}


def help_smoke() -> None:
app = App()
Expand Down

0 comments on commit e97bc0c

Please sign in to comment.