Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Thomas Robitaille
    @astrofrog
    so you mean that even Latitude doesn't add new attributes?
    Adam Ginsburg
    @keflavich
    it doesn't add new attributes, no, but it does have the case "If any arithmetic operation is done, then return a different class"
    Thomas Robitaille
    @astrofrog
    ah ok
    so just to be clear, the issue here is that we are adding arguments to the initializer?
    Adam Ginsburg
    @keflavich
    I don't know exactly what __array_wrap__ does.
    yes.
    LowerDimensionalObjects are required to have ._wcs
    so it's not just arguments in the initialization, but attributes that are added during intialization
    I'm testing out __array_wrap__ now
    Adam Ginsburg
    @keflavich
    I think it is the answer
    nope, not that simple.
    Thomas Robitaille
    @astrofrog
    hmm, I'll take a look in a sec (just battling some other issues)
    if we can't figure out, I think we should email astropy-dev
    maybe marten can help
    Adam Ginsburg
    @keflavich
    k
    Thomas Robitaille
    @astrofrog
    can you make a minimal example?
    Adam Ginsburg
    @keflavich
    I think I'm very close to an answer, but... there is some funny business...
    Thomas Robitaille
    @astrofrog
    ok
    Adam Ginsburg
    @keflavich
    not sure. I think if I can make a MWE, I will have solved the problem
    Thomas Robitaille
    @astrofrog
    ok
    Adam Ginsburg
    @keflavich
    I think I see the problem.... if you do something like Projection * Quantity, the Quantity's __array_wrap__ will be called instead of the Projection's
    Adam Ginsburg
    @keflavich
    numpy docs strongly indicate that it's the right thing to use: http://docs.scipy.org/doc/numpy-1.10.0/reference/arrays.classes.html#numpy.class.__array_wrap__
    the question is now just how to make Projection * Quantity use Projection's __array_wrap__
    Thomas Robitaille
    @astrofrog
    I think there's a priority flag
    for array subclasses
    Adam Ginsburg
    @keflavich
    oh!
    Thomas Robitaille
    @astrofrog
    maybe you need to set __array_priority__ for Projection higher than Quantity
    Adam Ginsburg
    @keflavich
    I'll try tyhat
    nope, no luck
    but I like it
    Thomas Robitaille
    @astrofrog
    hmm
    I wonder if it's a bug in Quantity since that should have an effect
    Adam Ginsburg
    @keflavich
    I think it's likelier that I misidentified the critical issue
    Projection * 5 uses Projection's __array_wrap__, but Projection * u.Jy doesn't.
    Thomas Robitaille
    @astrofrog
    ah
    that could be because __mul__ in Unit is hard-coded to use QUantity for that case?
    Adam Ginsburg
    @keflavich
    hmmm
    yeah
    Thomas Robitaille
    @astrofrog
    it should probably check if it's a subclass of Quantity
    Adam Ginsburg
    @keflavich
    overloading __array_wrap__ causes other problems
    np.isnan([5,6]*u.Jy) -> array([False, False], dtype=bool), but it will yield a new Projection with __array_wrap__ overloaded, which is bad.
    Thomas Robitaille
    @astrofrog
    hmm
    Adam Ginsburg
    @keflavich
    I'll prep an astropy-dev email
    Thomas Robitaille
    @astrofrog
    sounds good
    Adam Ginsburg
    @keflavich
    is it possible to @pytest.mark.parametrize a test and also pass it normal fixtures?
    Thomas Robitaille
    @astrofrog
    huh, never tried!
    Adam Ginsburg
    @keflavich
    dang
    I kinda need it, and it doesn't seem to be working...
    though maybe that's not the problem, nvm