473,411 Members | 1,880 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Numeric + wxPython, can't understand a bug...

Hi, folks,

This probably has to do with Numeric and not with wxPython, but I
mention both for completeness.

My OS: Win2000
Python: 2.3.4
wx: 2.6.1.0, Unicode version
Numeric: 23.8
Here's the minimal code:
================================================

height = 50
width = 60
L = []
for y in range(height):
for x in range(width):
L.append(wx.Point(3+(2*x+y%2)*4, 3+7*y))
print width, height, len(L)
pos = reshape(array(L), (height, width))

And here's the output:
================================================

60 50 3000

pos = reshape(array(L), (height, width))
ValueError: total size of new array must be unchanged

I've used exactly this approach to create 2D arrays from lists of
numbers, with no problems. Why does this fail with wx.Point objects?
Why is it telling me that I'm changing the array size, when the
dimensions indicate that I am NOT? Typecasting the array as
containing PyObject items does not change the error message...

Thanks for any advice!

+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Ladasky Home Solar, Inc.: blowing sunshine up your |
| power grid since March 24, 2005. Fiat lux! |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Uptime Downtime kWh generated kWh consumed |
| 744 days 13 hours 12886 14321 |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+

Apr 28 '07 #1
2 1987
John Ladasky wrote:
Hi, folks,

This probably has to do with Numeric and not with wxPython, but I
mention both for completeness.

My OS: Win2000
Python: 2.3.4
wx: 2.6.1.0, Unicode version
Numeric: 23.8
Here's the minimal code:
================================================

height = 50
width = 60
L = []
for y in range(height):
for x in range(width):
L.append(wx.Point(3+(2*x+y%2)*4, 3+7*y))
print width, height, len(L)
pos = reshape(array(L), (height, width))

And here's the output:
================================================

60 50 3000

pos = reshape(array(L), (height, width))
ValueError: total size of new array must be unchanged

I've used exactly this approach to create 2D arrays from lists of
numbers, with no problems. Why does this fail with wx.Point objects?
Why is it telling me that I'm changing the array size, when the
dimensions indicate that I am NOT? Typecasting the array as
containing PyObject items does not change the error message...
wx.Point objects are being recognized as sequences by array(). Consequently,
reshape() thinks you are trying to reshape a (height*width, 2) array into a
(height, width) array. You might want to create an empty (height, width)
PyObject array first, and simply assign wx.Point values into it. That bypasses
array()'s attempt at intuiting the structure of the list.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Apr 28 '07 #2
On Apr 27, 9:40 pm, Robert Kern <robert.k...@gmail.comwrote:
wx.Point objects are being recognized as sequences by array(). Consequently,
reshape() thinks you are trying to reshape a (height*width, 2) array into a
(height, width) array. You might want to create an empty (height, width)
PyObject array first, and simply assign wx.Point values into it. That bypasses
array()'s attempt at intuiting the structure of the list.
Thanks for the heads-up, Robert. I did as you suggested, and it works
fine. I'll need to read more about Numeric's array init procedure --
what it does it not immediately obvious to a newcomer.

+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Ladasky Home Solar, Inc.: blowing sunshine up your |
| power grid since March 24, 2005. Fiat lux! |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Uptime Downtime kWh generated kWh consumed |
| 744 days 13 hours 12886 14321 |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+

Apr 28 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: wang xiaoyu | last post by:
Hello: i want use activex in wxpython program,but when i use MakeActiveXClass an exception occurs. this is my source code dealing the DICOM ocx.I must note that in this program "hwtxcontrol" is...
3
by: Robert | last post by:
Hello list, could somebody point me to a good reference about wxPython event handling? I have seen many examples but which one is the best. Waht are the advantages and disadvantages? Can you...
19
by: Grant Edwards | last post by:
I've decided to learn wxPython, and I'm afraid I just don't grok the whole "id" thing where you have to pull unique integers out of your, er, the air and then use those to refer to objects: ...
15
by: Grant Edwards | last post by:
Can anybody recommend a good book on wxPython? Are there any books on wxPython? I've been trying to learn wxPython and/or wax for a few weeks, and I'm just not getting it. wxWindows seems...
25
by: BJörn Lindqvist | last post by:
See: http://www.wxpython.org/quotes.php. especially: "wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard...
22
by: Glurt Wuntal | last post by:
I am a newbie with Python. It's a great language, but I would like to be able to present a simple gui menu for some of my scripts; something better than using 'raw_input' prompts. Any...
25
by: Daniel Jonsson | last post by:
So, I've reached the point where my building pipeline tools actually needs to be used by other people in my company. By this reason I actually need to think about the usability, and I've come to...
5
by: Che M | last post by:
Hello, I'm curious if it is easy to get panels on your wxPython apps to have backgrounds which are given by a jpg or other bitmap. I found...
4
by: stef | last post by:
hello, I'm trying to move from Delphi to Python (move from MatLab to Python already succeeded, also thanks to this discussion group). From the discussions in this list about "the best" GUI for...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.