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

Handling of Empty and None values in dtype.py lead to load errors #245

Closed
mpsonntag opened this issue Mar 12, 2018 · 5 comments · Fixed by #251
Closed

Handling of Empty and None values in dtype.py lead to load errors #245

mpsonntag opened this issue Mar 12, 2018 · 5 comments · Fixed by #251
Assignees

Comments

@mpsonntag
Copy link
Contributor

The value handling of lists of "empty" values in dtypes.py lead to different results and
potentially broken odML documents:

  • int and float replace None by default values. Can be saved and loaded.

    prop = odml.Property(name="int", value=[""], dtype="int")
    leads to prop.value ... [0]

    prop = odml.Property(name="float", value=[None, None], dtype="float")
    leads to prop.value ... [0.0, 0.0]

  • string related dtypes (string, text, url, person) replace None by "None". Can be saved and loaded.

    prop = odml.Property(name="str", value=["", None], dtype="string")
    leads to prop.value ... ['', 'None']

  • bool, date, time and datetime save None to file but leads to an Error that is hard to identify when the file is loaded.

    prop = odml.Property(name="date", value=[None], dtype="date")
    leads on document load to ValueError: odml.Property.value: passed values are not of consistent type!

@mpsonntag
Copy link
Contributor Author

Should we consistently

  • return the defined dtype default value if an assigned list value is "" or None?
    or
  • handle the currently broken dtypes case by case - since e.g. returning the current date for every "" or None entry might be annoying as well.

@lzehl
Copy link

lzehl commented Mar 12, 2018

hi! I would vote for the first solution: always return the default dtype for "" or None

@jgrewe
Copy link
Member

jgrewe commented Mar 13, 2018

I agree, return default value. Or, we could return None for any non-existing value

@mpsonntag
Copy link
Contributor Author

  • If we return the default value, for date, time and datetime this will always be "now", for bool it will be False.
  • If we return None we need to handle this differently on load, currently it leads to an error.

My vote is to always return the default value.

@jgrewe
Copy link
Member

jgrewe commented Mar 13, 2018

ok, let's do it

@mpsonntag mpsonntag self-assigned this Mar 13, 2018
mpsonntag added a commit to mpsonntag/python-odml that referenced this issue Mar 16, 2018
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 a pull request may close this issue.

3 participants