Skip to content

Commit

Permalink
fix deprecation warning in pandas_to_df, add test, mv exports (#5)
Browse files Browse the repository at this point in the history
* fix deprecation warning in `pandas_to_df`, add test, mv exports

* format

* fix tests
  • Loading branch information
ericphanson authored Jun 7, 2021
1 parent 4ae7899 commit cbf085e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CatBoost"
uuid = "e2e10f9a-a85d-4fa9-b6b2-639a32100a12"
authors = ["Beacon Biosignals, Inc."]
version = "0.1.0"
version = "0.1.1"

[deps]
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
Expand Down
33 changes: 16 additions & 17 deletions src/CatBoost.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ using DataFrames
using OrderedCollections
using Tables

#####
##### Exports
#####

export catboost

export CatBoostRegressor, CatBoostClassifier
export fit!, cv, predict, predict_proba
export Pool
export pandas_to_df

# Datasets API.
export load_dataset

#####
##### _init_
#####
Expand Down Expand Up @@ -137,9 +151,8 @@ function pandas_to_df(pandas_df::PyObject)
ret = c isa PyObject ? PyAny(c) : c
return ret isa Int ? ret + 1 : ret
end
# Did the creators of PyCall seriously handle the conversion automatically?
# What were they thinking?
df = DataFrame(Any[Array(pandas_df[c].values) for c in colnames], map(Symbol, colnames))
df = DataFrame(Any[Array(getproperty(pandas_df, c).values) for c in colnames],
map(Symbol, colnames))
return df
end

Expand All @@ -152,18 +165,4 @@ function load_dataset(dataset_name::Symbol)
return train, test
end

#####
##### Exports
#####

export catboost

export CatBoostRegressor, CatBoostClassifier
export fit!, cv, predict, predict_proba
export Pool
export pandas_to_df

# Datasets API.
export load_dataset

end # module
21 changes: 16 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
using Test, CatBoost, Aqua
using Test, CatBoost, DataFrames, PyCall
using Aqua

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

for ex in readdir(EXAMPLES_DIR)
@testset "$ex" begin
# Just check the examples run, for now.
include(joinpath(EXAMPLES_DIR, ex))
@testset "`to_pandas` and `pandas_to_df`" begin
df = DataFrame(; floats=0.5:0.5:3.0, ints=1:6)
pd = CatBoost.to_pandas(df)
@test pd isa PyObject
df2 = pandas_to_df(pd)
@test df2 == df
end

@testset "Examples" begin
for ex in readdir(EXAMPLES_DIR)
@testset "$ex" begin
# Just check the examples run, for now.
include(joinpath(EXAMPLES_DIR, ex))
end
end
end

Expand Down

2 comments on commit cbf085e

@ericphanson
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/38350

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.1 -m "<description of version>" cbf085e34c655e72abe8235858c00609e15f1f6b
git push origin v0.1.1

Please sign in to comment.