Buckets:
| # Correction du notebook pour gérer les tuples retournés par get_field_to_plot | |
| import json | |
| # Charger le notebook | |
| with open('/root/fluidsim/tutos/analyse_taylor_green.ipynb', 'r') as f: | |
| nb = json.load(f) | |
| # Trouver la cellule avec les champs physiques | |
| for cell in nb['cells']: | |
| if cell['cell_type'] == 'code' and 'get_field_to_plot' in ''.join(cell['source']): | |
| # Ajouter la gestion des tuples | |
| source = cell['source'] | |
| new_source = [] | |
| for line in source: | |
| if 'get_field_to_plot' in line and ('rot_' in line or 'ux_' in line or 'uy_' in line): | |
| var_name = line.split('=')[0].strip() | |
| new_source.append(line) | |
| new_source.append(f"if isinstance({var_name}, tuple):\n") | |
| new_source.append(f" {var_name} = {var_name}[0]\n") | |
| else: | |
| new_source.append(line) | |
| cell['source'] = new_source | |
| break | |
| # Sauvegarder le notebook corrigé | |
| with open('/root/fluidsim/tutos/analyse_taylor_green.ipynb', 'w') as f: | |
| json.dump(nb, f, indent=1) | |
| print("Notebook corrigé pour gérer les tuples get_field_to_plot") |
Xet Storage Details
- Size:
- 1.15 kB
- Xet hash:
- cfb70b0d93e7b626e5eec00d7bb47d5efcd551ec7c4210d5f88e7fddf1f326f4
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.