-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Dimensionless unit looks the same regardless of scale #701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Would updating the The |
|
I agree that I think displaying the scale in the |
|
Definitely adding the scale to Going that route, then leaving I think it might make sense to add a paragraph or two in the docs about this, though. There's already a section called "The dimensionless unit", so stating there that |
|
@mdboom - this is what confused me: to me, both are syntactically the same, so as a user, I don't understand why they are different. |
|
@astrofrog: Your confusion suggest to me that one or the other should probably be renamed. But to what? |
|
What about |
|
I would expect |
|
What about having a variable |
|
I don't like This is a slightly more substantial suggestion, but seems less ambiguous to me:
That's really what we mean with |
|
@eteq: That's not a bad suggestion, but I wonder if it's wise to remove the fast path for the I do agree that |
|
We could have a check |
|
This looks a bit confusing: I wonder whether for dimensionless, the output should be while for any other units, what you have is fine, e.g. |
|
@astrofrog: That makes sense -- to put the scale at the end. I'll make that change -- and I guess you'll want to merge or cherry-pick the new commit. |
docs/units/standard_units.rst
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example will need to be updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used to, before the last commit. I thought it was more helpful to print it than not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I meant - shouldn't it say
Unit(dimensionless with a scale of 1000.0)
?
|
Apart from my small comments above, this will be ready to go. I've re-tagged as 0.2 since it's needed fo #669 which we also want in 0.2. |
|
I think we still want to get rid of I have a fairly comprehensive set of timings below (taken from this PR's branch). The only case where |
|
I did some further tests (which I won't copy here to not fill up the comments even further) that show that So I'm not sure we even need And even if you disagree and want to keep |
|
@eteq - if we are going to use instead of then we could just as well use as it's more concise. But it'd be nice to have a convenience method, so I think we should still keep |
|
Looking into it more, I think the current implementation of In order to get #669 moving, I'll simply define a convenience function _is_unity() there for now, so that we don't have to rush this discussion for 0.2.0 if we don't reach a consensus. |
|
I'm going to +1 @eteq's suggestion from earlier to remove which is testing that the overall type is not length, mass, etc. What I also wanted, but will not insist on a convenience method that is equivalent to and that is what I would call |
|
Since #669 doesn't depend on this PR anymore, shall we re-tag it as 0.2.1 or 0.3? Or do we want to fix it for 0.2? |
|
@eteq: Those benchmarks are helpful, but keep in mind many are doing different things. So I think we need to first decide what we're trying to achieve, then we can decide what to call it, and then optimize if necessary. @astrofrog: I don't understand your rationale for not wanting to decompose the unit first before checking whether it is unity. I think it's very unlikely that the user would create a unity quantity directly (which is the only case under which what you suggest would work). It's much more likely that the user would do something like: and this should be allowed to implicitly convert to a float in the context of what we're discussing for #669. I think |
|
Also, I think I'm fine with removing |
|
@mdboom - regarding #669, I've replied directly there. I think removing Regarding |
|
@iguananaut - do you have any opinions about |
|
Yes, but here's the problem (and come to think of it, we should probably add a test for this): |
|
Ah, I see - ok, so now I see that this makes sense! |
|
Well, I think |
|
@astrofrog - In my previous posts I was actually referring to the With that in mind, yes, I think I see @mdboom's point on It doesn't really bother me that much that this is a long name. If it starts with Sorry to be a pain, but I think this carries quite a bit of potential for confusion because most other aspects of |
|
I agree we can do |
|
I think we're reaching consensus here. |
|
Ok, that sounds good to me. Then, just for information, should one do |
|
👍 to @mdboom's plan here. |
|
@astrofrog: Yes. |
|
Great - let's go with that! |
|
The travis build passed without complaint. Looks good to me! Should we get rid of the |
|
@eteq - I think we can just fix it in a separate PR in future - it's a private method, so no rush. |
|
Looks good to me too! |
Dimensionless unit looks the same regardless of scale
|
I've completely lost track of this at this point--but this should be backported for 0.2 final right? |
|
I would think so. It's pretty low risk. |
|
I agree, it should be backported. |
Dimensionless unit looks the same regardless of scale
Dimensionless unit looks the same regardless of scale
This comes out of a discussion in #669.
Right now, the following behavior is in astropy:
This is counter-intuitive, because two things that say they are "dimensionless" give different behavior when compared to
u.dimensionless.This is "correct" behavior, because two units with different scale factors are different, but the fact that they both appear to be the same is problematic.
cc @mdboom