« first day (4941 days earlier)   

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.
 

« first day (4941 days earlier)