File tree 5 files changed +64
-8
lines changed 5 files changed +64
-8
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ Special-purpose namespaces
35
35
- :ref: `numpy.emath <routines.emath >` - mathematical functions with automatic domain
36
36
- :ref: `numpy.lib <routines.lib >` - utilities & functionality which do not fit the main namespace
37
37
- :ref: `numpy.rec <routines.rec >` - record arrays (largely superseded by dataframe libraries)
38
+ - :ref: `numpy.version <routines.version >` - small module with more detailed version info
38
39
39
40
Legacy namespaces
40
41
=================
@@ -67,6 +68,7 @@ and/or this code is deprecated or isn't reliable.
67
68
numpy.emath <routines.emath >
68
69
numpy.lib <routines.lib >
69
70
numpy.rec <routines.rec >
71
+ numpy.version <routines.version >
70
72
numpy.char <routines.char >
71
73
numpy.distutils <distutils >
72
74
numpy.f2py <../f2py/index >
Original file line number Diff line number Diff line change
1
+ .. currentmodule :: numpy.version
2
+
3
+ .. _routines.version :
4
+
5
+ *******************
6
+ Version information
7
+ *******************
8
+
9
+ The ``numpy.version `` submodule includes several constants that expose more
10
+ detailed information about the exact version of the installed ``numpy ``
11
+ package:
12
+
13
+ .. data :: version
14
+
15
+ Version string for the installed package - matches ``numpy.__version__ ``.
16
+
17
+ .. data :: full_version
18
+
19
+ Version string - the same as ``numpy.version.version ``.
20
+
21
+ .. data :: short_version
22
+
23
+ Version string without any local build identifiers.
24
+
25
+ .. rubric :: Examples
26
+
27
+ >>> np.__version__
28
+ '2.1.0.dev0+git20240319.2ea7ce0' # may vary
29
+ >>> np.version.short_version
30
+ '2.1.0.dev0' # may vary
31
+
32
+ .. data :: git_revision
33
+
34
+ String containing the git hash of the commit from which ``numpy `` was built.
35
+
36
+ .. data :: release
37
+
38
+ ``True `` if this version is a ``numpy `` release, ``False `` if a dev version.
Original file line number Diff line number Diff line change @@ -70,6 +70,9 @@ def git_version(version):
70
70
71
71
# For NumPy 2.0, this should only have one field: `version`
72
72
template = textwrap .dedent (f'''
73
+ """
74
+ Module to expose more detailed version info for the installed `numpy`
75
+ """
73
76
version = "{ version } "
74
77
__version__ = version
75
78
full_version = version
Original file line number Diff line number Diff line change @@ -39,3 +39,16 @@ def test_short_version():
39
39
else :
40
40
assert_ (np .__version__ .split ("+" )[0 ] == np .version .short_version ,
41
41
"short_version mismatch in development version" )
42
+
43
+
44
+ def test_version_module ():
45
+ contents = set ([s for s in dir (np .version ) if not s .startswith ('_' )])
46
+ expected = set ([
47
+ 'full_version' ,
48
+ 'git_revision' ,
49
+ 'release' ,
50
+ 'short_version' ,
51
+ 'version' ,
52
+ ])
53
+
54
+ assert contents == expected
Original file line number Diff line number Diff line change @@ -114,14 +114,14 @@ def test_NPY_NO_EXPORT():
114
114
"f2py" ,
115
115
"fft" ,
116
116
"lib" ,
117
- "lib.format" , # was this meant to be public?
117
+ "lib.array_utils" ,
118
+ "lib.format" ,
119
+ "lib.introspect" ,
118
120
"lib.mixins" ,
119
- "lib.recfunctions" ,
121
+ "lib.npyio" ,
122
+ "lib.recfunctions" , # note: still needs cleaning, was forgotten for 2.0
120
123
"lib.scimath" ,
121
124
"lib.stride_tricks" ,
122
- "lib.npyio" ,
123
- "lib.introspect" ,
124
- "lib.array_utils" ,
125
125
"linalg" ,
126
126
"ma" ,
127
127
"ma.extras" ,
@@ -134,11 +134,12 @@ def test_NPY_NO_EXPORT():
134
134
"polynomial.legendre" ,
135
135
"polynomial.polynomial" ,
136
136
"random" ,
137
+ "strings" ,
137
138
"testing" ,
138
139
"testing.overrides" ,
139
140
"typing" ,
140
141
"typing.mypy_plugin" ,
141
- "version" # Should be removed for NumPy 2.0
142
+ "version" ,
142
143
]]
143
144
if sys .version_info < (3 , 12 ):
144
145
PUBLIC_MODULES += [
@@ -158,7 +159,6 @@ def test_NPY_NO_EXPORT():
158
159
"numpy.char" ,
159
160
"numpy.emath" ,
160
161
"numpy.rec" ,
161
- "numpy.strings" ,
162
162
]
163
163
164
164
@@ -535,7 +535,7 @@ def test_core_shims_coherence():
535
535
# no need to add it to np.core
536
536
if (
537
537
member_name .startswith ("_" )
538
- or member_name == "tests"
538
+ or member_name in [ "tests" , "strings" ]
539
539
or f"numpy.{ member_name } " in PUBLIC_ALIASED_MODULES
540
540
):
541
541
continue
You can’t perform that action at this time.
0 commit comments