bugfix of mean method in DimArray class

This commit is contained in:
wyq 2022-07-18 21:46:02 +08:00
parent 5861eadf79
commit 2eb93cc030
3 changed files with 14 additions and 12 deletions

View File

@ -1,11 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MeteoInfo File="milconfig.xml" Type="configurefile"> <MeteoInfo File="milconfig.xml" Type="configurefile">
<Path OpenPath="D:\Working\MIScript\Jython\mis\chart\axis"> <Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\taylor">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\topology"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\classification"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\regression"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\regression"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
@ -13,20 +8,25 @@
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\LaSW"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\LaSW"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\wrf"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\wrf"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\axis"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\axis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\stats"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\taylor"/>
</Path> </Path>
<File> <File>
<OpenedFiles> <OpenedFiles>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow\geoshow_proj_merc_image.py"/> <OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow\geoshow_proj_merc_image.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\LaSW\typhoon_map_streamslice.py"/> <OpenedFile File="D:\Working\MIScript\Jython\mis\LaSW\typhoon_map_streamslice.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\chart\axis\yy_1.py"/> <OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\taylor\taylor_custom_std_max.py"/>
</OpenedFiles> </OpenedFiles>
<RecentFiles> <RecentFiles>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow\geoshow_proj_merc_image.py"/> <RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow\geoshow_proj_merc_image.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\LaSW\typhoon_map_streamslice.py"/> <RecentFile File="D:\Working\MIScript\Jython\mis\LaSW\typhoon_map_streamslice.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\chart\axis\yy_1.py"/> <RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\taylor\taylor_custom_std_max.py"/>
</RecentFiles> </RecentFiles>
</File> </File>
<Font> <Font>
@ -34,5 +34,5 @@
</Font> </Font>
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/> <LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
<Figure DoubleBuffering="true"/> <Figure DoubleBuffering="true"/>
<Startup MainFormLocation="-7,0" MainFormSize="1378,779"/> <Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
</MeteoInfo> </MeteoInfo>

View File

@ -873,16 +873,18 @@ class DimArray(NDArray):
dims.append(self.dims[i]) dims.append(self.dims[i])
return DimArray(r, dims, self.fill_value, self.proj) return DimArray(r, dims, self.fill_value, self.proj)
def mean(self, axis=None): def mean(self, axis=None, keepdims=False):
""" """
Compute tha arithmetic mean along the specified axis. Compute tha arithmetic mean along the specified axis.
:param axis: (*int*) Axis along which the value is computed. :param axis: (*int*) Axis along which the value is computed.
The default is to compute the value of the flattened array. The default is to compute the value of the flattened array.
:param keepdims: (*bool*) If this is set to True, the axes which are reduced are
left in the result as dimensions with size one. Default if `False`.
returns: (*array_like*) Mean result returns: (*array_like*) Mean result
""" """
r = super(DimArray, self).mean(axis) r = super(DimArray, self).mean(axis, keepdims)
if isinstance(r, numbers.Number): if isinstance(r, numbers.Number):
return r return r
else: else: