Skip to content

Commit c4d89e5

Browse files
authored
Add table map generator documentation (#394)
- Documented all table map generator methods - Provided an example of the tablemapREST class to demonstrate how to configure and use the Table Map Generator.
1 parent b368b15 commit c4d89e5

File tree

3 files changed

+169
-0
lines changed

3 files changed

+169
-0
lines changed

doc/source/lowlevelapi/TemplateObjects.rst

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,175 @@ These would be the lines of code to create the new template:
12411241
)
12421242
server.put_objects(my_template)
12431243
1244+
.. _tablemapREST:
1245+
1246+
tablemapREST object
1247+
^^^^^^^^^^^^^^^^^^^
1248+
1249+
Inherits from TemplateREST, GeneratorREST
1250+
1251+
Class that corresponds to the `Table Map`
1252+
Generator template type. Its specific methods
1253+
are:
1254+
1255+
**template.get_map_param()**
1256+
1257+
Get the value of Map. Possible outputs are:
1258+
1259+
- 'row': corresponds to Rows
1260+
- 'column': corresponds to Columns
1261+
1262+
**template.set_map_param(value='row')**
1263+
1264+
Set the value of Map. Input needs to be a string: either "row" or
1265+
"column".
1266+
1267+
**template.get_table_name()**
1268+
1269+
Get the value of Resulting table name.
1270+
1271+
**template.set_table_name(value = 'output_table')**
1272+
1273+
Set the value of Resulting table name. Input should be a string.
1274+
1275+
**template.get_operations()**
1276+
1277+
Get the values for the Map operations as a list. Each element
1278+
corresponds to a different operation. Each element is a dictionary,
1279+
where the following keys are presented:
1280+
1281+
- 'source_rows': corresponds to the name(s) of the rows/columns used in
1282+
the operation
1283+
- 'output_rows': corresponds to the Output row/column name
1284+
- 'output_columns_select': corresponds to the "Select columns/rows"
1285+
field
1286+
- 'function': corresponds to the Function field. Allowed functions are:
1287+
1288+
- '+': Addition
1289+
- '-': Subtraction
1290+
- '*': Multiplication
1291+
- '/': Division
1292+
- '^': Power
1293+
- 'abs()': Absolute Value
1294+
- 'exp()': Exponent
1295+
- 'log()': Logarithm
1296+
1297+
**template.delete_operation(name = [])**
1298+
1299+
Method to remove an entire Map operation. Takes as input a list with
1300+
the name(s) of the source rows/columns used in the operation. So for
1301+
example to delete the third Map operation from the following panel:
1302+
1303+
.. figure:: lib/NewItem314.png
1304+
:alt: Image
1305+
:align: center
1306+
1307+
1308+
use:
1309+
1310+
.. code-block:: python
1311+
1312+
template.delete_operation(name=["temperature", "pressure"])
1313+
1314+
To delete the first operation, use:
1315+
1316+
.. code-block:: python
1317+
1318+
template.delete_operation(name=["temperature"])
1319+
1320+
**template.add_operation(name=None, output_name="output row", select_names="*", function="value")**
1321+
1322+
Add a new Map operation.
1323+
1324+
- 'name': corresponds to the name(s) of the rows/columns used in the
1325+
operation. Input needs to be a list of strings
1326+
- 'output_name': corresponds to the Output row/column name.
1327+
- 'select_names': corresponds to the name(s) of the selected rows/columns in the output.
1328+
- 'function': corresponds to the operation field. See get_operations()
1329+
for the allowed functions.
1330+
1331+
For example to create the operation in the following widget:
1332+
1333+
.. figure:: lib/NewItem314.png
1334+
:alt: Image
1335+
:align: center
1336+
1337+
1338+
you would run:
1339+
1340+
.. code-block:: python
1341+
1342+
template.add_operation(
1343+
name=["temperature", "pressure"],
1344+
output_name="output row",
1345+
select_names="*",
1346+
function="value ^ 2",
1347+
)
1348+
1349+
**template.get_table_transpose()**
1350+
1351+
Get the value for Transpose results. Output is an integer: 0 for OFF, 1
1352+
for ON.
1353+
1354+
**template.set_table_transpose(value=0)**
1355+
1356+
Set the value for Transpose results. Input must be an integer: 0 for
1357+
OFF, 1 for ON.
1358+
1359+
**template.get_numeric_output()**
1360+
1361+
Get the value for Force numeric table output. Output is an integer: 0
1362+
for OFF, 1 for ON.
1363+
1364+
**template.set_numeric_output(value=0)**
1365+
1366+
Set the value for Force numeric table output. Input must be an integer:
1367+
0 for OFF, 1 for ON.
1368+
1369+
Example of usage. Let's assume you want to create a template like the
1370+
one shown in the picture:
1371+
1372+
.. figure:: lib/NewItem315.png
1373+
:alt: Image
1374+
:align: center
1375+
1376+
1377+
Let's also assume you want this template to be a child of the template
1378+
"Merge" in the database running locally on port 8000.
1379+
These would be the lines of code to create the new template:
1380+
1381+
.. code-block:: python
1382+
1383+
from ansys.dynamicreporting.core.utils import report_remote_server, report_objects
1384+
1385+
server = report_remote_server.Server("http://localhost:8000", "nexus", "cei")
1386+
all_reports = server.get_objects(objtype=report_objects.TemplateREST)
1387+
my_parent = [x for x in all_reports if x.name == "Merge"][0]
1388+
my_template = server.create_template(
1389+
name="Mapped Data", parent=my_parent, report_type="Generator:tablemap"
1390+
)
1391+
my_template.set_generated_items("replace")
1392+
my_template.delete_operation(name=["\*"])
1393+
my_template.add_operation(
1394+
name=["Phase I"],
1395+
output_name="Phase I * 2",
1396+
select_names="*",
1397+
function="value * 2",
1398+
)
1399+
my_template.add_operation(
1400+
name=["Phase II"],
1401+
output_name="Phase II + 3",
1402+
select_names="*",
1403+
function="value + 3",
1404+
)
1405+
my_template.add_operation(
1406+
name=["Phase III"],
1407+
output_name="exp(Phase III)",
1408+
select_names="*",
1409+
function="exp(value)",
1410+
)
1411+
server.put_objects(my_template)
1412+
12441413
.. _tablerowcolumnfilterREST:
12451414

12461415
tablerowcolumnfilterREST object
25.4 KB
Loading
61.8 KB
Loading

0 commit comments

Comments
 (0)