CNR-Engineering / PyTelTools

Python Telemac Tools for post-processing tasks (includes a workflow)
https://github.com/CNR-Engineering/PyTelTools/wiki
GNU General Public License v3.0
32 stars 15 forks source link

bug in Mesh2D __init__ #8

Closed alesok closed 6 years ago

alesok commented 6 years ago

mesh = MeshInterpolator(slf.header, True) gives TypeError: () got an unexpected keyword argument 'unit'

mesh2d.py line 15 def init(self, input_header, construct_index=False, iter_pbar=lambda x: x): probably should look like def init(self, input_header, construct_index=False, iter_pbar=lambda x, unit: x):

Thanks

lucduron commented 6 years ago

Thank you @alesok for reporting this bug. Could you give us more details about this problem : the complete traceback or the procedure you followed (what did you tried to do : compute a volume? a flux?).

alesok commented 6 years ago

Hi, Sorry, there is no traceback for this bug - I use pyteltools.slf.interpolation programmatically in my code. As far as I can see there is only one call of MeshInterpolator with construct_index=True in the PyTelTools code tree which possibly can affect the GUI of PyTelTools.

See workflow/util.py

    def build_mesh(self, input_data):
        return MeshInterpolator(input_data.header, True)
image
lucduron commented 6 years ago

Thank you for these details, I understand now your problem in case of calling MeshInterpolator without iter_pbar argment. Indeed some long computations/loops may require a progress (for the user) and to factor the code (for GUI and CLI) we used the "generic" argument called iter_pbar, but we did not try without any argument (in this case, there is no progress bar and iter_pbar should be a kind of "identity function"). Thanks to your issue, we fixed it in the last commit 5a1134e. If you want to display a progress bar in a terminal, you could use the module tqdm, furthermore the argument unit is used only for tqdm. Here is an example:

from pyteltools.slf.mesh2D import Mesh2D
from pyteltools.slf.Serafin import Read

from tqdm import tqdm

with Read("../PyTelTools_validation/data/pildepon/f3d_piledepon.slf", 'en') as in_slf:
    in_slf.read_header()
    header = in_slf.header
    mesh = Mesh2D(header, True, tqdm)
alesok commented 6 years ago

Great, thank you.