2121"""
2222
2323from sys import intern
24+ from warnings import warn
2425
2526from pyopencl .version import VERSION , VERSION_STATUS , VERSION_TEXT # noqa
2627
4344 import os
4445 from os .path import dirname , join , realpath
4546 if realpath (join (os .getcwd (), "pyopencl" )) == realpath (dirname (__file__ )):
46- from warnings import warn
4747 warn ("It looks like you are importing PyOpenCL from "
4848 "its source directory. This likely won't work." )
4949 raise
@@ -267,7 +267,6 @@ class CommandQueueUsedAfterExit(UserWarning):
267267
268268def compiler_output (text ):
269269 import os
270- from warnings import warn
271270 if int (os .environ .get ("PYOPENCL_COMPILER_OUTPUT" , "0" )):
272271 warn (text , CompilerWarning )
273272 else :
@@ -389,7 +388,6 @@ def enable_debugging(platform_or_context):
389388 import os
390389 os .environ ["CPU_MAX_COMPUTE_UNITS" ] = "1"
391390 else :
392- from warnings import warn
393391 warn ("do not know how to enable debugging on '%s'"
394392 % platform .name )
395393
@@ -428,7 +426,6 @@ def _get_prg(self):
428426 return self ._prg
429427 else :
430428 # "no program" can only happen in from-source case.
431- from warnings import warn
432429 warn ("Pre-build attribute access defeats compiler caching." ,
433430 stacklevel = 3 )
434431
@@ -662,7 +659,6 @@ def device_hashable_model_and_version_identifier(self):
662659 return ("v1" , self .vendor , self .vendor_id , self .name , self .version )
663660
664661 def device_persistent_unique_id (self ):
665- from warnings import warn
666662 warn ("Device.persistent_unique_id is deprecated. "
667663 "Use Device.hashable_model_and_version_identifier instead." ,
668664 DeprecationWarning , stacklevel = 2 )
@@ -684,7 +680,6 @@ def device_persistent_unique_id(self):
684680
685681 def context_init (self , devices , properties , dev_type , cache_dir = None ):
686682 if cache_dir is not None :
687- from warnings import warn
688683 warn ("The 'cache_dir' argument to the Context constructor "
689684 "is deprecated and no longer has an effect. "
690685 "It was removed because it only applied to the wrapper "
@@ -970,7 +965,6 @@ def image_init(self, context, flags, format, shape=None, pitches=None,
970965
971966 if hostbuf is not None and not \
972967 (flags & (mem_flags .USE_HOST_PTR | mem_flags .COPY_HOST_PTR )):
973- from warnings import warn
974968 warn ("'hostbuf' was passed, but no memory flags to make use of it." )
975969
976970 if hostbuf is None and pitches is not None :
@@ -1043,7 +1037,6 @@ def image_init(self, context, flags, format, shape=None, pitches=None,
10431037
10441038 class _ImageInfoGetter :
10451039 def __init__ (self , event ):
1046- from warnings import warn
10471040 warn ("Image.image.attr is deprecated and will go away in 2021. "
10481041 "Use Image.attr directly, instead." )
10491042
@@ -1927,7 +1920,6 @@ def enqueue_barrier(queue, wait_for=None):
19271920
19281921def enqueue_fill_buffer (queue , mem , pattern , offset , size , wait_for = None ):
19291922 if not (queue ._get_cl_version () >= (1 , 2 ) and get_cl_header_version () >= (1 , 2 )):
1930- from warnings import warn
19311923 warn ("The context for this queue does not declare OpenCL 1.2 support, so "
19321924 "the next thing you might see is a crash" )
19331925
0 commit comments