mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
bugfix for find common data type from arrays and scalars
This commit is contained in:
parent
aff5cb8722
commit
e7f88b3eee
@ -1,34 +1,32 @@
|
|||||||
<?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\io\grib">
|
<Path OpenPath="D:\Working\MIScript\Jython\mis\common_math\signal">
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot"/>
|
||||||
<RecentFolder Folder="D:\Temp\test"/>
|
<RecentFolder Folder="D:\Temp\test"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\stats"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\stats"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\netcdf"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\netcdf"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\burf"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\burf"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\test"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\test"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\dataconvert"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\dataconvert"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grib"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grib"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\signal"/>
|
||||||
</Path>
|
</Path>
|
||||||
<File>
|
<File>
|
||||||
<OpenedFiles>
|
<OpenedFiles>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_x_phase_2.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_x_phase_2.py"/>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\dataconvert\grib2nc-5.py"/>
|
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\grib\s2s_babj_1.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\grib\s2s_babj_1.py"/>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\grib\s2s_babj_2.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\common_math\signal\detrend.py"/>
|
||||||
</OpenedFiles>
|
</OpenedFiles>
|
||||||
<RecentFiles>
|
<RecentFiles>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_x_phase_2.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_x_phase_2.py"/>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\dataconvert\grib2nc-5.py"/>
|
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\grib\s2s_babj_1.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\io\grib\s2s_babj_1.py"/>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\grib\s2s_babj_2.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\common_math\signal\detrend.py"/>
|
||||||
</RecentFiles>
|
</RecentFiles>
|
||||||
</File>
|
</File>
|
||||||
<Font>
|
<Font>
|
||||||
@ -36,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="-6,-6" MainFormSize="1292,764"/>
|
<Startup MainFormLocation="8,11" MainFormSize="1292,764"/>
|
||||||
</MeteoInfo>
|
</MeteoInfo>
|
||||||
|
|||||||
Binary file not shown.
@ -141,19 +141,22 @@ class DataType(object):
|
|||||||
|
|
||||||
:return: kind string
|
:return: kind string
|
||||||
"""
|
"""
|
||||||
if self.name == 'bool' or self.name == 'boolean':
|
if self._dtype == JDataType.BOOLEAN:
|
||||||
return 'b'
|
return 'b'
|
||||||
elif self.name == 'int' or self.name == 'integer' or self.name == 'int32' or self.name == 'int16' or \
|
elif self._dtype in (JDataType.SHORT, JDataType.INT, JDataType.LONG):
|
||||||
self.name == 'uint' or self.name == 'short' or self.name == 'int64' or self.name == 'long':
|
|
||||||
return 'i'
|
return 'i'
|
||||||
elif self.name == 'float' or self.name == 'float64' or self.name == 'double':
|
elif self._dtype == JDataType.UINT:
|
||||||
|
return 'u'
|
||||||
|
elif self._dtype in (JDataType.FLOAT, JDataType.DOUBLE):
|
||||||
return 'f'
|
return 'f'
|
||||||
elif self.name == 'str' or self.name == 'string':
|
elif self._dtype == JDataType.STRING:
|
||||||
return 'S'
|
return 'S'
|
||||||
elif self.name == 'complex':
|
elif self._dtype == JDataType.COMPLEX:
|
||||||
return 'c'
|
return 'c'
|
||||||
elif self.name == 'date' or self.name == 'datetime':
|
elif self._dtype == JDataType.DATE:
|
||||||
return 'M'
|
return 'M'
|
||||||
|
elif self._dtype == JDataType.OBJECT:
|
||||||
|
return 'O'
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_char(c):
|
def from_char(c):
|
||||||
@ -163,9 +166,9 @@ class DataType(object):
|
|||||||
:return: The DataType
|
:return: The DataType
|
||||||
"""
|
"""
|
||||||
if c == 'b' or c == 'bool':
|
if c == 'b' or c == 'bool':
|
||||||
return DataType('boolean')
|
return dtype.bool
|
||||||
elif c == 'h':
|
elif c == 'h':
|
||||||
return DataType('short')
|
return dtype.short
|
||||||
elif c == 'l' or c == 'int':
|
elif c == 'l' or c == 'int':
|
||||||
return DataType('int')
|
return DataType('int')
|
||||||
elif c == 'q':
|
elif c == 'q':
|
||||||
@ -183,6 +186,30 @@ class DataType(object):
|
|||||||
else:
|
else:
|
||||||
return DataType('object')
|
return DataType('object')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def from_kind(k):
|
||||||
|
"""
|
||||||
|
Create DataType from kind.
|
||||||
|
:param k: (*str*) Kind string.
|
||||||
|
:return: The DataType
|
||||||
|
"""
|
||||||
|
if k == 'b':
|
||||||
|
return dtype.bool
|
||||||
|
elif k == 'i':
|
||||||
|
return dtype.int
|
||||||
|
elif k == 'u':
|
||||||
|
return dtype.uint
|
||||||
|
elif k == 'f':
|
||||||
|
return dtype.float
|
||||||
|
elif k == 'S':
|
||||||
|
return dtype.string
|
||||||
|
elif k == 'c':
|
||||||
|
return dtype.complex
|
||||||
|
elif k == 'M':
|
||||||
|
return dtype.date
|
||||||
|
else:
|
||||||
|
return dtype.obj
|
||||||
|
|
||||||
def is_numeric(self):
|
def is_numeric(self):
|
||||||
"""
|
"""
|
||||||
Is numeric data type or not.
|
Is numeric data type or not.
|
||||||
@ -217,7 +244,10 @@ class dtype(DataType):
|
|||||||
obj = DataType('object')
|
obj = DataType('object')
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
super(dtype, self).__init__(name)
|
if isinstance(name, DataType):
|
||||||
|
DataType.__init__(self, name.name)
|
||||||
|
else:
|
||||||
|
DataType.__init__(self, name)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def fromjava(dt):
|
def fromjava(dt):
|
||||||
|
|||||||
Binary file not shown.
@ -35,9 +35,10 @@ typecodes = {'Character':'c',
|
|||||||
# U -> Unicode string
|
# U -> Unicode string
|
||||||
# V -> record
|
# V -> record
|
||||||
# O -> Python object
|
# O -> Python object
|
||||||
_kind_list = ['b', 'u', 'i', 'f', 'c', 'S', 'U', 'V', 'O', 'M', 'm']
|
_kind_list = ['b', 'i', 'u', 'f', 'c', 'S', 'U', 'V', 'O', 'M', 'm']
|
||||||
|
_char_list = ['b','h','l','q','f','d','D','U','M','O']
|
||||||
|
|
||||||
__test_types = '?'+typecodes['AllInteger'][:-2]+typecodes['AllFloat']+'O'
|
__test_types = _char_list
|
||||||
__len_test_types = len(__test_types)
|
__len_test_types = len(__test_types)
|
||||||
|
|
||||||
# Keep incrementing until a common type both can be coerced to
|
# Keep incrementing until a common type both can be coerced to
|
||||||
@ -60,7 +61,7 @@ def _can_coerce_all(dtypelist, start=0):
|
|||||||
return dtypelist[0]
|
return dtypelist[0]
|
||||||
thisind = start
|
thisind = start
|
||||||
while thisind < __len_test_types:
|
while thisind < __len_test_types:
|
||||||
newdtype = dtype(__test_types[thisind])
|
newdtype = dtype.from_char(__test_types[thisind])
|
||||||
numcoerce = len([x for x in dtypelist if newdtype >= x])
|
numcoerce = len([x for x in dtypelist if newdtype >= x])
|
||||||
if numcoerce == N:
|
if numcoerce == N:
|
||||||
return newdtype
|
return newdtype
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user