mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
This commit is contained in:
parent
842c415a9f
commit
0599130c0d
@ -1,6 +1,6 @@
|
||||
import os
|
||||
|
||||
os.system("python3 prebuild.py")
|
||||
assert os.system("python prebuild.py") == 0
|
||||
|
||||
with open("include/pocketpy/opcodes.h", "rt", encoding='utf-8') as f:
|
||||
OPCODES_TEXT = '\n' + f.read() + '\n'
|
||||
|
@ -2,6 +2,8 @@ import os
|
||||
import sys
|
||||
import shutil
|
||||
|
||||
assert os.system("python prebuild.py") == 0
|
||||
|
||||
if not os.path.exists("build"):
|
||||
os.mkdir("build")
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -12,15 +12,14 @@ class complex:
|
||||
@property
|
||||
def imag(self):
|
||||
return self._imag
|
||||
|
||||
|
||||
def conjugate(self):
|
||||
return complex(self.real, -self.imag)
|
||||
|
||||
def __repr__(self):
|
||||
s = ['(', str(self.real)]
|
||||
if self.imag >= 0:
|
||||
s.append('+')
|
||||
s.append(str(self.imag))
|
||||
s.append('-' if self.imag < 0 else '+')
|
||||
s.append(str(abs(self.imag)))
|
||||
s.append('j)')
|
||||
return ''.join(s)
|
||||
|
||||
|
@ -505,8 +505,11 @@ int utf8len(unsigned char c, bool suppress){
|
||||
}
|
||||
|
||||
SStream& SStream::operator<<(f64 val){
|
||||
if(std::isinf(val) || std::isnan(val)){
|
||||
return (*this) << std::to_string(val);
|
||||
if(std::isinf(val)){
|
||||
return (*this) << (val > 0 ? "inf" : "-inf");
|
||||
}
|
||||
if(std::isnan(val)){
|
||||
return (*this) << "nan";
|
||||
}
|
||||
char b[32];
|
||||
if(_precision == -1){
|
||||
|
@ -1,4 +1,5 @@
|
||||
from cmath import isclose, sqrt
|
||||
from cmath import isclose, sqrt, nan, inf, nanj, infj
|
||||
import math
|
||||
|
||||
assert 1+2j == complex(1, 2) == 2j+1
|
||||
|
||||
@ -25,3 +26,13 @@ assert repr(1+2j) == '(1.0+2.0j)'
|
||||
assert repr(1+0j) == '(1.0+0.0j)'
|
||||
assert repr(-1-3j) == '(-1.0-3.0j)'
|
||||
assert repr(1-3j) == '(1.0-3.0j)'
|
||||
|
||||
|
||||
assert repr(math.nan) == repr(nan) == 'nan'
|
||||
assert repr(-math.nan) == repr(-nan) == 'nan'
|
||||
assert repr(math.inf) == repr(inf) == 'inf'
|
||||
assert repr(-math.inf) == repr(-inf) == '-inf'
|
||||
assert repr(nanj) == '(0.0+nanj)', nanj
|
||||
assert repr(-nanj) == '(0.0+nanj)', -nanj
|
||||
assert repr(infj) == '(0.0+infj)', infj
|
||||
assert repr(-infj) == '(0.0-infj)', -infj
|
||||
|
Loading…
x
Reference in New Issue
Block a user