« first day (4941 days earlier)      last day (8 days later) » 

3:49 AM
Isn't there Pyright integration for PyCharm, which would offer the same type checking capabilities from VSCode (since it uses Pyright afaik) into PyCharm?
 
 
3 hours later…
6:23 AM
Is it not possible to do parameterized function calls inside an f-string?
print(f' log2: {sympy.log(prim_n)/sympy.log(2)}')
Actually even print(sympy.log(prim_n)/sympy.log(2)) doesn't evaluate its args., for some reason.
Sorry, where prim_n = sympy.ntheory.primorial(6), for example, which is 30030.
 
@smci I don't really understand the problem. Everything seems to work as expected. Are you expecting to see 14.87 as output or something?
 
Ah, it turns outsympy.log(30030)/sympy.log(2) is an object of type Mul, not a value.
 
6:40 AM
..."To evaluate a numerical expression into a floating point number, use expr.evalf()"
 
7:26 AM
...which gives 14.8741168544445 as intended
 
8:09 AM
@Aran-Fey Weird. Looks like it can only handle 2 entries and the union and the rest breaks.
FWIW, I don't think the bound is sensible. A bound of A | B <: A | C <: A should just be A.
 
@MisterMiyagi FWIW You can change to Union["Div"] and "Div" and still get the error.
 
I tried changing Union[Quantity, "Mul", "Div"] to Union[Quantity, "Div", "Mul"] and it always flags the third type (plus any others after it).
 
I don't think the issue is scoping -- as I previously hypothesised. The issue seems to be recursion related to TypeVars
 
A = TypeVar("A", bound="Div") works for me in the playground.
@MisterMiyagi That should have said "two entries in the union" instead.
 
@MisterMiyagi Hmm, I've confirmed so in the playground. I wonder why my VS Code is erroring, but the playground isn't.
 
8:35 AM
@MisterMiyagi Oh, you're right. I added the inheritance afterward and didn't think to update the bound
In a way, this is the WETtest code I've ever written: one = Unit[One]("1", 1)
(It's required for hertz = one / second)
 
@Aran-Fey Why is One a type?
 
For Frequency = Div[One, Duration] (:
 
Ah interesting. I presume you'd also have Zero as a type, and possibly some other special numbers?
 
8:51 AM
No, I don't think I need anything aside from One. Quantities can be combined via multiplication and division (like acceleration = m/s²), and One represents the "neutral" value for those. Other numbers wouldn't serve any purpose, I don't think?
 
Ok makes sense. I thought πr² may be desirable, but perhaps my brain is still only at basic high school level maths and not thought things through ;)
 
Somewhat surprisingly, the static typing turned out to be easier than the runtime aspect. Now I have to figure out stuff like how to convert lightyears/fahrenheit to meters/celsius and what happens if you add two temperatures
 
9:06 AM
Oh nice. Possibly unneeded advice -- previously I came across color.graph which allows transforming between colours by traversing a graph. A similar approach may be useful. But yeah sounds like a bit of a pain :)
 
@user10478 If you start from Huggingface's glove-wiki-gigaword-50 page and browse the doc, don't they document that for GloVe models anywhere?
 
9:39 AM
@Peilonrayz The relevant keyword here is dimensionless quantity. You can often end up having no unit when dealing with ratios - representing that as the "unit" 1 is useful to avoid special-casing this.
 
@MisterMiyagi 1 makes a lot of sense -- since Div[1, T] is likely very handy to special case. Interestingly pi is listed as a dimensionless quantity -- but on further thought special casing pi in the type systems seems like a bit of a pain.
 
 
6 hours later…
3:36 PM
@smci Not that I could tell, but I did find the desired functionality on Stack Exchange after a bit.
 
 
2 hours later…
5:58 PM
I picked a bad time to tackle a project focused around static typing... PyRight is so broken currently, it's not even funny
 
6:23 PM
@Aran-Fey What makes PyRight so broken? -- I've encountered large amounts of type constructs missing, but haven't yet come across broken.
 
No clue what that TypeVar is doing there and nothing I've tried could get rid of it
 
Are you open-sourcing the project? As I wouldn't mind having a look
 
I haven't uploaded it anywhere yet, but I'll see if I can make an MRE
 
FWIW you don't need to make things too minimal, I'm used to spending hours on an answer to be met with a +2... :)
 
6:39 PM
So, apparently it's caused by the @functools.lru_cache(None) on my __mul__ method, but... I'm sure I already tried removing that earlier and it didn't change anything :/
I seem to have a thing for premature caching. This isn't the first time caching things has caused me problems (last time it even made my code slower)
 
I was gonna say - multiplication is so cheap that I'm not sure why you'd want to cache it unless it's a repeated signal?
I wouldn't even be surprised if multiplication and the assignment here is faster than a dict lookup, even before you look into compiling anything
 
Well, without caching there would be lots of instances being created and garbage collected again soon after
Since code like seconds(3) * ampere(5) would create its own copy of coulomb internally
 
I guess we have different aims in general. I spend a lot of time abstracting away from defined objects into arrays for calculations, while you're doing a whole lot to type all of the objects themselves.
 
It sounds even dumber now that I've said it. I'm fine with seconds and ampere being instantiated and thrown away, but not with coulomb? Stupid brain optimizing the wrong things
 
(The arrays have to be typed and homogenous, but they're usually pretty abstract from what you defined in my API)
 
 
2 hours later…
8:31 PM
@Aran-Fey I assume it's solving a different problem than yours (considering static typing), but are you aware of astropy.units? That's the go-to recommendation for units and it's pretty neat from what I can tell (never having needed it myself). But it looks very numpy specific which I assume is not your niche.
 
That does look pretty neat. Aside from the lack of static typing I don't see any major shortcomings
 

« first day (4941 days earlier)      last day (8 days later) »