Skip to content

Commit

Permalink
Stop put from failing when input is an Item
Browse files Browse the repository at this point in the history
  • Loading branch information
augustebaum committed Oct 4, 2024
1 parent 55474da commit c0661a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/skore/item/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

def object_to_item(object: Any) -> Item:
"""Transform an object into an Item."""
if isinstance(object, Item):
return object

for cls in (
PrimitiveItem,
PandasDataFrameItem,
Expand Down
1 change: 1 addition & 0 deletions src/skore/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def put(self, key: str, value: Any, on_error: Literal["warn", "raise"] = "warn")
The key to associate with `value` in the Project. Must be a string.
value : Any
The value to associate with `key` in the Project.
If an `Item`, will be inserted as-is.
on_error : "warn" or "raise", optional
Upon error (e.g. if the key is not a string), whether to raise an error or
to print a warning. Default is "warn".
Expand Down

0 comments on commit c0661a4

Please sign in to comment.