Graphs created as part of a `CspPerspectiveTable` do not memoize
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 441
- Forks
- 90
- Avg merge
- 1d 12m
- Merged PRs (30d)
- 5
Description
Describe the bug
When you create a graph as part of a CspPerspectiveTable it does not memoize nodes.
To Reproduce
Minimal repro
import csp
from datetime import datetime, timedelta
from PIL import Image
import perspective
from csp.impl.pandas_ext_type import TsDtype
from csp.impl.pandas_perspective import CspPerspectiveTable
import pandas as pd
df = pd.DataFrame()
df.insert(0, 'one1', pd.Series(csp.const(1.0), dtype=TsDtype(float)), True)
df.insert(1, 'one2', pd.Series(csp.const(1.0), dtype=TsDtype(float)), True)
table = CspPerspectiveTable(df, index_col='timestamp', keep_history=False, localize=True)
g = table.graph
# Note I use a roundabout to call show_graph since I'm in Jupyterlab
# You can replace the code below with a simple show_graph call
buffer = csp.showgraph.generate_graph(g)
image = Image.open(buffer)
display(image)
This gives an image clearly showing the const adapter is not memoized:
However, if I "manually" memoize the const nodes by only creating one and providing it both index 0 and 1 of the CspPerspectiveTable like:
df = pd.DataFrame()
u = csp.const(1.0)
df.insert(0, 'one1', pd.Series(u, dtype=TsDtype(float)), True)
df.insert(1, 'one2', pd.Series(u, dtype=TsDtype(float)), True)
We get what we expect:
Expected behavior
Memoization should work like it does for any other graph
Error Message
Runtime Environment
0.0.3
3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0]
linux
Additional context
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with csp.impl.pandas_perspective.CspPerspectiveTable and the table.graph entry point, using the supplied Python reproduction with csp.const and csp.showgraph.generate_graph. Compare the generated graph with the manually shared-const example; done means separately created equivalent const nodes are memoized as they are in other graphs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- stream-processing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100