Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cell = ipysheet.row(0, [0, 1.2])
assert cell.value == [0, 1.2]
assert cell.type == 'numeric'
cell = ipysheet.row(0, [0, 1])
assert cell.value == [0, 1]
assert cell.type == 'numeric'
cell = ipysheet.row(0, ['a', 'b'])
assert cell.value == ['a', 'b']
assert cell.type == 'text'
cell = ipysheet.row(0, [True, 0])
assert cell.type == 'numeric'
cell = ipysheet.row(0, [True, 'bla'])
assert cell.type is None
cell = ipysheet.cell(0, 0, choice=['a', 'b'])
assert cell.type == 'dropdown'
def test_row_and_column():
ipysheet.sheet(rows=3, columns=4)
ipysheet.row(0, [0, 1, 2, 3])
ipysheet.row(0, [0, 1, 2])
ipysheet.row(0, [0, 1, 2], column_end=2)
ipysheet.row(0, [0, 1, 2], column_start=1)
with pytest.raises(ValueError):
ipysheet.row(0, [0, 1, 2, 4, 5])
with pytest.raises(ValueError):
ipysheet.row(0, [0, 1], column_end=3)
with pytest.raises(ValueError):
ipysheet.row(0, [0, 1, 2, 4], column_start=1)
row = ipysheet.row(0, [0, 1, 2, 3])
with pytest.raises(ValueError):
row.value = [0, 1, 2]
with pytest.raises(ValueError):
row.value = 1
row.value = [0, 1, 2, 4]
assert row.value == [0, 1, 2, 4]
def test_to_dataframe():
sheet = ipysheet.sheet(rows=5, columns=4)
ipysheet.cell(0, 0, value=True)
ipysheet.row(1, value=[2, 34, 543, 23])
ipysheet.column(3, value=[1.2, 1.3, 1.4, 1.5, 1.6])
df = ipysheet.to_dataframe(sheet)
assert np.all(df['A'].tolist() == [True, 2, None, None, None])
assert np.all(df['B'].tolist() == [None, 34, None, None, None])
assert np.all(df['C'].tolist() == [None, 543, None, None, None])
assert np.all(df['D'].tolist() == [1.2, 1.3, 1.4, 1.5, 1.6])
sheet = ipysheet.sheet(rows=4, columns=4, column_headers=['c0', 'c1', 'c2', 'c3'], row_headers=['r0', 'r1', 'r2', 'r3'])
ipysheet.cell_range(
[
[2, 34, 543, 23],
[1, 1, 1, 1],
[2, 2, 222, 22],
[2, 0, 111, 11],
],
def test_row_and_column():
ipysheet.sheet(rows=3, columns=4)
ipysheet.row(0, [0, 1, 2, 3])
ipysheet.row(0, [0, 1, 2])
ipysheet.row(0, [0, 1, 2], column_end=2)
ipysheet.row(0, [0, 1, 2], column_start=1)
with pytest.raises(ValueError):
ipysheet.row(0, [0, 1, 2, 4, 5])
with pytest.raises(ValueError):
ipysheet.row(0, [0, 1], column_end=3)
with pytest.raises(ValueError):
ipysheet.row(0, [0, 1, 2, 4], column_start=1)
row = ipysheet.row(0, [0, 1, 2, 3])
with pytest.raises(ValueError):
row.value = [0, 1, 2]
with pytest.raises(ValueError):
row.value = 1
row.value = [0, 1, 2, 4]
assert row.value == [0, 1, 2, 4]
ipysheet.column(0, [0, 1, 2])
ipysheet.column(0, [0, 1])
ipysheet.column(0, [0, 1], row_end=1)
ipysheet.column(0, [0, 1], row_start=1)
with pytest.raises(ValueError):
def test_row_and_column():
ipysheet.sheet(rows=3, columns=4)
ipysheet.row(0, [0, 1, 2, 3])
ipysheet.row(0, [0, 1, 2])
ipysheet.row(0, [0, 1, 2], column_end=2)
ipysheet.row(0, [0, 1, 2], column_start=1)
with pytest.raises(ValueError):
ipysheet.row(0, [0, 1, 2, 4, 5])
with pytest.raises(ValueError):
ipysheet.row(0, [0, 1], column_end=3)
with pytest.raises(ValueError):
ipysheet.row(0, [0, 1, 2, 4], column_start=1)
row = ipysheet.row(0, [0, 1, 2, 3])
with pytest.raises(ValueError):
row.value = [0, 1, 2]
with pytest.raises(ValueError):
row.value = 1
row.value = [0, 1, 2, 4]
assert row.value == [0, 1, 2, 4]
ipysheet.column(0, [0, 1, 2])
ipysheet.column(0, [0, 1])
ipysheet.column(0, [0, 1], row_end=1)
def test_row_and_column():
ipysheet.sheet(rows=3, columns=4)
ipysheet.row(0, [0, 1, 2, 3])
ipysheet.row(0, [0, 1, 2])
ipysheet.row(0, [0, 1, 2], column_end=2)
ipysheet.row(0, [0, 1, 2], column_start=1)
with pytest.raises(ValueError):
ipysheet.row(0, [0, 1, 2, 4, 5])
with pytest.raises(ValueError):
ipysheet.row(0, [0, 1], column_end=3)
with pytest.raises(ValueError):
ipysheet.row(0, [0, 1, 2, 4], column_start=1)
row = ipysheet.row(0, [0, 1, 2, 3])
with pytest.raises(ValueError):
row.value = [0, 1, 2]
with pytest.raises(ValueError):
row.value = 1
row.value = [0, 1, 2, 4]
assert row.value == [0, 1, 2, 4]
ipysheet.column(0, [0, 1, 2])
ipysheet.column(0, [0, 1])
ipysheet.column(0, [0, 1], row_end=1)
ipysheet.column(0, [0, 1], row_start=1)
with pytest.raises(ValueError):
ipysheet.column(0, [0, 1, 2, 3])
with pytest.raises(ValueError):
ipysheet.column(0, [0, 1], row_end=0)
with pytest.raises(ValueError):
cell = ipysheet.cell(0, 0, value=1.2)
assert cell.value == 1.2
assert cell.type == 'numeric'
cell = ipysheet.cell(0, 0, value=1)
assert cell.value == 1
assert cell.type == 'numeric'
cell = ipysheet.Cell(value='1.2')
assert cell.value == '1.2'
assert cell.type is None
cell = ipysheet.row(0, [True, False])
assert cell.value == [True, False]
assert cell.type == 'checkbox'
cell = ipysheet.row(0, [0, 1.2])
assert cell.value == [0, 1.2]
assert cell.type == 'numeric'
cell = ipysheet.row(0, [0, 1])
assert cell.value == [0, 1]
assert cell.type == 'numeric'
cell = ipysheet.row(0, ['a', 'b'])
assert cell.value == ['a', 'b']
assert cell.type == 'text'
cell = ipysheet.row(0, [True, 0])
assert cell.type == 'numeric'
cell = ipysheet.row(0, [True, 'bla'])
assert cell.type is None
def test_row_and_column():
ipysheet.sheet(rows=3, columns=4)
ipysheet.row(0, [0, 1, 2, 3])
ipysheet.row(0, [0, 1, 2])
ipysheet.row(0, [0, 1, 2], column_end=2)
ipysheet.row(0, [0, 1, 2], column_start=1)
with pytest.raises(ValueError):
ipysheet.row(0, [0, 1, 2, 4, 5])
with pytest.raises(ValueError):
ipysheet.row(0, [0, 1], column_end=3)
with pytest.raises(ValueError):
ipysheet.row(0, [0, 1, 2, 4], column_start=1)
row = ipysheet.row(0, [0, 1, 2, 3])
with pytest.raises(ValueError):
row.value = [0, 1, 2]
with pytest.raises(ValueError):
row.value = 1
row.value = [0, 1, 2, 4]
assert row.value == [0, 1, 2, 4]
ipysheet.column(0, [0, 1, 2])