Skip to content

Commit cbf085e

Browse files
authored
fix deprecation warning in pandas_to_df, add test, mv exports (#5)
* fix deprecation warning in `pandas_to_df`, add test, mv exports * format * fix tests
1 parent 4ae7899 commit cbf085e

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CatBoost"
22
uuid = "e2e10f9a-a85d-4fa9-b6b2-639a32100a12"
33
authors = ["Beacon Biosignals, Inc."]
4-
version = "0.1.0"
4+
version = "0.1.1"
55

66
[deps]
77
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"

src/CatBoost.jl

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ using DataFrames
66
using OrderedCollections
77
using Tables
88

9+
#####
10+
##### Exports
11+
#####
12+
13+
export catboost
14+
15+
export CatBoostRegressor, CatBoostClassifier
16+
export fit!, cv, predict, predict_proba
17+
export Pool
18+
export pandas_to_df
19+
20+
# Datasets API.
21+
export load_dataset
22+
923
#####
1024
##### _init_
1125
#####
@@ -137,9 +151,8 @@ function pandas_to_df(pandas_df::PyObject)
137151
ret = c isa PyObject ? PyAny(c) : c
138152
return ret isa Int ? ret + 1 : ret
139153
end
140-
# Did the creators of PyCall seriously handle the conversion automatically?
141-
# What were they thinking?
142-
df = DataFrame(Any[Array(pandas_df[c].values) for c in colnames], map(Symbol, colnames))
154+
df = DataFrame(Any[Array(getproperty(pandas_df, c).values) for c in colnames],
155+
map(Symbol, colnames))
143156
return df
144157
end
145158

@@ -152,18 +165,4 @@ function load_dataset(dataset_name::Symbol)
152165
return train, test
153166
end
154167

155-
#####
156-
##### Exports
157-
#####
158-
159-
export catboost
160-
161-
export CatBoostRegressor, CatBoostClassifier
162-
export fit!, cv, predict, predict_proba
163-
export Pool
164-
export pandas_to_df
165-
166-
# Datasets API.
167-
export load_dataset
168-
169168
end # module

test/runtests.jl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
using Test, CatBoost, Aqua
1+
using Test, CatBoost, DataFrames, PyCall
2+
using Aqua
23

34
EXAMPLES_DIR = joinpath(@__DIR__, "..", "examples")
45

5-
for ex in readdir(EXAMPLES_DIR)
6-
@testset "$ex" begin
7-
# Just check the examples run, for now.
8-
include(joinpath(EXAMPLES_DIR, ex))
6+
@testset "`to_pandas` and `pandas_to_df`" begin
7+
df = DataFrame(; floats=0.5:0.5:3.0, ints=1:6)
8+
pd = CatBoost.to_pandas(df)
9+
@test pd isa PyObject
10+
df2 = pandas_to_df(pd)
11+
@test df2 == df
12+
end
13+
14+
@testset "Examples" begin
15+
for ex in readdir(EXAMPLES_DIR)
16+
@testset "$ex" begin
17+
# Just check the examples run, for now.
18+
include(joinpath(EXAMPLES_DIR, ex))
19+
end
920
end
1021
end
1122

0 commit comments

Comments
 (0)