We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Change a method reporting an error when CuPy is not correctly installed
Currently CuPy raises `importError` with this error message:
`ImportError: cannot import name core`

This is because `core` module is a native module (i mean .so file), and the setup script cannot build it when CUDA environment is not correctly setup. This error doesn't represent its situation. We need to change its message.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `cupy/__init__.py`
Content:
```
1 from __future__ import division
2 import sys
3 
4 import numpy
5 import six
6 
7 
8 from cupy import binary
9 from cupy import core
10 from cupy import creation
11 from cupy import indexing
12 from cupy import io
13 from cupy import linalg
14 from cupy import logic
15 from cupy import manipulation
16 from cupy import math
17 import cupy.random
18 from cupy import sorting
19 from cupy import statistics
20 from cupy import testing  # NOQA
21 from cupy import util
22 
23 random = cupy.random
24 
25 ndarray = core.ndarray
26 
27 # dtype short cut
28 number = numpy.number
29 integer = numpy.integer
30 signedinteger = numpy.signedinteger
31 unsignedinteger = numpy.unsignedinteger
32 inexact = numpy.inexact
33 floating = numpy.floating
34 
35 bool_ = numpy.bool_
36 byte = numpy.byte
37 short = numpy.short
38 intc = numpy.intc
39 int_ = numpy.int_
40 longlong = numpy.longlong
41 ubyte = numpy.ubyte
42 ushort = numpy.ushort
43 uintc = numpy.uintc
44 uint = numpy.uint
45 ulonglong = numpy.ulonglong
46 
47 half = numpy.half
48 single = numpy.single
49 float_ = numpy.float_
50 longfloat = numpy.longfloat
51 
52 int8 = numpy.int8
53 int16 = numpy.int16
54 int32 = numpy.int32
55 int64 = numpy.int64
56 uint8 = numpy.uint8
57 uint16 = numpy.uint16
58 uint32 = numpy.uint32
59 uint64 = numpy.uint64
60 
61 float16 = numpy.float16
62 float32 = numpy.float32
63 float64 = numpy.float64
64 
65 ufunc = core.ufunc
66 
67 newaxis = numpy.newaxis  # == None
68 
69 # =============================================================================
70 # Routines
71 #
72 # The order of these declarations are borrowed from the NumPy document:
73 # http://docs.scipy.org/doc/numpy/reference/routines.html
74 # =============================================================================
75 
76 # -----------------------------------------------------------------------------
77 # Array creation routines
78 # -----------------------------------------------------------------------------
79 empty = creation.basic.empty
80 empty_like = creation.basic.empty_like
81 eye = creation.basic.eye
82 identity = creation.basic.identity
83 ones = creation.basic.ones
84 ones_like = creation.basic.ones_like
85 zeros = creation.basic.zeros
86 zeros_like = creation.basic.zeros_like
87 full = creation.basic.full
88 full_like = creation.basic.full_like
89 
90 array = creation.from_data.array
91 asarray = creation.from_data.asarray
92 asanyarray = creation.from_data.asanyarray
93 ascontiguousarray = creation.from_data.ascontiguousarray
94 copy = creation.from_data.copy
95 
96 arange = creation.ranges.arange
97 linspace = creation.ranges.linspace
98 
99 diag = creation.matrix.diag
100 diagflat = creation.matrix.diagflat
101 
102 # -----------------------------------------------------------------------------
103 # Array manipulation routines
104 # -----------------------------------------------------------------------------
105 copyto = manipulation.basic.copyto
106 
107 reshape = manipulation.shape.reshape
108 ravel = manipulation.shape.ravel
109 
110 rollaxis = manipulation.transpose.rollaxis
111 swapaxes = manipulation.transpose.swapaxes
112 transpose = manipulation.transpose.transpose
113 
114 atleast_1d = manipulation.dims.atleast_1d
115 atleast_2d = manipulation.dims.atleast_2d
116 atleast_3d = manipulation.dims.atleast_3d
117 broadcast = manipulation.dims.broadcast
118 broadcast_arrays = manipulation.dims.broadcast_arrays
119 broadcast_to = manipulation.dims.broadcast_to
120 expand_dims = manipulation.dims.expand_dims
121 squeeze = manipulation.dims.squeeze
122 
123 column_stack = manipulation.join.column_stack
124 concatenate = manipulation.join.concatenate
125 dstack = manipulation.join.dstack
126 hstack = manipulation.join.hstack
127 vstack = manipulation.join.vstack
128 
129 asfortranarray = manipulation.kind.asfortranarray
130 
131 array_split = manipulation.split.array_split
132 dsplit = manipulation.split.dsplit
133 hsplit = manipulation.split.hsplit
134 split = manipulation.split.split
135 vsplit = manipulation.split.vsplit
136 
137 tile = manipulation.tiling.tile
138 repeat = manipulation.tiling.repeat
139 
140 roll = manipulation.rearrange.roll
141 
142 # -----------------------------------------------------------------------------
143 # Binary operations
144 # -----------------------------------------------------------------------------
145 bitwise_and = binary.elementwise.bitwise_and
146 bitwise_or = binary.elementwise.bitwise_or
147 bitwise_xor = binary.elementwise.bitwise_xor
148 invert = binary.elementwise.invert
149 left_shift = binary.elementwise.left_shift
150 right_shift = binary.elementwise.right_shift
151 
152 binary_repr = numpy.binary_repr
153 
154 # -----------------------------------------------------------------------------
155 # Data type routines (borrowed from NumPy)
156 # -----------------------------------------------------------------------------
157 can_cast = numpy.can_cast
158 promote_types = numpy.promote_types
159 min_scalar_type = numpy.min_scalar_type
160 result_type = numpy.result_type
161 common_type = numpy.common_type
162 obj2sctype = numpy.obj2sctype
163 
164 dtype = numpy.dtype
165 format_parser = numpy.format_parser
166 
167 finfo = numpy.finfo
168 iinfo = numpy.iinfo
169 MachAr = numpy.MachAr
170 
171 issctype = numpy.issctype
172 issubdtype = numpy.issubdtype
173 issubsctype = numpy.issubsctype
174 issubclass_ = numpy.issubclass_
175 find_common_type = numpy.find_common_type
176 
177 typename = numpy.typename
178 sctype2char = numpy.sctype2char
179 mintypecode = numpy.mintypecode
180 
181 # -----------------------------------------------------------------------------
182 # Optionally Scipy-accelerated routines
183 # -----------------------------------------------------------------------------
184 # TODO(beam2d): Implement it
185 
186 # -----------------------------------------------------------------------------
187 # Discrete Fourier Transform
188 # -----------------------------------------------------------------------------
189 # TODO(beam2d): Implement it
190 
191 # -----------------------------------------------------------------------------
192 # Indexing routines
193 # -----------------------------------------------------------------------------
194 take = indexing.indexing.take
195 diagonal = indexing.indexing.diagonal
196 
197 # -----------------------------------------------------------------------------
198 # Input and output
199 # -----------------------------------------------------------------------------
200 load = io.npz.load
201 save = io.npz.save
202 savez = io.npz.savez
203 savez_compressed = io.npz.savez_compressed
204 
205 array_repr = io.formatting.array_repr
206 array_str = io.formatting.array_str
207 
208 base_repr = numpy.base_repr
209 
210 # -----------------------------------------------------------------------------
211 # Linear algebra
212 # -----------------------------------------------------------------------------
213 dot = linalg.product.dot
214 vdot = linalg.product.vdot
215 inner = linalg.product.inner
216 outer = linalg.product.outer
217 tensordot = linalg.product.tensordot
218 
219 trace = linalg.norm.trace
220 
221 # -----------------------------------------------------------------------------
222 # Logic functions
223 # -----------------------------------------------------------------------------
224 isfinite = logic.content.isfinite
225 isinf = logic.content.isinf
226 isnan = logic.content.isnan
227 
228 isscalar = numpy.isscalar
229 
230 logical_and = logic.ops.logical_and
231 logical_or = logic.ops.logical_or
232 logical_not = logic.ops.logical_not
233 logical_xor = logic.ops.logical_xor
234 
235 greater = logic.comparison.greater
236 greater_equal = logic.comparison.greater_equal
237 less = logic.comparison.less
238 less_equal = logic.comparison.less_equal
239 equal = logic.comparison.equal
240 not_equal = logic.comparison.not_equal
241 
242 all = logic.truth.all
243 any = logic.truth.any
244 
245 # -----------------------------------------------------------------------------
246 # Mathematical functions
247 # -----------------------------------------------------------------------------
248 sin = math.trigonometric.sin
249 cos = math.trigonometric.cos
250 tan = math.trigonometric.tan
251 arcsin = math.trigonometric.arcsin
252 arccos = math.trigonometric.arccos
253 arctan = math.trigonometric.arctan
254 hypot = math.trigonometric.hypot
255 arctan2 = math.trigonometric.arctan2
256 deg2rad = math.trigonometric.deg2rad
257 rad2deg = math.trigonometric.rad2deg
258 degrees = math.trigonometric.degrees
259 radians = math.trigonometric.radians
260 
261 sinh = math.hyperbolic.sinh
262 cosh = math.hyperbolic.cosh
263 tanh = math.hyperbolic.tanh
264 arcsinh = math.hyperbolic.arcsinh
265 arccosh = math.hyperbolic.arccosh
266 arctanh = math.hyperbolic.arctanh
267 
268 rint = math.rounding.rint
269 floor = math.rounding.floor
270 ceil = math.rounding.ceil
271 trunc = math.rounding.trunc
272 
273 sum = math.sumprod.sum
274 prod = math.sumprod.prod
275 
276 exp = math.explog.exp
277 expm1 = math.explog.expm1
278 exp2 = math.explog.exp2
279 log = math.explog.log
280 log10 = math.explog.log10
281 log2 = math.explog.log2
282 log1p = math.explog.log1p
283 logaddexp = math.explog.logaddexp
284 logaddexp2 = math.explog.logaddexp2
285 
286 signbit = math.floating.signbit
287 copysign = math.floating.copysign
288 ldexp = math.floating.ldexp
289 frexp = math.floating.frexp
290 nextafter = math.floating.nextafter
291 
292 add = math.arithmetic.add
293 reciprocal = math.arithmetic.reciprocal
294 negative = math.arithmetic.negative
295 multiply = math.arithmetic.multiply
296 divide = math.arithmetic.divide
297 power = math.arithmetic.power
298 subtract = math.arithmetic.subtract
299 true_divide = math.arithmetic.true_divide
300 floor_divide = math.arithmetic.floor_divide
301 fmod = math.arithmetic.fmod
302 mod = math.arithmetic.remainder
303 modf = math.arithmetic.modf
304 remainder = math.arithmetic.remainder
305 
306 clip = math.misc.clip
307 sqrt = math.misc.sqrt
308 square = math.misc.square
309 absolute = math.misc.absolute
310 abs = math.misc.absolute
311 sign = math.misc.sign
312 maximum = math.misc.maximum
313 minimum = math.misc.minimum
314 fmax = math.misc.fmax
315 fmin = math.misc.fmin
316 
317 # -----------------------------------------------------------------------------
318 # Sorting, searching, and counting
319 # -----------------------------------------------------------------------------
320 count_nonzero = sorting.count.count_nonzero
321 
322 argmax = sorting.search.argmax
323 argmin = sorting.search.argmin
324 where = sorting.search.where
325 
326 # -----------------------------------------------------------------------------
327 # Statistics
328 # -----------------------------------------------------------------------------
329 amin = statistics.order.amin
330 min = statistics.order.amin
331 amax = statistics.order.amax
332 max = statistics.order.amax
333 
334 mean = statistics.meanvar.mean
335 var = statistics.meanvar.var
336 std = statistics.meanvar.std
337 
338 bincount = statistics.histogram.bincount
339 
340 
341 # CuPy specific functions
342 def asnumpy(a, stream=None):
343     """Returns an array on the host memory from an arbitrary source array.
344 
345     Args:
346         a: Arbitrary object that can be converted to :class:`numpy.ndarray`.
347         stream (cupy.cuda.Stream): CUDA stream object. If it is specified, then
348             the device-to-host copy runs asynchronously. Otherwise, the copy is
349             synchronous. Note that if ``a`` is not a :class:`cupy.ndarray`
350             object, then this argument has no effect.
351 
352     Returns:
353         numpy.ndarray: Converted array on the host memory.
354 
355     """
356     if isinstance(a, ndarray):
357         return a.get(stream=stream)
358     else:
359         return numpy.asarray(a)
360 
361 
362 _cupy = sys.modules[__name__]
363 
364 
365 def get_array_module(*args):
366     """Returns the array module for arguments.
367 
368     This function is used to implement CPU/GPU generic code. If at least one of
369     the arguments is a :class:`cupy.ndarray` object, the :mod:`cupy` module is
370     returned.
371 
372     Args:
373         args: Values to determine whether NumPy or CuPy should be used.
374 
375     Returns:
376         module: :mod:`cupy` or :mod:`numpy` is returned based on the types of
377         the arguments.
378 
379     .. admonition:: Example
380 
381        A NumPy/CuPy generic function can be written as follows::
382 
383        >>> def softplus(x):
384        ...     xp = cupy.get_array_module(x)
385        ...     return xp.maximum(0, x) + xp.log1p(xp.exp(-abs(x)))
386 
387     """
388     if six.moves.builtins.any(isinstance(arg, ndarray) for arg in args):
389         return _cupy
390     else:
391         return numpy
392 
393 
394 clear_memo = util.clear_memo
395 memoize = util.memoize
396 
397 ElementwiseKernel = core.ElementwiseKernel
398 ReductionKernel = core.ReductionKernel
399
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/cupy/__init__.py b/cupy/__init__.py
--- a/cupy/__init__.py
+++ b/cupy/__init__.py
@@ -4,9 +4,19 @@
 import numpy
 import six
 
+try:
+    from cupy import core
+except ImportError:
+    # core is a c-extention module.
+    # When a user cannot import core, it represents that CuPy is not correctly
+    # built.
+    msg = ('CuPy is not correctly installed. Please check your environment, '
+           'uninstall Chainer and reinstall it with `pip install chainer '
+           '--no-cache-dir -vvvv`.')
+    raise six.reraise(RuntimeError, msg, sys.exc_info()[2])
+
 
 from cupy import binary
-from cupy import core
 from cupy import creation
 from cupy import indexing
 from cupy import io

{"golden_diff": "diff --git a/cupy/__init__.py b/cupy/__init__.py\n--- a/cupy/__init__.py\n+++ b/cupy/__init__.py\n@@ -4,9 +4,19 @@\n import numpy\n import six\n \n+try:\n+    from cupy import core\n+except ImportError:\n+    # core is a c-extention module.\n+    # When a user cannot import core, it represents that CuPy is not correctly\n+    # built.\n+    msg = ('CuPy is not correctly installed. Please check your environment, '\n+           'uninstall Chainer and reinstall it with `pip install chainer '\n+           '--no-cache-dir -vvvv`.')\n+    raise six.reraise(RuntimeError, msg, sys.exc_info()[2])\n+\n \n from cupy import binary\n-from cupy import core\n from cupy import creation\n from cupy import indexing\n from cupy import io\n", "issue": "Change a method reporting an error when CuPy is not correctly installed\nCurrently CuPy raises `importError` with this error message:\n`ImportError: cannot import name core`\n\nThis is because `core` module is a native module (i mean .so file), and the setup script cannot build it when CUDA environment is not correctly setup. This error doesn't represent its situation. We need to change its message.\n\n", "before_files": [{"content": "from __future__ import division\nimport sys\n\nimport numpy\nimport six\n\n\nfrom cupy import binary\nfrom cupy import core\nfrom cupy import creation\nfrom cupy import indexing\nfrom cupy import io\nfrom cupy import linalg\nfrom cupy import logic\nfrom cupy import manipulation\nfrom cupy import math\nimport cupy.random\nfrom cupy import sorting\nfrom cupy import statistics\nfrom cupy import testing  # NOQA\nfrom cupy import util\n\nrandom = cupy.random\n\nndarray = core.ndarray\n\n# dtype short cut\nnumber = numpy.number\ninteger = numpy.integer\nsignedinteger = numpy.signedinteger\nunsignedinteger = numpy.unsignedinteger\ninexact = numpy.inexact\nfloating = numpy.floating\n\nbool_ = numpy.bool_\nbyte = numpy.byte\nshort = numpy.short\nintc = numpy.intc\nint_ = numpy.int_\nlonglong = numpy.longlong\nubyte = numpy.ubyte\nushort = numpy.ushort\nuintc = numpy.uintc\nuint = numpy.uint\nulonglong = numpy.ulonglong\n\nhalf = numpy.half\nsingle = numpy.single\nfloat_ = numpy.float_\nlongfloat = numpy.longfloat\n\nint8 = numpy.int8\nint16 = numpy.int16\nint32 = numpy.int32\nint64 = numpy.int64\nuint8 = numpy.uint8\nuint16 = numpy.uint16\nuint32 = numpy.uint32\nuint64 = numpy.uint64\n\nfloat16 = numpy.float16\nfloat32 = numpy.float32\nfloat64 = numpy.float64\n\nufunc = core.ufunc\n\nnewaxis = numpy.newaxis  # == None\n\n# =============================================================================\n# Routines\n#\n# The order of these declarations are borrowed from the NumPy document:\n# http://docs.scipy.org/doc/numpy/reference/routines.html\n# =============================================================================\n\n# -----------------------------------------------------------------------------\n# Array creation routines\n# -----------------------------------------------------------------------------\nempty = creation.basic.empty\nempty_like = creation.basic.empty_like\neye = creation.basic.eye\nidentity = creation.basic.identity\nones = creation.basic.ones\nones_like = creation.basic.ones_like\nzeros = creation.basic.zeros\nzeros_like = creation.basic.zeros_like\nfull = creation.basic.full\nfull_like = creation.basic.full_like\n\narray = creation.from_data.array\nasarray = creation.from_data.asarray\nasanyarray = creation.from_data.asanyarray\nascontiguousarray = creation.from_data.ascontiguousarray\ncopy = creation.from_data.copy\n\narange = creation.ranges.arange\nlinspace = creation.ranges.linspace\n\ndiag = creation.matrix.diag\ndiagflat = creation.matrix.diagflat\n\n# -----------------------------------------------------------------------------\n# Array manipulation routines\n# -----------------------------------------------------------------------------\ncopyto = manipulation.basic.copyto\n\nreshape = manipulation.shape.reshape\nravel = manipulation.shape.ravel\n\nrollaxis = manipulation.transpose.rollaxis\nswapaxes = manipulation.transpose.swapaxes\ntranspose = manipulation.transpose.transpose\n\natleast_1d = manipulation.dims.atleast_1d\natleast_2d = manipulation.dims.atleast_2d\natleast_3d = manipulation.dims.atleast_3d\nbroadcast = manipulation.dims.broadcast\nbroadcast_arrays = manipulation.dims.broadcast_arrays\nbroadcast_to = manipulation.dims.broadcast_to\nexpand_dims = manipulation.dims.expand_dims\nsqueeze = manipulation.dims.squeeze\n\ncolumn_stack = manipulation.join.column_stack\nconcatenate = manipulation.join.concatenate\ndstack = manipulation.join.dstack\nhstack = manipulation.join.hstack\nvstack = manipulation.join.vstack\n\nasfortranarray = manipulation.kind.asfortranarray\n\narray_split = manipulation.split.array_split\ndsplit = manipulation.split.dsplit\nhsplit = manipulation.split.hsplit\nsplit = manipulation.split.split\nvsplit = manipulation.split.vsplit\n\ntile = manipulation.tiling.tile\nrepeat = manipulation.tiling.repeat\n\nroll = manipulation.rearrange.roll\n\n# -----------------------------------------------------------------------------\n# Binary operations\n# -----------------------------------------------------------------------------\nbitwise_and = binary.elementwise.bitwise_and\nbitwise_or = binary.elementwise.bitwise_or\nbitwise_xor = binary.elementwise.bitwise_xor\ninvert = binary.elementwise.invert\nleft_shift = binary.elementwise.left_shift\nright_shift = binary.elementwise.right_shift\n\nbinary_repr = numpy.binary_repr\n\n# -----------------------------------------------------------------------------\n# Data type routines (borrowed from NumPy)\n# -----------------------------------------------------------------------------\ncan_cast = numpy.can_cast\npromote_types = numpy.promote_types\nmin_scalar_type = numpy.min_scalar_type\nresult_type = numpy.result_type\ncommon_type = numpy.common_type\nobj2sctype = numpy.obj2sctype\n\ndtype = numpy.dtype\nformat_parser = numpy.format_parser\n\nfinfo = numpy.finfo\niinfo = numpy.iinfo\nMachAr = numpy.MachAr\n\nissctype = numpy.issctype\nissubdtype = numpy.issubdtype\nissubsctype = numpy.issubsctype\nissubclass_ = numpy.issubclass_\nfind_common_type = numpy.find_common_type\n\ntypename = numpy.typename\nsctype2char = numpy.sctype2char\nmintypecode = numpy.mintypecode\n\n# -----------------------------------------------------------------------------\n# Optionally Scipy-accelerated routines\n# -----------------------------------------------------------------------------\n# TODO(beam2d): Implement it\n\n# -----------------------------------------------------------------------------\n# Discrete Fourier Transform\n# -----------------------------------------------------------------------------\n# TODO(beam2d): Implement it\n\n# -----------------------------------------------------------------------------\n# Indexing routines\n# -----------------------------------------------------------------------------\ntake = indexing.indexing.take\ndiagonal = indexing.indexing.diagonal\n\n# -----------------------------------------------------------------------------\n# Input and output\n# -----------------------------------------------------------------------------\nload = io.npz.load\nsave = io.npz.save\nsavez = io.npz.savez\nsavez_compressed = io.npz.savez_compressed\n\narray_repr = io.formatting.array_repr\narray_str = io.formatting.array_str\n\nbase_repr = numpy.base_repr\n\n# -----------------------------------------------------------------------------\n# Linear algebra\n# -----------------------------------------------------------------------------\ndot = linalg.product.dot\nvdot = linalg.product.vdot\ninner = linalg.product.inner\nouter = linalg.product.outer\ntensordot = linalg.product.tensordot\n\ntrace = linalg.norm.trace\n\n# -----------------------------------------------------------------------------\n# Logic functions\n# -----------------------------------------------------------------------------\nisfinite = logic.content.isfinite\nisinf = logic.content.isinf\nisnan = logic.content.isnan\n\nisscalar = numpy.isscalar\n\nlogical_and = logic.ops.logical_and\nlogical_or = logic.ops.logical_or\nlogical_not = logic.ops.logical_not\nlogical_xor = logic.ops.logical_xor\n\ngreater = logic.comparison.greater\ngreater_equal = logic.comparison.greater_equal\nless = logic.comparison.less\nless_equal = logic.comparison.less_equal\nequal = logic.comparison.equal\nnot_equal = logic.comparison.not_equal\n\nall = logic.truth.all\nany = logic.truth.any\n\n# -----------------------------------------------------------------------------\n# Mathematical functions\n# -----------------------------------------------------------------------------\nsin = math.trigonometric.sin\ncos = math.trigonometric.cos\ntan = math.trigonometric.tan\narcsin = math.trigonometric.arcsin\narccos = math.trigonometric.arccos\narctan = math.trigonometric.arctan\nhypot = math.trigonometric.hypot\narctan2 = math.trigonometric.arctan2\ndeg2rad = math.trigonometric.deg2rad\nrad2deg = math.trigonometric.rad2deg\ndegrees = math.trigonometric.degrees\nradians = math.trigonometric.radians\n\nsinh = math.hyperbolic.sinh\ncosh = math.hyperbolic.cosh\ntanh = math.hyperbolic.tanh\narcsinh = math.hyperbolic.arcsinh\narccosh = math.hyperbolic.arccosh\narctanh = math.hyperbolic.arctanh\n\nrint = math.rounding.rint\nfloor = math.rounding.floor\nceil = math.rounding.ceil\ntrunc = math.rounding.trunc\n\nsum = math.sumprod.sum\nprod = math.sumprod.prod\n\nexp = math.explog.exp\nexpm1 = math.explog.expm1\nexp2 = math.explog.exp2\nlog = math.explog.log\nlog10 = math.explog.log10\nlog2 = math.explog.log2\nlog1p = math.explog.log1p\nlogaddexp = math.explog.logaddexp\nlogaddexp2 = math.explog.logaddexp2\n\nsignbit = math.floating.signbit\ncopysign = math.floating.copysign\nldexp = math.floating.ldexp\nfrexp = math.floating.frexp\nnextafter = math.floating.nextafter\n\nadd = math.arithmetic.add\nreciprocal = math.arithmetic.reciprocal\nnegative = math.arithmetic.negative\nmultiply = math.arithmetic.multiply\ndivide = math.arithmetic.divide\npower = math.arithmetic.power\nsubtract = math.arithmetic.subtract\ntrue_divide = math.arithmetic.true_divide\nfloor_divide = math.arithmetic.floor_divide\nfmod = math.arithmetic.fmod\nmod = math.arithmetic.remainder\nmodf = math.arithmetic.modf\nremainder = math.arithmetic.remainder\n\nclip = math.misc.clip\nsqrt = math.misc.sqrt\nsquare = math.misc.square\nabsolute = math.misc.absolute\nabs = math.misc.absolute\nsign = math.misc.sign\nmaximum = math.misc.maximum\nminimum = math.misc.minimum\nfmax = math.misc.fmax\nfmin = math.misc.fmin\n\n# -----------------------------------------------------------------------------\n# Sorting, searching, and counting\n# -----------------------------------------------------------------------------\ncount_nonzero = sorting.count.count_nonzero\n\nargmax = sorting.search.argmax\nargmin = sorting.search.argmin\nwhere = sorting.search.where\n\n# -----------------------------------------------------------------------------\n# Statistics\n# -----------------------------------------------------------------------------\namin = statistics.order.amin\nmin = statistics.order.amin\namax = statistics.order.amax\nmax = statistics.order.amax\n\nmean = statistics.meanvar.mean\nvar = statistics.meanvar.var\nstd = statistics.meanvar.std\n\nbincount = statistics.histogram.bincount\n\n\n# CuPy specific functions\ndef asnumpy(a, stream=None):\n    \"\"\"Returns an array on the host memory from an arbitrary source array.\n\n    Args:\n        a: Arbitrary object that can be converted to :class:`numpy.ndarray`.\n        stream (cupy.cuda.Stream): CUDA stream object. If it is specified, then\n            the device-to-host copy runs asynchronously. Otherwise, the copy is\n            synchronous. Note that if ``a`` is not a :class:`cupy.ndarray`\n            object, then this argument has no effect.\n\n    Returns:\n        numpy.ndarray: Converted array on the host memory.\n\n    \"\"\"\n    if isinstance(a, ndarray):\n        return a.get(stream=stream)\n    else:\n        return numpy.asarray(a)\n\n\n_cupy = sys.modules[__name__]\n\n\ndef get_array_module(*args):\n    \"\"\"Returns the array module for arguments.\n\n    This function is used to implement CPU/GPU generic code. If at least one of\n    the arguments is a :class:`cupy.ndarray` object, the :mod:`cupy` module is\n    returned.\n\n    Args:\n        args: Values to determine whether NumPy or CuPy should be used.\n\n    Returns:\n        module: :mod:`cupy` or :mod:`numpy` is returned based on the types of\n        the arguments.\n\n    .. admonition:: Example\n\n       A NumPy/CuPy generic function can be written as follows::\n\n       >>> def softplus(x):\n       ...     xp = cupy.get_array_module(x)\n       ...     return xp.maximum(0, x) + xp.log1p(xp.exp(-abs(x)))\n\n    \"\"\"\n    if six.moves.builtins.any(isinstance(arg, ndarray) for arg in args):\n        return _cupy\n    else:\n        return numpy\n\n\nclear_memo = util.clear_memo\nmemoize = util.memoize\n\nElementwiseKernel = core.ElementwiseKernel\nReductionKernel = core.ReductionKernel\n", "path": "cupy/__init__.py"}], "after_files": [{"content": "from __future__ import division\nimport sys\n\nimport numpy\nimport six\n\ntry:\n    from cupy import core\nexcept ImportError:\n    # core is a c-extention module.\n    # When a user cannot import core, it represents that CuPy is not correctly\n    # built.\n    msg = ('CuPy is not correctly installed. Please check your environment, '\n           'uninstall Chainer and reinstall it with `pip install chainer '\n           '--no-cache-dir -vvvv`.')\n    raise six.reraise(RuntimeError, msg, sys.exc_info()[2])\n\n\nfrom cupy import binary\nfrom cupy import creation\nfrom cupy import indexing\nfrom cupy import io\nfrom cupy import linalg\nfrom cupy import logic\nfrom cupy import manipulation\nfrom cupy import math\nimport cupy.random\nfrom cupy import sorting\nfrom cupy import statistics\nfrom cupy import testing  # NOQA\nfrom cupy import util\n\nrandom = cupy.random\n\nndarray = core.ndarray\n\n# dtype short cut\nnumber = numpy.number\ninteger = numpy.integer\nsignedinteger = numpy.signedinteger\nunsignedinteger = numpy.unsignedinteger\ninexact = numpy.inexact\nfloating = numpy.floating\n\nbool_ = numpy.bool_\nbyte = numpy.byte\nshort = numpy.short\nintc = numpy.intc\nint_ = numpy.int_\nlonglong = numpy.longlong\nubyte = numpy.ubyte\nushort = numpy.ushort\nuintc = numpy.uintc\nuint = numpy.uint\nulonglong = numpy.ulonglong\n\nhalf = numpy.half\nsingle = numpy.single\nfloat_ = numpy.float_\nlongfloat = numpy.longfloat\n\nint8 = numpy.int8\nint16 = numpy.int16\nint32 = numpy.int32\nint64 = numpy.int64\nuint8 = numpy.uint8\nuint16 = numpy.uint16\nuint32 = numpy.uint32\nuint64 = numpy.uint64\n\nfloat16 = numpy.float16\nfloat32 = numpy.float32\nfloat64 = numpy.float64\n\nufunc = core.ufunc\n\nnewaxis = numpy.newaxis  # == None\n\n# =============================================================================\n# Routines\n#\n# The order of these declarations are borrowed from the NumPy document:\n# http://docs.scipy.org/doc/numpy/reference/routines.html\n# =============================================================================\n\n# -----------------------------------------------------------------------------\n# Array creation routines\n# -----------------------------------------------------------------------------\nempty = creation.basic.empty\nempty_like = creation.basic.empty_like\neye = creation.basic.eye\nidentity = creation.basic.identity\nones = creation.basic.ones\nones_like = creation.basic.ones_like\nzeros = creation.basic.zeros\nzeros_like = creation.basic.zeros_like\nfull = creation.basic.full\nfull_like = creation.basic.full_like\n\narray = creation.from_data.array\nasarray = creation.from_data.asarray\nasanyarray = creation.from_data.asanyarray\nascontiguousarray = creation.from_data.ascontiguousarray\ncopy = creation.from_data.copy\n\narange = creation.ranges.arange\nlinspace = creation.ranges.linspace\n\ndiag = creation.matrix.diag\ndiagflat = creation.matrix.diagflat\n\n# -----------------------------------------------------------------------------\n# Array manipulation routines\n# -----------------------------------------------------------------------------\ncopyto = manipulation.basic.copyto\n\nreshape = manipulation.shape.reshape\nravel = manipulation.shape.ravel\n\nrollaxis = manipulation.transpose.rollaxis\nswapaxes = manipulation.transpose.swapaxes\ntranspose = manipulation.transpose.transpose\n\natleast_1d = manipulation.dims.atleast_1d\natleast_2d = manipulation.dims.atleast_2d\natleast_3d = manipulation.dims.atleast_3d\nbroadcast = manipulation.dims.broadcast\nbroadcast_arrays = manipulation.dims.broadcast_arrays\nbroadcast_to = manipulation.dims.broadcast_to\nexpand_dims = manipulation.dims.expand_dims\nsqueeze = manipulation.dims.squeeze\n\ncolumn_stack = manipulation.join.column_stack\nconcatenate = manipulation.join.concatenate\ndstack = manipulation.join.dstack\nhstack = manipulation.join.hstack\nvstack = manipulation.join.vstack\n\nasfortranarray = manipulation.kind.asfortranarray\n\narray_split = manipulation.split.array_split\ndsplit = manipulation.split.dsplit\nhsplit = manipulation.split.hsplit\nsplit = manipulation.split.split\nvsplit = manipulation.split.vsplit\n\ntile = manipulation.tiling.tile\nrepeat = manipulation.tiling.repeat\n\nroll = manipulation.rearrange.roll\n\n# -----------------------------------------------------------------------------\n# Binary operations\n# -----------------------------------------------------------------------------\nbitwise_and = binary.elementwise.bitwise_and\nbitwise_or = binary.elementwise.bitwise_or\nbitwise_xor = binary.elementwise.bitwise_xor\ninvert = binary.elementwise.invert\nleft_shift = binary.elementwise.left_shift\nright_shift = binary.elementwise.right_shift\n\nbinary_repr = numpy.binary_repr\n\n# -----------------------------------------------------------------------------\n# Data type routines (borrowed from NumPy)\n# -----------------------------------------------------------------------------\ncan_cast = numpy.can_cast\npromote_types = numpy.promote_types\nmin_scalar_type = numpy.min_scalar_type\nresult_type = numpy.result_type\ncommon_type = numpy.common_type\nobj2sctype = numpy.obj2sctype\n\ndtype = numpy.dtype\nformat_parser = numpy.format_parser\n\nfinfo = numpy.finfo\niinfo = numpy.iinfo\nMachAr = numpy.MachAr\n\nissctype = numpy.issctype\nissubdtype = numpy.issubdtype\nissubsctype = numpy.issubsctype\nissubclass_ = numpy.issubclass_\nfind_common_type = numpy.find_common_type\n\ntypename = numpy.typename\nsctype2char = numpy.sctype2char\nmintypecode = numpy.mintypecode\n\n# -----------------------------------------------------------------------------\n# Optionally Scipy-accelerated routines\n# -----------------------------------------------------------------------------\n# TODO(beam2d): Implement it\n\n# -----------------------------------------------------------------------------\n# Discrete Fourier Transform\n# -----------------------------------------------------------------------------\n# TODO(beam2d): Implement it\n\n# -----------------------------------------------------------------------------\n# Indexing routines\n# -----------------------------------------------------------------------------\ntake = indexing.indexing.take\ndiagonal = indexing.indexing.diagonal\n\n# -----------------------------------------------------------------------------\n# Input and output\n# -----------------------------------------------------------------------------\nload = io.npz.load\nsave = io.npz.save\nsavez = io.npz.savez\nsavez_compressed = io.npz.savez_compressed\n\narray_repr = io.formatting.array_repr\narray_str = io.formatting.array_str\n\nbase_repr = numpy.base_repr\n\n# -----------------------------------------------------------------------------\n# Linear algebra\n# -----------------------------------------------------------------------------\ndot = linalg.product.dot\nvdot = linalg.product.vdot\ninner = linalg.product.inner\nouter = linalg.product.outer\ntensordot = linalg.product.tensordot\n\ntrace = linalg.norm.trace\n\n# -----------------------------------------------------------------------------\n# Logic functions\n# -----------------------------------------------------------------------------\nisfinite = logic.content.isfinite\nisinf = logic.content.isinf\nisnan = logic.content.isnan\n\nisscalar = numpy.isscalar\n\nlogical_and = logic.ops.logical_and\nlogical_or = logic.ops.logical_or\nlogical_not = logic.ops.logical_not\nlogical_xor = logic.ops.logical_xor\n\ngreater = logic.comparison.greater\ngreater_equal = logic.comparison.greater_equal\nless = logic.comparison.less\nless_equal = logic.comparison.less_equal\nequal = logic.comparison.equal\nnot_equal = logic.comparison.not_equal\n\nall = logic.truth.all\nany = logic.truth.any\n\n# -----------------------------------------------------------------------------\n# Mathematical functions\n# -----------------------------------------------------------------------------\nsin = math.trigonometric.sin\ncos = math.trigonometric.cos\ntan = math.trigonometric.tan\narcsin = math.trigonometric.arcsin\narccos = math.trigonometric.arccos\narctan = math.trigonometric.arctan\nhypot = math.trigonometric.hypot\narctan2 = math.trigonometric.arctan2\ndeg2rad = math.trigonometric.deg2rad\nrad2deg = math.trigonometric.rad2deg\ndegrees = math.trigonometric.degrees\nradians = math.trigonometric.radians\n\nsinh = math.hyperbolic.sinh\ncosh = math.hyperbolic.cosh\ntanh = math.hyperbolic.tanh\narcsinh = math.hyperbolic.arcsinh\narccosh = math.hyperbolic.arccosh\narctanh = math.hyperbolic.arctanh\n\nrint = math.rounding.rint\nfloor = math.rounding.floor\nceil = math.rounding.ceil\ntrunc = math.rounding.trunc\n\nsum = math.sumprod.sum\nprod = math.sumprod.prod\n\nexp = math.explog.exp\nexpm1 = math.explog.expm1\nexp2 = math.explog.exp2\nlog = math.explog.log\nlog10 = math.explog.log10\nlog2 = math.explog.log2\nlog1p = math.explog.log1p\nlogaddexp = math.explog.logaddexp\nlogaddexp2 = math.explog.logaddexp2\n\nsignbit = math.floating.signbit\ncopysign = math.floating.copysign\nldexp = math.floating.ldexp\nfrexp = math.floating.frexp\nnextafter = math.floating.nextafter\n\nadd = math.arithmetic.add\nreciprocal = math.arithmetic.reciprocal\nnegative = math.arithmetic.negative\nmultiply = math.arithmetic.multiply\ndivide = math.arithmetic.divide\npower = math.arithmetic.power\nsubtract = math.arithmetic.subtract\ntrue_divide = math.arithmetic.true_divide\nfloor_divide = math.arithmetic.floor_divide\nfmod = math.arithmetic.fmod\nmod = math.arithmetic.remainder\nmodf = math.arithmetic.modf\nremainder = math.arithmetic.remainder\n\nclip = math.misc.clip\nsqrt = math.misc.sqrt\nsquare = math.misc.square\nabsolute = math.misc.absolute\nabs = math.misc.absolute\nsign = math.misc.sign\nmaximum = math.misc.maximum\nminimum = math.misc.minimum\nfmax = math.misc.fmax\nfmin = math.misc.fmin\n\n# -----------------------------------------------------------------------------\n# Sorting, searching, and counting\n# -----------------------------------------------------------------------------\ncount_nonzero = sorting.count.count_nonzero\n\nargmax = sorting.search.argmax\nargmin = sorting.search.argmin\nwhere = sorting.search.where\n\n# -----------------------------------------------------------------------------\n# Statistics\n# -----------------------------------------------------------------------------\namin = statistics.order.amin\nmin = statistics.order.amin\namax = statistics.order.amax\nmax = statistics.order.amax\n\nmean = statistics.meanvar.mean\nvar = statistics.meanvar.var\nstd = statistics.meanvar.std\n\nbincount = statistics.histogram.bincount\n\n\n# CuPy specific functions\ndef asnumpy(a, stream=None):\n    \"\"\"Returns an array on the host memory from an arbitrary source array.\n\n    Args:\n        a: Arbitrary object that can be converted to :class:`numpy.ndarray`.\n        stream (cupy.cuda.Stream): CUDA stream object. If it is specified, then\n            the device-to-host copy runs asynchronously. Otherwise, the copy is\n            synchronous. Note that if ``a`` is not a :class:`cupy.ndarray`\n            object, then this argument has no effect.\n\n    Returns:\n        numpy.ndarray: Converted array on the host memory.\n\n    \"\"\"\n    if isinstance(a, ndarray):\n        return a.get(stream=stream)\n    else:\n        return numpy.asarray(a)\n\n\n_cupy = sys.modules[__name__]\n\n\ndef get_array_module(*args):\n    \"\"\"Returns the array module for arguments.\n\n    This function is used to implement CPU/GPU generic code. If at least one of\n    the arguments is a :class:`cupy.ndarray` object, the :mod:`cupy` module is\n    returned.\n\n    Args:\n        args: Values to determine whether NumPy or CuPy should be used.\n\n    Returns:\n        module: :mod:`cupy` or :mod:`numpy` is returned based on the types of\n        the arguments.\n\n    .. admonition:: Example\n\n       A NumPy/CuPy generic function can be written as follows::\n\n       >>> def softplus(x):\n       ...     xp = cupy.get_array_module(x)\n       ...     return xp.maximum(0, x) + xp.log1p(xp.exp(-abs(x)))\n\n    \"\"\"\n    if six.moves.builtins.any(isinstance(arg, ndarray) for arg in args):\n        return _cupy\n    else:\n        return numpy\n\n\nclear_memo = util.clear_memo\nmemoize = util.memoize\n\nElementwiseKernel = core.ElementwiseKernel\nReductionKernel = core.ReductionKernel\n", "path": "cupy/__init__.py"}]}