473,403 Members | 2,293 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,403 software developers and data experts.

float() takes at most 1 argument (2 given)

1
Expand|Select|Wrap|Line Numbers
  1. def make_square(im, min_size=0, fill_color=(206, 150, 106, 0)):
  2.     x, y = im.size
  3.     size = max(min_size, x, y)
  4.     new_im = Image.new('RGB', (size, size), fill_color)
  5.     new_im.paste(im, (float((size - x) / 2, (size - y) / 2)))
  6.     return new_im
  7.  
  8. then i got error :
  9. TypeError                                 Traceback (most recent call last)
  10. <ipython-input-15-d7020999e20a> in <module>()
  11.      11     size = (30, 30)
  12.      12 
  13. ---> 13     img = make_square(img)
  14.      14     img = img.resize(size, Image.ANTIALIAS)
  15.      15     matrix = np.array(img)
  16.  
  17. <ipython-input-14-8407033de8d8> in make_square(im, min_size, fill_color)
  18.       3         size = max(min_size, x, y)
  19.       4         new_im = Image.new('RGB', (size, size), fill_color)
  20. ----> 5         new_im.paste(im, (float((size - x) / 2, (size - y) / 2)))
  21.       6         return new_im
  22.  
TypeError: float() takes at most 1 argument (2 given)

help me please..
Feb 13 '18 #1
1 6969
dwblas
626 Expert 512MB
The error message is clear. float() converts one thing at a time. If you don't understand what is wrong, then do the arithmetic on the line(s) before calling float and send it one value.
Feb 13 '18 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Sybren Stuvel | last post by:
Hi all, I'm trying to make a float-like class (preferably a subclass of 'float') that wraps around. The background: I'm modeling a multi-dimensional space, and some of those dimensions are...
8
by: Russ | last post by:
Does it ever make sense to derive a class from a basic type such as float or int? Suppose, for example, that I want to create a class for physical scalars with units. I thought about deriving from...
2
by: Joris De Groote | last post by:
Hi I am busy trying to create a VB.NET program. I want to give the program an argument in the shortcut I created for that program (for example: program.exe argument). Now I just can't find how...
6
by: Martijn Mulder | last post by:
System.Drawing.Drawing2D.Matrix comes in two flavors, int and float. When doing graphics, you will you use float. Type double would be better, since it is, when well applied, simply more acurate...
116
by: Dilip | last post by:
Recently in our code, I ran into a situation where were stuffing a float inside a double. The precision was extended automatically because of that. To make a long story short, this caused...
30
by: Angel Tsankov | last post by:
Hello! Does the C++ standard define what happens when the size argument of void* operator new(size_t size) cannot represent the total number of bytes to be allocated? For example: struct S {...
6
by: Author | last post by:
I have class BaseClass { public BaseClass(string s1, string s2) { this.S1 = s1; this.S2 = s2; } public string S1 { get; set;}
3
by: jackie123 | last post by:
def money(coinPrice): import urllib connection = urllib.urlopen("http://www.usagold.com/gold/price.html") rate = connection.read() connection.close() currentLoc = rate.find(">...
3
by: morgiejude | last post by:
I understand that when a function takes an argument, there is an argument called to the function, which it then manipulated by/put through the function. I do not really understand what it means if a...
1
by: Mansi01 | last post by:
I need to know the conditions to write a if-else statement for a prime number
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.