-
Notifications
You must be signed in to change notification settings - Fork 167
config_checker update and linting for C408,C419,C405, C409, E721,F401,E722 #560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 30 commits
53e8796
fbbc232
2212461
51f078f
db59746
be609b3
08957ff
e6b6ade
857715a
7892191
4288ca2
1a00dd1
dfa7546
79b2559
0b20634
d3ccf03
9022bee
83a727a
15f387f
dd1a74b
9657c42
dbfa1b2
6b5dfec
89ad26a
ed34a99
5275729
96c96ae
f304a52
03e9e61
436d1e4
5f5d895
98c21d2
0f9b096
dc9c632
4936f9e
03986fa
8e4f7c9
0a77665
92c6942
c280c8e
f1a9b3a
ffa70f9
0b10f48
83453df
19914f6
9397208
9201154
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,16 +4,13 @@ | |
| """ | ||
|
|
||
| import os | ||
| import glob | ||
| import json | ||
| import shutil | ||
| import numpy as np | ||
|
|
||
| from scipy.ndimage import gaussian_filter | ||
| from time import time | ||
| from numbers import Number | ||
|
|
||
| from emdfile import tqdmnd, PointList, PointListArray | ||
| from emdfile import tqdmnd | ||
| from py4DSTEM.braggvectors.braggvectors import BraggVectors | ||
| from py4DSTEM.data import QPoints | ||
| from py4DSTEM.process.utils import get_maxima_2D | ||
|
|
@@ -103,12 +100,12 @@ def find_Bragg_disks_aiml_single_DP( | |
| """ | ||
| try: | ||
| import crystal4D | ||
| except: | ||
| except ModuleNotFoundError: | ||
| raise ImportError("Import Error: Please install crystal4D before proceeding") | ||
| try: | ||
| import tensorflow as tf | ||
| except: | ||
| raise ImportError( | ||
| except ModuleNotFoundError: | ||
| raise ModuleNotFoundError( | ||
| "Please install tensorflow before proceeding - please check " | ||
| + "https://www.tensorflow.org/install" | ||
| + "for more information" | ||
|
|
@@ -256,7 +253,7 @@ def find_Bragg_disks_aiml_selected( | |
|
|
||
| try: | ||
| import crystal4D | ||
| except: | ||
| except ModuleNotFoundError: | ||
| raise ImportError("Import Error: Please install crystal4D before proceeding") | ||
|
|
||
| assert len(Rx) == len(Ry) | ||
|
|
@@ -433,7 +430,7 @@ def find_Bragg_disks_aiml_serial( | |
|
|
||
| try: | ||
| import crystal4D | ||
| except: | ||
| except ModuleNotFoundError: | ||
alex-rakowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| raise ImportError("Import Error: Please install crystal4D before proceeding") | ||
|
|
||
| # Make the peaks PointListArray | ||
|
|
@@ -559,7 +556,7 @@ def find_Bragg_disks_aiml( | |
| model_path=None, | ||
| distributed=None, | ||
| CUDA=True, | ||
| **kwargs | ||
| **kwargs, | ||
| ): | ||
| """ | ||
| Finds the Bragg disks in all diffraction patterns of datacube by AI/ML method. This method | ||
|
|
@@ -643,8 +640,8 @@ def find_Bragg_disks_aiml( | |
| """ | ||
| try: | ||
| import crystal4D | ||
| except: | ||
| raise ImportError("Please install crystal4D before proceeding") | ||
| except ModuleNotFoundError: | ||
| raise ImportError("Import Error: Please install crystal4D before proceeding") | ||
alex-rakowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| def _parse_distributed(distributed): | ||
| import os | ||
|
|
@@ -840,7 +837,8 @@ def _integrate_disks(DP, maxima_x, maxima_y, maxima_int, int_window_radius=1): | |
| disks.append(np.average(disk)) | ||
| try: | ||
| disks = disks / max(disks) | ||
| except: | ||
| # TODO work out what exception would go here | ||
|
||
| except Exception: | ||
| pass | ||
| return (maxima_x, maxima_y, disks) | ||
|
|
||
|
|
@@ -878,8 +876,8 @@ def _get_latest_model(model_path=None): | |
|
|
||
| try: | ||
| import tensorflow as tf | ||
| except: | ||
| raise ImportError( | ||
| except ModuleNotFoundError: | ||
| raise ModuleNotFoundError( | ||
| "Please install tensorflow before proceeding - please check " | ||
| + "https://www.tensorflow.org/install" | ||
| + "for more information" | ||
|
|
@@ -891,8 +889,12 @@ def _get_latest_model(model_path=None): | |
| if model_path is None: | ||
| try: | ||
| os.mkdir("./tmp") | ||
| except: | ||
| except FileExistsError: | ||
| pass | ||
| except Exception as e: | ||
| # TODO work out if I want to pass or raise | ||
alex-rakowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pass | ||
| # raise e | ||
| # download the json file with the meta data | ||
| download_file_from_google_drive("FCU-Net", "./tmp/model_metadata.json") | ||
| with open("./tmp/model_metadata.json") as f: | ||
|
|
@@ -905,7 +907,10 @@ def _get_latest_model(model_path=None): | |
| with open("./tmp/model_metadata_old.json") as f_old: | ||
| metaold = json.load(f_old) | ||
| file_id_old = metaold["file_id"] | ||
| except: | ||
| # TODO Double check this is correct Error | ||
|
||
| except FileNotFoundError: | ||
| file_id_old = file_id | ||
| except Exception: | ||
alex-rakowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| file_id_old = file_id | ||
|
|
||
| if os.path.exists(file_path) and file_id == file_id_old: | ||
|
|
@@ -921,7 +926,8 @@ def _get_latest_model(model_path=None): | |
| download_file_from_google_drive(file_id, filename) | ||
| try: | ||
| shutil.unpack_archive(filename, "./tmp", format="zip") | ||
| except: | ||
| # TODO Work work what specific exception | ||
alex-rakowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| except Exception: | ||
| pass | ||
| model_path = file_path | ||
| os.rename("./tmp/model_metadata.json", "./tmp/model_metadata_old.json") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,7 +124,8 @@ def __init__( | |
| # this may be wrong for binned data... in which case the reader doesn't work anyway! | ||
| Q_Nx = gtg.allTags[".SI Image Tags.Acquisition.Parameters.Detector.height"] | ||
| Q_Ny = gtg.allTags[".SI Image Tags.Acquisition.Parameters.Detector.width"] | ||
| except: | ||
| # TODO check this is the correct error type | ||
|
||
| except (ValueError, KeyError): | ||
| print("Warning: diffraction pattern shape not detected!") | ||
| print("Assuming 1920x1792 as the diffraction pattern size!") | ||
| Q_Nx = 1792 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.