#voice-chat-text-1

1 messages ยท Page 35 of 1

delicate wren
mild flume
#

I don't like that

supple ingot
#

Hello

delicate wren
#

cx is very repetitive

mild flume
#

Is cx more common in other languages as well?

delicate wren
#

ctx is more common I think

#

I've definitely seen cx somewhere else but don't remember where

proper ridge
#
@Circuit.gatemethod
    def Identity(self,
                 qubit_indices: int | Collection[int]) -> None:
        # Create an Identity gate
        identity = I

        # Apply the identity gate to the specified qubit(s)
        if isinstance(qubit_indices, Collection):
            for index in qubit_indices:
                self.circuit.append(identity(self.qr[index]))
        else:
            self.circuit.append(identity(self.qr[qubit_indices]))

AF what do you think about the comments?

#

I am going for a more detailed and well documented approach.

delicate wren
#

first one is wrong

proper ridge
#

Why?

delicate wren
#

you're not creating it

proper ridge
#

It's the pointer to the method that creates the identity gate.

delicate wren
#

second comment should be the doc comment of the entire function

proper ridge
#

It is, this is a subclass.

#

I don't repaste the docs for subclasses (docstring I mean).

delicate wren
#

comment why not what

#

what's written in the comment is implied by the function and doc comment of the base class

proper ridge
#

I mean I am?

#

I am going for why this code approach.

proper ridge
#

And if so, do you personally find it as readable and comprehensive?

delicate wren
#

Apply the identity gate to the specified qubit(s) describes what happens below

#

not why certain design decisions where made

proper ridge
#

Well, yes, but isn't comment also to explain what a few lines of code are doing so you don't necessarily have to read every line?

#

Like I interpret it as answering why we're iterating a loop and appending the object to the circuit.

#

Is that wrong?

delicate wren
#

having to write a comment is always a hint that you're doing something wrong

proper ridge
delicate wren
#

this should probably be a separate function with argument f

if isinstance(qubit_indices, Collection):
    for index in qubit_indices:
        self.circuit.append(f(self.qr[index]))
else:
    self.circuit.append(f(self.qr[qubit_indices]))
proper ridge
#

I honestly feel naked without it.

stuck bluff
#

Linux doesn't have viruses. It has security vulnerabilities.

delicate wren
#

in that function explain why you if and why Collection

proper ridge
#

I don't follow.

delicate wren
#

tbf in that isolated function it wouldn't even require an explanation

#

simple enough, and types are right there

stuck bluff
#

Linux, but chaos monkey. Randomly introduces problems you have to learn to fix.

#

Nub.

proper ridge
delicate wren
proper ridge
#
@Circuit.gatemethod
    def RX(self,
           angle: float,
           qubit_index: int) -> None:
        # Create an RX gate with the specified angle
        rx = Rx(rads=angle)

        self.circuit.append(rx(self.qr[qubit_index]))

What about this one?

proper ridge
#

One would try to compensate for clarity with comments.

delicate wren
proper ridge
#

Ergo, given adequate clarity comments are not needed.

delicate wren
#

outer thing should mention that it's not degrees

proper ridge
#

I haven't seen anyone pass in degrees.

delicate wren
#

why does Rx constructor have it named rads

proper ridge
delicate wren
#

a bit inconsistent but okay

proper ridge
#

It's from cirq.

#

I'm only wrapping it here.

#

Would you keep the comment or remove it?

#

Technically it's an object (proper instance).

delicate wren
#

the comment doesn't add anything

#

@proper junco you can have examples/tests directories

#

a bit more persistent form of scratch files

#

in Rust, cargo has ./examples/ support

#

for running stuff in the context of the project but outside src/main.rs

#

./tmp

#

rrrrrr

#

I often have a gitignored /tmp/ at the root of a project for stuff that's definitely not needed afterwards

#

ignore venv entirely

delicate wren
#

ensemble joke

#

everyone participates

mild flume
delicate wren
#

I'd rather buy another x86-64 computer for that

mild flume
#

Just clip a RaspberryPI to your shirt

delicate wren
#

implant it

#

there are different arduinos

#

some are proper ARM

#

some are microcontrollers

#

(those two might overlap)

proper ridge
#

What about this one?

@Circuit.gatemethod
    def MCX(self,
            control_indices: int | Collection[int],
            target_indices: int | Collection[int]) -> None:
        control_indices = [control_indices] if isinstance(control_indices, int) else control_indices
        target_indices = [target_indices] if isinstance(target_indices, int) else target_indices

        # Create a Multi-Controlled X gate with the number of control qubits equal to
        # the length of control_indices
        mcx = cirq.ControlledGate(sub_gate=X, num_controls=len(control_indices))

        # Apply the MCX gate controlled by all control indices to each target index
        for target_index in target_indices:
            self.circuit.append(
                mcx(*map(self.qr.__getitem__, control_indices), self.qr[target_index])
            )
mild flume
#

A handful of the tools the presenter mentioned are Mac only

delicate wren
#

whole 8 ports not installed

mild flume
#

And he didn't say that ahead of time

#

I am the annoyed

delicate wren
#

x86-64 single-board computer

#

RISC-V slowly becomes normal too

proper ridge
delicate wren
#

I've seen executables compiled for aarch64 run on x86-64

#

like

#

what

#

how

#

default ARM

#

I think

#

yes, RISC

#

@mild flume inherited

delicate wren
#

H4s have a CPU with AVX support which means being able to run MongoDB >4.4

mild flume
delicate wren
#

MongoDB making AVX mandatory is such a problematic choice given how many hobbyists pick mongo for simplicity (only to end up in a situation where they don't have necessary hardware for it)

#

@proper junco you will almost always need a ipython kernel running

#

even conversion to html involves it

#

VSC has Jupyter support

#

jupyterlab is more complex

#

it's an extension of jupyter

#

you can put examples in something like Sphinx

#

or mkdocs

#

I'd expect both allow running them as inline tests

#

TeX is hard to read

#

when not rendered

#

it's optimised for writing not reading

#

@proper junco yes

#

in some Markdown cases it's supported

#

e.g mdbook

#

there's also an interesting question of how to embed diagrams

#

in my experience, all simple text to diagram software produces terrible results

#

like totally abhorrent at times

#

not something you would ever want to put where others can see

#

(or even where you yourself can see)

#

mermaid is close to being adequate

#

generic is markup

#

technically it is markup too, it's not in opposition

delicate wren
#

why does it overlap

#

rrrrrrrrrrrr

#

draw.io prevents such overlaps by default

#

by cutting out a part of the line

#

oh wait

#

I need to send the whole picture

#

the part on the top right specifically

#

what would a software equivalent of hypochondria be

#

healtchecks causing performance issues?

#

@mild flume "made to rival Arnold C"

proper ridge
#

Try MIT OCW 6.092

delicate wren
#

@proper junco
"every IO object has a file descriptor" rather

#

pidfd is very recent

#

like only 5 years

mild flume
#

Wonder how Ursina does it or if it does

delicate wren
lethal wadi
#

In video game development, programmer art refers to temporary assets added by the programmer to test functionality.

With this type of graphics, speed is a priority and aesthetics are secondary (if they are given any consideration at all). In fact, programmer art might be intentionally bad, to draw attention to the fact that the graphics are me...

#

that's the MS Paint joke

delicate wren
#

why is it off centre

delicate wren
mild flume
#

That's sick looking

proper junco
delicate wren
#

Python is somewhat hard to write esoterically

#

because not free-form

#

lambda is ugly not esoteric

#

unlike C

#include <stdio.h>// Usage: find k (<=n) roots of polynomial f such that deg f=n; Input: n c_0 c_1 ... c_n | c_i: double
#include <math.h>//  Output: roots:k x:x_1 f:f(x_1) x:x_2 f:f(x_2) ... x:x_k f:f(x_k) | x, f: double | roots are ordered
#include <float.h>// non-descenging. Note that roots can be repeated due to divisibility of f by (x-root)^k where k > 1!
#define P(o)if(B o T){for(u i=2048;i;--i){d m=(b+t)/2;*((d*[]){&b,&t})[0 o a(n,c,m)]=m;}return b;}// (c) afeistel 2020~2025
typedef double d;typedef unsigned short u;d a(u n,d*c,d x){d r=0;for(u i=n;i;--i)r=(r+c[i])*x;return r+c[0];}d s(u n,d*c
,d b,d t){d B=a(n,c,b);d T=a(n,c,t);P(<=)P(>=)return NAN;}u h(u n,d*c,d*g,u*r){while(n&&!c[n])g[--n]=NAN;if(n==0)return-
0;for(u i=1;i<=n;++i)c[i]*=i;h(n-1,c+1,g+1,r);for(u i=1;i<=n;++i)c[i]/=i;g[0]=-DBL_MAX;u j=0;for(u i=0;i<*r+1;++i){d t=i
<*r?g[i+1]:DBL_MAX;d B=a(n,c,g[i]);d T=a(n,c,t);if(B<=0&&0<=T||B>=0&&0>=T)g[j++]=s(n,c,g[i],t);}for(u i=j;i<n;++i)g[i]=-
NAN;*r=j;return 0;}int main(){u n;scanf("%hd",&n);d c[n+1];for(u i=0;i<n+1;++i)scanf("%lf",c+i);d g[n];u r;h(n,c// stuff
,g,&r);printf("roots:%d\n",r);for(u i=0;i<r;++i){printf("x:%f\nf:%f\n",g[i],a(n,c,g[i]));}return 0;}// cmake C 99 x86_64
proper ridge
#

Too messy.

rotund bough
#

damn bro even copyrighted it

delicate wren
#

esoteric often implies ugly but not the other way around

delicate wren
#

not really esoteric

proper ridge
#

I feel the same applies to code style.

delicate wren
proper ridge
#

You don't want to rant like I did before in your comments, or restate everything, but it does help every few lines.

#

And it does make the code seem prettier.

delicate wren
#

because it doesn't use complex numbers

proper ridge
#

Just the visual appearance of it.

delicate wren
lethal wadi
#

also guys don't listen to the js nerds who use arrow functions for everything

delicate wren
#

if you want something that's actually esoteric:

([]+![])[+!![]]+([]+![])[!![]+!![]]+([]+[][[]])[!![]+!![]+!![]+!![]+!![]]+([]+![])[!![]+!![]+!![]]+([]+![])[+!![]]+([]+{})[!![]+!![]+!![]+!![]+!![]+!![]+!![]]+([]+![])[+![]]+([]+![])[!![]+!![]+!![]+!![]]+([]+[][[]])[!![]+!![]+!![]+!![]+!![]]+([]+![])[!![]+!![]+!![]]+([]+!![])[+![]]+([]+![])[!![]+!![]+!![]+!![]]+([]+![])[!![]+!![]]
mild flume
#

Yeah that's made to be esoteric

#

Wait no

#

Is that BF or JS

delicate wren
#

JS

mild flume
#

God

#

Damn it

delicate wren
mild flume
#

It's so crazy how you can leverage the weird stuff

rotund bough
#

gangster babushka

delicate wren
#

(where letters come from)

proper ridge
#

Add a cat and some vegetables to clean and that's a proper siti.

delicate wren
#

@mild flume you can try solving that one ^, it's relatively simple

#

I should probably make a PR to rustlings adding something like that

misty sinew
atomic hinge
#
pygame 2.6.0 (SDL 2.28.4, Python 3.10.14)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "/nix/store/pbimfaxwiyagpkylc739nprkyyqziv2l-python3.10-replit-python-dap-wrapper-1.8.0/bin/.dap-python-wrapped", line 43, in <module>
    _main()
  File "/nix/store/pbimfaxwiyagpkylc739nprkyyqziv2l-python3.10-replit-python-dap-wrapper-1.8.0/bin/.dap-python-wrapped", line 39, in _main
    runpy.run_path(target_as_str, run_name="__main__")
  File "/nix/store/rwxj49zghamyhy07b67yhiq64bmznvmm-python3-3.10.14/lib/python3.10/runpy.py", line 289, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/nix/store/rwxj49zghamyhy07b67yhiq64bmznvmm-python3-3.10.14/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/nix/store/rwxj49zghamyhy07b67yhiq64bmznvmm-python3-3.10.14/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "edter_run.py", line 10, in <module>
    wm.add_window(window)
TypeError: Manager.add_window() missing 1 required positional argument: 'window'
delicate wren
#

do you have wm = Manager instead of wm = Manager()?

#

that might be the reason

atomic hinge
#

main.py:

import edter
import pygame as pg

import edter.WindowManager


window = "edter"
wm = edter.WindowManager.Manager

wm.add_window(window)

pg.init()
screen = pg.display.set_mode((1280, 720))
clock = pg.time.Clock()
running = True
focussed = True
pg.display.set_caption(window)
while running:
    for event in pg.event.get():
        if event.type == pg.QUIT:
            running = False


    pg.display.flip()

    clock.tick(60)





if __name__ == "__main__":
    pass
delicate wren
#

wm = edter.WindowManager.Manager()

#

making code readable for everyone is idealistic goal, which can't be achieved without damaging some other properties of the code

#

Comments that contradict the code are worse than no comments.
first line on comments from pep8

rotund bough
#

dont worry nobody uses pep8 , not even the std lib in python follows pep8 ๐Ÿ’€

delicate wren
#

if you can't ensure it's in sync with code, it will get wrong eventually

delicate wren
#

some parts of pep8 are just recommendations, but some are enfornced in codebases

#

many codebases, including the standard library

rotund bough
#
# this function returns the square root of x
def sqr(x):
    return x*x

๐Ÿ’€ contradictory comments!

delicate wren
#

in the past it was just from people chasing "comment everything" metrics

#

and now it's also because of AI tools

proper ridge
delicate wren
#

ChatGPT by default is trained to comment everything

lethal wadi
proper ridge
#

I don't like to make my own style, I would like to be consistent with what's considered best practice, BUT I want it to be very comprehensive to absolute beginners as well.

delicate wren
#

which means if it doesn't understand the code, it will make a wrong comment

proper ridge
lethal wadi
#

i just run black and isort and call it a day ๐Ÿคท

#

docstrings i just use rest

delicate wren
#

I prefer black over any alternative apart from, maybe, ruff

#

(ruff an lint style and is separate from black iirc, but quite close to it)

lethal wadi
#

ruff also nice

delicate wren
#

@proper ridge no

#

it also has ( separate

#

this no adequate formatter does:
(a
b
c
)

proper ridge
delicate wren
#

this style gets ugly, often, due to its tendency to waste space

(a
 b
 c
 d)
#

also not aligned to tab width

#

isort by default uses that style

#

and it's terrible if you import many things from a deeply nested module

lethal wadi
#
def foo(
  bar,
  baz,
) -> spam:
  return eggs
delicate wren
#

rustfmt is very similar to black

#

I also configured clang-format in that way

rotund bough
delicate wren
#

most settings come from the template

#

(I don't fully know what each setting does)

#

there definitely is some redundancy from specifying both the blanket rule and specific to same value

rotund bough
#

spasibooooooooo

#

๐Ÿ’€

#

now i need to recall where to tweak the settings

#

was i supposed to put this in a .clangd file per project lemon_thinking

delicate wren
# delicate wren it's an altered version of some base template <https://gist.github.com/afeistel/...

fields that are different compared to the template:
AccessModifierOffset, AlignAfterOpenBracket, AlignArrayOfStructures, AlignEscapedNewlines, AlignOperands, AlignTrailingComments, AllowShortBlocksOnASingleLine, AllowShortFunctionsOnASingleLine, AlwaysBreakTemplateDeclarations, BinPackArguments, BinPackParameters, BraceWrapping, BreakBeforeBinaryOperators, BreakBeforeConceptDeclarations, BreakBeforeBraces, CompactNamespaces, EmptyLineBeforeAccessModifier, PackConstructorInitializers, FixNamespaceComments, IncludeBlocks, IndentCaseLabels, IndentRequires, InsertTrailingCommas, KeepEmptyLinesAtTheStartOfBlocks, LambdaBodyIndentation, NamespaceIndentation, SeparateDefinitionBlocks, SpaceAfterTemplateKeyword, SpaceBeforeCtorInitializerColon, SpaceBeforeInheritanceColon, SpaceBeforeRangeBasedForLoopColon, SpacesInLineCommentPrefix, BitFieldColonSpacing, TabWidth

#

@proper ridge users need to know how to use the code;
so if there's anything influences the use (i.e. specific corner cases, performance considerations, etc.), that should be in docs;

if someone bothers to go and read the code, they probably can read the code, so you're not expected to guide them through it with comments; guide with code itself; write comments when it helps yourself

delicate wren
#

tricky places is what deserves non-meme comments

#

which in Rust would be unsafe blocks

#

in languages in general, that includes whenever you call C with some invariant considerations

proper ridge
#

I like to be verbose, but I also agree with you, so I'm sort of on the fence.

delicate wren
#

another impact of comments is that they slow down the reader

proper ridge
#

On one hand I really like the style of the code with comments, on the other I fully get I should just remove the comments.

delicate wren
proper ridge
proper ridge
lethal wadi
delicate wren
#

comprehension comes from addition, not repetition or reduction

delicate wren
#

, performance

#

nix seems to provide some conveniences

#

just don't go wasting your time on configuring it

lethal wadi
delicate wren
#

use it as a tool, not a higher goal, I'd say

rotund bough
wary fable
#

I use NixOS to make it so I don't have to fuck around with installing shit

#

Just make a nice config file and use it. And then don't fuck with it.

delicate wren
wary fable
#

I then containerize everything that isn't defined on that config file

proper ridge
#
@Circuit.gatemethod
    def RX(self,
           angle: float,
           qubit_index: int) -> None:
        self.circuit.append(Rx(rads=angle)(self.qr[qubit_index]))

    @Circuit.gatemethod
    def RY(self,
           angle: float,
           qubit_index: int) -> None:
        # Create an RY gate with the specified angle
        ry = Ry(rads=angle)

        self.circuit.append(ry(self.qr[qubit_index]))

Top or bottom?

wary fable
#

bottom

proper ridge
#

Yall are so contradictory HEHEHEHE

delicate wren
#

lower one without a comment

wary fable
#

although i would do a docstring

#

for either

proper ridge
#

I have docstrings.

delicate wren
wary fable
#

oop was a mistake

delicate wren
#

or "implemented" if we treat it as interfaces

#

interfaces are good

proper ridge
#

So, you all prefer this?

@Circuit.gatemethod
    def RX(self,
           angle: float,
           qubit_index: int) -> None:
        rx = Rx(rads=angle)
        self.circuit.append(rx(self.qr[qubit_index]))
delicate wren
#

concretion inheritance is bad

wary fable
#

well, honestly, anything other than TI-84 Plus BASIC was a mistake

delicate wren
#

in Python, Java-style interface implementation involves class inheritance because yes

wary fable
#

I've been using Gleam and Haskell more than python these days...so I may be biased.

delicate wren
wary fable
#

Docker costs money, use Podman instead.

delicate wren
#

yes

delicate wren
#

I use podman in CI

#

or buildah, to be more specific

wary fable
#

eh, i just use it to do math /shrugs

delicate wren
#

do monads

proper ridge
#
@Circuit.gatemethod
    def CX(self,
           control_index: int,
           target_index: int) -> None:
        cx = cirq.ControlledGate(sub_gate=X, num_controls=1)
        self.circuit.append(cx(self.qr[control_index], self.qr[target_index]))

    @Circuit.gatemethod
    def CY(self,
           control_index: int,
           target_index: int) -> None:
        # Create a Controlled-Y gate with a single control qubit
        cy = cirq.ControlledGate(sub_gate=Y, num_controls=1)

        self.circuit.append(cy(self.qr[control_index], self.qr[target_index]))
```?
delicate wren
#

don't explain, just do

proper ridge
#

So, top one?

delicate wren
#

(that was a response to Clari)

proper ridge
#

Oh apologies.

delicate wren
#

monads explanation should start with:
NOT THOSE MONOIDS, DIFFERENT MONOIDS

#

people trying to explain monads through monoids, in majority, end up using the wrong definiton of what a monoid is

rotund bough
#

monad is a wrapper right?

lethal wadi
#

monad is just monoid in category of endofunctors tbh

rotund bough
#

what is an endofunctor?

delicate wren
#

NOT THAT MONOID

delicate wren
proper ridge
#

GPT makes this when I ask for best practice

    @Circuit.gatemethod
    def CX(self, control_index: int, target_index: int) -> None:
        # Create a controlled-X gate with one control.
        cx = cirq.ControlledGate(sub_gate=X, num_controls=1)
        # Append the CX gate to the circuit, targeting the specified qubits.
        self.circuit.append(cx(self.qr[control_index], self.qr[target_index]))

I imagine this is definitely not best practice.

delicate wren
#

in Python terms, function from any type to some type

#

as a type generic

#

for any T that's a type, list[T] is a type too

rotund bough
#

so a monad is a functor within a category

delicate wren
#

the only category interesting in programming for monads is type category

#

(in most languages; not in Rust, not in C++)

rotund bough
#

template types?

delicate wren
#

templates behave as type->type functions too, yes

rotund bough
#

so we don't need monads if we have templates?

wary fable
#

I have been trying to learn Go. I suck at Go and I suck at Git, so I've been doing the "Build your own git in go" thing that CodeCrafters has to Git Good at both.

delicate wren
#

functors are just a mathematical description of what a thing like a C++ template is

rotund bough
wary fable
rotund bough
#

even has the goto keyword ๐Ÿ’€

wary fable
#

I never needed it, so I never practiced it

delicate wren
#

Java has goto reserved
still waiting

wary fable
#

As a result I am just as good with Go and C as I am with .NET and Scala.

rotund bough
delicate wren
#

with some operations

#

for SomeTemplate to be a functor, it also needs to provide a function that can:
given SomeTemplate<A> and std::function<B, A> produce SomeTemplate<B>

wary fable
#

and that's why i use flatpacks instead of appimages. if someone wants to contact me on ms teams i pull out my mac.

proper ridge
#
 @Circuit.gatemethod
    def X(self,
          qubit_indices: int | Collection[int]) -> None:
        if isinstance(qubit_indices, Collection):
            for index in qubit_indices:
                self.circuit.append(qml.PauliX(wires=index))
        else:
            self.circuit.append(qml.PauliX(wires=qubit_indices))

    @Circuit.gatemethod
    def Y(self,
          qubit_indices: int | Collection[int]) -> None:
        # Create a Pauli-Y gate
        y = qml.PauliY

        # Apply the Y gate to the specified qubit(s)
        if isinstance(qubit_indices, Collection):
            for index in qubit_indices:
                self.circuit.append(y(wires=index))
        else:
            self.circuit.append(y(wires=qubit_indices))
```?
delicate wren
wary fable
#

ffs it's 35 degrees (sane units not freedom units) out

#

normal around here is 25 degrees

#

at least in july

proper ridge
#

I don't like to use functools.partial.

#

Feels weird.

delicate wren
#

f = qml.PauliY

proper ridge
delicate wren
#

I prefer having that part as a separate function

#

just a normal python method

delicate wren
proper ridge
#

Can you show me what you mean please?

#

Like have f as an additional method arg?

wary fable
#

I will sometimes call methods functions for the exact same reason I'll call directories folders, or containers VMs.

I just want to see the world burn.

delicate wren
#
def run_gate(self, f: ???, qubit_indices: int | Collection[int]) -> None:
    if isinstance(qubit_indices, Collection):
        for index in qubit_indices:
            self.circuit.append(f(wires=index))
    else:
        self.circuit.append(f(wires=qubit_indices))
proper ridge
#
@Circuit.gatemethod
    def X(self,
          qubit_indices: int | Collection[int],
f) -> None:
        if isinstance(qubit_indices, Collection):
            for index in qubit_indices:
                self.circuit.append(f(wires=index))
        else:
            self.circuit.append(f(wires=qubit_indices))
```?
#

Ok...

#

Then I'd need partial to implement x, y, z etc.

delicate wren
#

you don't need to change that much

#

like literally just refactor the code

#

and pass in values as you do alreadty

proper ridge
delicate wren
#

though repetition sometimes is okay, in this case it's really excessive

#

it's a common behaviour that can trivially be refactored all across the code

delicate wren
proper ridge
proper ridge
delicate wren
#

if it's repeated at least three times, then refactor

proper ridge
delicate wren
#

just factor out a method

#

no need to use partials

proper ridge
#

Partial seems like the only way.

delicate wren
proper ridge
delicate wren
#

there is a common shared interface which is the if structure

proper ridge
#

I need X and Y to still be methods themselves.

delicate wren
proper ridge
#

I don't think I fully understand.

delicate wren
proper junco
#
Name=Aseprite
Exec=Aseprite
Terminal=false
Type=Application
Categories=Graphics```
proper ridge
#

Isn't this what you meant AF?

def non_parameterized_single_qubit_gate(self,
                                            gate: OpType,
                                            qubit_indices: int | Collection[int]) -> None:
        if isinstance(qubit_indices, Collection):
            for index in qubit_indices:
                self.circuit.add_gate(gate, [index])
        else:
            self.circuit.add_gate(gate, [qubit_indices])

    X = partial(non_parameterized_single_qubit_gate, gate=OpType.X)
    Y = partial(non_parameterized_single_qubit_gate, gate=OpType.Y)
    Z = partial(non_parameterized_single_qubit_gate, gate=OpType.Z)
    H = partial(non_parameterized_single_qubit_gate, gate=OpType.H)
    S = partial(non_parameterized_single_qubit_gate, gate=OpType.S)
    T = partial(non_parameterized_single_qubit_gate, gate=OpType.T)
```?
supple ingot
delicate wren
proper ridge
delicate wren
#

you can have a more strictly typed specialisation of partial to have it simpler to understand in code

proper ridge
#

Other way I can think of is to literally define X, Y, Z, H, S, and T as partials in my ABC from the get-go, with gate="X", and then make a dict for what the keys match to what (like here it's OpType.X for TKET) and then just implement the non_parameterized_single_qubit_gate in the subclass.

delicate wren
#

(I don't know the scope of the whole thing, so can't make suggestions more concrete than "this shouldn't be repeated", even if that one non-specific suggestion is very strong)

proper ridge
#

I can use partial like I said to not repeat the same code over and over but maintain the same interface as I have now (where users can call circuit.X() blah blah).

#

Is that what you meant?

#

Though with partial how would I write docstrings?

delicate wren
#

initially it was about just a straightforward refactor like this:

def a():
    for item in something:
        do(1)

def b():
    for item in something:
        do(2)

def c():
    for item in something:
        do(3)
def common(x):
    for item in something:
        do(x)

def a():
    common(1)

def b():
    common(2)

def c():
    common(3)
proper ridge
#

Same thing as partial does I imagine.

#

Though yours allows me to add docstring.

delicate wren
#

which would reduce DIFFERENT_SIGNATURES * 6 to DIFFERENT_SIGNATURES (6 being X,Y,Z,H,S,T)

#

in terms of the number of times that part gets repeated

#

reduce in a simple dumb way; reduce further later if needed

#

common must not have a and b mentioned at all

proper ridge
#

What would you think about

class Base(ABC):
  def __init__(self,
               blahblah) -> None:
      ....

  @abstractmethod
  def common(self,
             x) -> None:
      ...

  def a(self) -> None:
      common("a")
  
  def b(self) -> None:
      common("b")

class Subclass(Base):
    def common(x) -> None:
        gate_mapping = {"a": OpType.X, "b":OpType.Y}
        gate_mapping[x]()
delicate wren
#
  def a(self) -> None:
      common(OpType.X)
proper ridge
delicate wren
#

there is no reason displayed there for why mapping is necessary

proper ridge
#

!zen

coarse hearthBOT
#
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

delicate wren
#

is OpType.X common for all implementations of Base?

proper ridge
#

Harder to read (feels more complex), but would have least number of lines.

proper ridge
#

Hence the need for the dict in each subclass.

delicate wren
#

then mapping is okay

#

!d enum

coarse hearthBOT
delicate wren
#

just not with a string

proper ridge
#

With the string set in Base, I don't have to repeat a and b in Subclass.

delicate wren
#

Literal["X"] | Literal["Y"] | Literal["Z"] | Literal["H"] | Literal["S"] | Literal["T"]

proper ridge
#

Gotcha.

#

Lemme try this.

delicate wren
#

!e

from enum import StrEnum, auto

class Axis(StrEnum):
    X = auto()
    Y = auto()
    Z = auto()
    H = auto()
    S = auto()
    T = auto()

print(Axis.Y)
print(Axis.Y == "y")
print(type(Axis.Y))
coarse hearthBOT
delicate wren
#

another option

proper ridge
#

Which is better?

delicate wren
#

depends on whether you want to allow plain str to be accepted

#

convenience vs strictness

proper ridge
#

But I want it to show not any str in the type hint like you had.

#

Just X, Y, Z, H, S and T.

delicate wren
#

!e

from enum import StrEnum, auto

class Axis(StrEnum):
    X = auto()
    Y = auto()
    Z = auto()
    H = auto()
    S = auto()
    T = auto()

print(isinstance(Axis.Y, str))
print(isinstance("y", Axis))
print(Axis("y"))
try:
    Axis("other")
except Exception as e:
    print(e)
coarse hearthBOT
delicate wren
#

interface with Literal["x"] | ...,
implementation with class Axis(StrEnum)

proper ridge
#

Probably not?

#

By the way, how would this impact performance? We are adding a few additional steps in return for removing dozens of lines (Thousands actually).

delicate wren
#
MAPPING = {
    Axis.X: ...,
    Axis.Y: ...,
    ...: ...,
}

AxisLike = Axis | Literal("x") | Literal("y") | Literal("z") | Literal("h") | Literal("s") | Literal("t")

def example(axis: AxisLike):
    op = MAPPING[Axis(axis)]
delicate wren
#

using that to get 'other' is not a valid Axis error message for free

proper ridge
delicate wren
#

!e

from enum import StrEnum, auto

class Axis(StrEnum):
    X = auto()
    Y = auto()
    Z = auto()
    H = auto()
    S = auto()
    T = auto()

match Axis.Y:
    case Axis.X: print("X")
    case Axis.Y: print("Y")
    case Axis.Z: print("Z")
    case too_lazy_to_do_the_rest: print("what")
coarse hearthBOT
proper ridge
delicate wren
#

just checking that match works

proper ridge
ashen fjord
#

sudo apt remove

#

or sudo apt purge

delicate wren
#

Axis.X, ..., Axis.T are all the possible instances of Axis

proper ridge
delicate wren
#

conversion to Axis checks that str is valid

proper ridge
#

Feels clearer that it must be either X, Y, Z, H, S, or T.

delicate wren
#

and Literal unions get somewhat big

proper ridge
delicate wren
#

hard to look at when type hints are involved

proper ridge
#

I don't get why we'd keep both.

delicate wren
#

Literal union for inputs to allow both Axis.X and "x" to work

#

if that's ever necessary

#

even if we only allow "x" as input, conersion to Axis.X on the inside still makes sense

#

(see the error message)

proper ridge
#

My neanderthal brain understands having an explicit check with if not in ["X", "Y", "Z"] better.

#

If I have a hard time understanding it, I fear others will too. Trying to keep it as simple as possible.

delicate wren
#

Axis conversion check is shorter

#

also don't in list()

#

use a set

proper ridge
#

Using a frozenset right now.

delicate wren
#

or that

proper ridge
#

Lemme finish this example, and show you, and if all good I'll update the codebase.

delicate wren
#

lists of length >1 were slower than sets for in check last time I measured

proper ridge
#

I mean 1 is not really a list HEHEHE

delicate wren
#

this is not the case when you're working in something like Rust

#

where iteration is faster than hashing for a larger number of elements

proper ridge
#

For the meantime, could you have a look at this method please? I think it's written very very poorly, and since I'm changing the entire qickit.circuit module now it'd be nice to fix this too.

#

!paste

coarse hearthBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

proper ridge
#

.gatemethod() one.

#

It handles the stuff repeated in almost all methods.

#

Really useful, but right now written poorly.

delicate wren
#

instance validation is critical, and having it repeated the way it is might be problematic later on

proper ridge
delicate wren
#

!e

from numbers import Real
print(isinstance(1, Real))
print(isinstance(1.0, Real))
print(isinstance(1j, Real))
coarse hearthBOT
delicate wren
proper ridge
delicate wren
#

depends on what properties you rely on

proper ridge
#

Just being a float.

delicate wren
#

!e

float(1j)
coarse hearthBOT
# delicate wren !e ```py float(1j) ```

:x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     float(1j)
004 | TypeError: float() argument must be a string or a real number, not 'complex'
delicate wren
#

hmm

proper ridge
#

Yeah, complex shouldn't be allowed.

delicate wren
#

it can just assert floatness by converting it

proper ridge
delicate wren
#

!e

from contextlib import contextmanager

@contextmanager
def type_error(message):
    try:
        yield
    except TypeError as e:
        raise TypeError(message) from e

with type_error("test"):
    float(1j)
coarse hearthBOT
# delicate wren !e ```py from contextlib import contextmanager @contextmanager def type_error(m...

:x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 6, in type_error
003 |     yield
004 |   File "/home/main.py", line 11, in <module>
005 |     float(1j)
006 | TypeError: float() argument must be a string or a real number, not 'complex'
007 | 
008 | The above exception was the direct cause of the following exception:
009 | 
010 | Traceback (most recent call last):
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/JBC7NP445NUBH7OS42YHYXS2EA

delicate wren
#

^ read the whole traceback of this

#

Go for concurrent stuff

#

Rust's type system isn't that new

#

OCaml+Haskell

#

well, that's just the same as with Java

#

some companies just use Java

#

because Java

proper ridge
delicate wren
#

it is the better Java, as a language

#

JVM has more than just Java, so that keeps it alive outside Enterpriseโ„ข๏ธ

#

CLR has, like

#

C#

#

F#

#

that's all

#

there is also Zig

#

C-adjacent

proper ridge
#

It says this is not a valid type:

NON_PARAMETERIZED_SINGLE_QUBIT_GATES = Literal("I") | Literal("X") | Literal("Y") | Literal("Z")\
      | Literal("H") | Literal("S") | Literal("T")
delicate wren
#

(if you're planning to use C, nowadays you will into Zig as a toolchain)

proper ridge
#

Name's hard to pronounce for most guys.

delicate wren
#

@lethal wadi "you don't need to use someone else's recursion if you can create your own"

lambda f: (lambda x: f(x(x)))(lambda x: f(x(x)))
#

(this blows up in python because not lazy)

lethal wadi
proper ridge
#

Like beauty before experience?

lethal wadi
delicate wren
#

I'd expect it's just /home/<user>/.local's version/override of /usr/local/share

mild flume
#

Kind of surreal, I hadn't thought about us being knowable in this way

delicate wren
#

!e

print((lambda: lambda f: lambda: (lambda: lambda x: lambda: f()(x()(x))())()(lambda: lambda x: lambda: f()(x()(x))())())()(lambda: lambda g: lambda: lambda x: lambda: 1 if x() == 0 else x() * g()(lambda: x() - 1)())()(lambda: 5)())
coarse hearthBOT
delicate wren
#

finally

#

it took too long to debug

rotund bough
#

it's all scraped by Common Crawl and given to companies like OpenAI

mild flume
#

True true

#

I still thought it was neat

#

I wasn't joking about Copilot being slow. It's painful

rotund bough
#

i need to top up my bank account.. keep forgetting to do that ๐Ÿ˜ฆ

lethal wadi
delicate wren
mild flume
mild flume
delicate wren
#

!e

print((lambda: lambda f: lambda: (lambda: lambda x: lambda: f()(x()(x))())()(lambda: lambda x: lambda: f()(x()(x))())())()(lambda: lambda g: lambda: lambda x: lambda: 1 if x() == 0 else x() * g()(lambda: x() - 1)())()(lambda: 10)())
coarse hearthBOT
delicate wren
#

number of seconds in 6 weeks

rotund bough
delicate wren
#

!e

print((lambda: lambda f: lambda: (lambda: lambda x: lambda: f()(x()(x))())()(lambda: lambda x: lambda: f()(x()(x))())())()(lambda: lambda g: lambda: lambda x: lambda: 1 if x() == 0 else x() * g()(lambda: x() - 1)())()(lambda: 100)())
coarse hearthBOT
delicate wren
#

wah

#

how is it not crashing

mild flume
#

Were you expecting it to run out of memory or run out of space on the stack?

delicate wren
#

either stackoverflow or run out of time

#

it can compute factorial of 498

#

with default recursion limit

rotund bough
#

!e

print(2^(2^(2^2)))
coarse hearthBOT
delicate wren
#

**

rotund bough
#

smh

delicate wren
#

xor

#

!e

a, b = 2, 3
a ^= b
b ^= a
a ^= b
print(a, b)
coarse hearthBOT
delicate wren
#

!e

a, b = 2, 3
a **= b
b **= a
a **= b
print(a, b)
coarse hearthBOT
delicate wren
#

huh

#

it computed

#

just can't display

rotund bough
#

integer string conversion?

delicate wren
#

yes

#

!e

import sys

sys.set_int_max_str_digits(1_000_000)

a, b = 2, 3
a **= b
b **= a
a **= b
print(a, b)
coarse hearthBOT
# delicate wren !e ```py import sys sys.set_int_max_str_digits(1_000_000) a, b = 2, 3 a **= b ...

:white_check_mark: Your 3.12 eval job has completed with return code 0.

1490749437483138602749298211171890771944932002222732590141543150107638430827697168860956299898208768103383042046125717680414504697162830849320642009933279918750145665098665006053232645457813304543557399402358472032673076270064074329561491188566191463794294838536284169187739762000994109181808567947703682261682667228562787084156635145887021676629723250075409894003982070022751911345085675862741997584195018068831851550656130586870150217387848281225134870058383913316670978064259909133330326265994405905843435830546918990810719009756056980229251142270914390981954951931287504270375643147681497200025450647062697740871740746391686103284614204877967678645586519738538636861361934498229220397924369801928214662429187086948360592388739423228612588402796532245819260742523155023617433434220689799427245248123190634942336603754173227848918146046320690524243866538622093549131543860879095813716209917240043402157927581271454973351431877111195879385579412993417719750515556196130302689769269190567711820432568
... (truncated - too long)

Full output: https://paste.pythondiscord.com/ORVUWXBZQZ6UWU73CTUXXEEPZQ

delicate wren
#

๐ŸŽ‰

#

@mortal stone graphical front-end

#

not bash/sh/ash/zsh/others

#

though if you have plain sh might as well install something else

#

word wrap off

#

word wrap on

#

what

#

(there's 6 thousand more characters that are in the line)

mild flume
delicate wren
#

@mortal stone reminder that Git Bash exists

#

from what I understand, only sh is somewhat guaranteed to be present

#

on Linux

#

(or generally OSes attempting to be POSIX-compatible)

rotund bough
#

bash is ootb on most distros

delicate wren
#

"you've said you're high; but recommending comments is too much"

#

all I've said today about refactoring is literally just in the books

#

it's literally basic software architecture theory

#

you need to test 3542132832.249878 rats to get one rat with an IQ of 7

#

Kevlin Henney
It is all to easy to dismiss problematic codebases on some nebulous idea of bad practice or bad programmers. Poor code, however, is rarely arbitrary and random in its structure or formulation.
Systems of code, well or poorly structured, emerge from systems of practice, whether effective or ineffective. To improve code quality, it m...

โ–ถ Play video
delicate wren
proper ridge
#

Hehehe

delicate wren
#

however bad Clean Code, the book, may be, towards the beginning it has some okay parts, including on splitting methods, names and comments

#

just don't read the examples it gives

delicate wren
#

just, like
read a book
even if it's bad, it'll cover most of this stuff anyway

#

I'd expect even ChatGPT 3.5 can do this

#

it's one of the most non-creative parts of altering architecture

mild flume
#

Only 3 more years left

#

Almost done

delicate wren
#

I prefer my tabs at 2.54 spaces

lethal wadi
#

cm to inch

delicate wren
#

time to embed a whole dissertation-sized excuse into docs

#

(still writing that Rust thing)

hearty heath
#

Hello everyone ๐Ÿ‘‹

delicate wren
#

@mild flume I just bought everything I could be interested in and could buy

#

there's nothing left no more interested in gaming really

mild flume
#

Yeah that's what I did. I think my actually played games was like... 50%?

delicate wren
#

NFTs are more wasteful

#

Valorant is unplayable for me

#

which is good

#

R6 for a long time had no marketplace

#

I think they do now

#

but you can't, like, buy a game from selling skins if I understand correctly

#

I don't think discord decorations are overpriced

#

don't want, don't spend

mild flume
delicate wren
#

I don't like the aesthetics of those decorations

obsidian nebula
delicate wren
#

there's nothing interesting for me to buy if I was able to

#

but I'm fine with their prices

#

which is NaN

hearty heath
#

Would you buy a Wumpus plushie?

delicate wren
#

misread that as 9'

#

instead of 9''

hearty heath
delicate wren
#

why is there a choice then

#

(it says no more than 1)

#

something broke

obsidian nebula
#

470ml for whoever was asking

delicate wren
#

Outline on its way to become the preferred markdown editor for me

#

the only wysiwig I'm okay with

#

because it's just markdown when you type it

mild flume
delicate wren
#

on the website it's better than I remember it seeing previously

mild flume
#

Yeah it's much prettier

lethal wadi
#

This button only works with Discover and other AppStream application stores. You can also use your distribution's package manager.

delicate wren
#

I uh

#

have Kate installed

#

it comes with the preview built-in

#

hmm

#

weird

lethal wadi
#

apt-get install markdownpart

delicate wren
#

but no syntax highlighting for code blocks

#

idk which renderer I have enabled

hearty heath
#

Linux commands are like "it's called 'less' because 'less is more' and it shows you more" ๐Ÿ˜”

proper ridge
#

Can I get an attaboy?

lethal wadi
#

attaboy

proper ridge
#

I coded till 4 AM

#

Thank youu!

#

My left side of the brain burns.

#

I'm gonna go, have ALOT to change tomorrow. Hopefully it'll be an easy change (unlikely, I'll probably break sth in the process).

obsidian nebula
lethal wadi
#

heck

proper ridge
#

AF, thank you so so much for the guidance, I bothered you for literally 5 hours, really really sorry.

#

Bless you and that 300IQ of yours.

obsidian nebula
delicate wren
#

maybe it's just lying

hearty heath
#

Cya @proper ridge ๐Ÿ‘‹

proper ridge
delicate wren
#

"pretend you don't see it"

misty sinew
#

I can't speak in the VC ๐Ÿ˜ฆ

delicate wren
#

!voice

coarse hearthBOT
#
Voice verification

Canโ€™t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

misty sinew
delicate wren
#

@mild flume that makes me thing maybe my body produces ADHD meds on its own

mild flume
#

HA

misty sinew
#

I'm new to learning python. Got any tips?

delicate wren
#

!resources

coarse hearthBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

lethal wadi
#

practice

delicate wren
#

Jupyter might be part of the bundle

misty sinew
delicate wren
#

VSC cred forwarding recently started misbehaving for me

#

tbf it wasn't fully expected to work because it's not using user-password

mild flume
#

And if you have any questions or need something explained, don't hesitate to ask!

misty sinew
obsidian nebula
misty sinew
#

@mild flume OUCH! ;-;

#

I code on a laptop

rotund bough
#

i code on a whiteboard

misty sinew
#

I'm scared of you.

delicate wren
#

I have low-profile keys with increased movement height (compared to what laptops have) so it doesn't feel too far from normal

lethal wadi
misty sinew
#

What language did you guys start your coding journey with?

rotund bough
#

Right now it just says server update which has been on my pending list

lethal wadi
#

or c++

misty sinew
#

I've never heard of those...

lethal wadi
#

pretty sure wolfram then c++ then labview

delicate wren
lethal wadi
#

neither have i. didn't know they were languages for a long long time

rotund bough
delicate wren
#

git diff whiteboard

rotund bough
#

must have been my UI prototype idea for my hangman game

misty sinew
delicate wren
#

@lethal wadi I learned Wolfram very early too; more than 10 years ago

#

by that time I only knew a bit of Pascal

lethal wadi
rotund bough
#

C++ ๐Ÿซถ

hearty heath
#

I think Panda3D has kind of an interesting back-story

#

It was made by Disney for Disney Quest, which was like a short-lived indoor themepark they made based around video games

misty sinew
delicate wren
# delicate wren by that time I only knew a bit of Pascal

truly a progress in 8 years up to that point:
learned primitive arithmetic and I/O in Pascal with text-only IDE,
downloaded Java in the times of Oracle being even more cringe than now,
wrote one line of Java,
wrote some C,
wrote a lot of Wolfram, learned 2D and 3D plots, equation solving, and other stuff

misty sinew
#

wait, how many of you all are working in a company?

delicate wren
delicate wren
#

for later on, when you're getting into advanced stuff

rotund bough
obsidian nebula
delicate wren
#

me when
vim + gcc + C++14 + copium

#

hopefully the company will give up on everything pre-Ubuntu20 soon

proper junco
#

I'm thinking of turning vim keybindings on in Kate

delicate wren
#

maybe there's a way to embed the entire Vim into it

rotund bough
#

atleast use C++17

delicate wren
#

this way you also get all the LSPs

#

some parts need to be built with C++14
thankfully I don't have to deal with those

supple ingot
#

can anyone tell me how to use proxies with aiohttp ?

delicate wren
#

any environment I work in assumes smart pointer availability

supple ingot
#

because i search it up on google i did not find anything that can help me

delicate wren
#

or are you using it as a client?

supple ingot
#

as a client

delicate wren
#

you're following that page, right?

supple ingot
#

yes

#
async def get(session, url, header, proxy):
    valid_proxy = set_proxy_to_dict(proxy)
    async with session.get(url, headers=header, proxy=valid_proxy) as response:
        return await response.json()


async def post(session, url, data, header, proxy):
    valid_proxy = set_proxy_to_dict(proxy)
    async with session.post(url, data=data, headers=header, proxy=valid_proxy) as response:
        return await response.json()
delicate wren
#

no proxy_auth?

supple ingot
#

i tried this but not working

supple ingot
#

its free proxy

misty sinew
#

I want to talk on vc too!! Mods, lend me your power! SHOW ME THE WAY! [lightning strike]

delicate wren
#

three days

misty sinew
#

;-;

mild flume
#

It'll go by faster than you think

hearty heath
#

Yea there's an environment variable you can set to disallow global pip installs

delicate wren
#

docker run -it --rm python:3.12

supple ingot
#

aiohttp.client_exceptions.ClientOSError: [WinError 64] The specified network name is no longer available i got this error

delicate wren
#

connecting to proxy by IP?

supple ingot
#

yes

supple ingot
misty sinew
rotund bough
supple ingot
#

is that means that the proxy not working or what ?

hearty heath
#

Wait, you can forward discord messages now?

misty sinew
hearty heath
#

Ah right, cool

misty sinew
#

you guys wanna hear a joke?

supple ingot
#

i found the solution thanks

mild flume
delicate wren
#

.pyc is bytecode, yes

misty sinew
rotund bough
#

my birthday is rn ๐Ÿ˜‚

misty sinew
rotund bough
#

where's the ๐Ÿฅƒ

hearty heath
#

Happy birthday! ๐Ÿฐ

misty sinew
#

give me strength to deal with the weird shit that happens here.

rotund bough
#

thanks ๐Ÿป

delicate wren
#

I don't understand where the collaborative part of this app comes in
https://appflowy.io/

AppFlowy is an AI collaborative workspace where you achieve more without losing control of your data

misty sinew
#

wanna hear a joke?

#

Yesterday, I was abducted by a group of mimes... they did UNSPEAKABLE things to me.

delicate wren
#

@lethal wadi there is a good self-hosted alternative to Notion: Outline

but it's not that

#

Outline is a good Markdown editor

#

wysiwig Markdown

like you literally type Markdown and you see the result inline instantly

#

and Outline has real-time sync

misty sinew
#

It's getting late, I should go... Good night, you guys!

delicate wren
#

Outline has Mermaid support allegedly

lethal wadi
delicate wren
#

it's markdown code block, yes

#

Mermaid is bundled by default, TeX is bundled by default

#

so that's okay-ish for embedding

#

theming is hard

#

I prefer clicking and dragging because that ends up producing better looking results

#

text to diagram just isn't there yet

#

the emoji count at the correct number

hearty heath
#

Yeah that sounds the worst

delicate wren
#

!d import

coarse hearthBOT
#

7.11. The import statement


import_stmt     ::=  "import" module ["as" identifier] ("," module ["as" identifier])*
                     | "from" relative_module "import" identifier ["as" identifier]
                     ("," identifier ["as" identifier])*
                     | "from" relative_module "import" "(" identifier ["as" identifier]
                     ("," identifier ["as" identifier])* [","] ")"
                     | "from" relative_module "import" "*"
module          ::=  (identifier ".")* identifier
relative_module ::=  "."* module | "."+
```...
delicate wren
#

that

#

!d import the common test dummy

#

"why is there so much of me"

#

so there's part I should cut out from this

#

and it should be usable

hearty heath
#

Cya

#

That might be the case ๐Ÿ˜„

#

Back in a bit ๐Ÿ‘‹

buoyant dagger
versed elk
proper ridge
#

Opal Mist

#

!e

import numpy as np

a = np.array(1+0j)
print(a)
coarse hearthBOT
proper ridge
#
    @Circuit.gatemethod
    def MCRZ(self,
             angle: float,
             control_indices: int | Collection[int],
             target_indices: int | Collection[int]) -> None:
        control_indices = [control_indices] if isinstance(control_indices, int) else control_indices
        target_indices = [target_indices] if isinstance(target_indices, int) else target_indices

        # Create a Multi-Controlled RZ gate with the number of control qubits equal to
        # the length of `control_indices` with the specified angle
        mcrz = cirq.ControlledGate(sub_gate=Rz(rads=angle), num_controls=len(control_indices))

        # Apply the MCRZ gate controlled by all control indices to each target index
        for target_index in target_indices:
            self.circuit.append(
                mcrz(*map(self.qr.__getitem__, control_indices), self.qr[target_index])
            )
#

    @Circuit.gatemethod
    def MCU3(self,
             angles: Collection[float],
             control_indices: int | Collection[int],
             target_indices: int | Collection[int]) -> None:
        control_indices = [control_indices] if isinstance(control_indices, int) else control_indices
        target_indices = [target_indices] if isinstance(target_indices, int) else target_indices

        # Create a single qubit unitary gate
        u3 = [[np.cos(angles[0]/2), -np.exp(1j*angles[2]) * np.sin(angles[0]/2)],
              [np.exp(1j*angles[1]) * np.sin(angles[0]/2), np.exp(1j*(angles[1] + angles[2])) * \
                                                           np.cos(angles[0]/2)]]

        # Define the U3 gate class
        class U3(cirq.Gate):
            def __init__(self):
                super(U3, self)

            def _num_qubits_(self):
                return 1

            def _unitary_(self):
                return np.array(u3)

            def _circuit_diagram_info_(self, args):
                return "U3"

        # Create a Multi-Controlled U3 gate with the number of control qubits equal to
        # the length of `control_indices` with the specified angle
        mcu3 = cirq.ControlledGate(sub_gate=U3(), num_controls=len(control_indices))

        # Apply the MCU3 gate controlled by all control indices to each target index
        for target_index in target_indices:
            self.circuit.append(
                mcu3(*map(self.qr.__getitem__, control_indices), self.qr[target_index])
            )
stuck bluff
#

@misty sinew ๐Ÿ‘‹

#

Hey, Osyra.

proper ridge
#

!e

a = 1
b = list(1)
coarse hearthBOT
# proper ridge !e ```py a = 1 b = list(1) ```

:x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 2, in <module>
003 |     b = list(1)
004 |         ^^^^^^^
005 | TypeError: 'int' object is not iterable
fair heron
proper ridge
#
def _parameterized_controlled_gate(self,
                                       gate: Literal["RX", "RY", "RZ", "U3"],
                                       angles: float | Collection[float],
                                       control_indices: int | Collection[int],
                                       target_indices: int | Collection[int]) -> None:
        angles = [angles] if isinstance(angles, (int, float)) else angles
        control_indices = [control_indices] if isinstance(control_indices, int) else control_indices
        target_indices = [target_indices] if isinstance(target_indices, int) else target_indices

        # Define the gate mapping for the parameterized controlled gates
        gate_mapping = {
            "RX": qml.RX(angles[0], wires=0).matrix(),
            "RY": qml.RY(angles[0], wires=0).matrix(),
            "RZ": qml.RZ(angles[0], wires=0).matrix(),
            "U3": qml.U3(theta=angles[0], phi=angles[1], delta=angles[2], wires=0).matrix()
        }

        # Apply the controlled gate controlled by all control indices to each target index
        for target_index in target_indices:
            self.circuit.append(
                qml.ControlledQubitUnitary(
                    gate_mapping[gate],
                    control_wires=control_indices,
                    wires=target_index
                )
            )
delicate wren
#

overload?

#

"U3": ... line gives an error, right?

misty sinew
#

i have no idea sir

versed elk
#

@proper jungle is your pfp of squid games?

delicate wren
versed elk
#

I'm just watching a video about it, would be a cool coincidence ashdahdahs

delicate wren
#

R{X,Y,Z} expect data different from U3

#

conditionals are often not the right way to abstract

#

there are simple cases where abstraction is obvious

#

U3 might need to be a separate method

#

it is a special case, from what I see there

valid ocean
#

woah so many tabs

delicate wren
#

rn trying to figure out if there's a way to provide an iterator with __length_hint__ to self.circuit.extend

#

map doesn't define it, generator comprehensions don't define it either

valid ocean
delicate wren
#

I don't

#

some people do

valid ocean
#

What are you guys doing btw

#

can you dumb it down for me?

delicate wren
#

there was a screenshot somewhere there with "you're about to close 49XX tabs, are you sure?"

delicate wren
#

trying to simplify how it's structured

#

by factoring out common elements

valid ocean
delicate wren
#

something quantum-related

valid ocean
#

Good shit

versed elk
proper jungle
versed elk
#

But based on what you've said and the culture library in my brain:

#

La casa de papel?

proper jungle
#

@versed elk wait are you a c++ dev

delicate wren
delicate wren
#

!rule 9

coarse hearthBOT
#

9. Do not offer or ask for paid work of any kind.

valid ocean
#

!rule 1

coarse hearthBOT
valid ocean
#

!rule 2

coarse hearthBOT
versed elk
delicate wren
#

(you ask still for ask for non-contractual collaboration)

#

e.g. if you have an open-source project

versed elk
#

Anyway, the only thing I have with C++ is that I have researched extensevely C, C++ and C# characteristics and pros and cons yesterday, I never written even a CHARACTER in any of them (yet, probly)

delicate wren
#

C# is somewhat far from the first two

#

closer to Java

versed elk
#

Wish you luck in your find for a collaborator o/ ^^

versed elk
#

but I didn't knew it until I researched

delicate wren
#

for language similar to C, there's Zig
for C++, Rust
for C#, Java

versed elk
#

I'm somewhat aware of the general characteristics now

proper ridge
#

In Layman terms, writing code that can be translated to Qiskit, Cirq, PyTKET, Pennylane or CUDA-Quantum packages.

versed elk
delicate wren
#

part of Zig's popularity is its build system

#

you can use Zig to build parts of C/C++/Rust

versed elk
#

It's like life was just a simulation and suddenly
*Insert new language
*Insert new language into everyone's memory as if it existed from X years ago
*Create new videos and make as if they were posted months ago
*No one will suspect

delicate wren
#

first time I interacted with Zig beyond reading/watching was in around October-November 2023

#

@slow terrace ChatGPT is bad for review

versed elk
#

I feel like the world will now try to gaslight me into believing it was always there since I was born

#

World gaslighting me:

delicate wren
delicate wren
#

for me ChatGPT and alike are just a waste of time

#

like a toy

#

I read and test code way more often than I write it

#

I'm completely fine with increasing the time I write code by 2~3 times

#

I'm ready for Java

#

@slow terrace you can build your own AI tools on top of it, yes, and that's actually quite useful

versed elk
delicate wren
#

like
ChatGPT helps you => find a way to embed it into your IDE/dev process in a way different than what Copilot does

versed elk
#

It may have passed to me a lot of missinformation about how windows works, but thaaaat's a surprise for later

#

As I have no knowledge to know it right now

delicate wren
versed elk
delicate wren
#

Rust was in pre-1.0 for 9 years

versed elk
#

That's unexpected based on what I see about Rust, when I see it

delicate wren
#

Zig has been in pre-1.0 for 8 years so far

versed elk
#

I would think it was 5-10 years old

delicate wren
#

Rust 1.0 was in 2015

#

has been stable for only half its life

versed elk
delicate wren
#

there are some specific advances that made Rust gain popularity

#

the most important being around 2018 with the stabilisation of async-await

versed elk
versed elk
#

and Zig, what the hell happened with it, why it suddenly (seemingly) sprouted out of nowhere?

delicate wren
#

also thanks to some specific projects that use it

#

examples: tigerbeetle, bun

versed elk
delicate wren
#

not entirely

versed elk
#

I'm going to sleep soon

delicate wren
#

tigerbeetle is a financial transactional database

#

bun is a JavaScript runtime/toolchain

#

as a replacement for Node.js

versed elk
#

toolchain?

delicate wren
#

tools for building, testing, packaging

versed elk
#

hmmmmmmmmmm

delicate wren
#

@ashen willow you're using raw HTML, right? or are you using a framework?

#

(I haven't heard what the question actually was, only heard dropdown)

ashen willow
#

Button

#

text

delicate wren
#

where do you expect it to show up?

#

somewhere else on the site or overlayed on top?

proper ridge
#

Brb, gonna grab a snack.

delicate wren
#

scroll down to second example

#
<dialog>
  <button autofocus>Close</button>
  <p>This modal dialog has a groovy backdrop!</p>
</dialog>
<button>Show the dialog</button>
::backdrop {
  background-image: linear-gradient(
    45deg,
    magenta,
    rebeccapurple,
    dodgerblue,
    green
  );
  opacity: 0.75;
}
const dialog = document.querySelector("dialog");
const showButton = document.querySelector("dialog + button");
const closeButton = document.querySelector("dialog button");

// "Show the dialog" button opens the dialog modally
showButton.addEventListener("click", () => {
  dialog.showModal();
});

// "Close" button closes the dialog
closeButton.addEventListener("click", () => {
  dialog.close();
});
#

this is the code they provide for the example

#

dialog is somewhat new

#

chrome/opera: since 2014
edge: since 2020
firefox/safari: since 2022

#

as a single file:

<style>
  ::backdrop {
    background-image: linear-gradient(
      45deg,
      magenta,
      rebeccapurple,
      dodgerblue,
      green
    );
    opacity: 0.75;
  }
</style>
<dialog>
  <button autofocus>Close</button>
  <p>This modal dialog has a groovy backdrop!</p>
</dialog>
<button>Show the dialog</button>
<script>
  const dialog = document.querySelector("dialog");
  const showButton = document.querySelector("dialog + button");
  const closeButton = document.querySelector("dialog button");
  showButton.addEventListener("click", () => {
    dialog.showModal();
  });
  closeButton.addEventListener("click", () => {
    dialog.close();
  });
</script>
mild flume
#

uwuser

deep niche
#

Evening Ace

#

and Hemlock

mild flume
#

Yo

#

@hybrid steppe @vapid beacon Yo to you both

#

!stream 958057865032106045

coarse hearthBOT
#

โœ… @ashen willow can now stream until <t:1720794475:f>.

proper ridge
#
def _non_parameterized_single_qubit_gate(self,
                                             gate: Literal["I", "X", "Y", "Z", "H", "S", "T"],
                                             qubit_indices: int | Collection[int]) -> None:
        # Define the gate mapping for the non-parameterized single qubit gates
        gate_mapping = {
            "I": qml.Identity,
            "X": qml.PauliX,
            "Y": qml.PauliY,
            "Z": qml.PauliZ,
            "H": qml.Hadamard,
            "S": qml.S,
            "T": qml.T
        }

        # Apply the gate to the specified qubit(s)
        if isinstance(qubit_indices, Collection):
            for index in qubit_indices:
                self.circuit.append(gate_mapping[gate](wires=index))
        else:
            self.circuit.append(gate_mapping[gate](wires=qubit_indices))

    def _parameterized_single_qubit_gate(self,
                                         gate: Literal["RX", "RY", "RZ"],
                                         angle: float,
                                         qubit_index: int) -> None:
        # Define the gate mapping for the parameterized single qubit gates
        gate_mapping = {
            "RX": qml.RX,
            "RY": qml.RY,
            "RZ": qml.RZ,
        }

        self.circuit.append(gate_mapping[gate](angle, wires=qubit_index))
thin lintel
proper ridge
#
def _non_parameterized_controlled_gate(self,
                                           gate: Literal["X", "Y", "Z", "H", "S", "T"],
                                           control_indices: int | Collection[int],
                                           target_indices: int | Collection[int]) -> None:
        control_indices = [control_indices] if isinstance(control_indices, int) else control_indices
        target_indices = [target_indices] if isinstance(target_indices, int) else target_indices

        # Define the gate mapping for the non-parameterized controlled gates
        gate_mapping = {
            "X": qml.PauliX(0).matrix(),
            "Y": qml.PauliY(0).matrix(),
            "Z": qml.PauliZ(0).matrix(),
            "H": qml.Hadamard(0).matrix(),
            "S": qml.S(0).matrix(),
            "T": qml.T(0).matrix()
        }

        # Apply the controlled gate controlled by all control indices to each target index
        for target_index in target_indices:
            self.circuit.append(
                qml.ControlledQubitUnitary(
                    gate_mapping[gate],
                    control_wires=control_indices,
                    wires=target_index
                )
            )
#
    def _parameterized_controlled_gate(self,
                                       gate: Literal["RX", "RY", "RZ"],
                                       angle: float,
                                       control_indices: int | Collection[int],
                                       target_indices: int | Collection[int]) -> None:
        control_indices = [control_indices] if isinstance(control_indices, int) else control_indices
        target_indices = [target_indices] if isinstance(target_indices, int) else target_indices

        # Define the gate mapping for the parameterized controlled gates
        gate_mapping = {
            "RX": qml.RX(angle, wires=0).matrix(),
            "RY": qml.RY(angle, wires=0).matrix(),
            "RZ": qml.RZ(angle, wires=0).matrix(),
        }

        # Apply the controlled gate controlled by all control indices to each target index
        for target_index in target_indices:
            self.circuit.append(
                qml.ControlledQubitUnitary(
                    gate_mapping[gate],
                    control_wires=control_indices,
                    wires=target_index
                )
            )
wary fable
proper ridge
#
    def _single_qubit_gate(self,
                           gate: Literal["I", "X", "Y", "Z", "H", "S", "T", "RX", "RY", "RZ"],
                           qubit_indices: int | Collection[int],
                           angle: float | None = 0) -> None:
        # Define the gate mapping for the non-parameterized single qubit gates
        gate_mapping = {
            "I": [OpType.noop],
            "X": [OpType.X],
            "Y": [OpType.Y],
            "Z": [OpType.Z],
            "H": [OpType.H],
            "S": [OpType.S],
            "T": [OpType.T],
            "RX": [OpType.Rx, angle/np.pi],
            "RY": [OpType.Ry, angle/np.pi],
            "RZ": [OpType.Rz, angle/np.pi]
        }

        # Apply the gate to the specified qubit(s)
        if isinstance(qubit_indices, Collection):
            for index in qubit_indices:
                self.circuit.add_gate(*gate_mapping[gate], [index])
        else:
            self.circuit.add_gate(*gate_mapping[gate], [qubit_indices])
wary fable
#
import math as maths  # for the UK users
proper ridge
#
     def _non_parameterized_single_qubit_gate(self,
                                              gate: Literal["I", "X", "Y", "Z", "H", "S", "T"],
                                              qubit_indices: int | Collection[int]) -> None:
         # Define the gate mapping for the non-parameterized single qubit gates
         gate_mapping = {
             "I": OpType.noop,
             "X": OpType.X,
             "Y": OpType.Y,
             "Z": OpType.Z,
             "H": OpType.H,
             "S": OpType.S,
             "T": OpType.T
         }

         # Apply the gate to the specified qubit(s)
         if isinstance(qubit_indices, Collection):
             for index in qubit_indices:
                 self.circuit.add_gate(gate_mapping[gate], [index])
         else:
             self.circuit.add_gate(gate_mapping[gate], [qubit_indices])

     def _parameterized_single_qubit_gate(self,
                                          gate: Literal["RX", "RY", "RZ"],
                                          angle: float,
                                          qubit_index: int) -> None:
         # Define the gate mapping for the parameterized single qubit gates
         gate_mapping = {
             "RX": OpType.Rx,
             "RY": OpType.Ry,
             "RZ": OpType.Rz,
         }

         # Apply the gate to the specified qubit
         self.circuit.add_gate(gate_mapping[gate], angle/np.pi, [qubit_index])

#

@delicate wren Do you think this is a good change?

proper ridge
wary fable
#
%homework 3 Question 4

phi_0 = 5.5e+4; % m^2s^-2 for 500hPa
f_0 = 1e-4; % coriolis parameter at 45N s^-1
U_0 = 10; % average Zonal wind, ms^-1
A = 8e+6; % Wave Amplitude
k = (pi/2)*(10^(-6)); % wavenumber m^-1
x = linspace(-4000000,4000000,1000);
y = linspace(-1000000,1000000,1000);
[X,Y] = meshgrid(x,y);
phi = phi_0 - f_0.*U_0.*Y + f_0.*A.*sin(k.*X);
subplot(1,2,1)
mesh(X,Y,phi)
subplot(1,2,2)
contour(X,Y,phi)
#

this was the output

proper ridge
#

!paste

coarse hearthBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

wary fable
#
CC
CC  Fortran 77 program to integrate the linearized barotropic
CC  vorticity equation at 500hPa for a single latitude, only 
CC  considering advection by the mean wind and ignoring all
CC  variation in y:
CC
CC    d/dt vort = -U*d/dx vort - beta*v
CC
CC  The model is global in longitude
CC 
C
    parameter(nx=144) ! same as reanalysis grid
        parameter(dt=60*15) ! time step (seconds)
    parameter(nt=10*24*4) ! number of time steps
    parameter(ntout=4) ! how many time steps to skip on output
    parameter(clat=45.0) ! latitude 
    parameter(re=6.378E6) ! radius of Earth (meters)
    parameter(rpi=3.1415926) ! Pi
        parameter(omega=7.292E-5) ! angular velocity of Earth
    parameter(s=4e6) ! spatial scale of initial disturbance
C
    real vortold(nx),vortnew(nx),vort(nx)
    real u,temp(nx)
    real phi(nx),ddxphi(nx),ddxvort(nx),v(nx)
C
C  set up input and output files and data
C
    open(13,file="baro_1d_output.dat",status="unknown",
     &    access="direct",recl=4*nx)
C
C  calculate grid spacing from number of grid points and latitude
C
    dx=cos(clat*rpi/180.0)*2.0*rpi*re/real(nx)
        f0=2.0*omega*sin(45.0*3.14159/180.0)
    beta=2.0*omega*cos(45.0*3.14159/180.0)/re
C
    irec=1
C
C  specify value for u and for initial phi
C
    u=15.0
C
    do ix=1,nx
           x=(ix-nx/2)*dx
       gauss=exp(-x*x/(s*s))
       phi(ix)=500.0*gauss*sin(10.0*2.0*rpi*real(ix-1)/real(nx))
    enddo
    phiav=0.0
    do ix=1,nx
      phiav=phiav+phi(ix)/real(nx)
    enddo
    do ix=1,nx
      phi(ix)=phi(ix)-phiav
    enddo
    write(13,rec=irec)phi
    irec=irec+1
C
#

fun times

void cedar
#

hi

#

are u devs?

#

@quiet bear @tranquil drift

tranquil drift
#

@buoyant wolf yes

void cedar
#

the things goes like this: ive started cs journey from last week and my college has java in the first year

#

is it good

#

tho im learning python

#

and how much should I know

#

of a language

tranquil drift
#

yes absolutely

#

when it comes to "good" vs "not good" programming languages, they arent necessarily good/bad

#

a wrench isnt considered bad because you dont use it to hammer a nail

void cedar
#

i have this alot of questions on my mind like how many languages do I have to know to work like program or code

#

yeah

tranquil drift
#

JSON

#

{"data": {...}

#

not a language but is used/applied in every language (configuration stuff for example)

#

stuff like that you learn as you go

void cedar
#

until now I am studying python i feel like i understand it really quick

#

is this the basics?!

#

I have learnt variables, functions, lists, dictionaries, objects

#

can i share what I have written myself?

tranquil drift
#

yes for sure, any questions you have with what youve written or those concepts in the screenshot too feel free to ask

void cedar
void cedar
tranquil drift
#

certainly a start

misty sinew
#

tan is better tho

tranquil drift
#

whats something thats intimidating you right now that you want to know?

void cedar
#

how am i going to code?

#

like do i have to remember this whole thing?

misty sinew
#

see if you think I won't remember math module function, it's upto you how much you use it