TulipaEnergy / TulipaIO.jl

Apache License 2.0
0 stars 3 forks source link

Refactor use of name, tmp, show triplet #31

Closed abelsiqueira closed 1 month ago

abelsiqueira commented 4 months ago

There are $2^3 = 8$ possibilities. Refactor so these are clear. Possibly create a function to assist.

A possible implementation is using Val. E.g.,

function foo(::Val{true}, x)
  return x + 1
end

function foo(::Val{false}, x)
  return x - 1
end

function foo(x)
  if x > 0
    return foo(Val(true), x)
  else
    return foo(Val(false), x)
  end
end
suvayu commented 1 month ago

Some notes on behaviour, for a given source:

  1. source is a file: return show ? DataFrame(...) | table_name

    name tmp remarks
    non-empty as provided
    empty true table name: t_<safe_filename>
    empty false table name: <safe_filename>

    The above behaviour reduces the coupled possibilities to only 2. When name is empty, the generated table name differs based on tmp.

  2. source is another table: TBD since now the scope of TIO also includes use as a library by TEM.