Skip to content

Conversation

@wschin
Copy link
Member

@wschin wschin commented Dec 4, 2018

Fixes #1706.

@wschin wschin self-assigned this Dec 4, 2018
@wschin wschin changed the title [WIP] Make SchemaShape.Column a struct instead of a class Make SchemaShape.Column a struct instead of a class Dec 4, 2018
@wschin wschin requested review from Ivanidzo4ka and sfilipi December 4, 2018 22:15
/// This documents that the parameter can not legally be null because it is struct.
/// </summary>
[Conditional("INVARIANT_CHECKS")]
public static void CheckValueOrDefault<T>(T val) where T : struct
Copy link
Contributor

Choose a reason for hiding this comment

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

CheckValueOrDefault [](start = 27, length = 19)

Given that we're now doing this through other means, should probably revert these changes as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok. Note that in TrainerEstimatorBase.cs we now do

        private protected TrainerEstimatorBase(IHost host,
            SchemaShape.Column feature,
            SchemaShape.Column label,
            SchemaShape.Column weight = default)
        {
            Contracts.CheckValue(host, nameof(host));
            Host = host;
            Host.Check(feature.IsValid, nameof(feature));
            Host.Check(label.IsValid, nameof(label));

            FeatureColumn = feature;
            LabelColumn = label;
            WeightColumn = weight;
        }

after removing CheckValueOrDefault(weight, nameof(weight)) and CheckValueOrDefault(label, nameof(label)).


In reply to: 238870053 [](ancestors = 238870053)

public static bool IsNormalized(this SchemaShape.Column col)
{
Contracts.CheckValue(col, nameof(col));
Contracts.Check(col.IsValid, nameof(col));
Copy link
Contributor

@TomFinley TomFinley Dec 4, 2018

Choose a reason for hiding this comment

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

Check [](start = 22, length = 5)

This would be CheckParam. Also you will want to provide some sort of message. #Resolved

Copy link
Member Author

@wschin wschin Dec 4, 2018

Choose a reason for hiding this comment

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

Sure. We will use Contracts.CheckParam(col.IsValid, nameof(col), "struct not initialized"); I will do the same for other public functions.


In reply to: 238870227 [](ancestors = 238870227)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks

Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka left a comment

Choose a reason for hiding this comment

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

🕐

Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka left a comment

Choose a reason for hiding this comment

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

:shipit:

Copy link
Contributor

@TomFinley TomFinley left a comment

Choose a reason for hiding this comment

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

Just an urgent note about Schema.

/// and also since it doesn't specify exact <see cref="ColumnType"/>'s for vectors and keys.
/// </summary>
public sealed class SchemaShape
public sealed class SchemaShape : IReadOnlyList<SchemaShape.Column>
Copy link
Contributor

Choose a reason for hiding this comment

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

: IReadOnlyList<SchemaShape.Column> [](start = 36, length = 35)

This is not right! You can make this a ReadOnlyList with proper indexers and so forth. Or you could expose this Columns thing as you do below. You CANNOT DO BOTH.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're absolutely right. Thanks a lot for pointing this out.


In reply to: 239226291 [](ancestors = 239226291)

protected override void CheckLabelCompatible(SchemaShape.Column labelCol)
{
Contracts.AssertValue(labelCol);
Contracts.Assert(labelCol.IsValid, nameof(labelCol));
Copy link
Contributor

@TomFinley TomFinley Dec 5, 2018

Choose a reason for hiding this comment

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

, nameof(labelCol) [](start = 45, length = 18)

This is an assert. It doesn't need or benefit from a message. Also this message, being just the parameter name, might not be the most helpful. (Again not suggesting that it needs a message, just pointing out that if it needed one this would not necessarily be helpful. But please don't add one.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed this and other places. Thanks.


In reply to: 239262489 [](ancestors = 239262489)

Copy link
Contributor

@TomFinley TomFinley left a comment

Choose a reason for hiding this comment

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

:shipit:

@wschin wschin merged commit d7d4e99 into dotnet:master Dec 5, 2018
@wschin wschin deleted the schemashape-column-api branch December 5, 2018 23:56
@ghost ghost locked as resolved and limited conversation to collaborators Mar 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants