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

[WIP] Introduce more intuitive method names in Data classes and reduce required input parameter for TrajectoryData.set_trajectory() method #2310

Merged

Conversation

astamminger
Copy link
Contributor

@astamminger astamminger commented Dec 6, 2018

The changes in this pull request address issue #201 providing more intuitive method names. I clustered the changes into three major topics and would be glad to hear your opinion

1. Renamed functions

  • ArrayData
    • .iterarrays() -> .get_iterarrays()
  • TrajectoryData
    • ._get_cif() -> .get_cif()
    • ._get_aiida_structure -> .get_structure()
  • StructureData
    • ._get_cif() -> .get_cif()
  • Code
    • .full_text_info() -> .get_full_text_info()

Functions have been renamed and the tests have been adopted accordingly. (Deprecation warnings have been added to all "old" functions)

2. Methods changed to properties

  • Code
    • .is_hidden() -> .hidden
  • RemoteData
    • .is_empty() -> .is_empty
  • StructureData, Kind
    • .is_alloy() -> .is_alloy
    • .has_vacancies() -> .has_vacancies

Idea was that these values are rather "attributes" of these classes and it is more intuitive to treat them as properties rather than actual methods. Question here is: Is this OK and how to exactly deal with this since we cannot simply add deprecation warnings.

3. Changes in TrajectoryData.set_trajectory():
Input parameters stepid and cells are now optional and the implemented behavior is as follows:

  • If cells parameter is missing: Nothing will be stored for cells.
  • If stepids parameter is missing: stepids defaults to the consecutive sequence [0,1,...,len(positions)-1]

Element symbols passed to the set_trajectory() method are now passed as a list (instead of a numpy.ndarray) and are stored in the TrajectoryData.symbols attribute (as requested in #201 to simplify querying)

Change tests for dataclasses (StructureData, TrajectoryData) to call the
renamed functions .get_structures() (former ._get_aiida_structures()) and
.get_cif() (former ._get_cif())
Change TrajectoryData to make passing stepids and cells optional. While
nothing will be stored for cells if not given a consecutive sequence will be
automatically assigned to stepids if missing from the inputs.
As proposed in issue aiidateam#201 symbols are now stored in a
TrajectoryData attribute rather than an array to simplify the
query for these symbols
Move set of pylint options inside CifData class. Disable check for
too-many-public-methods complaining about 21/20 public methods
after renaming _get_aiida_structure -> get_structure making get_structure()
method public
Make class methods .is_alloy() and .has_vacancies() for StrutureData
and Kind classes accessible as class properties .is_alloy and
.has_vacancies
Copy link
Member

@giovannipizzi giovannipizzi left a comment

Choose a reason for hiding this comment

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

Beside the comments above:

  • rename is_hidden to hidden
  • we would need a data migration before merging, for the symbols going from an array to a attribute.
    If you do all other changes, we can then fork off your branch and implement the migration ourselves. Thanks!

aiida/orm/data/array/trajectory.py Outdated Show resolved Hide resolved
aiida/orm/data/array/trajectory.py Outdated Show resolved Hide resolved
aiida/orm/data/array/trajectory.py Show resolved Hide resolved
@giovannipizzi giovannipizzi changed the title Introduce more intuitive method names in Data classes and reduce required input parameter for TrajectoryData.set_trajectory() method [WIP] Introduce more intuitive method names in Data classes and reduce required input parameter for TrajectoryData.set_trajectory() method Dec 7, 2018
@coveralls
Copy link

coveralls commented Dec 8, 2018

Coverage Status

Coverage decreased (-6.9%) to 61.728% when pulling 82ffebb on boschresearch:issue_201 into 19110f9 on aiidateam:provenance_redesign.

In function _internal_validate the 'symbols' list containing
atomic names is checked for being 1D using the shape of the
array. However, each entry of this list is ensured to be of type
six.string_types somewhere upstream in this function which would
already have triggered if the list is not purely 1D (contains one
or more lists as entry somewhere)
@astamminger
Copy link
Contributor Author

Renamed is_hidden-> hidden: 980b34d
Documented changes (#2320): 44b2e88

astamminger and others added 2 commits December 29, 2018 11:36
Had to reformat the warning.warn() function arguments to get pylint
invoke the set 'disable=no-member' option.
@giovannipizzi giovannipizzi changed the base branch from provenance_redesign to fix_201_method_names_for_data January 14, 2019 09:58
@giovannipizzi giovannipizzi merged commit 8398f24 into aiidateam:fix_201_method_names_for_data Jan 14, 2019
@giovannipizzi
Copy link
Member

Squash-merged into a working branch to keep attribution to @astamminger and we'll continue working from there

elsapassaro pushed a commit to elsapassaro/aiida-core that referenced this pull request Jan 25, 2019
…ired input parameter for TrajectoryData.set_trajectory() method (aiidateam#2310)

* Rename ArrayData.iterarrays() to ArrayData.get_iterarrays()

* [TrajectoryData] Rename _get_aiida_structure() -> get_structure()

* [TrajectoryData] Rename _get_cif() -> get_cif()

* Rename _get_cif() -> get_cit() in tcod.py

* [StructureData] Rename _get_cif() -> get_cif()

* Make stepid and cells parameter optional
  Change TrajectoryData to make passing stepids and cells optional. While
  nothing will be stored for cells if not given a consecutive sequence will be
  automatically assigned to stepids if missing from the inputs.

* Store symbols in TrajectoryData attribute instead of array
  As proposed in issue aiidateam#201 symbols are now stored in a
  TrajectoryData attribute rather than an array to simplify the
  query for these symbols

* Change passed symbols from numpy.ndarray to list in set_structurelist

* Change TrajectoryData tests to use symbols attribute rather than symbols array

* Make Code.is_hidden() available as class property

* Rename Code.full_text_info() method to .get_full_text_info()

* Change RemoteData.is_empty() method to class property .is_empty

* Change is_alloy() and has_vacancies() methods to properties

  Make class methods .is_alloy() and .has_vacancies() for StrutureData
  and Kind classes accessible as class properties .is_alloy and
  .has_vacancies

* Change symbols type from numpy.array to list

* Add deprecation warning to renamed methods

* Rename code attribute is_hidden to hidden.

* Set allowed symbols type to be Iterable rather than list

* Ensure symbols are stored as list

* Adjust argument ordering in set_trajectory() docstring.

* Document introduced changes in concepts/workflows
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.

None yet

3 participants