Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #164 +/- ##
==========================================
+ Coverage 88.20% 88.60% +0.40%
==========================================
Files 5 5
Lines 814 834 +20
Branches 107 108 +1
==========================================
+ Hits 718 739 +21
- Misses 56 57 +1
+ Partials 40 38 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@orbeckst pls check this kindly |
orbeckst
left a comment
There was a problem hiding this comment.
This is already looking pretty good. Please also add doc strings and update CHANGELOG. Will have a closer look once this is done. Thank you!
|
|
||
| assert isinstance(dx_field, gridData.OpenDX.field) | ||
|
|
||
| assert any('test_density' and 'test_user' in str(c) for c in dx_field.comments) |
There was a problem hiding this comment.
This is a logic error. 'test_density' and 'test_user' in str(c) evaluates as 'test_user' in str(c) due to Python's and short-circuit semantics — 'test_density' is truthy (not None / empty string), so it's ignored. Should be:
assert any('test_density' in str(c) for c in dx_field.comments)
assert any('test_user' in str(c) for c in dx_field.comments)There was a problem hiding this comment.
Actually to get what you are doing there, you might need
assert any(('test_density' in str(c) and 'test_user' in str(c)) for c in dx_field.comments)If you need them both to be true for a single comment.
|
|
||
| converter = { | ||
| 'MRC': mrc.MRC.from_grid, | ||
| 'VDB': None, |
There was a problem hiding this comment.
VDB is going to be implemented but it should be removed for now. Currently the self.converter[]() has potential to try and call None() so best to just not include until the VDB support is added (or add a guard for such in the later usage).
There was a problem hiding this comment.
You can comment out this line.
| grid, edges = g.histogramdd() | ||
| self._load(grid=grid, edges=edges, metadata=self.metadata) | ||
|
|
||
| def convert_to(self, format_specifier, tolerance=None, **kwargs): |
There was a problem hiding this comment.
The tolerance is currently not used at all. Should be removed and left for the PR that introduces VDB.
| if filename is not None: | ||
| self.read(filename, assume_volumetric=assume_volumetric) | ||
|
|
||
| @staticmethod |
There was a problem hiding this comment.
Should these be classmethods instead of staticmethods?
There was a problem hiding this comment.
In the issue it was staticmethod and it's fine for basic usage as well. But classmethod is more good, if somebody subclasses mrc/dx
Should I change it?
There was a problem hiding this comment.
I did't know any better ;-). After some reading I also recommend going with @classmethod — if we need to work with inheritance or use it from another classmethod then classmethod will work better.
orbeckst
left a comment
There was a problem hiding this comment.
Overall looking good but there are some necessary changes. In particular, the MRC.native should return a MrcFile.
Could you please also add a section to the gridData.core docs about using from_grid() and .native? Have a look at the issue text for #161 and you can probably copy and paste from there. We just want to document somewhere for users that this API exists.
| * 1.1.1 | ||
|
|
||
| Fixes | ||
| Changes |
| ??/??/???? orbeckst | ||
| ??/??/???? orbeckst, spyke7 | ||
|
|
||
| * 1.1.1 |
There was a problem hiding this comment.
Change to 1.2.0 (under semantic versioning, we must increase minor version for new features)
| Returns | ||
| ------- | ||
| field | ||
| OpenDX field wrapper |
There was a problem hiding this comment.
add a .. versionadded:: 1.2.0 (with two blank lines above)
| grid : Grid | ||
| type : str, optional | ||
| typequote : str, optional |
There was a problem hiding this comment.
add minimal explanations (can copy from other docs)
|
|
||
| @property | ||
| def native(self): | ||
| """Return native object""" |
There was a problem hiding this comment.
- Add a sentence "The "native" object is the :class:
gridData.OpenDX.fielditself." - add a
.. versionadded:: 1.2.0(with two blank lines above)
| assert isinstance(dx_field, gridData.OpenDX.field) | ||
|
|
||
| assert any('test_density' and 'test_user' in str(c) for c in dx_field.comments) | ||
| # assert any('test_user' in str(c) for c in dx_field.comments) |
| assert_equal(dx_field.components['data'].array, data) | ||
| assert_equal(dx_field.components['positions'].origin, g.origin) |
| g = Grid(data, origin=[0, 0, 0], delta=[1, 1, 1]) | ||
|
|
||
| dx_field = gridData.OpenDX.field.from_grid(g) | ||
| assert dx_field.native is dx_field No newline at end of file |
There was a problem hiding this comment.
This checks that it's the same object. Add another assertion that checks the type explicitly
assert isinstance(dx_field.native, OpenDX.field)
|
|
||
| mrc_obj = mrc.MRC.from_grid(g) | ||
|
|
||
| assert mrc_obj.native is mrc_obj |
There was a problem hiding this comment.
Needs to change as the native object should be the mrcfile.MrcFile.
- check type
- check some values
|
|
||
| assert isinstance(mrc_obj, mrc.MRC) | ||
|
|
||
| assert_equal(mrc_obj.array, data) |
There was a problem hiding this comment.
Given that the data are integers, assert_equal is technically correct but for consistency and robustness, also use assert_allclose, please.
This is regarding #161
Implemented from_grid() a static method and native (property) inside OpenDX.py and mrc.py