Skip to content

Commit

Permalink
changing find_spec to try except
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-rakowski committed Nov 14, 2023
1 parent f304a52 commit 03e9e61
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions py4DSTEM/braggvectors/diskdetection_aiml.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import json
import shutil
import numpy as np
from importlib.util import find_spec

from time import time

Expand Down Expand Up @@ -99,7 +98,9 @@ def find_Bragg_disks_aiml_single_DP(
Returns:
(PointList): the Bragg peak positions and correlation intensities
"""
if find_spec("crystal4D") is None:
try:
import crystal4D
except ModuleNotFoundError:
raise ImportError("Import Error: Please install crystal4D before proceeding")
try:
import tensorflow as tf
Expand Down Expand Up @@ -250,7 +251,9 @@ def find_Bragg_disks_aiml_selected(
correlation intensities at each scan position (Rx,Ry).
"""

if find_spec("crystal4D") is None:
try:
import crystal4D
except ModuleNotFoundError:
raise ImportError("Import Error: Please install crystal4D before proceeding")

assert len(Rx) == len(Ry)
Expand Down Expand Up @@ -425,7 +428,9 @@ def find_Bragg_disks_aiml_serial(
(PointListArray): the Bragg peak positions and correlation intensities
"""

if find_spec("crystal4D") is None:
try:
import crystal4D
except ModuleNotFoundError:
raise ImportError("Import Error: Please install crystal4D before proceeding")

# Make the peaks PointListArray
Expand Down Expand Up @@ -633,8 +638,10 @@ def find_Bragg_disks_aiml(
Returns:
(PointListArray): the Bragg peak positions and correlation intensities
"""
if find_spec("crystal4D") is None:
raise ImportError("Please install crystal4D before proceeding")
try:
import crystal4D
except ModuleNotFoundError:
raise ImportError("Import Error: Please install crystal4D before proceeding")

def _parse_distributed(distributed):
import os
Expand Down

0 comments on commit 03e9e61

Please sign in to comment.