-
Notifications
You must be signed in to change notification settings - Fork 623
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
Add Invalid Encoding Channel Warning #3426
Conversation
Thank you for the pull request. Please make this a warning and delete the encoding instead of throwing an error. Also, let's add a test. |
The warning and deletion of encoding is already implemented in encoding.ts. |
I'd trace what causes the error in #3415 and make sure that it's handled either by the code you found or something new you write. |
ec5d71b
to
e91c4fe
Compare
Updated the PR. 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for submitting a PR.
Please see my comments. I think you're getting there. :)
src/channel.ts
Outdated
@@ -214,6 +214,8 @@ export function getSupportedMark(channel: Channel): SupportedMark { | |||
return {point: true, geoshape: true}; | |||
case TEXT: | |||
return {text: true}; | |||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is the right place to correct this?
If the channel you have isn't a valid Channel
at all, then it doesn't satisfy the signature of this method.
A better check would be using isChannel
method to check if a key of the encoding object is a channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the changes. Thanks for the help!
test/compile/unit.test.ts
Outdated
_y: {type: 'quantitative'} | ||
} | ||
} as any); // To make parseUnitModel accept the model with invalid encoding channel | ||
assert.equal(model.encoding.shape, undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this is related to model.encoding.shape
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the assert.
b53d1ab
to
13e46a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. A few more minor correction and this should be good to go! :)
src/log.ts
Outdated
@@ -175,6 +175,10 @@ export namespace message { | |||
return `${channel} dropped as it is incompatible with "${markOrFacet}"${when ? ` when ${when}` : ''}.`; | |||
} | |||
|
|||
export function invalidEncodingChannel(encoding: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encoding
normally refer to encoding mapping, which is an object.
Rename to channel
would be less misleading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/log.ts
Outdated
@@ -175,6 +175,10 @@ export namespace message { | |||
return `${channel} dropped as it is incompatible with "${markOrFacet}"${when ? ` when ${when}` : ''}.`; | |||
} | |||
|
|||
export function invalidEncodingChannel(encoding: string) { | |||
return `${encoding} dropped as it is invalid.`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
${channel}-encoding is dropped as ${channel} is not a valid encoding channel.
test/compile/unit.test.ts
Outdated
@@ -19,6 +19,17 @@ describe('UnitModel', function() { | |||
assert.equal(localLogger.warns[0], log.message.incompatibleChannel(SHAPE, BAR)); | |||
})); | |||
|
|||
it('should drop invalid channel and throws warning', log.wrap((localLogger) => { | |||
const INVALID_CHANNEL = '_y'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line and just use "_y"
below?
Thank you @invokesus! |
Please:
site/docs/
yarn lint
andyarn test
. If your change affects Vega outputs of some examples, please runyarn build:example EXAMPLE_NAME
to re-compile a specific example oryarn build:examples
to re-compile all examples.)master
branch.#1
)Fixes #3415.