Closed yt-fido closed 7 years ago
Original comment by Matt Turk (Bitbucket: MatthewTurk, GitHub: MatthewTurk):
Merged in drudd/yt (pull request #1217)
[Bugfix] ds.derived_field_list is often out of sync with ds.field_info [Fixes #898]
Original comment by Matt Turk (Bitbucket: MatthewTurk, GitHub: MatthewTurk):
Merged in drudd/yt (pull request #1217)
[Bugfix] ds.derived_field_list is often out of sync with ds.field_info [Fixes #898]
Original comment by chummels (Bitbucket: chummels, GitHub: chummels):
This is along similar lines of the question I asked a few days ago on another PR. I personally do not understand why we have a field_info
object that is not always in sync with the derived_field_list
. Perhaps it is not feasible, or there is a reason for this, but I like the idea that @drudd suggests of having the derived_field_list
derived explicitly from the field_info.keys()
in order to avoid things getting out of sync. Is there a reason for having two separate ways of cataloguing fields? I'm not asking to be a jerk--just because I don't understand this area of the code well.
Original comment by Douglas Rudd (Bitbucket: drudd, GitHub: drudd):
I don't fully understand the code, so some of these are probably not possible due to lazy-instantiation (either avoiding I/O or allowing fields to be defined out of order
Original comment by Matt Turk (Bitbucket: MatthewTurk, GitHub: MatthewTurk):
I'm really open to suggestions for improvement.
Original comment by Douglas Rudd (Bitbucket: drudd, GitHub: drudd):
The field handling code does not keep itself internally consistent, and because of that it's not clear how to uniquely check whether a field is defined. This particular instance, the add_field function that creates this field
#!python
ds.field_info.add_field(("gas","v_los"), function=_vlos, units="cm/s")
does not add that field to ds.derived_fields. We can add another line to _determine_fields:
#!python
# really ugly check to ensure that this field really does exist somewhere,
# in some naming convention, before returning it as a possible field type
if (ftype, fname) not in self.ds.field_info and \
(ftype,fname) not in self.ds.field_list and \
fname not in self.ds.field_list and \
(ftype,fname) not in self.ds.derived_field_list and \
fname not in self.ds.derived_field_list and \
(ftype,fname) not in self._container_fields:
raise YTFieldNotFound((ftype,fname),self.ds)
but it really seems that add_field should keep everything in sync.
Originally reported by: Kacper Kowalik (Bitbucket: xarthisius, GitHub: xarthisius)
Following script:
yields:
with current tip. Regression was introduced in changeset a9aa29ba3512