Skip to content
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

Some usability suggestions #5

Open
NunoSempere opened this issue Dec 19, 2021 · 4 comments
Open

Some usability suggestions #5

NunoSempere opened this issue Dec 19, 2021 · 4 comments

Comments

@NunoSempere
Copy link
Contributor

Priority, importance: low. These were just things I came across.

  1. Allow for empty lines to separate parts of the model
  2. Ignore lines beginning with # so that models resemble markdown files.
  3. Allow unit exponentiation (more elegant)
  4. Add SI units by default?
  5. Allow singular and plurals, e.g., 1 second, 2 seconds

Of these, the one that bugs me the most is unit exponentiation. It took a while until I realized that

unit seconds
// Correct: 
s1 = (1 seconds) * (1 seconds)
s2 = 1 seconds2
s3 = 1 seconds-2
// Incorrect:
s4 = 1 seconds^2
s5 = (1 seconds)^2
s6 = (1 seconds)^(2)
@Hazelfire
Copy link
Owner

Hazelfire commented Dec 19, 2021

Hey! Thanks for your recommendations.
As for your recommendations:

  1. Do you mean that the empty lines separate parts of the model in the output? I like this idea!
  2. The C style comments do look a bit off. # would be clever in terms of making it a bit more pythonic. But I'm wondering why markdown style pedant files would be a goal? In the future, I'm looking to create
  3. This one is difficult in terms of parsing and interpretation. Let me use your example:
s5 = (1 seconds)^2

You want this to end up with the seconds^2 unit, however, it doesn't have to be a 2 in the exponent... what if it was:

s5 = (1 second)^exp_var

Now if exp_var is dimensionless, this now is in 1 (seconds^exp_var) units. This is annoying because now the dimensions and types depend on values that have been put into them in runtime, making it much harder to check the types. I mean, I think it's possible, but it would probably get very confusing.

I have an underlying theory of dimensional analysis, that basically a unit is dimensionful if you can define a function that can convert any unit into an equivalent set of other units (I should probably write this down somewhere). Doing what you propose does violate this underlying theory.

s4 however, might be possible

s4 = 1 seconds^2

This could simply be syntactic sugar for s4 = 1 seconds2. But then I need to distinguish it from s5 = (1 seconds)^2 which means something completely different.

Or I might have an exception that thinks along the lines of "If the exponent is a constant integer, then just multiply it into the type". But then it's confusing when you have a number that's not 1, say does 2 seconds^2 mean 4 seconds2 or 2 seconds2. I don't know, there are lots of questions here.

  1. I'm not sure I like this idea, simply because it gives people more to remember, and that in none of my examples or use cases do I actually use SI units? I actually prefer having much more descriptive units, such as unit metersrunbyparticipants. Which has the benefits that when you define other modules (once modules are introduced), you can correctly incorporate calculations without using a number that they might not understand.
  2. Understanding English plurals is again something that is confusing. Especially considering that English plurals are not just "add an s" (bus vs buses, or radius and radii). Ruby on Rails understands English plurals, and honestly I find it one of the most confusing components of the system. It might be possible to add aliases for units to write them in explicitly (I think I am at some point thinking of adding a unit aliasing system, but for different reasons). This could be valuable.

@NunoSempere
Copy link
Contributor Author

NunoSempere commented Dec 20, 2021

  1. Do you mean that the empty lines separate parts of the model in the output? I like this idea!
    Oh, at this point I just meant allowing empty lines to separate parts of the input file.

  2. I'm wondering why markdown style pedant files would be a goal?
    It wouldn't be, but #-style comments allow you to add a bit of structure for free (#, ##, ###), in a way which C-style comments don't. They also seem more pleasant to me, so this is at least partly a question of style.

  3. Syntactic sugar so that n seconds^m is equivalent to n secondsm seems fine.

Also note that (1 seconds)^2 or (2 seconds)^2 right now compiles to nothing. Intuitively I was expecting it that it would be equivalent to (2 seconds)*(2 seconds). Maybe worth specifying in the documentation that only dimensionless quantities can be exponentiated?

4.& 5. Yep, this is tricky, and more like a nice to have. Similarly one could think of automatically understanding seconds, minutes, days, weeks, years, out of the box. I imagine that it would become clearer which of these might be worth implementing as pedant is used more.

@Hazelfire
Copy link
Owner

Hazelfire commented Dec 20, 2021

  1. Huh... but they can? Am I missing something?

    // GiveDirectly's cost effectiveness Analysis. Taken from GiveWell
    // units
    unit usd usddonated usdtransfered usdinvested usdtransfered usdconsumed usdreturned
    unit people years value households
    // Donation size is arbitrary
    donation_size = 100000 usddonated
    transfers_of_cost = 0.83 usdtransfered usddonated-1
    total_funding_available = transfers_of_cost * donation_size
    total_transfer_size = 1000 usdtransfered households-1
    average_household_size = 4.7 people households-1
    size_of_transfer_per_people = total_transfer_size / average_household_size
    percent_of_transfers_invested = 0.39 usdinvested usdtransfered-1
    amount_invested = percent_of_transfers_invested * size_of_transfer_per_people
    duration_of_initial_consumption = 1 years

  2. I'm kind of agreeing with you here, I think this might be worth changing to

  3. This one is still a bit controversial... because it would mean like:

y = 1 seconds^2

compiles but

x = 2
y = 1 seconds^x

doesn't. Which might be easier on the intuition for a beginner, but confusing for someone who might use pedant heavily. And yes, the documentation needs a lot of work, I've added this problem in #8.

@NunoSempere
Copy link
Contributor Author

  1. Re: Empty lines
    Huh, running the program again I see that it works. Weird. I probably added the new lines at the same time I removed the last line.

  2. Yeah... And the moment one starts playing with e.g., isoelasticity coefficients, one'll want to have them in their own variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants