<html><body>
<p>3 new commits in yt:</p>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/a07c8e01e08a/">https://bitbucket.org/yt_analysis/yt/commits/a07c8e01e08a/</a> Changeset:   a07c8e01e08a Branch:      yt User:        ngoldbaum Date:        2016-03-28 19:09:15+00:00 Summary:     Ensure user-defined derived fields names that are strings work in python3. Closes #1053 Affected #:  1 file</p>
<p>diff -r 61be4a106d8843629a48f23b27cc532a1e4ee91e -r a07c8e01e08a37adcfc731f7ab851031cf1c2dbd yt/fields/field_info_container.py --- a/yt/fields/field_info_container.py +++ b/yt/fields/field_info_container.py @@ -38,6 +38,13 @@</p>
<pre>    add_volume_weighted_smoothed_field, \
    sph_whitelist_fields
</pre>
<p>+def tupleize(inp): +    if isinstance(inp, tuple): +        return inp +    # prepending with a ‘?’ ensures that the sort order is the same in py2 and +    # py3, since names of field types shouldn't begin with punctuation +    return ('?', inp, ) +</p>
<pre>class FieldInfoContainer(dict):
    """
    This is a generic field container.  It contains a list of potential derived</pre>
<p>@@ -271,7 +278,7 @@</p>
<pre>self.ds.field_dependencies.update(deps)
# Note we may have duplicated
dfl = set(self.ds.derived_field_list).union(deps.keys())</pre>
<ul><li><p>self.ds.derived_field_list = list(sorted(dfl))</p></li></ul>
<p>+        self.ds.derived_field_list = list(sorted(dfl, key=tupleize))</p>
<pre>        return loaded, unavailable

    def add_output_field(self, name, **kwargs):</pre>
<p>@@ -357,5 +364,5 @@</p>
<pre>deps[field] = fd
mylog.debug("Succeeded with %s (needs %s)", field, fd.requested)
         dfl = set(self.ds.derived_field_list).union(deps.keys())</pre>
<ul><li><p>self.ds.derived_field_list = list(sorted(dfl))</p></li></ul>
<p>+        self.ds.derived_field_list = list(sorted(dfl, key=tupleize))</p>
<pre>return deps, unavailable</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/94f7e5f1403e/">https://bitbucket.org/yt_analysis/yt/commits/94f7e5f1403e/</a> Changeset:   94f7e5f1403e Branch:      yt User:        ngoldbaum Date:        2016-03-28 19:24:09+00:00 Summary:     Add a test for adding a field as a string Affected #:  1 file</p>
<p>diff -r a07c8e01e08a37adcfc731f7ab851031cf1c2dbd -r 94f7e5f1403edb68cb185c306b8331b944cc864b yt/fields/tests/test_fields.py --- a/yt/fields/tests/test_fields.py +++ b/yt/fields/tests/test_fields.py @@ -301,6 +301,19 @@</p>
<pre>    u2 = array_like_field(ad, 1., ("all", "particle_mass")).units
    assert u1 == u2
</pre>
<p>+def test_add_field_string(): +    ds = fake_random_ds(16) +    ad = ds.all_data() + +    def density_alias(field, data): +        return data['density'] + +    ds.add_field('density_alias', function=density_alias, units='g/cm**3') + +    ad['density_alias'] +    assert ds.derived_field_list[0] == ‘density_alias’ + +</p>
<pre>if __name__ == "__main__":
    setup()
    for t in test_all_fields():</pre>
<p>@@ -308,3 +321,4 @@</p>
<pre>test_add_deposited_particle_field()
test_add_field_unit_semantics()
test_array_like_field()</pre>
<p>+    test_add_field_string()</p>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/47103efaf15a/">https://bitbucket.org/yt_analysis/yt/commits/47103efaf15a/</a> Changeset:   47103efaf15a Branch:      yt User:        ngoldbaum Date:        2016-04-06 18:15:40+00:00 Summary:     Merged in ngoldbaum/yt (pull request #2092)</p>
<p>Ensure user-defined derived fields names that are strings work in python3. Closes #1053 Affected #:  2 files</p>
<p>diff -r 9488a6181a069af1fbc2339b144039342ea1a437 -r 47103efaf15acd4f13408b11f292e05e1cb4abcc yt/fields/field_info_container.py --- a/yt/fields/field_info_container.py +++ b/yt/fields/field_info_container.py @@ -38,6 +38,13 @@</p>
<pre>    add_volume_weighted_smoothed_field, \
    sph_whitelist_fields
</pre>
<p>+def tupleize(inp): +    if isinstance(inp, tuple): +        return inp +    # prepending with a ‘?’ ensures that the sort order is the same in py2 and +    # py3, since names of field types shouldn't begin with punctuation +    return ('?', inp, ) +</p>
<pre>class FieldInfoContainer(dict):
    """
    This is a generic field container.  It contains a list of potential derived</pre>
<p>@@ -271,7 +278,7 @@</p>
<pre>self.ds.field_dependencies.update(deps)
# Note we may have duplicated
dfl = set(self.ds.derived_field_list).union(deps.keys())</pre>
<ul><li><p>self.ds.derived_field_list = list(sorted(dfl))</p></li></ul>
<p>+        self.ds.derived_field_list = list(sorted(dfl, key=tupleize))</p>
<pre>        return loaded, unavailable

    def add_output_field(self, name, **kwargs):</pre>
<p>@@ -357,5 +364,5 @@</p>
<pre>deps[field] = fd
mylog.debug("Succeeded with %s (needs %s)", field, fd.requested)
         dfl = set(self.ds.derived_field_list).union(deps.keys())</pre>
<ul><li><p>self.ds.derived_field_list = list(sorted(dfl))</p></li></ul>
<p>+        self.ds.derived_field_list = list(sorted(dfl, key=tupleize))</p>
<pre>return deps, unavailable</pre>
<p>diff -r 9488a6181a069af1fbc2339b144039342ea1a437 -r 47103efaf15acd4f13408b11f292e05e1cb4abcc yt/fields/tests/test_fields.py --- a/yt/fields/tests/test_fields.py +++ b/yt/fields/tests/test_fields.py @@ -301,6 +301,19 @@</p>
<pre>    u2 = array_like_field(ad, 1., ("all", "particle_mass")).units
    assert u1 == u2
</pre>
<p>+def test_add_field_string(): +    ds = fake_random_ds(16) +    ad = ds.all_data() + +    def density_alias(field, data): +        return data['density'] + +    ds.add_field('density_alias', function=density_alias, units='g/cm**3') + +    ad['density_alias'] +    assert ds.derived_field_list[0] == ‘density_alias’ + +</p>
<pre>if __name__ == "__main__":
    setup()
    for t in test_all_fields():</pre>
<p>@@ -308,3 +321,4 @@</p>
<pre>test_add_deposited_particle_field()
test_add_field_unit_semantics()
test_array_like_field()</pre>
<p>+    test_add_field_string()</p>
<p>Repository URL: <a href="https://bitbucket.org/yt_analysis/yt/">https://bitbucket.org/yt_analysis/yt/</a></p>
<p>—</p>
<p>This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.</p>

<img src="http://link.bitbucket.org/wf/open?upn=ll4ctv0L-2ByeRZFC1LslHcg6aJmnQ70VruLbmeLQr27DnPtEVEYoiYKqkMJv6TSZVKtdgd-2FCajnazvQeclOodrKKzPwi86-2FN-2BYWnXMseRG5NJndERaE8uo8b0tJQCdOZErio3u0Dqw9V0joLyIVOH3GQrMVPa3XFhk-2BYk0hqQ-2FPmljLqaoBK48uR-2F0T4GFnfJYNSJkFV6XKsFJLAtiY0maouPugAS4VN-2FlnOJG8TgxX4-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;"/>
</body></html>