Skip to content

Commit

Permalink
mob next [ci-skip] [ci skip] [skip ci]
Browse files Browse the repository at this point in the history
lastFile:tests/unit/test_project.py
  • Loading branch information
thomass-dev committed Sep 9, 2024
1 parent acf2763 commit cf63bef
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/skore/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def transform(o: Any) -> Item:
raw_class_name="sklearn.base.BaseEstimator",
serialized=json.dumps(
{
"skops": skops.io.dumps(o),
"skops": skops.io.dumps(o).decode(),
"html": sklearn.utils.estimator_html_repr(o),
}
),
Expand Down
41 changes: 37 additions & 4 deletions tests/unit/test_project.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import json
import pandas
import numpy
import sklearn.svm
import skops.io
from skore.project import Item, transform


Expand All @@ -10,12 +14,41 @@ def test_transform_primitive():


def test_transform_pandas_dataframe():
o = pandas.DataFrame()
o = pandas.DataFrame([{"key": "value"}])
actual = transform(o)
expected = Item(
raw=pandas.DataFrame(), raw_class_name="pandas.DataFrame", serialized=""
raw=o,
raw_class_name="pandas.DataFrame",
serialized=o.to_json(orient="split"),
)

assert actual == expected


def test_transform_numpy_ndarray():
o = numpy.ndarray([1, 2, 3])
actual = transform(o)
expected = Item(
raw=o,
raw_class_name="numpy.ndarray",
serialized=json.dumps(o.tolist()),
)

assert actual == expected

# o = 3.3
# transform(o)

def test_transform_sklearn_base_baseestimator():
o = sklearn.svm.SVC()
actual = transform(o)
expected = Item(
raw=o,
raw_class_name="numpy.ndarray",
serialized=json.dumps(
{
"skops": skops.io.dumps(o).decode(),
"html": sklearn.utils.estimator_html_repr(o),
}
),
)

assert actual == expected

0 comments on commit cf63bef

Please sign in to comment.