Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply rename to initialize_from_schema to ContrastiveOutput #1196

Merged
merged 1 commit into from
Jul 11, 2023
Merged
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
4 changes: 2 additions & 2 deletions merlin/models/torch/outputs/contrastive.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
)

if schema:
self.setup_schema(schema)
self.initialize_from_schema(schema)

self.init_hook_handle = self.register_forward_pre_hook(self.initialize)
if not torch.jit.is_scripting():
Expand Down Expand Up @@ -121,7 +121,7 @@ def tie_weights(

return self

def setup_schema(self, target: Union[ColumnSchema, Schema]):
def initialize_from_schema(self, target: Union[ColumnSchema, Schema]):
"""Set up the schema for the output.

Parameters
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/torch/outputs/test_constrastive.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class TestContrastiveOutput:
def test_setup_schema(self, item_id_col_schema, user_id_col_schema):
def test_initialize_from_schema(self, item_id_col_schema, user_id_col_schema):
contrastive = ContrastiveOutput()

dot = ContrastiveOutput(schema=Schema([item_id_col_schema, user_id_col_schema]))
Expand All @@ -23,10 +23,10 @@ def test_setup_schema(self, item_id_col_schema, user_id_col_schema):
assert isinstance(target.to_call, CategoricalTarget)

with pytest.raises(ValueError):
contrastive.setup_schema(1)
contrastive.initialize_from_schema(1)

with pytest.raises(ValueError):
contrastive.setup_schema(Schema(["a", "b", "c"]))
contrastive.initialize_from_schema(Schema(["a", "b", "c"]))

def test_outputs_without_downscore(self, item_id_col_schema):
contrastive = ContrastiveOutput(item_id_col_schema, downscore_false_negatives=False)
Expand Down
Loading