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

Comparison of odml objects #265

Closed
rickskyy opened this issue Mar 21, 2018 · 0 comments · Fixed by #375
Closed

Comparison of odml objects #265

rickskyy opened this issue Mar 21, 2018 · 0 comments · Fixed by #375

Comments

@rickskyy
Copy link
Collaborator

I was testing RDFReader and ran into the problem with comparing odml objects. The thing is after building an odml document from an RDF graph the initial order of values, properties and sections become lost. That is why I cannot simply check if the processed document after conversion is equal to initial one. (See tests in test_parser.py)

For example:

Although the lists [<Section TheStarship[starship] (1)>, <Section TheCrew[crew] (4)>] and [<Section TheCrew[crew] (4)>, <Section TheStarship[starship] (1)>] contains same objects, the lists object itself are not equal. The same case happens with all attributes of base odml classes that have list values.

From conceptual view do the lists from above example are considered equal if its consist of an equal set of elements? If so can I add code to __eq__ method of baseobject(_baseobj) class to process the described cases?

The most straightforward way:

  1. If the attribute value is the instance of a list compare the length, return false if different.
  2. Compare each element from the first to each element from the second and track the number the same objects which should be equal to the number of elements in each list.

I implemented this method and all tests have passed.

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.

1 participant