Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ UnsafePointers = "e17b2a0c-0bdf-430a-bd0c-3a23cae4ff39"
[compat]
Aqua = "0 - 999"
CondaPkg = "0.2.23"
DataFrames = "1.7.0"
Dates = "1"
Libdl = "1"
MacroTools = "0.5"
Expand All @@ -35,8 +36,10 @@ julia = "1.6.1"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"

[targets]
test = ["Aqua", "Test", "TestItemRunner"]
test = ["Aqua", "CondaPkg", "DataFrames", "Test", "TestItemRunner"]
7 changes: 5 additions & 2 deletions test/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,14 @@ end
end

@testitem "Tables.jl" begin
using CondaPkg
CondaPkg.add("pandas")

@testset "pytable" begin
x = (x = [1, 2, 3], y = ["a", "b", "c"])
# pandas
# TODO: install pandas and test properly
@test_throws PyException pytable(x, :pandas)
t = pytable(x, :pandas)
@test pyconvert.(Int, Tuple(t.shape)) == (3, 2)
# columns
y = pytable(x, :columns)
@test pyeq(Bool, y, pydict(x = [1, 2, 3], y = ["a", "b", "c"]))
Expand Down
26 changes: 14 additions & 12 deletions test/Wrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -432,24 +432,26 @@ end

@testitem "PyPandasDataFrame" begin
using Tables
using DataFrames
using CondaPkg
CondaPkg.add("pandas")
@test PyPandasDataFrame isa Type
# TODO: figure out how to get pandas into the test environment
# for now use some dummy type and take advantage of the fact that the code doesn't actually check it's a real dataframe
@pyexec """
class DataFrame:
def __init__(self, **kw):
self.__dict__.update(kw)
""" => DataFrame
df = DataFrame(shape = (4, 3), columns = pylist(["foo", "bar", "baz"]))
x = PyPandasDataFrame(df)
x = (x = [1, 2, 3], y = ["a", "b", "c"])
py_df = pytable(x, :pandas)
@test Tables.istable(PyTable(py_df))
df = DataFrame(PyTable(py_df))
@test df == DataFrame(x = [1, 2, 3], y = ["a", "b", "c"])

x = PyPandasDataFrame(py_df)
df = DataFrame(x)
@test df == DataFrame(x = [1, 2, 3], y = ["a", "b", "c"])
@test ispy(x)
@test Py(x) === df
@test Tables.istable(x)
@test Tables.columnaccess(x)
@test_throws Exception Tables.columns(x)
@test Tables.columns(x)[:x] == [1, 2, 3]
@test_throws Exception pyconvert(PyPandasDataFrame, 1)
str = sprint(show, MIME("text/plain"), x)
@test occursin(r"4×3 .*PyPandasDataFrame", str)
@test occursin(r"3×2 .*PyPandasDataFrame", str)
end

@testitem "PySet" begin
Expand Down
Loading