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

Class MinVersion

numpy/core/code_generators/genapi.py:102–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100
101
102class MinVersion:
103 def __init__(self, version):
104 """ Version should be the normal NumPy version, e.g. "1.25" """
105 major, minor = version.split(".")
106 self.version = f"NPY_{major}_{minor}_API_VERSION"
107
108 def __str__(self):
109 # Used by version hashing:
110 return self.version
111
112 def add_guard(self, name, normal_define):
113 """Wrap a definition behind a version guard"""
114 wrap = textwrap.dedent(f"""
115 #if NPY_FEATURE_VERSION >= {self.version}
116 {{define}}
117 #endif""")
118
119 # we only insert `define` later to avoid confusing dedent:
120 return wrap.format(define=normal_define)
121
122
123class StealRef:

Callers 1

numpy_api.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected