Skip to content

Commit

Permalink
Throwing warning if frameworks get imported on importing ivy (#11784)
Browse files Browse the repository at this point in the history
Co-authored-by: Ved Patwardhan <[email protected]>
  • Loading branch information
soma2000-lang and vedpatwardhan authored Mar 9, 2023
1 parent 6dd641a commit b715ecf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ivy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,3 +1155,12 @@ def __exit__(self, type, value, traceback):

def dynamic_backend_as(value):
return DynamicBackendContext(value)


modules = ivy.utils.backend.handler._backend_dict.keys()
for module in modules:
if module != "numpy" and module in sys.modules:
warnings.warn(
f"{module} module has been imported while ivy doesn't import it without "
"setting a backend, ignore if that's intended"
)

0 comments on commit b715ecf

Please sign in to comment.