Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.

Generic interface for Mesh#326

Merged
mehdisadeghi merged 16 commits into
masterfrom
generic-interface-mesh
Nov 3, 2016
Merged

Generic interface for Mesh#326
mehdisadeghi merged 16 commits into
masterfrom
generic-interface-mesh

Conversation

@stefanoborini

Copy link
Copy Markdown
Contributor

This PR introduces the generic interface for datasets and applies it to the Mesh object, with minimal disruption to the internals and no disruptions to the old interface.
We expect a loss of efficiency but that's the price to pay for not knowing the uid->type association. At the moment, it's probably not wise to implement optimization strategies to solve this issue, and will be part of a separate PR once we migrated all objects.

@codecov-io

codecov-io commented Oct 19, 2016

Copy link
Copy Markdown

Current coverage is 85.62% (diff: 93.46%)

No coverage report found for master at 2b6e5f7.

Powered by Codecov. Last update 2b6e5f7...7aaedb0

"""

@abstractmethod
def has(self, uid): # pragma: no cover

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest to implement __contains__ instead of this.
https://docs.python.org/3/reference/datamodel.html#object.__contains__

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

However, the same applies to all the other pythonic container methods. Perhaps it's better to leave this the subject of another PR. (And I see we have has_something methods there)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

well, if you do so, it's certainly possible, but at that point we should just reimplement the dict() interface... :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! However, we have to attack the problem of being a dict or not soon...

"""

@abstractmethod
def count_of(self, item_type): # pragma: no cover

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shell we implement __len__ beside this? Of course it will return the whole number of elements inside the dataset.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's possible, yes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added

from abc import ABCMeta, abstractmethod


class ABCDataset(object):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

DataSets must conform the the structore of CUBA.DATA_SET, i.e. they need uid, name, etc defined.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok then I probably used the wrong name. I just picked dataset but I am not sure about it.
What is the generic name for things like particles, mesh, and lattice?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

DataSet!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you suggest that I add these as well, or that I should choose another name? This is just an interface to the generic interface, so I am not sure if we want to name it after the Dataset.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the name is fine. How about adding meta.DataSet as a parent to get the properties?

Comment thread simphony/cuds/abc_mesh.py
"""
raise NotImplementedError("Remove is not implemented for Mesh")

def iter(self, uids=None, item_type=None):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Docstring for item_type is missing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added

@stefanoborini

Copy link
Copy Markdown
Contributor Author

@mehdisadeghi please re-review.

@stefanoborini

Copy link
Copy Markdown
Contributor Author

Some failures are due to the fact that we are now dependent on the DataSet. Some assumptions of the test are no longer valid, but they will be restored when we merge #335

I'll merge that branch into this one, but this mean that #335 must be merged first.

@stefanoborini

Copy link
Copy Markdown
Contributor Author

Another source of problem is that with the new hierarchy involving the generated base meta classes, the data object now contains None entries, that are converted to the string "None" when written on the hdf5 file with pytables.

@stefanoborini

Copy link
Copy Markdown
Contributor Author

The problem of None should be solved by setting appropriate defaults to strings, as from PR #343. In any case, the base classing will be done on a separate PR.

@mehdisadeghi

mehdisadeghi commented Nov 3, 2016

Copy link
Copy Markdown
Contributor

@stefanoborini since you have made separated PRs for bad default values (#343) in the schema and the copy vs. reference data property (#335), and those PRs are merged I proceed with merging this one.

@mehdisadeghi mehdisadeghi merged commit 1d0189d into master Nov 3, 2016
@mehdisadeghi mehdisadeghi deleted the generic-interface-mesh branch November 3, 2016 12:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants