Exemplo n.º 1
0
def check_intcolumn_typing():

	dm = DataMatrix(length=4, default_col_type=IntColumn)
	dm.f = 1.1, '1.8', 2, '2'
	ok_(all(isinstance(v, int) for v in dm.f))
	@raises(TypeError)
	def _():
		dm.inf = INF, -INF, 'inf', '-inf'
	_()
	@raises(TypeError)
	def _():
		dm.nan = NAN, NAN, 'nan', 'nan'
	_()
	@raises(TypeError)
	def _():
		dm.none = None, None, None, None
	_()
	@raises(TypeError)
	def _():
		dm.s = 'alpha', 'beta', 'None', ' '
	_()
	@raises(TypeError)
	def _():
		dm.err = Exception, tuple, str, map
	_()
Exemplo n.º 2
0
def check_floatcolumn_typing():

	dm = DataMatrix(length=4, default_col_type=FloatColumn)
	dm.f = 1.1, '1.1', 1, '2'
	ok_(all(isinstance(v, float) for v in dm.f))
	dm.inf = INF, -INF, 'inf', '-inf'
	ok_(all(math.isinf(v) for v in dm.inf))
	dm.nan = NAN, NAN, 'nan', 'nan'
	ok_(all(math.isnan(v) for v in dm.nan))
	dm.none = None, None, None, None
	ok_(all(math.isnan(v) for v in dm.none))
	dm.s = 'alpha', 'beta', 'None', ' '
	ok_(all(math.isnan(v) for v in dm.s))
	@raises(TypeError)
	def _():
		dm.err = Exception, tuple, str, map
	_()
Exemplo n.º 3
0
def check_floatcolumn_typing():

    dm = DataMatrix(length=4, default_col_type=FloatColumn)
    dm.f = 1.1, '1.1', 1, '2'
    assert all(isinstance(v, float) for v in dm.f)
    dm.inf = INF, -INF, 'inf', '-inf'
    assert all(math.isinf(v) for v in dm.inf)
    dm.nan = NAN, NAN, 'nan', 'nan'
    assert all(math.isnan(v) for v in dm.nan)
    with pytest.warns(UserWarning):
        dm.none = None, None, None, None
    assert all(math.isnan(v) for v in dm.none)
    with pytest.warns(UserWarning):
        dm.s = 'alpha', 'beta', 'None', ' '
    assert all(math.isnan(v) for v in dm.s)
    with pytest.raises(TypeError):
        dm.err = Exception, tuple, str, map
Exemplo n.º 4
0
def check_mixedcolumn_typing():

	dm = DataMatrix(length=4)
	dm.i = 1, '1', 2, '2'
	ok_(all(isinstance(v, int) for v in dm.i))
	dm.f = 1.1, '1.1', 2.1, '2.2'
	ok_(all(isinstance(v, float) for v in dm.f))
	dm.inf = INF, -INF, 'inf', '-inf'
	ok_(all(math.isinf(v) for v in dm.inf))
	dm.nan = NAN, NAN, 'nan', 'nan'
	ok_(all(math.isnan(v) for v in dm.nan))
	dm.none = None, None, None, None
	ok_(all(v is None for v in dm.none))
	dm.s = 'alpha', 'beta', 'None', ''
	ok_(all(isinstance(v, str) for v in dm.s))
	@raises(TypeError)
	def _():
		dm.err = Exception, tuple, str, map
	_()