#voice-chat-text-0

1 messages ยท Page 248 of 1

vocal basin
#

but I don't want my IP/username in edit history

wooden sequoia
#

Maybe use a VPN if it ticks you off

somber heath
#

@whole bear ๐Ÿ‘‹

wooden sequoia
#

and they're gone

vocal basin
wooden sequoia
#

Wear a mask. Wear it on your face.

#

where else does one wear a mask, may I ask

#

that negates the whole point

upper basin
#

Doctors must complete a four-year undergraduate program, along with four years in medical school and three to seven years in a residency program to learn the specialty they chose to pursue. In other words, it takes between 10 to 14 years to become a fully licensed doctor.

somber heath
#

!paste

wise cargoBOT
#
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.

somber heath
#

!code

wise cargoBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

upper basin
vocal basin
#

what's up with the comments

#

@somber heath no it doesn't

#

comments visually make it look unprofessional

#

yeah

upper basin
vocal basin
#
// add 1 to i
i += 1;
#

explain why not what

upper basin
#

Understood

vocal basin
#

it's adding lowerbound to random_int not other way around

#

there's an error in the comment

#

is upperbound inclusive or exclusive?

#

that should be written in docs

#

(line 40)

#
# shift random_int's range from [0;upperbound-lowerbound-1] to [lowerbound;upperbound-1]
random_int += lowerbound
#

if you do need to explain that line, this might be a better way

#

just as an example

#

it's more descriptive than "Add the random integer to the lowerbound"

#

(since it explains high-level effects and purpose of that statement)

#

and Python should warn about it

#

!e

x = 1
x is 1
wise cargoBOT
#

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

001 | /home/main.py:2: SyntaxWarning: "is" with 'int' literal. Did you mean "=="?
002 |   x is 1
vocal basin
#

is isn't same as ==

#

it only works sometimes

wooden sequoia
#

Will the while loop at line 161 ever exit? Does it affect the indices list?

vocal basin
#

yes

#

append

#
indices = [self.randint(0, len(items)) for _ in range(num_selections)]
#

what's the difference between choices and sample?

vocal basin
#

sample's loop may end up waiting forever

#

I don't remember how to efficiently sample unique

wooden sequoia
#

collections.abc isn't used later on

vocal basin
#

Container isn't, Iterable is

#

there are some Iterable-related type errors

#

it should be Sequence instead

#

because Iterable doesn't have __len__

#

(no return)

wooden sequoia
#

You used the Any type, I think you would need to import it from typing first

vocal basin
#

on 3.12, there is [T] notation which is probably better than Any

#

in this case

#
def identity[T](value: T) -> T:
    return value
wooden sequoia
#

Nice

vocal basin
#

yes, it's an invalid annotation

#

Sequence allows to call len on it

#

use Sequence for annotation instead of Iterable

#

if you can len on it

#

this is type error

def test(value: Iterable):
    len(value)
#

yes, tell users that they need to pass Sequence in

#

if you need len

#

Sequence also allows indexing

#

typing.Sequence

#

collections.abc.Sequence should work too

#

maybe that's even preferred

#

yeah, use collections.abc.Sequence

#

typing one is deprecated since 3.9

#

it used to be a generic alias

#

but now collections.abc.Sequence supports generics itself

#

collections.abc.MutableSequence allows, iirc

#

maybe not

#

are you using an IDE?

#

with Pylance?

upper basin
vocal basin
#

this is what Pylance says:

#

you can run it through mypy

#

which checks types

upper basin
#
def MCX(self,
            control_indices: int or Iterable[int],
            target_indices: int or Iterable[int]) -> None:
        """ Apply a MCX gate to the circuit.

        Parameters
        ----------
        `control_indices (int or Iterable[int]):
            The index of the control qubit(s).
        `target_indices` (int or Iterable[int]):
            The index of the target qubit(s).
        """
        # Ensure control_indices and target_indices are always treated as Iterables
        control_indices = [control_indices] if isinstance(control_indices, int) else control_indices
        target_indices = [target_indices] if isinstance(target_indices, int) else target_indices

        # Apply the MCX gate to the circuit at the control and target qubits
        for i in range(len(target_indices)):
            self.circuit.append(qml.ControlledQubitUnitary(qml.PauliX(0).matrix(), control_wires=control_indices, wires=target_indices[i]))

        # Add the gate to the log
        self.circuit_log.append({'gate': 'MCX', 'control_indices': control_indices, 'target_indices': target_indices})
vocal basin
#

or has no effect

#

it just ignores int

#

int | Iterable[int] would be union

vocal basin
#

I forgot how or works

#

and would ignore int

#

it doesn't work

#

whereas | works correctly

#

what do you mean by "works"?

#

runtime errors?

#

well of course it wouldn't

#

type-wise it fails

#

type annotations do nothing during runtime

#

in this case

upper basin
#

MCX(1, [2, 3])

vocal basin
#

so you can't judge based on runtime errors

upper basin
#

MCX([1, 2], 3)

vocal basin
#

!d typing.Union

wise cargoBOT
#

typing.Union```
Union type; `Union[X, Y]` is equivalent to `X | Y` and means either X or Y.

To define a union, use e.g. `Union[int, str]` or the shorthand `int | str`. Using that shorthand is recommended. Details...
vocal basin
#

output doesn't matter

#

runtime errors don't matter

#

it's not about runtime

#

it's about types

#

int or str is int

#

int and str is str

#

the type annotation is wrong

#

if you want union, use |

#

!e

print(int or str)
print(int and str)
print(int | str)
wise cargoBOT
#

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

001 | <class 'int'>
002 | <class 'str'>
003 | int | str
vocal basin
#

the latter is same as typing.Union[int, str]

vocal basin
#

option1:
int, list[int]
option2:
np.ndarray, list[int]

#
list[int]
set[frozenset[str]]
...
#
a: list[int] = [1, 2, 3]
#

since 3.9, list itself is generic

#

this is the signature I'd expect

def choices[T](
    self,
    items: Sequence[T],
    num_selections: int,
) -> list[T]: ...
#

why list:
- implementation will have to create list anyway
- provide more functionality to whoever uses the output
- make it clear that all values are computed before returning

#

last point means that it's not a generator-like thing

upper basin
#
Traceback (most recent call last):
  Cell In[11], line 2
    test_qc.MCX(np.array([1, 2]), [3, 4])
  Cell In[7], line 489 in MCX
    self.circuit.append(mcx, control_indices[:] + [target_indices[i]])
  File /opt/conda/lib/python3.10/site-packages/qiskit/circuit/quantumcircuit.py:1273 in append
    expanded_qargs = [self.qbit_argument_conversion(qarg) for qarg in qargs or []]
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
vocal basin
wise cargoBOT
#

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

001 | before yield
002 | 1
vocal basin
#

if choices was generating output element-by-element, Iterable would be a reasonable output type

#

Iterable[T] covers both Iterator[T] (something you can call next() of) and list[T];
if the intent is to not have the implementation tied to specifics, Iterable[T] might be appropriate

#

what, again?
(didn't understand yet)

#

starting from this?

@command
def click(x: int, y: int): ...
#

so the problem is that arguments aren't the same?

@command
def click(x: int, y: int): ...

@command
def drag(startx: int, starty: int, endx: int, endy: int): ...
tepid edge
#
@command(**args1)
@option(**args2)
@option(**args3)
def click(x, y):
  ...
vocal basin
#

first option relates to x and second to y?

#

what is passed as arguments to it?

#

name/description/default?

#
@command
def click(
    x: Annotated[int, Option(name = "x", description = "click position's horizontal coordinate")],
    y: Annotated[int, Option(name = "y", description = "click position's vertical coordinate")],
): ...
#

!d typing.Annotated

wise cargoBOT
#

typing.Annotated```
Special typing form to add context-specific metadata to an annotation.

Add metadata `x` to a given type `T` by using the annotation `Annotated[T, x]`. Metadata added using `Annotated` can be used by static analysis tools or at runtime. At runtime, the metadata is stored in a `__metadata__` attribute.

If a library or tool encounters an annotation `Annotated[T, x]` and has no special logic for the metadata, it should ignore the metadata and simply treat the annotation as `T`. As such, `Annotated` can be useful for code that wants to use annotations for purposes outside Pythonโ€™s static typing system.
vocal basin
#

I've seen it somewhere recently but I don't remember where

#

(I knew about it for longer but there is some tool that uses it quite extensively for which I need to write that)

#

yes

#

to then parse from __annotations__

#

!e

from typing import Annotated

def click(
    x: Annotated[int, "x argument"],
    y: Annotated[int, "y argument"],
): ...

print(click.__annotations__)
wise cargoBOT
#

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

{'x': typing.Annotated[int, 'x argument'], 'y': typing.Annotated[int, 'y argument']}
vocal basin
#

!source e

wise cargoBOT
#
Command: eval

Run Python code and get the results.

Source Code
vocal basin
#

code: Annotated[list[str], CodeblockConverter]

upper basin
#

@stark river greetings

vocal basin
#

so for that function's case:

def MCX[T: (int | Iterable[int], np.ndarray)](
    self,
    control_indices: T,
    target_indices: T,
) -> None: ...
upper basin
#

if target_rows != int(target_rows) or target_cols != int(target_cols):

vocal basin
#

!e

"" or ""
"" | ""
wise cargoBOT
#

@vocal basin :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 |     "" | ""
004 |     ~~~^~~~
005 | TypeError: unsupported operand type(s) for |: 'str' and 'str'
vocal basin
#

they're not equivalent

#

!e

def one():
    print("one")
    return 1

def two():
    print("two")
    return 2

one() | two()
one() or two()
wise cargoBOT
#

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

001 | one
002 | two
003 | one
vocal basin
#

!e

print({1} or {2})
print({1} | {2})
wise cargoBOT
#

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

001 | {1}
002 | {1, 2}
vocal basin
#

a or b is mostly equivalent to temp if (temp := a) else b

#

it's analogous to sets:

#

!e

print({"int"} | {"str"})
print(int | str)
wise cargoBOT
#

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

001 | {'str', 'int'}
002 | int | str
upper basin
#
Do :
int | Iterable[int]
Instead of :
int or Iterable[int]
vocal basin
#

!e

print({"int"} | {"int"})
print(int | int)
wise cargoBOT
#

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

001 | {'int'}
002 | <class 'int'>
vocal basin
upper basin
#

a=1, or a=[1,2,3].

vocal basin
#
def func(arg: int | list[int]): ...

func(1)          # ok
func([1, 2, 3])  # ok
func("1")        # error
#
def func(
    arg0: int | list[int],
    arg1: int | list[int],
): ...

# all these are valid:
func(1, 1)
func([1], [1])
func(1, [1])
func([1], 1)
#
def func[T: (int, list[int])](
    arg0: T,
    arg1: T,
): ...

func(1, 1)      # ok
func([1], [1])  # ok
func(1, [1])    # error
func([1], 1)    # error
upper basin
#
data_arg = Iterable[float] | Iterable[Iterable[float]] | Data
vocal basin
#

nested works too, yes

upper basin
#

Use Sequence instead of Iterable (How to best annotate and write methods with generic iterables in mind)

#
    def MCX(self,
            control_indices: int | Iterable[int],
            target_indices: int | Iterable[int]) -> None:
        """ Apply a MCX gate to the circuit.

        Parameters
        ----------
        `control_indices (int | Iterable[int]):
            The index of the control qubit(s).
        `target_indices` (int | Iterable[int]):
            The index of the target qubit(s).
        """
        # Ensure control_indices and target_indices are always treated as Iterables
        control_indices = [control_indices] if isinstance(control_indices, int) else control_indices
        target_indices = [target_indices] if isinstance(target_indices, int) else target_indices

        # Apply the MCX gate to the circuit at the control and target qubits
        for i in range(len(target_indices)):
            self.circuit.append(qml.ControlledQubitUnitary(qml.PauliX(0).matrix(), control_wires=control_indices, wires=target_indices[i]))

        # Add the gate to the log
        self.circuit_log.append({'gate': 'MCX', 'control_indices': control_indices, 'target_indices': target_indices})
noble rose
#

hi everyone

knotty flint
#
noble rose
#

what

gentle flint
#

@whole bear you may be unaware, but these voice chats are offtopic. Talking about random topics is the standard; if you want ontopic, go to #python-discussion .
If you choose to mute me, that's certainly your prerogative. Pretty petty but whatever.

#

christ

wet scroll
#

@somber heath hai

#

who said that

#

oh mayor

#

ehh im being lazy

#

i really wanna finish what im doing rn but i have nothing good for it ๐Ÿ˜ญ

#

idk i just picked a random word and tuna came up

somber heath
#

"It's not a tuna."

somber heath
#

@runic nimbus ๐Ÿ‘‹

noble rose
#

hes japanese because he/she's tuna

runic nimbus
#

hi:)

noble rose
#

yep

runic nimbus
#

blue fin tuna

wet scroll
noble rose
#

ok

wet scroll
#

(im not into pronouns or idk)

vivid palm
#

!mute 293195225734840320 4d if you have an issue with another user, do not resort to insults. this is your final warning for such behavior and the next time you do this you will be removed from the community.

wise cargoBOT
#

:incoming_envelope: :ok_hand: applied timeout to @whole bear until <t:1706537250:f> (4 days).

wet scroll
#

what the

#

dang

peak depot
somber heath
#

@hallow oxide @torpid shard ๐Ÿ‘‹

peak depot
#

@gentle flint

rugged root
#

Danthrax

#

I always figured I'd go by DJ D.J.

#

Oooo, true

peak depot
#

Hi dad joke!

peak depot
somber heath
#

@strong pebble ๐Ÿ‘‹

strong pebble
peak depot
#

@rugged root can I get streaming permits for 5min

rugged root
#

To do what? What's up?

peak depot
#

Show my kitty..

whole bear
#

Alr Imma go workout

peak depot
#

Toebeans, toebeans, toebeaaaaans!!

somber heath
#

@stoic sparrow ๐Ÿ‘‹

rugged root
#

!stream 425552190283972608

wise cargoBOT
#

โœ… @peak depot can now stream until <t:1706195311:f>.

somber heath
#

@fathom fox ๐Ÿ‘‹

somber heath
#

@sleek mango ๐Ÿ‘‹

sleek mango
#

hi!

#

I cant speak.

#

since I dont have permissions.

#

xD @somber heath

somber heath
sleek mango
#

ah thnx!

#

I need to send more messages.

#

50 is a bunch to send.

peak depot
sleek mango
#

especially if you don't talk much about coding ๐Ÿ˜„

#

hahah

somber heath
#

The trick is to not try. You just chat normally. Eventually it happens.

upper basin
#

Hemlock, would you like to see the finished QRNG?

rugged root
#

py -m pip install [package_here]

somber heath
#

@north pawn @trail mulch ๐Ÿ‘‹

rugged root
#

!resources

wise cargoBOT
#
Resources

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

rugged root
#

py -0

somber heath
#

Numpy dropped out of Snekbox and got recently put back in.

gentle flint
rugged root
#

@somber heath

#

I'm so sad

#

I had such high hopes

somber heath
#

Okay boomerang.

rugged root
#

@jaunty turret What site are you trying to get info from

stark river
#

scrape it

gentle flint
#

@jaunty turret post it here

stark river
#

what i do for my whatsapp bots

gentle flint
#

yes

#

the link

jaunty turret
upper basin
#
[mid_point[0], *[mid_point[i] + perturbations[i-1] for i in range(1, len(mid_point))]]
#

Sazk is this a stupid way of doing this?

#

mid_point is a list of float.

#

perturbations is also a list of float, whose length is one less than mid_points's.

rugged root
#

I almost have an answer

upper basin
#

Ohh thank you!

stark river
#

it's a bit difficult to read but if it's working do it

upper basin
#

Well that's my point

#

I want to do it more sanely

quaint oyster
#

bro just thanked hemlock for an almost answer

stark river
#

break it up n assign it to variables

rugged root
upper basin
obsidian dragon
rugged root
#

Jakarta Server Pages (JSP; formerly JavaServer Pages) is a collection of technologies that helps software developers create dynamically generated web pages based on HTML, XML, SOAP, or other document types. Released in 1999 by Sun Microsystems, JSP is similar to PHP and ASP, but uses the Java programming language.
To deploy and run Jakarta Serve...

exotic moss
rugged root
#

@sudden wyvern Better if you ask in here

stark river
sudden wyvern
#

OKay yea. I think I have to send 50 messages to register the voice chat.

rugged root
noble rose
#

hi

#

idk

#

only 38 msg

#

need to keep it up

#

ok

#

im not a dick

rugged root
#

Didn't figure you were

#

Just force of habit to mention it

noble rose
#

heh

rugged root
rugged root
#

I'll be back later, wanting to focus more on fixing this

quaint oyster
#

๐Ÿซก I will be voice lead

#

favorite flavor of pop tarts anyone?

stark river
#

what are pop tarts

peak depot
#

have not tried this but I think I would like it: confetti cupcake -flavour

stark river
#

smh.. are these biscuits?

#

kelloggs products

peak depot
stark river
#

nah too corporatey
probably taste like cardboard like all corporate products

peak depot
#

it does

quaint oyster
#

few seconds in the microwave and boom

#

ur set

#

what do u eat sazk

#

what is ur 2 days of rations consist of

stark river
#

i eat a variety of thigns

#

rn it's just 2 days of ration left

#

which is worrying

#

vegetables

fading quiver
#

permission to speak

quaint oyster
#

permission granted

#

what can i do you for

fading quiver
#

i am having a problem in installing seal library in python

#

on google collab

quaint oyster
#

seals are creatures that live in the ocean not your computer silly

stark river
#

is it in a jupyter notebook?

fading quiver
#

lol are you a bot

quaint oyster
#

yes

fading quiver
stark river
#

you may need to use a magic method to access pip.. iirc it was !pip install .....

fading quiver
#

yeah i did that

stark river
#

was there an erro?

fading quiver
#

wait let me show you the error

#

this

#

if you could allow me to talk in VC i can explain

stark river
#

faulty package?

stark river
# fading quiver

While working with Python packages, programmers may encounter a specific error โ€” โ€˜python setup.py egg_infoโ€™ failed with error code 1. This error is related to the package installation process and can arise due to several reasons, such as outdated or improperly installed pip or other package installation tools. You can fix the โ€˜python setup.py eg...

quaint oyster
fading quiver
#

give me perk to speak in VC

quaint oyster
#

cant

#

no one can

fading quiver
#

ok ok

#

imma gonna check the blog , thanks for the help btw

#

i really love your support

quaint oyster
#

I love you too

whole bear
#

What did I just walk into?

quaint oyster
#

it's not what it looks like

whole bear
#

love you both

#

somebody text in here so my messages dont look like spam ๐Ÿ™‚

quaint oyster
#

ask a programming question or something

golden sonnet
#

๐Ÿ‘‹

#

they should give ipv6 for free

rugged root
#

True

gentle flint
#

it's not like they're gonna run out

golden sonnet
#

what happend to if we have to much of something it doesn't have value?

#

just give it away

rugged root
#

What do you mean? They're literally values

golden sonnet
peak depot
#

can someone help me with my graphics card issue?

stark river
#

maybe

pallid hazel
#

meh.. wish i had time to hangout more.. between meetings and projects.. just cant sit at the pc for my free time ๐Ÿ˜ฆ
add in the normalization hell im in.. why cant vendors normalize their own data.. its like wtf dont they use this data also... mimd boggiling

dusky radish
#

hello

#

need someone who knows how to code a discord token account generator

whole bear
#

Yeah no Idea

#

@round marten ๐Ÿ‘‹

round marten
#

Hey

whole bear
#

!voice

wise cargoBOT
#
Voice verification

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

round marten
#

No access to mic

#

Need voice verification

whole bear
#

Yes

#

Check the channel out

round marten
#

Not eligible apparently

#

Need to send more messages

whole bear
#

Yes

round marten
#

Do messages here count lol

whole bear
#

Yes

round marten
#

What are you guys talking about

whole bear
#

Bro just read the channel

vocal basin
#

what does "discord token account generator" mean?

#

!rule 5 if for any reason you're trying to access user tokens:

wise cargoBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

bleak sleet
#

yeaah

dusky radish
gentle flint
#

@stark river do you never leave voice chat

#

you're always there

#

but mostly don't respond if I join and speak to you

stark river
#

stalker

#

and you never speak to me

#

@somber heath i mean it in jest

#

besides me explaining the speaking is a moot point.. mostly i'm on my desktop so i don't have a mic there

#

my ๐Ÿง  is fried ๐Ÿ˜ฎโ€๐Ÿ’จ

#

git squashed without testing ๐Ÿ˜ฆ

somber heath
#

@empty spruce ๐Ÿ‘‹

empty spruce
#

๐Ÿ‘‹

tall ridge
# golden sonnet they should give ipv6 for free

"They" do. It's just that if you want a block, you have to show that you know what to do with it.
Which is a good idea because, or example, I have two contiguous IPv4 Class C blocks, but I haven't kept up my contact info so they are in limbo and no one else can use them.

somber heath
#

@main spade ๐Ÿ‘‹

whole bear
#

Wait why can't I talk?

#

@tulip gyro I can't talk

#

help

somber heath
#

First in first out - FIFO - queue
First in last out - FILO - stack
Yeah?

#

Stack - I have a vertical, ordered pile of things on the floor. Each time I add or take from it, I'm adding or taking it from the top.

Queue - I have a tube. I shove things in one end and take them out from the other in the same order they went in.

#

@languid solstice ๐Ÿ‘‹

tulip gyro
somber heath
#

Scutelleridae is a family of true bugs. They are commonly known as jewel bugs or metallic shield bugs due to their often brilliant coloration. They are also known as shield-backed bugs due to the enlargement of the thoracic scutellum into a continuous shield over the abdomen and wings. This latter characteristic distinguishes them from most othe...

#

@rigid brook ๐Ÿ‘‹

rigid brook
#

hi @somber heath

somber heath
#

From turtle.py```py

Copyright (C) 2006 - 2010 Gregor Lingl

email: glingl@aon.at

This software is provided 'as-is', without any express or implied

warranty. In no event will the authors be held liable for any damages

arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,

including commercial applications, and to alter it and redistribute it

freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not

claim that you wrote the original software. If you use this software

in a product, an acknowledgment in the product documentation would be

appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be

misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.```

#

@modest adder ๐Ÿ‘‹

modest adder
#

Hello!

#

I'm sorry to bother

somber heath
#

Bother.

#

That's what the server is for.

#

(With a correct interpretation of "bother")

#

Bother with questions about Python, yes.

modest adder
#

I am currently working on a Discord, but within the constraints of the discord, API, and trying to find many workarounds to create a thread using a discord bot. The goal is to have this bot automatically create a thread, dependent on different variables. And I have attempted the simulate command, the API described code and other various options. Currently at loss. I am using Replit to deploy this bot. And I have adjusted my code accordingly, but to no avail.

#

I am truly just trying to create a thread automatically with the bot

#

๐Ÿซ 

#

Yeah, discord thread within the text channel

#

Like a sub channel

#

but they have a separate form channel archetype

somber heath
modest adder
#

I thank you for that

#

Will, I need to wait the entirety of the three days before I can ask for help?

#

Iโ€™ve had a separate bot running for over 30 days at this point

#

So Iโ€™m feeling confident that Replit should be able to provide what I need

muted hinge
#

You're still free to talk (text) in the rest of the server until then though!

modest adder
#

Understood that is good information. Thank you!

#

I will seek out the answer, and hopefully come up further than I have recently

#

It does appear that I can text in these chats

#

So I shouldnโ€™t have issues seeking the answers with your peers

#

Thank you for all the help!

#

I wish you the best and have a wonderful day/night

#

๐Ÿ˜

whole bear
#

๐Ÿ˜‚

somber heath
#

@fallen echo ๐Ÿ‘‹

#

@obsidian dragon "Am I moe enough for you?"

turbid sandal
#

2,570$ USD after tax

obsidian dragon
#

@somber heath I don't get it surri

turbid sandal
somber heath
#

"Honk."

wind warren
#

class Phonebook:
def init(self):
self.contacts = {}

def add_contact(self, name, number):
    self.contacts[name] = number
    print(f"Contact {name} added successfully.")

def search_contact(self, name):
    if name in self.contacts:
        print(f"Contact {name}: {self.contacts[name]}")
    else:
        print(f"Contact {name} not found.")

def display_contacts(self):
    print("Phonebook Contacts:")
    for name, number in self.contacts.items():
        print(f"{name}: {number}")

def main():
phonebook = Phonebook()

while True:
    print("\n1. Add Contact\n2. Search Contact\n3. Display Contacts\n4. Exit")
    choice = input("Enter your choice (1-4): ")

    if choice == '1':
        name = input("Enter the name: ")
        number = input("Enter the phone number: ")
        phonebook.add_contact(name, number)

    elif choice == '2':
        name = input("Enter the name to search: ")
        phonebook.search_contact(name)

    elif choice == '3':
        phonebook.display_contacts()

    elif choice == '4':
        print("Exiting phonebook.")
        break

    else:
        print("Invalid choice. Please enter a valid option.")

if name == "main":
main()

upper basin
#

!code

wise cargoBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

wind warren
#
    def __init__(self):
        self.contacts = {}

    def add_contact(self, name, number):
        self.contacts[name] = number
        print(f"Contact {name} added successfully.")

    def search_contact(self, name):
        if name in self.contacts:
            print(f"Contact {name}: {self.contacts[name]}")
        else:
            print(f"Contact {name} not found.")

    def display_contacts(self):
        print("Phonebook Contacts:")
        for name, number in self.contacts.items():
            print(f"{name}: {number}")

def main():
    phonebook = Phonebook()

    while True:
        print("\n1. Add Contact\n2. Search Contact\n3. Display Contacts\n4. Exit")
        choice = input("Enter your choice (1-4): ")

        if choice == '1':
            name = input("Enter the name: ")
            number = input("Enter the phone number: ")
            phonebook.add_contact(name, number)

        elif choice == '2':
            name = input("Enter the name to search: ")
            phonebook.search_contact(name)

        elif choice == '3':
            phonebook.display_contacts()

        elif choice == '4':
            print("Exiting phonebook.")
            break

        else:
            print("Invalid choice. Please enter a valid option.")

if __name__ == "__main__":
    main()
upper basin
#

IBM Quantum Lab

rotund stag
#

built-in python IDE

#

VSCode is basically just a text editor with extensions combined with the command line

somber heath
somber heath
#

@torn adder ๐Ÿ‘‹

brisk bridge
#

hi

upper basin
#
def define_distance_matrix(self) -> Iterable[Iterable[float]]:
        """ Function to define the distance matrix for the given coordinates.

        Returns
        -------
        `Distance_matrix` : Iterable[Iterable[float]]
            The distance matrix.
        """
        # Distance Matrix
        Distance_matrix = []
        temp_set = []

        # Function for calculating the euclidean distance
        def distance_between_points(point_A, point_B):
            return np.sqrt((point_A[0] - point_B[0]) ** 2 + (point_A[1] - point_B[1]) ** 2)

        # Generating the distance matrix
        for i in range(len(self.coordinates)):
            for j in range(len(self.coordinates)):
                temp_set.append(distance_between_points(self.coordinates[i], self.coordinates[j]))
            Distance_matrix.append(temp_set)
            temp_set = []

        return Distance_matrix
somber heath
#
v: int = 5```
vocal basin
#

indexable immutable:
Sequence[Sequence[T]]

#

you can make a wrapper that indexes it the same way numpy allows to

#

with tuples

#
Mapping[tuple[int, ...], int]
#

indexed like

multidimensional[a, b, c]
#

(lists don't allow that)

#

!e

class MultiDimensional:
    def __init__(self, inner):
        self.inner = inner

    def __getitem__(self, key: tuple[int, ...]):
        inner = self.inner
        for index in key:
            inner = inner[index]
        return inner

md = MultiDimensional([[1,2],[3,4]])
print(md[0, 1])
wise cargoBOT
#

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

2
vocal basin
#

idk if it's a good idea at all to have arbitrary dimensions and not using np.ndarray

#

probably not

#

I think this is roughly what ndarray does

class Axis:
    step: int
    length: int

class NdArray[T]:
    data: list[T]
    start: int
    axes: list[Axis]
somber heath
#

@whole bear ๐Ÿ‘‹

vocal basin
#

and indexing goes something like:

position = start
for axis, index in zip(axes, indices, strict=True):
    assert index in range(axis.length)
    position += axis.step * index
return data[position]
#

(trying to remember for myself how that works)

#

!e

from dataclasses import dataclass

@dataclass
class Axis:
    step: int
    length: int

@dataclass
class NdArray[T]:
    data: list[T]
    start: int
    axes: tuple[Axis]

    def __getitem__(self, indices: tuple[int]):
        position = self.start
        for axis, index in zip(self.axes, indices, strict=True):
            assert index in range(axis.length)
            position += axis.step * index
        assert position in range(len(self.data))
        return self.data[position]

array = NdArray(data=[0,1,2,3], start=0, axes=(Axis(step=2, length=2), Axis(step=1, length=2)))
print(array[0, 0])
print(array[0, 1])
print(array[1, 0])
print(array[1, 1])
wise cargoBOT
#

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

001 | 0
002 | 1
003 | 2
004 | 3
vocal basin
#

huh

#

it even worked

#

downsides to this are same as with numpy:
no resizing

somber heath
#

@pallid peak ๐Ÿ‘‹

rotund stag
#

isn't that basically an array

vocal basin
#

!d numpy.ndarray

wise cargoBOT
#

class numpy.ndarray(shape, dtype=float, buffer=None, offset=0, strides=None, order=None)```
An array object represents a multidimensional, homogeneous array of fixed-size items. An associated data-type object describes the format of each element in the array (its byte-order, how many bytes it occupies in memory, whether it is an integer, a floating point number, or something else, etc.)

Arrays should be constructed using [`array`](https://numpy.org/devdocs/reference/generated/numpy.array.html#numpy.array), [`zeros`](https://numpy.org/devdocs/reference/generated/numpy.zeros.html#numpy.zeros) or [`empty`](https://numpy.org/devdocs/reference/generated/numpy.empty.html#numpy.empty) (refer to the See Also section below). The parameters given here refer to a low-level method (*ndarray(โ€ฆ)*) for instantiating an array.

For more information, refer to the [`numpy`](https://numpy.org/devdocs/reference/index.html#module-numpy) module and examine the methods and attributes of an array.
rotund stag
#

like i don't think an array can be resized

vocal basin
#

depends on the definition

#

C arrays can't be resized

#

Python arrays can

#

!d array

wise cargoBOT
#

This module defines an object type which can compactly represent an array of basic values: characters, integers, floating point numbers. Arrays are sequence types and behave very much like lists, except that the type of objects stored in them is constrained. The type is specified at object creation time by using a type code, which is a single character. The following type codes are defined:

vocal basin
#

this Python array

#

Rust array can't be resized because they're const-sized

#

I don't remember what else calls them arrays

#

JS I guess too

#

there it's resizable

#

Java's arrays are fixed size (this I had to look up)

somber heath
#

@fair geyser ๐Ÿ‘‹

vocal basin
#

!d builtin

wise cargoBOT
vocal basin
#

what

#

why is it pytest

#

(I meant this)

#

!e

a_list = []
a_tuple = (a_list, a_list)
print(a_tuple)
a_list.append(None)
print(a_tuple)
wise cargoBOT
#

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

001 | ([], [])
002 | ([None], [None])
vocal basin
#

this is why I don't really like calling tuples immutable
or using notion of immutability in Python generally

#

hashability is closest Python has to immutability, imo

#

!e

print(hash((1, 2, 3)))
print(hash(([1], [2], [3])))
wise cargoBOT
#

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

001 | 529344067295497451
002 | Traceback (most recent call last):
003 |   File "/home/main.py", line 2, in <module>
004 |     print(hash(([1], [2], [3])))
005 |           ^^^^^^^^^^^^^^^^^^^^^
006 | TypeError: unhashable type: 'list'
upper basin
#

@vocal basin I'm gonna go with my own class, and use the code you sent, and try that.

#

Thank you so much!

#

I feel your way is more reliable, at least I'd know what I can and can't do.

#

Easier to commit.

wooden sequoia
#

Hey why did the tuple scream into its mic?

vocal basin
#

better scream at tuples instead lyrics from Tallah -- Shaken:
"you couldn't be changed"

wooden sequoia
#

It was immutable

#

Ah

#

Okay

#

I'm sorry

somber heath
#

@whole sierra ๐Ÿ‘‹

wooden sequoia
#

I am honoured

vocal basin
#

meme-oriented programming

wooden sequoia
#

It's okay

#

Why do programmers confuse Halloween with Christmas? Because OCT 31 == DEC 25. --pyjokes

#

This is my favourite package on pypi

#

strange

#

I already have it installed, so I can read dumb python jokes whenever I'm burnt out

#

That's every english joke

somber heath
#

@whole bear ๐Ÿ‘‹

wooden sequoia
#

Pyjokes has an entire category just for Chuck Norris

#

I mean, it is created by developers

#

True

#

Sorry, truth-y

#

Statements aren't techically True or False, but they evaluate to either one. So voila, they are truth-y

vocal basin
#

expressions

wooden sequoia
#

Not Python statements

#

I meant statements in English

vocal basin
#

true, false, other

gray kraken
#

ok

#

can some learn me how to use pyinstaller

#

i wont work

#

just make py files exe files

#

say if you read this

#

wanna learn togeter

#

i mean making py exe files

#

o ok

#

il find it out then but stil thx

#

tomorow i can finaly talk in this channel

#

dont exuse yourself

#

no problem

#

i have an error while using pyinstaller

#

i mean installing

#

can we privatecall

#

you dont have to help me but then i can atleast talk back

gray kraken
#

did it

somber heath
#

@whole bear ๐Ÿ‘‹

#

@reef vessel ๐Ÿ‘‹

#

@woven mango ๐Ÿ‘‹

rapid chasm
somber heath
#

@neon osprey ๐Ÿ‘‹

turbid sandal
#

hi opal

eager thorn
whole bear
#

@somber heath sorry I joined by wrong

somber heath
#

@uneven brook ๐Ÿ‘‹

uneven brook
#

@somber heath hello

somber heath
wind warren
#

if 5 > 2:
print("Five is greater than two!")

#

if 5 > 2: print("Five is greater than two!")

obsidian dragon
#
if 5 > 2:
  print("Five is greater than two!\n")
somber heath
#

'''abc
def'''

#

!e py print('''abc def''')

wise cargoBOT
#

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

001 | abc
002 | def
somber heath
#

@ashen plover ๐Ÿ‘‹

ashen plover
#

Hello

somber heath
#

@strange horizon ๐Ÿ‘‹

#

@cold steppe ๐Ÿ‘‹

cold steppe
somber heath
#

@atomic imp ๐Ÿ‘‹

#

@narrow verge ๐Ÿ‘‹

#

@uncut latch ๐Ÿ‘‹

uncut latch
#

hello @somber heath

#

actually I can't open my mic

#

permission!!

somber heath
uncut latch
#

50 messages requirement not found!

uncut latch
#

let me spam 50 messages

upper basin
somber heath
eager thorn
#

smh

uncut latch
#

yep!!..don't wanna to get banned

#

but do you think the rules are pretty much harsh

coral forge
#

Is there any program that will give me new challenges every day to learn python

upper basin
coral forge
upper basin
coral forge
#

Although I have very limited knowledge

somber heath
#

!kindling May be of interest to you.

wise cargoBOT
#
Kindling Projects

The Kindling projects page on Ned Batchelder's website contains a list of projects and ideas programmers can tackle to build their skills and knowledge.

uncut latch
coral forge
coral forge
eager thorn
#

@turbid sandal please stop , genuinely asking nicely

upper basin
#

Maybe try something a bit easier?

#

How about a card game?

uncut latch
#

btw...I am confusing to learn coding like sometimes I watch web dev tutorials and when I see my friend coding in python I do that...there's very uncertainity

upper basin
#

Well there are some great resources to learn python if you need some basics.

#

!resources

wise cargoBOT
#
Resources

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

upper basin
#

If you have the basics, then try to learn through the project itself. You'll learn better by facing issues and questions, and then solving/answering them through it.

#

I can give you a project, or you can use the kindling ones Opal sent. They are likely much better.

uncut latch
eager thorn
upper basin
upper basin
#

If you are doing sth that is too hard, try sth simpler, and build your way up.

upper basin
#

@whole bear Greetings

#

matplotlib

#

plt.show() or plt.imshow()

#

import matplotlib.pyplot as plt

noble rose
#

hi

#

wow super dev

#

send nitro

#

:3

#

i hate these leetcode problems

turbid sandal
#

me too

noble rose
#

i tried codewars

#

and they were much easier tbh

eager thorn
noble rose
#

gonna check amount of messages

whole bear
#

does anyone know how to print in python whithout using the "print()" function??

whole bear
#

in pyton

#

python

#

who have put that fucking flag on my message!

#

fuck isreal

#

isreal is losing the war

noble rose
#

its irregular verb

whole bear
#

ok

#

you are not brave

#

to go and fight face to face

candid panther
#

!silence

wise cargoBOT
#

โœ… silenced current channel for 10 minute(s).

candid panther
#

@whole bear @noble rose This is not the way to interact in the server. If you are not able to stay civil then your time here may be limited. Both of you take a break and read the #rules and #code-of-conduct

#

!unsilence

wise cargoBOT
#

โœ… unsilenced current channel.

whole bear
#

alnurr didn't do anything

noble rose
#

yeah

turbid sandal
candid panther
#

Apologies, then @turbid sandal please read my message above

whole bear
#

yeah

noble rose
#

oh

stark river
#

@noble rose catching strays

turbid sandal
whole bear
#

@candid panther @noble rose didn't do anything

candid panther
#

Spamming reactions is not appropriate

whole bear
#

i did

noble rose
#

he got it

turbid sandal
#

I know

#

talking to mr.hemlock

whole bear
turbid sandal
#

is it?

#

Please dont

gritty garnet
#

@whole bear @turbid sandal drop it, alright? We're moving on.

turbid sandal
#

thanks you!

noble rose
#

life goes on

turbid sandal
#

hell yeah

whole bear
#

I am not moving on then are killing babies and women

whole bear
#

who didn't doc anythingg

noble rose
#

please not politics

candid panther
#

!mute 882233326704930837 Take a break

wise cargoBOT
#

:incoming_envelope: :ok_hand: applied timeout to @whole bear until <t:1706282959:f> (1 hour).

turbid sandal
#

jesus

candid panther
upper basin
#

Greetings Brad!

noble rose
#

no problem

upper basin
#

Great meeting your acquaintance sir. Please do drop into the call sometime.

candid panther
#

I don't do voice chat, too many meetings

stark river
#

brad be like.. i don't mix with the plebs /jk

upper basin
#

I see. Well I wish you a blessed weekend ahead good sir.

stark river
#

๐Ÿง

noble rose
quasi sand
#

yo what happened here?

candid panther
turbid sandal
#

yepp

candid panther
turbid sandal
somber heath
#

@hollow totem ๐Ÿ‘‹

somber heath
#

@frosty token ๐Ÿ‘‹

frosty token
stark river
#

i gtg food searching ๐Ÿ˜ฆ
i may have to resort to eating from outside โ˜น๏ธ

#

i mean a food stall.. not a dumpster

somber heath
#

@tawdry kernel ๐Ÿ‘‹

stark river
quasi sand
stark river
#

๐Ÿคฃ

quasi sand
#

BTW starship 3rd launch maybe in Feb, excited.

stark river
#

that reminds me there's a marathon coming up in the start of feb.. i need to check the dates to register and participate

gentle flint
#

@rugged root ordered some small bike stuff

#

the contents

#

it was mostly filled with wadding

quasi sand
gentle flint
#

why they had to use such a huge box I do not know

obsidian dragon
#

they needed that giant box so it fits exactly in the truck

quasi sand
#

maybe separate a section of the truck that can fit small box

gentle flint
#

ig

#

bit weird

crystal fox
rugged root
somber heath
rugged root
#

Rotate pages clockwise and counterclockwise
Fuck. You. Adobe

somber heath
#

I use LibreOffice if I need to do pdf stuff.

stark river
#

LaTeX

somber heath
#
10 print "Hello, world."
20 Geauxteaux 10```
stark river
#

well let me know if you need anything made @rugged root

rugged root
#

Not a matter of making, just have to rotate my owl for science

somber heath
#

As part of Mercedes-Benz Intelligent Drive, MAGIC BODY CONTROL ensures optimum driving comfort. Watch the โ€œChickenโ€ advertisement here. More information about the Mercedes-Benz S-Class: http://mb4.me/sclass_website

โ–บSubscribe to Mercedes-Benz on YouTube: http://www.youtube.com/subscription_center?add_user=MercedesBenzTV

โ–บExperience the world o...

โ–ถ Play video
crystal fox
#

How did the Tyrannosaurus Rex and it's kind come to dominate their prehistoric world? Palaeontologist Dr David Hone explores the evolution, ecology and behaviour of these amazing dinosaurs, and explains what Jurassic Park got wrong.
Watch the Q&A here: https://www.youtube.com/watch?v=eTWG5WY_XoM
Subscribe for weekly videos http://bit.ly/RiSubscR...

โ–ถ Play video
rugged root
stark river
rugged root
#

Eh, it's already done

crystal fox
upper basin
#

ngl, he's kinda bad.

#

Seeing Stacy's mom in his arms, it makes me beyond sad
But one day he'll see my charms, and it will make him mad,
maaad with love

#

Someday LOVE will find YOUUU

#
  • Guitar solooo
crystal fox
rugged root
#

list[]

upper basin
#
def define_distance_matrix(self) -> List[List[float]]:
        """ Defines the distance matrix for the given coordinates.

        Returns
        -------
        `Distance_matrix` (List[List[float]]):
            The distance matrix.
        """
        # Initialize the distance matrix
        distance_matrix = []

        def distance_between_points(point_A: List[int],
                                    point_B: List[int]) -> float:
            """ Function for calculating the euclidean distance.

            Parameters
            ----------
            `point_A` (List[int]):
                The first point.
            `point_B` (List[int]):
                The second point.

            Returns
            -------
            `distance` (float):
                The euclidean distance between the two points.
            """
            return np.sqrt((point_A[0] - point_B[0]) ** 2 + (point_A[1] - point_B[1]) ** 2)

        # Calculate the distance matrix
        for a in self.coordinates:
            distance_matrix.append([distance_between_points(a, b) for b in self.coordinates])

        # Return the distance matrix
        return distance_matrix
#

Type matrix = List[List[float]]?

#

from typing import List

#

list[]

whole bear
#

Yo

upper basin
#

list[list[float]]

#

list[list[list[float]]] for dimension 3

rugged root
#
def define_distatnce_matrix(self) -> list:
   ...
#

!d typing.overload

wise cargoBOT
#

@typing.overload```
Decorator for creating overloaded functions and methods.

The `@overload` decorator allows describing functions and methods that support multiple different combinations of argument types. A series of `@overload`-decorated definitions must be followed by exactly one non-`@overload`-decorated definition (for the same function/method).

`@overload`-decorated definitions are for the benefit of the type checker only, since they will be overwritten by the non-`@overload`-decorated definition. The non-`@overload`-decorated definition, meanwhile, will be used at runtime but should be ignored by a type checker. At runtime, calling an `@overload`-decorated function directly will raise [`NotImplementedError`](https://docs.python.org/3/library/exceptions.html#NotImplementedError).
rugged root
#

!d typing.Sequence

wise cargoBOT
#

class typing.Sequence(Reversible[T_co], Collection[T_co])```
Deprecated alias to [`collections.abc.Sequence`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence).

Deprecated since version 3.9: [`collections.abc.Sequence`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence) now supports subscripting (`[]`). See [**PEP 585**](https://peps.python.org/pep-0585/) and [Generic Alias Type](https://docs.python.org/3/library/stdtypes.html#types-genericalias).
rugged root
#

!d typing.Iterable

wise cargoBOT
#

class typing.Iterable(Generic[T_co])```
Deprecated alias to [`collections.abc.Iterable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterable).

Deprecated since version 3.9: [`collections.abc.Iterable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterable) now supports subscripting (`[]`). See [**PEP 585**](https://peps.python.org/pep-0585/) and [Generic Alias Type](https://docs.python.org/3/library/stdtypes.html#types-genericalias).
rugged root
#

Did I die?

upper basin
#

NdimList(shape, dtype)

rugged root
#

Yeah, that'd work then

upper basin
rugged root
#

OH

upper basin
#

They said to use List, but I didn't really fully comprehend, so I waited until you would be available.

rugged root
rugged root
upper basin
rugged root
#

Yeeeeeeeeeeeeeeeeeeeeeeeeeeeep

stark river
whole bear
stark river
#

one finger typing?

upper basin
stark river
#

learn on my keyboard layout instead of qwerty. it's the best keyboard layout in the world

rugged root
#

"Legitimate research"

stark river
#

smh these luddites

#

outperforms qwerty on distance covered, same finger bigrams and home row usage metrics

rugged tundra
#

@whole bear

whole bear
#

ok

rugged root
#

NDA Jam: Tournament Edition

upper basin
#

!e

from dataclasses import dataclass

@dataclass
class Axis:
    step: int
    length: int

@dataclass
class NdArray[T]:
    data: list[T]
    start: int
    axes: tuple[Axis]

    def __getitem__(self, indices: tuple[int]):
        position = self.start
        for axis, index in zip(self.axes, indices, strict=True):
            assert index in range(axis.length)
            position += axis.step * index
        assert position in range(len(self.data))
        return self.data[position]

array = NdArray(data=[0,1,2,3], start=0, axes=(Axis(step=2, length=2), Axis(step=1, length=2)))
print(array[0, 0])
print(array[0, 1])
print(array[1, 0])
print(array[1, 1])
wise cargoBOT
#

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

001 | 0
002 | 1
003 | 2
004 | 3
upper basin
#

Why am I getting this error when I run this in my notebook?

Traceback (most recent call last):
  File /opt/conda/lib/python3.10/site-packages/IPython/core/compilerop.py:86 in ast_parse
    return compile(source, filename, symbol, self.flags | PyCF_ONLY_AST, 1)
  Cell In[10], line 9
    class NdArray[T]:
                 ^
SyntaxError: invalid syntax
#

Is this a python version thing?

rapid chasm
# rapid chasm

@rugged root Here is my aircheck if you want to take a look pithink

rugged root
#

Nifty

upper basin
#

@rugged tundra so I'm trying to correct how I should use type hinting for generic lists.

stark river
#

you may need to define T?

upper basin
#

I don't know how to do it well, so I've been asking for opinions from the guys, and trying to learn.

crystal fox
rugged root
#

!code

wise cargoBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

rugged root
#

Do the hightlighting

rugged tundra
#

Trying to fix a bug ATM

vocal basin
upper basin
rugged root
#

Using the overloading decorator I pointed out earlier

upper basin
#

I was sort of following on the ND class way you suggested.

upper basin
#

How would that work for Ndarray?

#

I am not sure how I should use it in this context.

vocal basin
# wise cargo

another way to expressed what I showed with TypeVar bounds

#

also works for different numbers of arguments

rugged root
#

Ooo ooo ooo veggie tray in the kitchen brb

vocal basin
#

for fixed-size I'd probably still prefer typevar

#

*fixed-count

upper basin
#

What do you mean by fixed-size? I forgot.

vocal basin
upper basin
#

Ooh

#

So what I would like to have would be the dimension (or shape, whatever) and dtype.

#

That's all.

#

I think dimension is better?

#

For type annotating at least.

crystal fox
upper basin
#

Like NDArray(dim=2, dtype=float) would be same as list[list[float]].

rugged root
#

It's like it's wearing shin guards backwards

#

@mild quartz Yo

upper basin
#

Greetings @mild quartz

mild quartz
#

yoyo

upper basin
#

Missed you mate

#

Thank you for dropping by

stark river
#

i asked in the lobby why do we need pydantic when typing stdlib has NewType
i got ans: ur pfp is js
smh

rugged root
upper basin
#

@mild quartz Are you in the headspace to take a crack at my question?

#

Python typing question.

rugged root
#

@warm jackal Buddyyyyyyyyy

mild quartz
upper basin
#

Oooh thank you!

warm jackal
upper basin
#

Ok, so I would like to know what is the best way to type hint (and how to write the code) for generic lists in python.

mild quartz
upper basin
#

Let's say using sth like this code :

def define_distance_matrix(self) -> list[list[float]]:
        """ Defines the distance matrix for the given coordinates.

        Returns
        -------
        `Distance_matrix` (list[list[float]]):
            The distance matrix.
        """
        # Initialize the distance matrix
        distance_matrix = []

        def distance_between_points(point_A: list[int],
                                    point_B: list[int]) -> float:
            """ Function for calculating the euclidean distance.

            Parameters
            ----------
            `point_A` (List[int]):
                The first point.
            `point_B` (List[int]):
                The second point.

            Returns
            -------
            `distance` (float):
                The euclidean distance between the two points.
            """
            return np.sqrt((point_A[0] - point_B[0]) ** 2 + (point_A[1] - point_B[1]) ** 2)

        # Calculate the distance matrix
        for a in self.coordinates:
            distance_matrix.append([distance_between_points(a, b) for b in self.coordinates])

        # Return the distance matrix
        return distance_matrix
warm jackal
upper basin
#

I would like to know what's the best way to do this, in a way that is readible (user would know if the variable is a vector, or matrix, or some tensor of rank N. Also a way that if a professional developer looks at wouldn't think I'm a stupid person.

upper basin
mild quartz
#

you can use numpy and numpy types

#

or torch and torch types

#

or a generic container

#

or a union type of list, NDArray, Tensor

warm jackal
upper basin
upper basin
stark river
upper basin
#

I was doing a class for representing this, so that's why I said object.

upper basin
warm jackal
mild quartz
#

abc.MutableSequence?

warm jackal
#

The rest you can compose yourself w/type aliasing.

mild quartz
#

you probably just want a generic list

upper basin
mild quartz
#

yeah

#

you should use list

upper basin
mild quartz
#

i dont think python can do dimension

upper basin
warm jackal
mild quartz
#

I don't believe you can do that with typing

upper basin
#

Ok, so let's say I make a class for this. Is it sth I can do but shouldn't or sth that is good to do given my circumstance?

mild quartz
#

you could use pydantic

#

for this

#

and write a verifier for the length of the object

lusty veldt
upper basin
upper basin
upper basin
#

Is it a bad practice?

rugged root
mild quartz
warm jackal
#

@upper basin Here, I did your googling for you. You can do with this what you will. But this seems like you should be able to implement something that match any formal definition of a vector/matrix: https://stackoverflow.com/a/49434182

mild quartz
#

numpy.typing has NDArray

upper basin
warm jackal
mild quartz
#

He's talking about NDArray type

upper basin
mild quartz
#

its a type defined in numpy.typing

rugged root
#

Arbitrarily deep arrays that's what she said

upper basin
#

I was hoping for sth more generic.

warm jackal
#

Okay

mild quartz
#

I'm just saying that NDArray in np.typing isn't sized

upper basin
#

Yeah, sth like np.ndarray, but with syntax similar to list?

mild quartz
#

you should try what x10an14 suggested or Pydantic

upper basin
amber raptor
warm jackal
#

Tbf, a tuple is designed to be of a specific size, with a specific type variable T.

upper basin
mild quartz
#

you can define types with validators

upper basin
rugged root
#

You can feed it a JSON or what have you and it'll validate the data, making sure it conforms to the spec

mild quartz
#

This would only work at runtime though

#

I don't think the hints would work

#

like wouldn't detect wrongly sized array in your ide

upper basin
#

Well the hints are more of being a good programmer.

#

I know it doesn't affect the code.

#

Like runtime-wise.

rugged root
#

There are ways to make it do so

#

But it's... weird

#

I think they're called converters?

upper basin
#

Also, what I would REALLY hope for is to allow it to take in numpy.ndarray, or list, etc. and convert it to its own format?

crystal fox
#
BBC

Subscribe and ๐Ÿ”” to the BBC ๐Ÿ‘‰ https://bit.ly/BBCYouTubeSub
Watch the BBC first on iPlayer ๐Ÿ‘‰ https://bbc.in/iPlayer-Home http://www.bbc.co.uk/thursdays
Thursdays at 9.30pm on BBC Two
Comic actor Peter Serafinowicz (Look Around You, Hardware, Spaced) morphs into a visual cacophony of characters in this new, off-the-wall comedy sketch show on BBC ...

โ–ถ Play video
upper basin
#

Like maybe sth like :

if not isinstance(list_passed, NdArray):
    list_passed = NdArray.convert(list_passed)
#

Am I over-complicating it?

#

Like I feel I'm going on a tanget that makes everyone slap their foreheads, smh style.

mild quartz
#

Why do you need such a generic interface?

#

why not just use ndarrays

upper basin
#

Because from what I experienced, numpy has its own specific methods and syntax, and I dominantly use list, mainly because it's more generic and straightforward to use, and also feel like when users think of a list of let's say indices, they do [1, 2, 3], not np.array([1, 2, 3]).

I know it's a very flawed reasoning, but it's why I haven't really fully depended on numpy.

rugged root
#

If you're making something like this, pick one

kind wharf
rugged root
#

Trying to cover too many cases is just going to bog down your code and actually overcomplicate things

upper basin
stark river
upper basin
#

I am thinking of way too many things.

mild quartz
#

so lists will be slow

#

numpy has built in vectorization and other optimizations

upper basin
rugged root
#

Huh, hadn't heard of JAX before

upper basin
mild quartz
mild quartz
rugged root
#

Correction: My ADHD brain did not properly abosrb information about JAX because I don't have a usecase

mild quartz
#

this is why numpy exists

upper basin
#

I understand.

rugged root
#

numpy itself is super super efficient

mild quartz
#

just rewrite everything in numpy

rugged root
#

So enforcing or pushing your users to use it is only benenficial

mild quartz
#

or if you need GPUs use Jax or torch

upper basin
#

Let's see, I use padding and normalization and flattening , so in those cases numpy is better?

mild quartz
#

oh yeah

rugged root
#

Very much so

upper basin
#

So I should adopt numpy as the generic iterable/list interface?

mild quartz
#

try benchmarking L2 norm in numpy vs your own implementation

#

just use NDArray types

upper basin
mild quartz
#

exactly

#

and you get it for free in numpy

#

very optimal C implementations

upper basin
#

Ok, so I have to adopt numpy.ndarray as my generic interface, and use np.array as vector, and np.ndarray for N dimensional lists?

upper basin
#

That makes more sense. Thank you so much for that.

mild quartz
#

use the numpy typing module

upper basin
#

@rugged root @mild quartz @vocal basin thank you guys!

kind wharf
#

Any idea why JAX fails with joblib?

upper basin
mild quartz
kind wharf
# mild quartz are you trying to serialize something that is still on device?

This is what I'm doing -

# This experiment showed that more CPUs (from 2 to 6) did help speedup JAX code

from joblib import Parallel, delayed
import gym
import os
from sbx import SAC
import multiprocessing

def my_func():

    env = gym.make("Humanoid-v4")

    model = SAC("MlpPolicy", env,verbose=0)
    model.learn(total_timesteps=7e5, progress_bar=True)


Parallel(n_jobs=6)(delayed(my_func)() for i in range(6))
rugged root
#

@prisma swallow @prime coral Yo to you both

mild quartz
#

jax has its own parallelism modules

kind wharf
kind wharf
#

Oof

#

Firstly thank you for your help

kind wharf
mild quartz
#

why do you need ot use jax

#

is it that this gym lib is written in jax?

kind wharf
mild quartz
#

unfortunately you need to read and learn the docs about this

kind wharf
mild quartz
#

this library youre using should have this built in

mild quartz
#

brb standup

rugged root
#

How goes it