This should be so simple, but I could not make it work.
I want to use aliases but it returns syntax? error?
Below is syntax from manual:
system.tag.queryTagCalculations(paths, calculations, startDate, endDate, rangeHours, rangeMinutes, aliases)
This is my code:
dsAveAndMaxPower_kw = system.tag.queryTagCalculations(
tagPaths, ["Average", "Maximum"], startDateTime, endDateTime)
Results:
[tagpath, Average, Maximum]
[u'power_kW', 365.82751767161477, 597L]
[u'power_kW', 150.73466397841045, 597L]
I want to use Alias so I can rename tagpath.
but I had syntax error.
dsAveAndMaxPower_kw = system.tag.queryTagCalculations(
tagPaths, ["Average", "Maximum"], startDateTime, endDateTime, parentPathList)
Use keyword arguments to specify the exact parameters you're passing, and ensure they're not evaluated as the wrong argument:
dsAveAndMaxPower_kw = system.tag.queryTagCalculations(
paths=tagPaths,
calculations=["Average", "Maximum"],
startDate=startDateTime,
endDate=endDateTime,
aliases=parentPathList
)
If you don't do that, the system has to guess what you mean, and it guesses that the value you're intending to pass for aliases
is what you intended to supply for rangeHours
, which is incompatible.
Thanks..
I found out what is wrong..
The list I was passing was not string.. but type unicode
I promise that's not what was wrong.
In Python 2, basestring
is divided into two types, str
and unicode
. Both are basically interchangable as strings to any Java consumer, such as a system function.
To be fair, if I use equal assignment on paths, -> syntax error:
Oh.. you are right..
The list I entered initially was a PySequence. (coming from ds.getColumnAsList)
lrose
September 10, 2024, 2:39am
7
Also, not the problem.
Read Paul’s first response.
1 Like
lrose
September 10, 2024, 11:42am
8
You should also note, that once you have started using parameter assignments in the function signature you need to use them for everything following:
dsAveAndMaxPower_kw = system.tag.queryTagCalculations(
paths=tagPaths,
['Average','Maximum'],
startDateTime,
endDateTime,
aliases=l)
Will not work.
This will:
dsAveAndMaxPower_kw = system.tag.queryTagCalculations(
paths=tagPaths,
calculations=['Average','Maximum'],
startDate=startDateTime,
endDate=endDateTime,
aliases=l)
2 Likes
This is probably it (This is it)..
Mixing keyword and positional arguments.
My bad.
Thank you.