audeering / audobject

Generic Python interface for serializing objects to YAML
https://audeering.github.io/audobject/
Other
1 stars 0 forks source link

Add Object.is_loaded_from_dict #53

Closed frankenjoe closed 2 years ago

frankenjoe commented 2 years ago

Closes #52

image

codecov[bot] commented 2 years ago

Codecov Report

Merging #53 (aeebd0b) into master (78234b1) will not change coverage. The diff coverage is 100.0%.

:exclamation: Current head aeebd0b differs from pull request most recent head 60bb0ac. Consider uploading reports for the commit 60bb0ac to get more accurate results

Impacted Files Coverage Δ
audobject/core/api.py 100.0% <100.0%> (ø)
audobject/core/define.py 100.0% <100.0%> (ø)
audobject/core/dictionary.py 100.0% <100.0%> (ø)
audobject/core/object.py 100.0% <100.0%> (ø)
frankenjoe commented 2 years ago

I'm not completely convinced by the name

I would stick with is_* as this is usually used to express a boolean property. So maybe Object.is_loaded_from_yaml. The only concern I have is that theoretically we might add support for other formats at some point, e.g. JSON by adding audobject.from_json(). And then the name would not really fit anymore.

hagenw commented 2 years ago

I'm not completely convinced by the name

I would stick with is_* as this is usually used to express a boolean property. So maybe Object.is_loaded_from_yaml. The only concern I have is that theoretically we might add support for other formats at some point, e.g. JSON by adding audobject.from_json(). And then the name would not really fit anymore.

OK, is there a way to summarize the possible options. I guess Object.is_loaded_from_file does not work as we also support loading from strings. So I guess we need to point more to the fact that it was loaded from a serialized object representation, so maybe Object.is_loaded_from_representation, or just Object.is_loaded_from_string?

frankenjoe commented 2 years ago

OK, is there a way to summarize the possible options. I guess Object.is_loaded_from_file does not work as we also support loading from strings. So I guess we need to point more to the fact that it was loaded from a serialized object representation, so maybe Object.is_loaded_from_representation, or just Object.is_loaded_from_string?

Actually, the correct name would be is_loaded_from_dict()

hagenw commented 2 years ago

I would be fine with is_loaded_from_dict().

hagenw commented 2 years ago

There could also be a problem, since we have Object.from_dict() one might think it refers only to that method, but I think it should still be fine.

frankenjoe commented 2 years ago

There could also be a problem, since we have Object.from_dict() one might think it refers only to that method, but I think it should still be fine.

I extended the docstring slightly:

image

frankenjoe commented 2 years ago

I would be fine with is_loaded_from_dict().

I renamed it accordingly.