Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mscolnick committed Feb 2, 2025
1 parent 60f7ddf commit dceae81
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 40 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ unfixable = ["F401"]
convention = "google"

[tool.ruff.lint.per-file-ignores]
"**/{tests}/*" = ["ANN201", "ANN202", "T201", "D"]
"**/{tests}/*" = ["ANN201", "ANN202", "T201", "D", "F841"]
"dagger/*" = ["TID252"]

[tool.ruff.lint.isort]
Expand Down
4 changes: 2 additions & 2 deletions tests/_output/formatters/test_sympy.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_sympy_formatters_power() -> None:

from sympy import symbols

x, _y, _z = symbols("x y z")
x, y, z = symbols("x y z")
x_squared = x**2

# x^2
Expand Down Expand Up @@ -109,7 +109,7 @@ def test_sympy_formatters_Integral() -> None:

from sympy import Integral, sqrt, symbols

x, _y, _z = symbols("x y z")
x, y, z = symbols("x y z")
out_exp = Integral(sqrt(1 / x), x)

# symbolic integral
Expand Down
62 changes: 25 additions & 37 deletions tests/_save/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ def __():

@app.cell
def __(mo):
_state, _set_state = mo.state(None)
state, set_state = mo.state(None)

@mo.cache
def g(state):
Expand All @@ -1283,7 +1283,7 @@ def __():

@app.cell
def __(mo):
state, _set_state = mo.state(None)
state, set_state = mo.state(None)

@mo.cache
def g():
Expand All @@ -1309,11 +1309,11 @@ def __():

@app.cell
def __(mo):
state0, _set_state0 = mo.state(1)
state1, _set_state1 = mo.state(1)
state2, _set_state2 = mo.state(10)
state0, set_state0 = mo.state(1)
state1, set_state1 = mo.state(1)
state2, set_state2 = mo.state(10)

_state, _set_state = mo.state(100)
state, set_state = mo.state(100)

@mo.cache
def h(state):
Expand Down Expand Up @@ -1344,11 +1344,11 @@ def __():

@app.cell
def __(mo):
state0, _set_state0 = mo.state(1)
state1, _set_state1 = mo.state(1)
state2, _set_state2 = mo.state(10)
state0, set_state0 = mo.state(1)
state1, set_state1 = mo.state(1)
state2, set_state2 = mo.state(10)

state, _set_state = mo.state(100)
state, set_state = mo.state(100)

# Example of a case where things start to get very tricky. There
# comes a point where you might also have to capture frame levels
Expand Down Expand Up @@ -1380,11 +1380,11 @@ def __():

@app.cell
def __(mo):
state1, _set_state1 = mo.state(1)
state2, _set_state2 = mo.state(2)
state1, set_state1 = mo.state(1)
state2, set_state2 = mo.state(2)

# Here as a var for shadowing
_state, _set_state = mo.state(3)
state, set_state = mo.state(3)

@mo.cache
def g(state):
Expand Down Expand Up @@ -1437,38 +1437,32 @@ async def test_pickle_context(
) -> None:
await k.run(
[
exec_req.get(
"""
exec_req.get("""
import marimo as mo
import os
from pathlib import Path
pc = mo.persistent_cache
"""
),
"""),
exec_req.get(
f'tmp_path_fixture = Path("{tmp_path.as_posix()}")'
),
exec_req.get(
"""
exec_req.get("""
assert not os.path.exists(tmp_path_fixture / "basic")
with pc("basic", save_path=tmp_path_fixture) as cache:
_b = 1
assert _b == 1
assert not cache._cache.hit
assert cache._cache.meta["version"] == mo._save.MARIMO_CACHE_VERSION
assert os.path.exists(tmp_path_fixture / "basic" / f"P_{cache._cache.hash}.pickle")
"""
),
exec_req.get(
"""
"""),
exec_req.get("""
with pc("basic", save_path=tmp_path_fixture) as cache_2:
_b = 1
assert _b == 1
assert cache_2._cache.hit
assert cache._cache.hash == cache_2._cache.hash
assert os.path.exists(tmp_path_fixture / "basic" / f"P_{cache._cache.hash}.pickle")
"""
),
"""),
]
)
assert not k.stdout.messages, k.stdout
Expand All @@ -1479,37 +1473,31 @@ async def test_json_context(
) -> None:
await k.run(
[
exec_req.get(
"""
exec_req.get("""
import marimo as mo
import os
from pathlib import Path
pc = mo.persistent_cache
"""
),
"""),
exec_req.get(
f'tmp_path_fixture = Path("{tmp_path.as_posix()}")'
),
exec_req.get(
"""
exec_req.get("""
assert not os.path.exists(tmp_path_fixture / "json")
with pc("json", save_path=tmp_path_fixture, method="json") as json_cache:
_b = 1
assert _b == 1
assert not json_cache._cache.hit
assert os.path.exists(tmp_path_fixture / "json" / f"P_{json_cache._cache.hash}.json")
"""
),
exec_req.get(
"""
"""),
exec_req.get("""
with pc("json", save_path=tmp_path_fixture, method="json") as json_cache_2:
_b = 1
assert _b == 1
assert json_cache_2._cache.hit
assert json_cache._cache.hash == json_cache_2._cache.hash
assert os.path.exists(tmp_path_fixture / "json" / f"P_{json_cache._cache.hash}.json")
"""
),
"""),
]
)
assert not k.stdout.messages, k.stdout
Expand Down

0 comments on commit dceae81

Please sign in to comment.