« first day (4940 days earlier)   

7:14 AM
Is it possible to make a generic type that appends a type to a tuple?
Input = tuple[int, str]
Output = Append[Input, bool]  # Output should be tuple[int, str, bool]
I'm gonna go ahead and say "probably not" because so far that has always ended with Miyagi proving me wrong
I'm manipulating fate
 
7:52 AM
Have you tried typing.Unpack?
 
And there it is! I only tried Concatenate :/
I devised an alternative implementation in the meantime, so now I have to decide which one I wanna go with
The quail of the whale
(German inside joke, don't worry about it)
 
(cringes in German)
@Aran-Fey Now I'm interested in just how you did that. ^^
 
Proving once again that germans have no sense of humor :/
(Whether that's me or Miyagi is up for interpretation)
@MisterMiyagi The idea was to represent units as a tuple. For example, acceleration would be Unit[Distance, Invert[Time], Invert[Time]]. But typing out the whole thing every time was annoying, so I wanted something like Divide[Speed, Time] to give the same output
The alternative is to represent that as a bunch of nested Mul and Div types, i.e. Acceleration = Div[Div[Distance, Time], Time]
 
8:38 AM
@Aran-Fey Ooooh, that sounds like fun if you want to support conversions between equivalent units.
 
I don't think that's going to be possible. Unit[A, B] and Unit[B, A] will be treated as distinct types, and we're just gonna have to live with that
 
Union supports that, but it's probably special-cased.
 
The problem with Union is that it doesn't allow duplicates, so it can't express Area = Mul[Distance, Distance]
 
True. You'll probably run into some further issues along the line anyways if you go down that rabbit hole.
 
 
2 hours later…
10:40 AM
@Aran-Fey I'd assume something dodgy like Mul = _Mul[A, B] | _Mul[B, A] could work. However, I wouldn't be surprised if mypy breaks at some point
 
 
3 hours later…
1:32 PM
@MisterMiyagi thanks, that's what I'm gonna go with
@Marco Conda is known to have many problems, I avoid it at all costs
 
2:28 PM
@Hakaishin hmmm, what environment manager do you use instead?
 
@Marco just pip
 
2:46 PM
Well, I say the opposite, I've had a lot of problems using just pip, with conda I only end up having problems when I end up involving some installation via pip.
When you use conda it checks which package should be installed so that it is compatible with your installed packages.
 
That's what pip does. Dependency resolution.
 
Well, I don't know what dependency resolution this is when it ends up breaking packages in many cases.
I've never broken packages using just conda.
 
Jedem Tierchen sein Pläsierchen :)
Pycharm is giving me a strange warning
Unexpected type(s): (LiteralString | str | bytes) Possible type(s): (LiteralString) (str)

Does that make sense to you guys? I mean if the possible types are the same as the ones given how is it unexpected? Is it because it could also be bytes?
 
3:04 PM
@Hakaishin haha
 
3:24 PM
@Hakaishin What's the context? Is it complaining that you're trying to assign a value of type LiteralString | str | bytes to a variable of type LiteralString | str?
 
It's this: youtrack.jetbrains.com/issue/PY-65191/… I guess it's a false positive they have to fix
 
4:08 PM
@Hakaishin The PyCharm type checker is very much... not so good.
It's one of the major reasons why I switched to VSCode.
FWIW, in that specific case it complains that you might be passing it a bytes object, when only str is allowed.
(I have no idea why they reify str to both str and LiteralString.)
 
 
4 hours later…
7:41 PM
If you install a library, etc., is there a human-readable file somewhere on your machine to view? I acquired a word embedding tool using import gensim.downloader and gensim.downloader.load("glove-wiki-gigaword-50") (the one mentioned in the recent 3Blue1Brown video on word embeddings), and I can use model["word"] to get a vector and use it for basic arithmetic
...but I can't find an online resource for any other functionality (I want to search for the closest vectors to an input vector and return their words). Is there a way to find the available functions on my machine?
 
Depends on the library. You can try print(gensim.__file__) and hope it's written in python
 
Thanks
 
7:56 PM
Uhhh, why doesn't pyright like this code?
It worked with the 3.12 syntax :/
 
8:52 PM
@Aran-Fey wow, seems like quite the bug
Perhaps a TypeVar scoping issue if you make C a copy of A things work:
C = TypeVar("C", bound=Union[Quantity, "Mul[Any, Any]", "Div[Any, Any]"])
class Div(Generic[C, B], Quantity): ...
 
Huh, interesting
 

« first day (4940 days earlier)