Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formula usage in a template problematic #116

Open
Vindaar opened this issue Jun 10, 2021 · 1 comment
Open

Formula usage in a template problematic #116

Vindaar opened this issue Jun 10, 2021 · 1 comment

Comments

@Vindaar
Copy link
Owner

Vindaar commented Jun 10, 2021

I just thought I introduced a regression with PR #115, because the following is broken:

import ggplotnim

template callMe(): untyped =
  let couplings = newSeq[float](10)
  let vals = newSeq[float](10)
  let df = seqsToDf({"Couplings" : couplings, "Vals": vals})
    .mutate(f{"Couplings" ~ `Couplings` * 1e-12 * 1e-12})

proc foo() =
  callMe()

foo()

it errors out with Error: undeclared identifier: '~'.

However, this is already present on the master branch.

Maybe related to: nim-lang/Nim#11091 ?

@Vindaar
Copy link
Owner Author

Vindaar commented Jun 29, 2021

Great, add to that generic procedures. This is broken:

proc plotGasGain*[T](charge, counts: seq[T],
                     fitX, fitY: seq[T],
                     xMin, xMax: float,
                     G_fit, chiSq: float,
                     chipNumber, runNumber: int,
                     pathPrefix: string,
                     gasGainInterval = none[GasGainIntervalData]()) =
  ## given a seq of traces (polya distributions for gas gain) plot
  ## the data and the fit, save plots as svg.
  let dfRaw = seqsToDf({ "charge / e-" : charge,
                         "counts" : counts })
  let dfFit = seqsToDf({ "charge / e-" : fitX,
                         "counts" : fitY })
  let df = bind_rows([("Polya", dfRaw),
                      ("Fit", dfFit)],
                     id = "Type")
    # filter to max 2.5e4 electrons, more irrelevant for polya
    .filter(f{c"charge / e-" <= 2.5e4})
    .mutate(f{float -> bool: "FitRange" ~ c"charge / e-" >= xMin})

The stage of adding all symbols to a typed table is not being run (or the symbols aren't resolved? But the CT table is simply empty) before we enter the actual column extraction and type inference.

Also thanks Github for not allowing me to transfer this issue over to Datamancer.

edit: this can be fixed by making compileFormulaImpl a proper typed macro (which we can do now 🥳)

Vindaar added a commit to SciNim/Datamancer that referenced this issue Jun 29, 2021
As added to the docstring, this is to avoid issues in generics, namely
the second comment:

Vindaar/ggplotnim#116 (comment)
Vindaar added a commit to SciNim/Datamancer that referenced this issue Jul 3, 2021
As added to the docstring, this is to avoid issues in generics, namely
the second comment:

Vindaar/ggplotnim#116 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant