Git Product home page Git Product logo

Comments (3)

chrishavlin avatar chrishavlin commented on September 27, 2024 1

Thanks for the detailed thoughts, @neutrinoceros ! And searching back through issues and PRs, I see now that there's been a lot of related discussion and attempts circling around this problem (should have searched a bit more before posting my question...). In any case, it does seem like a bigger refactor is needed... I do have more thoughts on this, will try to come back later today or tomorrow to type them up!

from yt.

neutrinoceros avatar neutrinoceros commented on September 27, 2024

Related to #4362

This has been a problem for as long as spherical coordinates have been supported. To me, the issue is primarily that the API, which was originally designed for cartesian coordinates only, is ill suited for non-cartesian geometries; in particular, specifying a {center, width} combo is ambiguous in spherical geometries: does it result in a spherical selection (possibly off-center), or does it really just select a slab in the data cube1 ? what coordinates is center in ? native, or cartesian2 ? is the width akin to a radius, a diameter, an azimuth, a latitude ? Combined with the fact that angular coordinates are, under the hood, represented as length dimensions, none of these questions have obvious answers to me.
So far, my approach has been very conservative, but I think we can't really beat this problem without a broader redesign of non-cartesian coordinates.

I think we'd need a couple fundamental changes:

  • stop representing all coordinates as lengths. This means in particular that coord triplets returned by, e.g., ds.find_max, need to be tuples of scalar unyt_quantity3 instead of a single unyt_quantity (which cannot have more than 1 dimensionality)
  • NormalPlot API:
    • elect a coordinate system (Cartesian or data-native) that the center. I don't think it matters much what we choose to support as long as it's explicit. I do have a slight preference for choosing data-native because it's a bit easier to convert to cartesian than the other way around, which might avoid some foot guns to users.
    • forbid passing a scalar width for non-cartesian geometries3: only triplets should be accepted (or pairs in 2D)
    • clarify, in docs, that center + width always selects a slab in data-native coordinates

Footnotes

  1. currently, the latter is true

  2. the current default, (0,0,0), is ambiguous but degenerate, which is why it "works" by default, but user-provided value are ignored. Also note that this ambiguity+degeneracy is intrinsic in cartesian coordinates, which is why it was never a problem there.

  3. That would be a major breaking API change. So, time for yt 5.0 ?? 2

from yt.

matthewturk avatar matthewturk commented on September 27, 2024

I wanted to mention two things -- the first is that I think we could absolutely explore a new method of designing these slices and whatnot.

The second is that we should explore how we could revive the "IndexArray" type that @jzuhone worked on a few years ago in unyt. This would be a big change, and we may decide it's too much. But the idea there is twofold -- one is to make all of the arrays used for indexing read-only -- which could be a huge performance increase in some areas of the code that constantly do conversions or checks that arrays are in code-length. But the other part is to make some types of arrays non-broadcastable along all dimensions, and allow for non-homogeneous units. (Making this a general purpose solution in unyt would likely be a lot harder than making it work in yt, to be clear. So it's also possible that we could implement it in yt for that one specific use case.)

from yt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.