Commit Graph

156 Commits

Author SHA1 Message Date
Jeong YunWon
1bac582921 &str::to_string -> &str::to_owned for literals 2020-02-05 22:55:33 +09:00
Jeong YunWon
7fd92fcc71 Py_TPFLAGS_BASETYPE 2020-01-30 16:32:09 +09:00
Jeong YunWon
8c7e01b4f6 pyslot guess slot name from function name 2020-01-15 10:28:39 +09:00
Jeong YunWon
36ebb048ef cleanup bytes 2020-01-13 11:20:42 +09:00
Jeong YunWon
6bba9ff446 PyComparisonValue 2020-01-05 03:01:06 +09:00
Jeong YunWon
b1e582e138 Adapt PyReturn to PyFloat 2020-01-05 03:00:29 +09:00
Abe
765089d560 Add support for the % format code for floats.
Contributes to #1656
2020-01-03 16:14:24 -07:00
Abe
30473d3058 Add support for string formatting of floats with ":f" format code
Also adds automatic conversion of int -> float when the ":f"
format code is specified.

Fixes a f-string formatting style regression introduced in #1625.
2019-12-31 18:52:46 -07:00
Noah
deee1f7df7 Merge pull request #1644 from RustPython/coolreader18/exc-cleanup
Use PyBaseExceptionRef in places where we expect exceptions
2019-12-29 17:17:26 -05:00
Noah
97c8d11092 Make PyResult<T> = Result<T, PyBaseExceptionRef> 2019-12-27 11:22:52 -06:00
Jeong YunWon
801d01161c Refactor PyFloat cmp/op 2019-12-26 22:17:24 +09:00
Jeong YunWon
00b0a8abfe PyObject::payload_if_subclass 2019-12-25 19:11:07 +09:00
Jeong YunWon
0932d6912d refactor PyInt 2019-12-15 23:15:37 +09:00
Jeong YunWon
a7bee70685 objint::get_float_value -> objfloat::from_int_value
because objint::get_float_value is only used in objfloat
2019-12-15 23:15:37 +09:00
Adolfo Gonzalez III
256f3562c2 Changed to use existing method
Made try_to_bigint public and then used for math.ceil and math.floor
2019-12-02 11:24:18 -06:00
johan.park
bbd274a498 Improve float.fromhex module representation case
- Embrace hexadecimal without '0x', '.', 'p'
- Embrace variety of 'nan', 'inf' case
- Still overflow and near min, max, 0, 1 case isn't handled
2019-11-03 02:06:44 +09:00
Johan
40a22f217d Improve float.fromhex module of objfloat (#1552)
* Improve  float.fromhex module of objfloat

- Python float.fromhex can handle string of float and hex without `.`
  - For example '0.0', '-0.0', '0x0p0', '-0x0p0'
- Add test case mantioned

* Change unwrap to expect for error handling

* Improve error handling with pattern matching

- `expect` that can't express python vm error message changed to pattern match
- Erase duplicated test case

* Refactoring with or_else and map_err

- Use `or_else` instead of value condition and `match` statement
  - For floating-point input
- Use `map_err` instead of `match ` statement
  - For hexadecimal floating-point input without dot

* Add else condition
2019-10-31 19:54:28 +01:00
HyeockJinKim
ed8573e2a6 Modify str to float
Fix to receive a string value with '_' when creating a float value

Fixes #1527
2019-10-26 14:19:30 +09:00
ChJR
814018f7b6 Fix float.__repr__() method 2019-10-20 17:49:39 +09:00
Aviv Palivoda
37f01fd9ae Simeplify float.__round__ 2019-10-17 17:47:38 +03:00
Seo Sanghyeon
6887365092 Update lexical to 4 2019-10-15 21:40:59 +09:00
Windel Bouwman
6f624c6f95 Merge pull request #1521 from janrg/round_to_n_decimals
Implement round(number, digits) for digits != 0
2019-10-14 20:19:40 +02:00
janrg
4fd38e6220 Add test snippets, fix rounding for very small numbers 2019-10-14 17:06:07 +02:00
Noah
d42d422566 Merge pull request #1505 from youknowone/defer-new-int-clone
Defer BigInt::clone() for new_int
2019-10-13 14:27:37 -05:00
janrg
122aa96887 Fix linter errors 2019-10-13 14:09:17 +02:00
janrg
458fa3cb7b Fix formatting 2019-10-13 13:22:19 +02:00
janrg
b858ae8776 Implement round(number, digits) for digits != 0 2019-10-13 13:04:24 +02:00
Jeong YunWon
6c0f852b62 Refactor pymethod return types to be smaller as possible 2019-10-11 03:27:23 +09:00
Jeong YunWon
dc09fb7539 Defer BigInt::clone() for new_int 2019-10-11 00:40:31 +09:00
HyeockJinKim
37e85df527 Add __ne__ for float
Issue #1442
2019-10-10 03:49:13 +09:00
Jeong YunWon
2153ebbc23 Fix pow(0, exp) with negative exp to raise ZeroDivisionError 2019-10-05 00:04:31 +09:00
Noah
9ed825742c Revert " Fix argument keyword error in int/float/bool.__new__" 2019-10-02 21:33:43 -05:00
Sang-Heon Jeon
49577e0713 Merge branch 'master' into fix-int-arg 2019-10-02 15:19:01 +09:00
lntuition
a209169d9c Fix argument keyword error in float.__new__
Add FloatArgs struct to fix argument keyword error in float.__new
2019-10-02 15:13:45 +09:00
Noah
d22cac2dd8 Rename new slots to tp_new 2019-09-29 23:14:37 -05:00
coolreader18
c46b5b50bd Fix weirdness with type.__new__()/type()/metaclass.__new__() 2019-09-29 23:14:31 -05:00
Daniel Alley
32b4a9255f Allow float() to be called without an argument
closes #1421
2019-09-26 22:54:47 -04:00
Noah
00a0e455f3 Merge pull request #1387 from RustPython/coolreader18/string-hash-field
Add a hash field to PyString á la CPython, make PyString.value private
2019-09-21 17:15:17 -05:00
MinJeong Kim
6e7e6ecfce Fix the ValueError for whitespace in float()
Ignore whitespace

Fixed: #1391
2019-09-20 18:21:15 +00:00
Noah
0def37d78e Make PyString.value private 2019-09-19 17:45:48 -05:00
tsvankay
5b2158ab18 fixed __repr__ return value for -0.0 2019-09-18 01:03:29 +09:00
Aviv Palivoda
a5026eded0 Use IntoPyFloat in complex 2019-09-14 12:55:22 +03:00
Aviv Palivoda
6a6a10afa1 Use IntoPyFloat in math.rs 2019-09-14 12:50:58 +03:00
coolreader18
825ee4bc7c Fix tests/clippy 2019-08-23 17:52:38 -05:00
coolreader18
b8eba6abe3 Add the array module 2019-08-23 17:34:52 -05:00
Windel Bouwman
32634b2d53 Merge pull request #1080 from JimJeon/feature/round
Feature/round
2019-08-15 19:50:52 +02:00
Windel Bouwman
589c431c8c Merge master branch 2019-08-15 18:59:29 +02:00
Marcin Pajkowski
e65e9ff7c3 Make func_ref an &PyObjectRef 2019-08-15 13:45:47 +02:00
JimJeon
befb9a239e Add round feature for objfloat when ndigits is 0 2019-08-15 16:16:40 +09:00
Windel Bouwman
d06dec77ea Attempt to reduce the size of the pyobject.rs files by splitting out builtin types. 2019-08-14 19:08:47 +02:00