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!
#๐ Depreciation Error
60 messages ยท Page 1 of 1 (latest)
@spice quarry
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.
Closes after a period of inactivity, or when you send !close.
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
it is a warning, not an error
It means that in later python version, it will not work anymore
oh ok
is there a better way of setting up my code that it will run in later versions?
r and c are integers ?
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
i dont know if i can copy and paste because im on a vertial machine, but i can take a screenshot?
try to copy paste, it's easier to use
but yeah if it is not working go for a screenshot
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))
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!')```
what do you think np.all returns ?
'''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))
''
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
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
ohhhhhh ok i think i was overthinking it 'cause thats what i was doing before
!e
import numpy as np
x = np.array([[1, 2], [3, 1], [1, 4]])
print(x.shape[0], x.shape[1])
:white_check_mark: Your 3.14 eval job has completed with return code 0.
3 2
if i did that do you think the warning would still happen? like is the warning from np.all or something else?
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
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
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
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
!code
for formatting
and, the good thing with programming, is that you can test your ideas pretty quickly, so give it a go
is this okay though, or am i doubling up my arguments/parameters a bit?
sorry im really tired today so logic aint logicing atm
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
okie
also: test it, that's how you learn. trial and errors
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!!
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.