Object representation improvements #140
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When we call the object pyxnat it returns just a collection object and an ID number.
Feature
We want to return more information (metadata information) from the object. Some metadata information examples are the age, gender, handedness, insert data, insert user, number of subjects, experiments, scans...etc.
Solution
The changes has been done in resources.py file.
A repr method has been added to each class (Project, Subject, Experiment, Scan and Resource)
Each method is capable to return the main information for each object dynamically (will just appear the information that the obejct contains, the empty fields will not appear) and a link that redirects you to the XNAT page where the object is.
This method allows us to know more information about the object immediately and find out more just clicking the link.
Unit Tests
For each object, 3 tests cases has been added. So in total we have 15 unit tests in a new file tests/repr_test.py.
The tests cover if the object exist, if the object does not exist and if it exists that the information that returns is correct.