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

Add Set_HWD and related tests #70

Merged
merged 8 commits into from
Oct 6, 2022
Merged

Add Set_HWD and related tests #70

merged 8 commits into from
Oct 6, 2022

Conversation

giacomomarchioro
Copy link
Contributor

This add pull request adds the method Set_HWD to Canvases and ResourceItem and tests for checking it works correctly.

#54

@giacomomarchioro giacomomarchioro requested a review from a team May 27, 2022 16:02
Comment on lines 17 to 22
if duration is None and height is None and width is None:
raise TypeError("At least one of height, width, or duration must be set")
if height is not None and width is None:
raise TypeError("width must be set if height is set")
if width is not None and height is None:
raise TypeError("height must be set if width is set")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is zero allowed, or any other empty values? Or is important to check explicitly for None?

If not, could just do a boolean check here, e.g. if not (height or width or duration)

Copy link
Member

Choose a reason for hiding this comment

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

The spec doesn't explicitly say width and height must be non-zero, but then it also doesn't say they must be positive integers either.

@azaroth42 @glenrobson ?

Copy link
Member

Choose a reason for hiding this comment

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

I suppose there could be an instance where a user tries to set H+W to 0 for an Audio resource, which would technically be correct, I suppose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mmm interesting point I think both solutions are valid, maybe Rebecca choice is safer if one wants to enforce h and w to be zero he could assign them manually

Copy link
Contributor

Choose a reason for hiding this comment

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

The spec says "The value must be a positive integer." so I think it implies its 1 or over...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

The spec says "The value must be a positive integer." so I think it implies its 1 or over...

Somehow my eyes completely bypassed that sentence when I was reading the spec 😂

Is there a way to enforce this in the Schema? That would seem the best place to do so, but if it's not possible, then we should add it here in the helper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

We'd also need to add a minimum for the height and width:
https://github.com/IIIF/presentation-validator/blob/bd7468500f8ebfa82aa54f6c80ddd4f22f20c71a/schema/iiif_3_0.json#L141
https://github.com/IIIF/presentation-validator/blob/bd7468500f8ebfa82aa54f6c80ddd4f22f20c71a/schema/iiif_3_0.json#L531

One thing we should check is if a minimum value of 1 will prevent blank values (because of an evaluation to 0). I don't know if this is the case with how Pydantic works (I suspect not) but it might be for some JSON Validators?

The potential issue is that for an audio file, H & W = 0 would technically be correct, although it would violate the wording of the spec (if we read "positive integer" as >= 1, that is), so we should maybe have a chat about how we want to handle this.

Copy link
Member

Choose a reason for hiding this comment

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

@azaroth42 @zimeon @jpstroop - any thoughts on this as editors?

Co-authored-by: Rebecca Sutton Koeser <rlskoeser@users.noreply.github.com>
@glenrobson glenrobson linked an issue May 27, 2022 that may be closed by this pull request
14 tasks
@giacomomarchioro
Copy link
Contributor Author

I have opend an issue #79 for the duration problem.

giacomomarchioro and others added 2 commits May 27, 2022 21:03
Co-authored-by: Rebecca Sutton Koeser <rlskoeser@users.noreply.github.com>
Co-authored-by: Rebecca Sutton Koeser <rlskoeser@users.noreply.github.com>
Copy link
Contributor

@glenrobson glenrobson left a comment

Choose a reason for hiding this comment

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

Happy to merge this and look at greater than duration validation in the schema.

@rlskoeser
Copy link
Contributor

if you are able to get this merged, I should have time tomorrow to update and finish my work on #56

@digitaldogsbody
Copy link
Member

I think we can merge without the minimum duration being resolved, since that will be a change in the schema and we still need to determine if 0 can be valid in some circumstances (per discussion above).

@digitaldogsbody digitaldogsbody merged commit e45d3a0 into iiif-prezi:main Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set HWD
4 participants