MCPcopy Create free account
hub / github.com/numpy/numpy / initialize_static_globals

Function initialize_static_globals

numpy/core/src/multiarray/multiarraymodule.c:5028–5062  ·  view source on GitHub ↗

* Initializes global constants. At some points these need to be cleaned * up, and sometimes we also import them where they are needed. But for * some things, adding an `npy_cache_import` everywhere seems inconvenient. * * These globals should not need the C-layer at all and will be imported * before anything on the C-side is initialized. */

Source from the content-addressed store, hash-verified

5026 * before anything on the C-side is initialized.
5027 */
5028static int
5029initialize_static_globals(void)
5030{
5031 assert(npy_DTypePromotionError == NULL);
5032 npy_cache_import(
5033 "numpy.exceptions", "DTypePromotionError",
5034 &npy_DTypePromotionError);
5035 if (npy_DTypePromotionError == NULL) {
5036 return -1;
5037 }
5038
5039 assert(npy_UFuncNoLoopError == NULL);
5040 npy_cache_import(
5041 "numpy.core._exceptions", "_UFuncNoLoopError",
5042 &npy_UFuncNoLoopError);
5043 if (npy_UFuncNoLoopError == NULL) {
5044 return -1;
5045 }
5046
5047 /* Initialize from certain environment variabels: */
5048 char *env = getenv("NPY_NUMPY_2_BEHAVIOR");
5049 if (env != NULL && strcmp(env, "0") != 0) {
5050 npy_numpy2_behavior = NPY_TRUE;
5051 }
5052
5053 env = getenv("NUMPY_WARN_IF_NO_MEM_POLICY");
5054 if ((env != NULL) && (strncmp(env, "1", 1) == 0)) {
5055 numpy_warn_if_no_mem_policy = 1;
5056 }
5057 else {
5058 numpy_warn_if_no_mem_policy = 0;
5059 }
5060
5061 return 0;
5062}
5063
5064
5065static struct PyModuleDef moduledef = {

Callers 1

PyInit__multiarray_umathFunction · 0.85

Calls 1

npy_cache_importFunction · 0.85

Tested by

no test coverage detected