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

Fix #3507 #3508

Merged
merged 6 commits into from
Mar 15, 2020
Merged

Fix #3507 #3508

merged 6 commits into from
Mar 15, 2020

Conversation

adamjakab
Copy link
Contributor

@adamjakab adamjakab commented Mar 2, 2020

Adding normalize method to class types.INTEGER overriding the inherited method from the Type class that simply returned the provided value. Also provides Fix #762 and Fix #3507.

Adam Jakab added 4 commits March 2, 2020 00:16
- renamed test test_format_fixed_field to test_format_fixed_field_string
- test_format_fixed_field_string not tests `field_two` with string values
- added new test_format_fixed_field_integer to test field `field_one` as INTEGER
- added new test_format_fixed_field_integer_normalized to test rounding float values
@adamjakab adamjakab changed the title Fixes #3507 Fix #3507 Mar 2, 2020
Copy link
Member

@sampsyo sampsyo left a comment

Choose a reason for hiding this comment

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

Nice work! This is really great!! I expected this to break more things, but it looks like the effects on the tests were rather small. As you can see from this tragic inline comment:

# TODO This should eventually be replaced by
# `self.model_type(value)`

…we always intended to make the normalization more strict in dbcore, and this is a step in the right direction.

Would you mind adding a quick changelog entry? Then this should be ready to merge.

@@ -91,7 +93,10 @@ def test_current_metadata_likelies(self):
for i in range(5)]
likelies, _ = match.current_metadata(items)
for f in fields:
self.assertEqual(likelies[f], '%s_1' % f)
if type(items[0]._fields[f]) in (Integer, PaddedInt):
Copy link
Member

Choose a reason for hiding this comment

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

Maybe a slightly easier way to do this would be isinstance(likelies[f], int)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it looks simpler.

@adamjakab
Copy link
Contributor Author

Nice work! This is really great!!

I am happy you think so. I was surprised to find an issue (#762) from 2014 which already brings this up. But TBH, I am being a bit selfish here in proposing this fix because I need this to work correctly for my new plugin. But hey! Isn't that always like that? ;)

I expected this to break more things, ...

Yes, me too ;) But there are not many tests targeting this. In fact one of the things I wanted to add here is some more tests - I'll look at the coverage and see if I can cover Integers.

Would you mind adding a quick changelog entry?

Sure.

@adamjakab
Copy link
Contributor Author

@sampsyo - this is ready to go!

@sampsyo
Copy link
Member

sampsyo commented Mar 15, 2020

Looks great! Thank you!!

sampsyo added a commit that referenced this pull request Mar 15, 2020
@sampsyo sampsyo merged commit 3261f07 into beetbox:master Mar 15, 2020
@adamjakab adamjakab deleted the bpm_is_int branch March 15, 2020 11:46
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.

Integers are not normalized Expose floating-point BPM in MediaFile or normalize floats to ints in database
2 participants