#๐Ÿ”’ Depreciation Error

60 messages ยท Page 1 of 1 (latest)

spice quarry
#

Hey! sorry i just dont really know what it means by this?
sorry i havent given any context btw - i'm allowed to ask for help on errors and astuff but i cant have people directly telling me what to code; ill try and give as much context as possible
I've got a colormap what is stored as an array of different values. Ive set up np.all() commands to scan each row (axis=1) then column (axis-0) as r and c in for loops respectively. i want a particular event ot occur when the colormap/array value is 0 or 11
I know its hard without context, but any help you could give me would be fantastic!

vivid hemlockBOT
#

@spice quarry

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

spice quarry
#

thing is my code still runs - i can go aspt that point which makes me think i can just try/except it, but i wouldnt even know what im looking for

humble blade
#

it is a warning, not an error

#

It means that in later python version, it will not work anymore

spice quarry
#

oh ok

#

is there a better way of setting up my code that it will run in later versions?

humble blade
#

likely yes, what is emo_world ?

#

is it a 2d array?

spice quarry
#

it's the array for the colormap

#

yeah - 20x30

humble blade
#

r and c are integers ?

spice quarry
#

im not really sure waht id call them? sorry im still new to python
its basically:
for row (r) in np.all etc:
fpr col (c)

#

the iteration thing

humble blade
#

can you show the code

#

like, copy and paste the relevant part

spice quarry
#

i dont know if i can copy and paste because im on a vertial machine, but i can take a screenshot?

humble blade
#

try to copy paste, it's easier to use

#

but yeah if it is not working go for a screenshot

spice quarry
#

wait is there a way i can paste as code? or do you mind it just being in txt form

#

global blocked list for character and peeps

global_blocked = []
for r in np.all(emo_world, axis=1):
for c in np.all(emo_world, axis=0):
if emo_world[r,c] == 0 or emo_world[r,c] == 8:
Global_blocked.append((r,c))

vivid hemlockBOT
#

Hey @spice quarry!

Please edit your message to use a code block

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

This will result in the following:

print('Hello, world!')```
humble blade
#

what do you think np.all returns ?

spice quarry
#

'''py

global blocked list for character and peeps

global_blocked = []
for r in np.all(emo_world, axis=1):
for c in np.all(emo_world, axis=0):
if emo_world[r,c] == 0 or emo_world[r,c] == 8:
Global_blocked.append((r,c))
''

humble blade
#

you need backticks

#

`

spice quarry
# humble blade what do you think np.all returns ?

im ont entirely sure.. its my first time using np.all specifically. i was trying to iteract accross each row and then each column, but i couldnt work out how to do it with slicing without having some logic/rutime error

humble blade
#

np.all is like the all function, it's a boolean thing

#

if you want to iterate over the dimensions, use a range and the shape attribute of arrays

spice quarry
#

ohhhhhh ok i think i was overthinking it 'cause thats what i was doing before

humble blade
#

!e

import numpy as np
x = np.array([[1, 2], [3, 1], [1, 4]])
print(x.shape[0], x.shape[1])
vivid hemlockBOT
spice quarry
#

if i did that do you think the warning would still happen? like is the warning from np.all or something else?

humble blade
#

look

#

the warning happens because iterating over np.all(...) got you arrays, and not integers

#

so c and r were arrays

#

so emo_world[r,c] was an array

spice quarry
#

ahh ok becuase it's two different data types, so it was getting confused

#

'cause it cant do what i was telling it to do

humble blade
#

so emo_world[r, c] == 0 was an array, and python do not like to test a condition on a array

#

if emo_world[r, c] == 0:, python accepts it for now (but probably like not how you think it does), but it will not accept later

#

so yes, you need to iterate over a range of the array's shape

spice quarry
#

ok so could i do it like (soryr i have no idea how to do that cool python cell so bare with me here)

for r in emo_world[:, range(y)]:
for c in emo_world[range(x), ;]
if emo_world[r, c] == 0:
<do stuff>

its just those frst two lines im getting stuck on becuase i feel like im almost doubling up my arguments

humble blade
#

!code

vivid hemlockBOT
#
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.

humble blade
#

for formatting

#

and, the good thing with programming, is that you can test your ideas pretty quickly, so give it a go

spice quarry
humble blade
#

I don't want to give you to many hints

#

but I suggest you take some time to read what you have written

#

and to consider what can be the values of r and c

spice quarry
#

okie

humble blade
#

also: test it, that's how you learn. trial and errors

spice quarry
#

thank you so much for your help!!

#

thank you, you've genuinely been such a help that's cleared up so much

#

have a good day!!

humble blade
#

no problem

#

you too

vivid hemlockBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.