Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit f54cd9ce authored by Camilla Dodge Koslowsky Harris's avatar Camilla Dodge Koslowsky Harris
Browse files

Made tecplottools.apply_equations more robust, anticipated some different...

Made tecplottools.apply_equations more robust, anticipated some different formats in equations files
parent 05ac3452
......@@ -33,8 +33,8 @@ def apply_equations(eqn_path: str, verbose: bool = False):
Args:
eqn_file_path (str): The path to the equation macro file (typically with
extension `.eqn`).
verbose (bool): (Optional) Whether or not to print the equations as they are
applied. Default behavior is silent.
verbose (bool): (Optional) Whether or not to print the equations as they
are applied. Default behavior is silent.
Examples:
```python
......@@ -68,10 +68,17 @@ def apply_equations(eqn_path: str, verbose: bool = False):
print('Executing:')
with open(eqn_path, 'r') as eqn_file:
for line in eqn_file:
if line[0] == ' ':
eqnstr = line.split("'")[1]
tecplot.data.operate.execute_equation(eqnstr)
if '$!alterdata' in line.lower():
eqn_line = eqn_file.readline()
try:
eqn_str = eqn_line.split("'")[1]
except IndexError:
try:
eqn_str = eqn_line.split("\"")[1]
except:
raise ValueError(f'Unable to read equation: {eqn_line}')
tecplot.data.operate.execute_equation(eqn_str)
if verbose:
print(eqnstr)
print(eqn_str)
if verbose:
print('Successfully applied equations.')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment