当前位置: 首页>>代码示例>>Python>>正文


Python System.Double方法代码示例

本文整理汇总了Python中System.Double方法的典型用法代码示例。如果您正苦于以下问题:Python System.Double方法的具体用法?Python System.Double怎么用?Python System.Double使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System的用法示例。


在下文中一共展示了System.Double方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_type___clrtype__

# 需要导入模块: import System [as 别名]
# 或者: from System import Double [as 别名]
def test_type___clrtype__(self):
        '''
        Tests out type.__clrtype__ directly.
        '''
        import System
        #Make sure it exists
        self.assertTrue(hasattr(type, "__clrtype__"))
        
        #Make sure the documentation is useful
        self.assertTrue("Gets the .NET type which is" in type.__clrtype__.__doc__, type.__clrtype__.__doc__)
        
        self.assertEqual(type.__clrtype__(type),  type)
        self.assertEqual(type.__clrtype__(float), float)
        self.assertEqual(type.__clrtype__(System.Double), float)
        self.assertEqual(type.__clrtype__(float), System.Double)
        self.assertTrue(not type.__clrtype__(float)==type)
        self.assertTrue(type.__clrtype__(float)!=type) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test___clrtype__.py

示例2: _dfsu_element_coordinates

# 需要导入模块: import System [as 别名]
# 或者: from System import Double [as 别名]
def _dfsu_element_coordinates(dfsu_object):
    """ Use MIKE SDK method to calc element coords from dfsu_object """

    element_coordinates = np.zeros(shape=(dfsu_object.NumberOfElements, 3))

    # Convert nodes to .NET System double to input to method
    xtemp = Array.CreateInstance(System.Double, 0)
    ytemp = Array.CreateInstance(System.Double, 0)
    ztemp = Array.CreateInstance(System.Double, 0)

    # Get element coords
    elemts_temp = dfs.dfsu.DfsuUtil.CalculateElementCenterCoordinates(dfsu_object, xtemp, ytemp, ztemp)

    # Place in array; need to get from .NET Array to numpy array
    for n in range(3):
        ele_coords_temp = []
        for ele in elemts_temp[n+1]:
            ele_coords_temp.append(ele)
        element_coordinates[:, n] = ele_coords_temp

    return element_coordinates 
开发者ID:robjameswall,项目名称:dhitools,代码行数:23,代码来源:mesh.py

示例3: test_cp13401

# 需要导入模块: import System [as 别名]
# 或者: from System import Double [as 别名]
def test_cp13401(self):
        import System
        import copy
        
        #A few special cases
        self.assertEqual(System.Char.MinValue, copy.copy(System.Char.MinValue))
        self.assertTrue(System.Char.MinValue != copy.copy(System.Char.MaxValue))
        self.assertEqual(System.StringSplitOptions.None, copy.copy(System.StringSplitOptions.None))
        self.assertEqual(System.StringSplitOptions.RemoveEmptyEntries, copy.copy(System.StringSplitOptions.RemoveEmptyEntries))
        self.assertTrue(System.StringSplitOptions.None != copy.copy(System.StringSplitOptions.RemoveEmptyEntries))
        
        #Normal cases
        test_dict = {   System.Byte : [System.Byte.MinValue, System.Byte.MinValue+1, System.Byte.MaxValue, System.Byte.MaxValue-1],
                        System.Char : [],
                        System.Boolean : [True, False],
                        System.SByte   : [System.SByte.MinValue, System.SByte.MinValue+1, System.SByte.MaxValue, System.SByte.MaxValue-1],
                        System.UInt32  : [System.UInt32.MinValue, System.UInt32.MinValue+1, System.UInt32.MaxValue, System.UInt32.MaxValue-1],
                        System.Int64   : [System.Int64.MinValue, System.Int64.MinValue+1, System.Int64.MaxValue, System.Int64.MaxValue-1],
                        System.Double  : [0.00, 3.14],
                        }
        
        for key in test_dict.keys():
            temp_type = key
            self.assertTrue(hasattr(temp_type, "__reduce_ex__"), 
                "%s has no attribute '%s'" % (str(temp_type), "__reduce_ex__"))
        
            for temp_value in test_dict[key]:
                x = temp_type(temp_value)
                x_copy = copy.copy(x)
                self.assertEqual(x, x_copy)
                self.assertEqual(x, temp_value) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:33,代码来源:test_stdmodules.py

示例4: get_values

# 需要导入模块: import System [as 别名]
# 或者: from System import Double [as 别名]
def get_values(values, itypes, ftypes):
    """
    This will return structure of values converted to variety of types as a list of tuples:
    [ ...
    ( python_value, [ all_values ] ),
    ... ]

    all_values: Byte, UInt16, UInt32, UInt64, SByte, Int16, Int32, Int64, Single, Double, myint, mylong, myfloat
    """
    all = []
    for v in values:
        sv  = str(v)
        py  = int(v)
        clr = get_clr_values(sv, itypes)
        clr.append(long(py))
        clr.append(myint(py))
        clr.append(mylong(py))
        all.append( (py, clr) )

        py  = long(v)
        clr = get_clr_values(sv, itypes)
        clr.append(py)
        clr.append(myint(py))
        clr.append(mylong(py))
        all.append( (py, clr) )

        py  = float(v)
        clr = get_clr_values(sv, ftypes)
        clr.append(myfloat(py))
        all.append( (py, clr) )

        for imag in [0j, 1j, -1j]:
            py = complex(v + imag)
            all.append( (py, [ py, mycomplex(py) ] ) )

    all.append( (True, [ True ] ))
    all.append( (False, [ False ] ))

    return all 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:41,代码来源:test_numtypes.py

示例5: mystr

# 需要导入模块: import System [as 别名]
# 或者: from System import Double [as 别名]
def mystr(x):
    if isinstance(x, tuple):
        return "(" + ", ".join(mystr(e) for e in x) + ")"
    elif isinstance(x, Single):
        return str(round(float(str(x)), 3))
    elif isinstance(x, Double):
        return str(round(x, 3))
    else:
        s = str(x)
        if s.endswith("L"): return s[:-1]
        else: return s 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_numtypes.py

示例6: test_cp13401

# 需要导入模块: import System [as 别名]
# 或者: from System import Double [as 别名]
def test_cp13401(self):
        import System
        import copy
        
        #A few special cases
        StringSplitOptions_None = getattr(System.StringSplitOptions, "None")
        self.assertEqual(System.Char.MinValue, copy.copy(System.Char.MinValue))
        self.assertTrue(System.Char.MinValue != copy.copy(System.Char.MaxValue))
        self.assertEqual(StringSplitOptions_None, copy.copy(StringSplitOptions_None))
        self.assertEqual(System.StringSplitOptions.RemoveEmptyEntries, copy.copy(System.StringSplitOptions.RemoveEmptyEntries))
        self.assertTrue(StringSplitOptions_None != copy.copy(System.StringSplitOptions.RemoveEmptyEntries))
        
        #Normal cases
        test_dict = {   System.Byte : [System.Byte.MinValue, System.Byte.MinValue+1, System.Byte.MaxValue, System.Byte.MaxValue-1],
                        System.Char : [],
                        System.Boolean : [True, False],
                        System.SByte   : [System.SByte.MinValue, System.SByte.MinValue+1, System.SByte.MaxValue, System.SByte.MaxValue-1],
                        System.UInt32  : [System.UInt32.MinValue, System.UInt32.MinValue+1, System.UInt32.MaxValue, System.UInt32.MaxValue-1],
                        System.Int64   : [System.Int64.MinValue, System.Int64.MinValue+1, System.Int64.MaxValue, System.Int64.MaxValue-1],
                        System.Double  : [0.00, 3.14],
                        }
        
        for key in test_dict.keys():
            temp_type = key
            self.assertTrue(hasattr(temp_type, "__reduce_ex__"), 
                "%s has no attribute '%s'" % (str(temp_type), "__reduce_ex__"))
        
            for temp_value in test_dict[key]:
                x = temp_type(temp_value)
                x_copy = copy.copy(x)
                self.assertEqual(x, x_copy)
                self.assertEqual(x, temp_value) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:34,代码来源:test_stdmodules.py

示例7: fill_in_profiles

# 需要导入模块: import System [as 别名]
# 或者: from System import Double [as 别名]
def fill_in_profiles(dose_or_image, profile_fxn, row_buffer, dtype, pre_buffer=None):
    '''fills in 3D profile data (dose or segments)'''
    mask_array = np.zeros((dose_or_image.XSize, dose_or_image.YSize, dose_or_image.ZSize))

    # note used ZSize-1 to match zero indexed loops below and compute_voxel_points_matrix(...)
    z_direction = VVector.op_Multiply(Double((dose_or_image.ZSize - 1) * dose_or_image.ZRes), dose_or_image.ZDirection)
    y_step = VVector.op_Multiply(dose_or_image.YRes, dose_or_image.YDirection)

    for x in range(dose_or_image.XSize):  # scan X dimensions
        start_x = VVector.op_Addition(dose_or_image.Origin,
                                      VVector.op_Multiply(Double(x * dose_or_image.XRes), dose_or_image.XDirection))

        for y in range(dose_or_image.YSize):  # scan Y dimension
            stop = VVector.op_Addition(start_x, z_direction)

            # get the profile along Z dimension 
            if pre_buffer is None:
                profile_fxn(start_x, stop, row_buffer)
            else:
                profile_fxn(start_x, stop, pre_buffer)
                pre_buffer.CopyTo(row_buffer, 0)

            # save data
            mask_array[x, y, :] = to_ndarray(row_buffer, dtype)

            # add step for next point
            start_x = VVector.op_Addition(start_x, y_step)

    return mask_array 
开发者ID:VarianAPIs,项目名称:PyESAPI,代码行数:31,代码来源:__init__.py

示例8: make_dose_for_grid

# 需要导入模块: import System [as 别名]
# 或者: from System import Double [as 别名]
def make_dose_for_grid(dose, image=None):
    '''returns a 3D numpy.ndarray of doubles matching dose (default) or image grid indexed like [x,y,z]'''

    if image is not None:
        row_buffer = Array.CreateInstance(Double, image.ZSize)
        dose_array = fill_in_profiles(image, dose.GetDoseProfile, row_buffer, c_double)
    else:
        # default
        dose_array = dose_to_nparray(dose)

    dose_array[np.where(np.isnan(dose_array))] = 0.0
    return dose_array 
开发者ID:VarianAPIs,项目名称:PyESAPI,代码行数:14,代码来源:__init__.py

示例9: overflowErrorTrigger

# 需要导入模块: import System [as 别名]
# 或者: from System import Double [as 别名]
def overflowErrorTrigger(in_type):
    ret_val = {}
    
    ############################################################
    ret_val["VARIANT_BOOL"] =  []
                     
    ############################################################              
    ret_val["BYTE"] = []
    ret_val["BYTE"] += overflow_num_helper(System.Byte)
        
    ############################################################
    #Doesn't seem possible to create a value (w/o 1st overflowing
    #in Python) to pass to the COM method which will overflow.
    ret_val["BSTR"] = [] #["0123456789" * 1234567890]
    
    ############################################################ 
    ret_val["CHAR"] = []
    ret_val["CHAR"] +=  overflow_num_helper(System.SByte)
    
    ############################################################
    ret_val["FLOAT"] = []  
    ret_val["FLOAT"] += overflow_num_helper(System.Double)
    
    #Shouldn't be possible to overflow a double.
    ret_val["DOUBLE"] =  []
    
    
    ############################################################            
    ret_val["USHORT"] =  []
    ret_val["USHORT"] += overflow_num_helper(System.UInt16)
      
    ret_val["ULONG"] =  []
    ret_val["ULONG"] +=  overflow_num_helper(System.UInt32)
               
    ret_val["ULONGLONG"] =  []
    # Dev10 475426
    #ret_val["ULONGLONG"] +=  overflow_num_helper(System.UInt64)
      
    ret_val["SHORT"] =  []
    ret_val["SHORT"] += overflow_num_helper(System.Int16)
      
    ret_val["LONG"] =  []
    # Dev10 475426
    #ret_val["LONG"] += overflow_num_helper(System.Int32)
                
    ret_val["LONGLONG"] =  []
    # Dev10 475426
    #ret_val["LONGLONG"] += overflow_num_helper(System.Int64)
    
    ############################################################
    return ret_val[in_type] 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:53,代码来源:cominterop_util.py

示例10: test_sanity

# 需要导入模块: import System [as 别名]
# 或者: from System import Double [as 别名]
def test_sanity(self):
        '''Make sure that numbers within the constraints of the numerical types are allowed.'''
        import clr
        import System
        temp_list = [   ["System.Byte", 0, 255],
                        ["System.SByte", -128, 127],
                        ["System.Byte", 0, 255],
                        ["System.Int16", -32768, 32767],
                        ["System.UInt16", 0, 65535],
                        ["System.Int32", -2147483648, 2147483647],
                        ["System.UInt32", 0, 4294967295],
                        ["System.Int64", -9223372036854775808, 9223372036854775807],
                        ["System.UInt64", 0, 18446744073709551615],
                        ["System.Single", -3.40282e+038, 3.40282e+038],
                        ["System.Double", -1.79769313486e+308, 1.79769313486e+308],
                        ["System.Decimal", -79228162514264337593543950335, 79228162514264337593543950335],
                        ["int", -2147483648, 2147483647]
                    ]

        for num_type, small_val, large_val in temp_list:
            self.assertTrue(self.num_ok_for_type(1, num_type))
            self.assertTrue(self.num_ok_for_type(1.0, num_type))

            #Minimum value
            self.assertTrue(self.num_ok_for_type(small_val, num_type))
            self.assertTrue(self.num_ok_for_type(small_val + 1, num_type))
            self.assertTrue(self.num_ok_for_type(small_val + 2, num_type))

            #Maximum value
            self.assertTrue(self.num_ok_for_type(large_val, num_type))
            self.assertTrue(self.num_ok_for_type(large_val - 1, num_type))
            self.assertTrue(self.num_ok_for_type(large_val - 2, num_type))

            #Negative cases
            if num_type!="System.Single" and num_type!="System.Double" and num_type!="System.Decimal":
                self.assertTrue(not self.num_ok_for_type(small_val - 1, num_type))
                self.assertTrue(not self.num_ok_for_type(small_val - 2, num_type))
                self.assertTrue(not self.num_ok_for_type(large_val + 1, num_type))
                self.assertTrue(not self.num_ok_for_type(large_val + 2, num_type))

        #Special cases
        self.assertTrue(self.num_ok_for_type(0, "long"))
        self.assertTrue(self.num_ok_for_type(1, "long"))
        self.assertTrue(self.num_ok_for_type(-1, "long"))
        self.assertTrue(self.num_ok_for_type(5, "long"))
        self.assertTrue(self.num_ok_for_type(-92233720368547758080000, "long"))
        self.assertTrue(self.num_ok_for_type( 18446744073709551615000, "long"))

        self.assertTrue(self.num_ok_for_type(0.0, "float"))
        self.assertTrue(self.num_ok_for_type(1.0, "float"))
        self.assertTrue(self.num_ok_for_type(-1.0, "float"))
        self.assertTrue(self.num_ok_for_type(3.14, "float"))
        self.assertTrue(self.num_ok_for_type(-92233720368547758080000.0, "float"))
        self.assertTrue(self.num_ok_for_type( 18446744073709551615000.0, "float")) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:56,代码来源:test_clrnuminterop.py

示例11: test_return_numbers

# 需要导入模块: import System [as 别名]
# 或者: from System import Double [as 别名]
def test_return_numbers(self):
        import clr
        import System
        from Merlin.Testing.Call import Int32RInt32EventHandler
        from Merlin.Testing.TypeSample import EnumInt16, SimpleStruct
        for (f, t, val) in [
            (self.c.ReturnByte, System.Byte, 0), 
            (self.c.ReturnSByte, System.SByte, 1), 
            (self.c.ReturnUInt16, System.UInt16, 2), 
            (self.c.ReturnInt16, System.Int16, 3), 
            (self.c.ReturnUInt32, System.UInt32, 4), 
            (self.c.ReturnInt32, System.Int32, 5), 
            (self.c.ReturnUInt64, System.UInt64, 6), 
            (self.c.ReturnInt64, System.Int64, 7), 
            (self.c.ReturnDouble, System.Double, 8), 
            (self.c.ReturnSingle, System.Single, 9), 
            (self.c.ReturnDecimal, System.Decimal, 10), 
            
            (self.c.ReturnChar, System.Char, 'A'), 
            (self.c.ReturnBoolean, System.Boolean, True), 
            (self.c.ReturnString, System.String, "CLR"), 
            
            (self.c.ReturnEnum, EnumInt16, EnumInt16.C),
        ]:
            x = f()
            self.assertEqual(x.GetType(), clr.GetClrType(t))
            self.assertEqual(x, val)
            
        # return value type
        x= self.c.ReturnStruct()
        self.assertEqual(x.Flag, 100)
        
        x= self.c.ReturnClass()
        self.assertEqual(x.Flag, 200)
        
        x= self.c.ReturnNullableInt1()
        self.assertEqual(x.GetType(), clr.GetClrType(int))
        self.assertEqual(x, 300)
        
        x= self.c.ReturnNullableStruct1()
        self.assertEqual(x.GetType(), clr.GetClrType(SimpleStruct))
        self.assertEqual(x.Flag, 400)
        
        x= self.c.ReturnInterface()
        self.assertEqual(x.Flag, 500)
        
        # return delegate
        x= self.c.ReturnDelegate()
        self.assertEqual(x.GetType(), clr.GetClrType(Int32RInt32EventHandler))
        self.assertEqual(x(3), 6)
        self.assertEqual(x(3.0), 6)
        
        # array
        x= self.c.ReturnInt32Array()
        self.assertEqual(x[0], 1)
        self.assertEqual(x[1], 2)
        
        x= self.c.ReturnStructArray()
        self.assertEqual(x[0].Flag, 1)
        self.assertEqual(x[1].Flag, 2) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:62,代码来源:test_returnvalue.py

示例12: test_clrtype_returns_existing_clr_types

# 需要导入模块: import System [as 别名]
# 或者: from System import Double [as 别名]
def test_clrtype_returns_existing_clr_types(self):
        '''
        Our implementation of __clrtype__ returns existing .NET types
        instead of subclassing from type or System.Type.
        '''
        global called
        import clr
        import System
        if is_netcoreapp:
            clr.AddReference("System.Collections")
            clr.AddReference("System.Data.Common")
        else:
            clr.AddReference("System.Data")
        
        types = [
                    System.Byte,
                    System.Int16,
                    System.UInt32,
                    System.Int32,
                    System.Int64,
                    System.Double,
                    System.Data.CommandType,
                    System.Data.Common.DataAdapter,
                    System.Boolean,
                    System.Char,
                    System.Decimal,
                    System.IntPtr,
                    System.Object,
                    System.String,
                    System.Collections.BitArray,
                    System.Collections.Generic.List[System.Char],
                    ]

        for x in types:
            called = False
            
            class MyType(type):
                def __clrtype__(self):
                    global called
                    called = True
                    return x
            
            class X(object):
                __metaclass__ = MyType
            
            self.assertEqual(called, True) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:48,代码来源:test___clrtype__.py

示例13: test_return_numbers

# 需要导入模块: import System [as 别名]
# 或者: from System import Double [as 别名]
def test_return_numbers(self):
        import clr
        import System
        from Merlin.Testing.Call import Int32RInt32EventHandler
        from Merlin.Testing.TypeSample import EnumInt16, SimpleStruct
        for (f, t, val) in [
            (self.c.ReturnByte, System.Byte, 0), 
            (self.c.ReturnSByte, System.SByte, 1), 
            (self.c.ReturnUInt16, System.UInt16, 2), 
            (self.c.ReturnInt16, System.Int16, 3), 
            (self.c.ReturnUInt32, System.UInt32, 4), 
            (self.c.ReturnInt32, System.Int32, 5), 
            (self.c.ReturnUInt64, System.UInt64, 6), 
            (self.c.ReturnInt64, System.Int64, 7), 
            (self.c.ReturnDouble, System.Double, 8), 
            (self.c.ReturnSingle, System.Single, 9), 
            (self.c.ReturnDecimal, System.Decimal, 10), 
            
            (self.c.ReturnChar, System.Char, 'A'), 
            (self.c.ReturnBoolean, System.Boolean, True), 
            (self.c.ReturnString, System.String, "CLR"), 
            
            (self.c.ReturnEnum, EnumInt16, EnumInt16.C),
        ]:
            x = f()
            self.assertEqual(x.GetType(), clr.GetClrType(t))
            self.assertEqual(x, val)
            
        # return value type
        x= self.c.ReturnStruct()
        self.assertEqual(x.Flag, 100)
        
        x= self.c.ReturnClass()
        self.assertEqual(x.Flag, 200)
        
        x= self.c.ReturnNullableInt1()
        self.assertEqual(x.GetType(), clr.GetClrType(int))
        self.assertEqual(x, 300)
        
        x= self.c.ReturnNullableStruct1()
        self.assertEqual(x.GetType(), clr.GetClrType(SimpleStruct))
        self.assertEqual(x.Flag, 400)
        
        x= self.c.ReturnInterface()
        self.assertEqual(x.Flag, 500)
        
        # return delegate
        x= self.c.ReturnDelegate()
        self.assertEqual(x.GetType(), clr.GetClrType(Int32RInt32EventHandler))
        self.assertEqual(x(3), 6)
        
        # array
        x= self.c.ReturnInt32Array()
        self.assertEqual(x[0], 1)
        self.assertEqual(x[1], 2)
        
        x= self.c.ReturnStructArray()
        self.assertEqual(x[0].Flag, 1)
        self.assertEqual(x[1].Flag, 2) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:61,代码来源:test_returnvalue.py


注:本文中的System.Double方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。