def full_dispersion(k, n, Da, Pe, S, l): b = np.clongdouble(l * np.pi) b2 = b ** 2 k2 = k**2 k4 = k2 * k2 k6 = k2 * k4 Da = np.clongdouble(Da) Da2 = Da ** 2 Da3 = Da * Da2 Da4 = Da2 * Da2 K = 1.0 + k2 / Da / np.clongdouble(Pe) K2 = K ** 2 K4 = K2 * K2 S2 = np.clongdouble(S ** 2) # upper branch su = (2.0 * n * np.sqrt(-Da4 * K4 * b2 - Da4 * K4 * k2 + Da4 * K2 * S2 * k4 - 3.0 * Da3 * K2 * S * k4 - 2.0 * Da2 * K2 * b2 * k2 - Da * S * k6 - b2 * k4) + 4.0 * Da * K * b2 * n + Da * K * k2 * n + 2.0 * Da2 * K * S * k2 * n) / (4.0 * S * Da2 * K2 * b2 + 4.0 * S * Da2 * K2 * k2 + S * k4) iu = np.imag(su) == 0.0 # lower branch sl = -(2.0 * n * np.sqrt(-Da4 * K4 * b2 - Da4 * K4 * k2 + Da4 * K2 * S2 * k4 - 3.0 * Da3 * K2 * S * k4 - 2.0 * Da2 * K2 * b2 * k2 - Da*S*k6 - b2 * k4) - K*(4 * Da * n * b2 + n * (2.0 * S * Da2 + Da) * k2)) / (S*(4 * Da2 * K2 * b2 + 4.0 * Da2 * K2 * k2 + k4)) il = np.imag(sl) == 0 s = SA_Dispersion() s.s = np.hstack([np.flip(np.real(su[iu]).astype(np.float32)), np.real(sl[il]).astype(np.float32)]) s.k = np.hstack([np.flip(np.real(k[iu]).astype(np.float32)), np.real(k[il]).astype(np.float32)]) return s
def draw_julia(Z, rect, w, h, pos, pos_m, max_itr): global size i, j = cuda.grid(2) if i + rect[0] < size[0] and j + rect[1] < size[1]: a = (rect[0] + i) * w / size[0] - w / 2 + pos[0] b = (rect[1] + j) * h / size[1] - h / 2 + pos[1] itr = iterate_julia(np.clongdouble(a + b * 1j), max_itr, np.clongdouble(pos_m[0] + pos_m[1] * 1j)) r, g, b = color(itr) Z[i + rect[0], j + rect[1], 0] = r Z[i + rect[0], j + rect[1], 1] = g Z[i + rect[0], j + rect[1], 2] = b
def test_coercion(self): def res_type(a, b): return np.add(a, b).dtype self.check_promotion_cases(res_type) # Use-case: float/complex scalar * bool/int8 array # shouldn't narrow the float/complex type for a in [np.array([True,False]), np.array([-3,12], dtype=np.int8)]: b = 1.234 * a assert_equal(b.dtype, np.dtype('f8'), "array type %s" % a.dtype) b = np.longdouble(1.234) * a assert_equal(b.dtype, np.dtype(np.longdouble), "array type %s" % a.dtype) b = np.float64(1.234) * a assert_equal(b.dtype, np.dtype('f8'), "array type %s" % a.dtype) b = np.float32(1.234) * a assert_equal(b.dtype, np.dtype('f4'), "array type %s" % a.dtype) b = np.float16(1.234) * a assert_equal(b.dtype, np.dtype('f2'), "array type %s" % a.dtype) b = 1.234j * a assert_equal(b.dtype, np.dtype('c16'), "array type %s" % a.dtype) b = np.clongdouble(1.234j) * a assert_equal(b.dtype, np.dtype(np.clongdouble), "array type %s" % a.dtype) b = np.complex128(1.234j) * a assert_equal(b.dtype, np.dtype('c16'), "array type %s" % a.dtype) b = np.complex64(1.234j) * a assert_equal(b.dtype, np.dtype('c8'), "array type %s" % a.dtype)
def test_precisions_consistent(self): z = 1 + 1j for f in self.funcs: fcf = f(np.csingle(z)) fcd = f(np.cdouble(z)) fcl = f(np.clongdouble(z)) assert_almost_equal(fcf, fcd, decimal=6, err_msg="fch-fcd %s" % f) assert_almost_equal(fcl, fcd, decimal=15, err_msg="fch-fcl %s" % f)
def test_precisions_consistent(self): z = 1 + 1j for f in self.funcs: fcf = f(np.csingle(z)) fcd = f(np.cdouble(z)) fcl = f(np.clongdouble(z)) assert_almost_equal(fcf, fcd, decimal=6, err_msg='fch-fcd %s' % f) assert_almost_equal(fcl, fcd, decimal=15, err_msg='fch-fcl %s' % f)
def test_int_from_infinite_longdouble___int__(self): x = np.longdouble(np.inf) assert_raises(OverflowError, x.__int__) with suppress_warnings() as sup: sup.record(np.ComplexWarning) x = np.clongdouble(np.inf) assert_raises(OverflowError, x.__int__) assert_equal(len(sup.log), 1)
def test_longdouble_int(self): # gh-627 x = np.longdouble(np.inf) assert_raises(OverflowError, int, x) with suppress_warnings() as sup: sup.record(np.ComplexWarning) x = np.clongdouble(np.inf) assert_raises(OverflowError, int, x) self.assertEqual(len(sup.log), 1)
def test_longdouble_int(self): # gh-627 x = np.longdouble(np.inf) assert_raises(OverflowError, int, x) with suppress_warnings() as sup: sup.record(np.ComplexWarning) x = np.clongdouble(np.inf) assert_raises(OverflowError, int, x) assert_equal(len(sup.log), 1)
def test_clongdouble_inf_loop(op): if op in {operator.mod} and False: pytest.xfail("The modulo operator is known to be broken") try: op(np.clongdouble(3), None) except TypeError: pass try: op(None, np.longdouble(3)) except TypeError: pass
def Dispersion(k, n, Da, Pe, S): k = k.astype(np.clongdouble) k2 = k * k k4 = k2 * k2 k6 = k4 * k2 n, Da, Pe, S = np.clongdouble([n, Da, Pe, S]) K = 1 + k ** 2 / Da / Pe K2 = K * K K4 = K2 * K2 Da2 = Da * Da Da3 = Da2 * Da Da4 = Da2 * Da2 b = np.clongdouble(np.pi) b2 = b * b S2 = S * S # upper branch s = (2.0 * n * np.sqrt(-Da4 * K4 * b2 - Da4 * K4 * k2 + Da4 * K2 * S2 * k4 - 3.0 * Da3 * K2 * S * k4 - 2 * Da2 * K2 * b2 * k2 - Da * S * k6 - b2 * k4) + 4.0 * Da * K * b2 * n + Da * K * k2 * n + 2 * Da2 * K * S * k2 * n) / (4 * S * Da2 * K2 * b2 + 4.0 * S * Da2 * K2 * k2 + S * k4) s[np.imag(s) != 0.0] = np.nan return np.real(s).astype(np.float32)
def test_accepts_npcomplexfloating(self): # Related to #16466 assert_array_almost_equal( mgrid[0.1:0.3:3j, ], mgrid[0.1:0.3:np.complex64(3j), ] ) # different code path for single slice assert_array_almost_equal( mgrid[0.1:0.3:3j], mgrid[0.1:0.3:np.complex64(3j)] ) # Related to #16945 grid64_a = mgrid[0.1:0.3:3.3j] grid64_b = mgrid[0.1:0.3:3.3j, ][0] assert_(grid64_a.dtype == grid64_b.dtype == np.float64) assert_array_equal(grid64_a, grid64_b) grid128_a = mgrid[0.1:0.3:np.clongdouble(3.3j)] grid128_b = mgrid[0.1:0.3:np.clongdouble(3.3j), ][0] assert_(grid128_a.dtype == grid128_b.dtype == np.longdouble) assert_array_equal(grid64_a, grid64_b)
reveal_type(np.short()) # E: {short} reveal_type(np.intc()) # E: {intc} reveal_type(np.intp()) # E: {intp} reveal_type(np.int0()) # E: {intp} reveal_type(np.int_()) # E: {int_} reveal_type(np.longlong()) # E: {longlong} reveal_type(np.ubyte()) # E: {ubyte} reveal_type(np.ushort()) # E: {ushort} reveal_type(np.uintc()) # E: {uintc} reveal_type(np.uintp()) # E: {uintp} reveal_type(np.uint0()) # E: {uintp} reveal_type(np.uint()) # E: {uint} reveal_type(np.ulonglong()) # E: {ulonglong} reveal_type(np.half()) # E: {half} reveal_type(np.single()) # E: {single} reveal_type(np.double()) # E: {double} reveal_type(np.float_()) # E: {double} reveal_type(np.longdouble()) # E: {longdouble} reveal_type(np.longfloat()) # E: {longdouble} reveal_type(np.csingle()) # E: {csingle} reveal_type(np.singlecomplex()) # E: {csingle} reveal_type(np.cdouble()) # E: {cdouble} reveal_type(np.complex_()) # E: {cdouble} reveal_type(np.cfloat()) # E: {cdouble} reveal_type(np.clongdouble()) # E: {clongdouble} reveal_type(np.clongfloat()) # E: {clongdouble} reveal_type(np.longcomplex()) # E: {clongdouble}
_cast_dict['LONG'] = _cast_dict['INT'] + ['LONG'] _cast_dict['ULONG'] = _cast_dict['UINT'] + ['ULONG'] _cast_dict['LONGLONG'] = _cast_dict['LONG'] + ['LONGLONG'] _cast_dict['ULONGLONG'] = _cast_dict['ULONG'] + ['ULONGLONG'] _cast_dict['FLOAT'] = _cast_dict['SHORT'] + ['USHORT', 'FLOAT'] _cast_dict['DOUBLE'] = _cast_dict['INT'] + ['UINT', 'FLOAT', 'DOUBLE'] _cast_dict['CFLOAT'] = _cast_dict['FLOAT'] + ['CFLOAT'] # 32 bit system malloc typically does not provide the alignment required by # 16 byte long double types this means the inout intent cannot be satisfied # and several tests fail as the alignment flag can be randomly true or fals # when numpy gains an aligned allocator the tests could be enabled again if ((intp().dtype.itemsize != 4 or clongdouble().dtype.alignment <= 8) and sys.platform != 'win32'): _type_names.extend(['LONGDOUBLE', 'CDOUBLE', 'CLONGDOUBLE']) _cast_dict['LONGDOUBLE'] = _cast_dict['LONG'] + \ ['ULONG', 'FLOAT', 'DOUBLE', 'LONGDOUBLE'] _cast_dict['CLONGDOUBLE'] = _cast_dict['LONGDOUBLE'] + \ ['CFLOAT', 'CDOUBLE', 'CLONGDOUBLE'] _cast_dict['CDOUBLE'] = _cast_dict['DOUBLE'] + ['CFLOAT', 'CDOUBLE'] class Type(object): _type_cache = {} def __new__(cls, name): if isinstance(name, dtype): dtype0 = name
_cast_dict["ULONG"] = _cast_dict["UINT"] + ["ULONG"] _cast_dict["LONGLONG"] = _cast_dict["LONG"] + ["LONGLONG"] _cast_dict["ULONGLONG"] = _cast_dict["ULONG"] + ["ULONGLONG"] _cast_dict["FLOAT"] = _cast_dict["SHORT"] + ["USHORT", "FLOAT"] _cast_dict["DOUBLE"] = _cast_dict["INT"] + ["UINT", "FLOAT", "DOUBLE"] _cast_dict["CFLOAT"] = _cast_dict["FLOAT"] + ["CFLOAT"] # 32 bit system malloc typically does not provide the alignment required by # 16 byte long double types this means the inout intent cannot be satisfied # and several tests fail as the alignment flag can be randomly true or fals # when numpy gains an aligned allocator the tests could be enabled again if (np.intp().dtype.itemsize != 4 or np.clongdouble().dtype.alignment <= 8) and sys.platform != "win32": _type_names.extend(["LONGDOUBLE", "CDOUBLE", "CLONGDOUBLE"]) _cast_dict["LONGDOUBLE"] = _cast_dict["LONG"] + [ "ULONG", "FLOAT", "DOUBLE", "LONGDOUBLE", ] _cast_dict["CLONGDOUBLE"] = _cast_dict["LONGDOUBLE"] + [ "CFLOAT", "CDOUBLE", "CLONGDOUBLE", ] _cast_dict["CDOUBLE"] = _cast_dict["DOUBLE"] + ["CFLOAT", "CDOUBLE"]
_cast_dict['LONGLONG'] = _cast_dict['LONG'] + ['LONGLONG'] _cast_dict['ULONGLONG'] = _cast_dict['ULONG'] + ['ULONGLONG'] _cast_dict['FLOAT'] = _cast_dict['SHORT'] + ['USHORT', 'FLOAT'] _cast_dict['DOUBLE'] = _cast_dict['INT'] + ['UINT', 'FLOAT', 'DOUBLE'] _cast_dict['CFLOAT'] = _cast_dict['FLOAT'] + ['CFLOAT'] # 32 bit system malloc typically does not provide the alignment required by # 16 byte long double types this means the inout intent cannot be satisfied # and several tests fail as the alignment flag can be randomly true or fals # when numpy gains an aligned allocator the tests could be enabled again # # Furthermore, on macOS ARM64, LONGDOUBLE is an alias for DOUBLE. if ((np.intp().dtype.itemsize != 4 or np.clongdouble().dtype.alignment <= 8) and sys.platform != 'win32' and (platform.system(), platform.processor()) != ('Darwin', 'arm')): _type_names.extend(['LONGDOUBLE', 'CDOUBLE', 'CLONGDOUBLE']) _cast_dict['LONGDOUBLE'] = _cast_dict['LONG'] + \ ['ULONG', 'FLOAT', 'DOUBLE', 'LONGDOUBLE'] _cast_dict['CLONGDOUBLE'] = _cast_dict['LONGDOUBLE'] + \ ['CFLOAT', 'CDOUBLE', 'CLONGDOUBLE'] _cast_dict['CDOUBLE'] = _cast_dict['DOUBLE'] + ['CFLOAT', 'CDOUBLE'] class Type: _type_cache = {} def __new__(cls, name): if isinstance(name, np.dtype):
def test_longdouble_int(self): # gh-627 x = np.longdouble(np.inf) assert_raises(OverflowError, x.__int__) x = np.clongdouble(np.inf) assert_raises(OverflowError, x.__int__)
np.short(valor) # entero corto con signo (definido por la plataforma) np.ushort(valor) # entero corto sin signo (definido por la plataforma) np.intc(valor) # entero medio con signo (definido por la plataforma) np.uintc(valor) # entero medio sin signo (definido por la plataforma) np.int_(valor) # entero largo con signo (definido por la plataforma) np.uint(valor) # entero largo sin signo (definido por la plataforma) np.longlong(valor) # entero largo largo con signo (definido por la plataforma) np.ulonglong(valor) # entero largo largo sin signo (definido por la plataforma) np.half(valor) # Flotante de precisión media (signo de 1 bit, exponente de 5 bits, mantisa de 10 bits) np.float16(valor) # Flotante de precisión media (signo de 1 bit, exponente de 5 bits, mantisa de 10 bits) np.single(valor) # Flotante de precisión simple (signo de 1 bit, exponente de 8 bits, mantisa de 23 bits) np.double(valor) # Flotante de precisión doble (signo de 1 bit, exponente de 11 bits, mantisa de 52 bits) np.longdouble(valor) # Flotante de precisión extendida (definido por la plataforma) np.csingle(valor) # Número complejo representado por dos flotantes de precisión simple (componente real e imaginario) np.cdouble(valor) # Número complejo representado por dos flotantes de precisión doble (componente real e imaginario) np.clongdouble(valor) # Número complejo representado por dos flotantes de precisión extendida (componente real e imaginario) # Tipos de datos con Alias de tamaño (se convierte el valor al tipo especificado) np.int8(valor) # entero de 1 byte con signo (-128 a 127) np.uint8(valor) # entero de 1 byte sin signo (0 a 255) np.int16(valor) # entero de 2 bytes con signo (-32768 a 32767) np.uint16(valor) # entero de 2 bytes sin signo (0 a 65535) np.int32(valor) # entero de 4 bytes con signo (-2147483648 a 2147483647) np.uint32(valor) # entero de 4 bytes sin signo (0 a 4294967295) np.int64(valor) # entero de 8 bytes con signo (-9223372036854775808 a 9223372036854775807) np.uint64(valor) # entero de 8 bytes sin signo (0 a 18446744073709551615) np.intp(valor) intptr_t # entero utilizado para indexar np.uintp(valor) uintptr_t # entero lo suficientemente grande como para contener un puntero np.float32(valor) # Flotante de precisión simple (signo de 1 bit, exponente de 8 bits, mantisa de 23 bits) np.float64(valor) # Flotante de precisión doble (signo de 1 bit, exponente de 11 bits, mantisa de 52 bits) np.float_(valor) # Flotante de precisión doble (signo de 1 bit, exponente de 11 bits, mantisa de 52 bits)
import interface import numpy as np import eight_knot_solutions arg = sys.argv; i = int(arg[1]) scale = 0.02 base = (3.00, -0.) end = (4.50 + scale, 0.4 + scale) modus = int((end[0] - base[0])/scale) parameter = np.clongdouble(base[0] + int(i%modus) * scale + base[1]*1.j + int(i/modus) * scale * 1.j) name = (np.format_float_positional(parameter.real, unique=False, precision=3, fractional=True, trim='k') + '_' + np.format_float_positional(parameter.imag, unique=False, precision=3, fractional=True, trim='k')) #print(name) path_results = 'eight_knot-results/' interf = interface.Interface(path_results) solution = eight_knot_solutions.EightKnotSolution(parameter) try: solution = eight_knot_solutions.EightKnotSolution(parameter)
np.uint() np.ulonglong() np.half() np.single() np.double() np.float_() np.longdouble() np.longfloat() np.csingle() np.singlecomplex() np.cdouble() np.complex_() np.cfloat() np.clongdouble() np.clongfloat() np.longcomplex() np.bool_().item() np.int_().item() np.uint64().item() np.float32().item() np.complex128().item() np.str_().item() np.bytes_().item() np.bool_().tolist() np.int_().tolist() np.uint64().tolist() np.float32().tolist()
def test_gentype_nonzero(self): # This exercises gentype_nonzero, and thus may point the path to # executing other gentype_* functions. z = np.clongdouble(4 + 5j) r = np.nonzero(z)
n = int(arg[1]) if len(arg) == 7: stay_parabolic = (int(arg[4]) == 1) stay_boundary = (int(arg[5]) == 1) insoluble_parabolic = (int(arg[6]) == 1) if parabolic_lagragian and n != 0: X = np.clongdouble( 4 * np.cos(np.longdouble(np.pi) / n)**2 / (-8 * np.cos(np.longdouble(np.pi) / n)**4 - 2 * np.cos(np.longdouble(np.pi) / n)**2 + 2 * np.sqrt( np.clongdouble(16 * np.cos(np.longdouble(np.pi) / n)**8 - 8 * np.cos(np.longdouble(np.pi) / n)**6 - 7 * np.cos(np.longdouble(np.pi) / n)**4 - 2 * np.cos(np.longdouble(np.pi) / n)**2 + 1)) + 2)**(1 / 3) + (-8 * np.cos(np.longdouble(np.pi) / n)**4 - 2 * np.cos(np.longdouble(np.pi) / n)**2 + 2 * np.sqrt( np.clongdouble(16 * np.cos(np.longdouble(np.pi) / n)**8 - 8 * np.cos(np.longdouble(np.pi) / n)**6 - 7 * np.cos(np.longdouble(np.pi) / n)**4 - 2 * np.cos(np.longdouble(np.pi) / n)**2 + 1)) + 2)**(1 / 3) + 1).real x = ((X * X - 1 - 8 * np.cos(np.longdouble(np.pi) / n)**2) / 2).real y = np.clongdouble( np.sqrt( 16 * np.cos(np.longdouble(np.pi) / n)**4 - 8 * np.sqrt(8 * np.cos(np.longdouble(np.pi) / n)**2 + 2 * x + 1) * np.cos(np.longdouble(np.pi) / n)**2 - x * x - 8 * np.cos(np.longdouble(np.pi) / n)**2 + 4 * np.sqrt(8 * np.cos(np.longdouble(np.pi) / n)**2 + 2 * x + 1) * x -
'float_6': np.half(1234.0), 'float_7': np.single(1234.0), 'float_8': np.double(1234.0), 'float_9': np.longdouble(1234.0), 'float_10': np.float32(1234.0), 'float_11': np.float64(1234.0), # Needs typeshed sync 'complex_1': complex(0.0j), # type: ignore # Needs typeshed sync 'complex_2': complex(0.0 + 0.0j), # type: ignore 'complex_3': 1.0j, 'complex_4': 1.0 + 1.0j, 'complex_5': 1.0 - 1.0j, 'complex_7': np.csingle(1234 + 1234j), 'complex_8': np.cdouble(1234 + 1234j), 'complex_9': np.clongdouble(1234 + 1234j), # needs newer numpy 'complex_10': np.complex64(1234 + 1234j), # type: ignore # needs newer numpy 'complex_11': np.complex128(1234 + 1234j), # type: ignore 'bool_1': False, 'bool_2': True, 'bool_3': np.bool_(False), 'bool_4': np.bool_(True), 'seq-str_1': [], 'seq-str_2': ['0'], 'seq-str_3': ['0, 1', 'abc', '@#!$^%&(#'], 'seq-str_4': ['A'] * 10, 'seq-int_1': [], 'seq-int_2': [0], 'seq-int_3': [0, 1,
class TestNumpy: @staticmethod def test_get_numpy() -> None: """ Test get_numpy when module is present """ # Arrange # Act result = Numpy.get_numpy() # Assert assert result is np @staticmethod def test_get_numpy_missing(mocker: MockFixture) -> None: """ Test get_numpy when module is missing """ # Arrange mocker.patch.dict("sys.modules", {"numpy": None}) # Act result = Numpy.get_numpy() # Assert assert result is None @staticmethod def test_get_numpy_missing_error(mocker: MockFixture) -> None: """ Test get_numpy when module is missing raises error """ # Arrange mocker.patch.dict("sys.modules", {"numpy": None}) # Act / assert with pytest.raises(ImportError, match="foo"): Numpy.get_numpy(raise_error=True, custom_error_message="foo") @staticmethod @pytest.mark.parametrize("value, expected", [(np.array([1, 2, 3]), True), ([1, 2, 3], False)]) def test_is_numpy_object(value, expected) -> None: """ Test is_numpy_object """ # Arrange # Act result = Numpy.is_numpy_object(value) # Assert assert result == expected @staticmethod def test_get_numpy_primatives() -> None: """ Test _get_numpy_primatives """ # Arrange # Act result = Numpy._get_numpy_primatives(np) # Assert assert len(result) == 33 # Expected number of types for thing in result: assert "numpy" in getattr(thing, "__module__", "").split( ".") # Check that type is from numpy assert type(thing) is type # Check that each type is a type @staticmethod def test_encode_numpy_error(): """ Test that the encode_numpy raises an error if no encoding is defined. """ # Arrange value = "not a numpy" # Act & Assert with pytest.raises(NotImplementedError): Numpy.encode_numpy(value) @staticmethod @pytest.mark.parametrize( "value, expected", [ # fmt: off (np.array([['balloons'], ['are'], ['awesome'] ]), [['balloons'], ['are'], ['awesome']]), (np.bool_(1), True), (np.byte(4), 4), (np.ubyte(4), 4), (np.short(4), 4), (np.ushort(4), 4), (np.intc(4), 4), (np.uintc(4), 4), (np.int_(4), 4), (np.uint(4), 4), (np.longlong(4), 4), (np.ulonglong(4), 4), (np.float16(4), 4), (np.single(4), 4), (np.double(4), 4), (np.longdouble(4), 4), (np.csingle(4), 4), (np.cdouble(4), 4), (np.clongdouble(4), 4), (np.int8(4), 4), (np.int16(4), 4), (np.int32(4), 4), (np.int64(4), 4), (np.uint8(4), 4), (np.uint16(4), 4), (np.uint32(4), 4), (np.uint64(4), 4), (np.intp(4), 4), (np.uintp(4), 4), (np.float32(4), 4), (np.float64(4), 4), (np.complex64(4), 4 + 0j), (np.complex128(4), 4 + 0j), (np.complex_(4), 4 + 0j), # fmt: on ], ) def test_encode_numpy(value, expected) -> None: """ Test encode_numpy """ # Arrange # Act result = Numpy.encode_numpy(value) # Assert assert result == expected
def test_table_typing_numpy(): # Pulled from https://numpy.org/devdocs/user/basics.types.html # Numerics table = wandb.Table(columns=["A"], dtype=[NumberType]) table.add_data(None) table.add_data(42) table.add_data(np.byte(1)) table.add_data(np.short(42)) table.add_data(np.ushort(42)) table.add_data(np.intc(42)) table.add_data(np.uintc(42)) table.add_data(np.int_(42)) table.add_data(np.uint(42)) table.add_data(np.longlong(42)) table.add_data(np.ulonglong(42)) table.add_data(np.half(42)) table.add_data(np.float16(42)) table.add_data(np.single(42)) table.add_data(np.double(42)) table.add_data(np.longdouble(42)) table.add_data(np.csingle(42)) table.add_data(np.cdouble(42)) table.add_data(np.clongdouble(42)) table.add_data(np.int8(42)) table.add_data(np.int16(42)) table.add_data(np.int32(42)) table.add_data(np.int64(42)) table.add_data(np.uint8(42)) table.add_data(np.uint16(42)) table.add_data(np.uint32(42)) table.add_data(np.uint64(42)) table.add_data(np.intp(42)) table.add_data(np.uintp(42)) table.add_data(np.float32(42)) table.add_data(np.float64(42)) table.add_data(np.float_(42)) table.add_data(np.complex64(42)) table.add_data(np.complex128(42)) table.add_data(np.complex_(42)) # Booleans table = wandb.Table(columns=["A"], dtype=[BooleanType]) table.add_data(None) table.add_data(True) table.add_data(False) table.add_data(np.bool_(True)) # Array of Numerics table = wandb.Table(columns=["A"], dtype=[[NumberType]]) table.add_data(None) table.add_data([42]) table.add_data(np.array([1, 0], dtype=np.byte)) table.add_data(np.array([42, 42], dtype=np.short)) table.add_data(np.array([42, 42], dtype=np.ushort)) table.add_data(np.array([42, 42], dtype=np.intc)) table.add_data(np.array([42, 42], dtype=np.uintc)) table.add_data(np.array([42, 42], dtype=np.int_)) table.add_data(np.array([42, 42], dtype=np.uint)) table.add_data(np.array([42, 42], dtype=np.longlong)) table.add_data(np.array([42, 42], dtype=np.ulonglong)) table.add_data(np.array([42, 42], dtype=np.half)) table.add_data(np.array([42, 42], dtype=np.float16)) table.add_data(np.array([42, 42], dtype=np.single)) table.add_data(np.array([42, 42], dtype=np.double)) table.add_data(np.array([42, 42], dtype=np.longdouble)) table.add_data(np.array([42, 42], dtype=np.csingle)) table.add_data(np.array([42, 42], dtype=np.cdouble)) table.add_data(np.array([42, 42], dtype=np.clongdouble)) table.add_data(np.array([42, 42], dtype=np.int8)) table.add_data(np.array([42, 42], dtype=np.int16)) table.add_data(np.array([42, 42], dtype=np.int32)) table.add_data(np.array([42, 42], dtype=np.int64)) table.add_data(np.array([42, 42], dtype=np.uint8)) table.add_data(np.array([42, 42], dtype=np.uint16)) table.add_data(np.array([42, 42], dtype=np.uint32)) table.add_data(np.array([42, 42], dtype=np.uint64)) table.add_data(np.array([42, 42], dtype=np.intp)) table.add_data(np.array([42, 42], dtype=np.uintp)) table.add_data(np.array([42, 42], dtype=np.float32)) table.add_data(np.array([42, 42], dtype=np.float64)) table.add_data(np.array([42, 42], dtype=np.float_)) table.add_data(np.array([42, 42], dtype=np.complex64)) table.add_data(np.array([42, 42], dtype=np.complex128)) table.add_data(np.array([42, 42], dtype=np.complex_)) # Array of Booleans table = wandb.Table(columns=["A"], dtype=[[BooleanType]]) table.add_data(None) table.add_data([True]) table.add_data([False]) table.add_data(np.array([True, False], dtype=np.bool_)) # Nested arrays table = wandb.Table(columns=["A"]) table.add_data([[[[1, 2, 3]]]]) table.add_data(np.array([[[[1, 2, 3]]]]))
reveal_type(np.short()) # E: numpy.signedinteger[numpy.typing._ reveal_type(np.intc()) # E: numpy.signedinteger[numpy.typing._ reveal_type(np.intp()) # E: numpy.signedinteger[numpy.typing._ reveal_type(np.int0()) # E: numpy.signedinteger[numpy.typing._ reveal_type(np.int_()) # E: numpy.signedinteger[numpy.typing._ reveal_type(np.longlong()) # E: numpy.signedinteger[numpy.typing._ reveal_type(np.ubyte()) # E: numpy.unsignedinteger[numpy.typing._ reveal_type(np.ushort()) # E: numpy.unsignedinteger[numpy.typing._ reveal_type(np.uintc()) # E: numpy.unsignedinteger[numpy.typing._ reveal_type(np.uintp()) # E: numpy.unsignedinteger[numpy.typing._ reveal_type(np.uint0()) # E: numpy.unsignedinteger[numpy.typing._ reveal_type(np.uint()) # E: numpy.unsignedinteger[numpy.typing._ reveal_type(np.ulonglong()) # E: numpy.unsignedinteger[numpy.typing._ reveal_type(np.half()) # E: numpy.floating[numpy.typing._ reveal_type(np.single()) # E: numpy.floating[numpy.typing._ reveal_type(np.double()) # E: numpy.floating[numpy.typing._ reveal_type(np.float_()) # E: numpy.floating[numpy.typing._ reveal_type(np.longdouble()) # E: numpy.floating[numpy.typing._ reveal_type(np.longfloat()) # E: numpy.floating[numpy.typing._ reveal_type(np.csingle()) # E: numpy.complexfloating[numpy.typing._ reveal_type(np.singlecomplex()) # E: numpy.complexfloating[numpy.typing._ reveal_type(np.cdouble()) # E: numpy.complexfloating[numpy.typing._ reveal_type(np.complex_()) # E: numpy.complexfloating[numpy.typing._ reveal_type(np.cfloat()) # E: numpy.complexfloating[numpy.typing._ reveal_type(np.clongdouble()) # E: numpy.complexfloating[numpy.typing._ reveal_type(np.clongfloat()) # E: numpy.complexfloating[numpy.typing._ reveal_type(np.longcomplex()) # E: numpy.complexfloating[numpy.typing._
def run(self): while self.isRunning(): self.mutex.lock() devicePixelRatio = self.devicePixelRatio resultSize = self.resultSize * devicePixelRatio requestedScaleFactor = self.scaleFactor scaleFactor = requestedScaleFactor / devicePixelRatio centerX = self.centerX centerY = self.centerY self.mutex.unlock() halfWidth = resultSize.width() // 2 halfHeight = resultSize.height() // 2 image = QImage(resultSize, QImage.Format_RGB32) image.setDevicePixelRatio(devicePixelRatio) NumPasses = 8 curpass = 0 while curpass < NumPasses: Limit = int(BailoutRadius) allBlack = True for y in range(-halfHeight, halfHeight): if self.restart: break if self.abort: return ay = (centerY + (y * scaleFactor)) ayy = 1j * (centerY + (y * scaleFactor)) for x in range(-halfWidth, halfWidth): c0 = centerX + (x * scaleFactor) + ayy c = complex(Decimal(StartRe), Decimal(StartIm)) ax = centerX + (x * scaleFactor) a1 = ax b1 = ay if PrecisionVal == "Single": c = np.complex64(c) c0 = np.complex64(c0) elif PrecisionVal == "Double": c = np.complex128(c) c0 = np.complex128(c0) elif PrecisionVal == "Triple": c = np.clongdouble(c) c0 = np.clongdouble(c0) elif PrecisionVal == "Quadruple": c = np.complex256(c) c0 = np.complex256(c0) elif PrecisionVal == "Multiple": c = mp.mpc(c) c0 = mp.mpc(c0) # print(c0) numIterations = 0 while numIterations < int(MaxIterations): numIterations += 1 if fractalType == "Mandelbrot": c = pow(c, float(PowerRe)) + c0 if abs(c) > Limit: break elif fractalType == "Fast Mandelbrot": a2 = (a1 * a1) - (b1 * b1) + ax b2 = (a1 * b1 * 2) + ay if (a2 * a2) + (b2 * b2) > Limit * 2: break numIterations += 1 a1 = (a2 * a2) - (b2 * b2) + ax b1 = (a2 * b2 * 2) + ay if (a1 * a1) + (b1 * b1) > Limit * 2: break elif fractalType == "Tricorn / Mandelbar": if not IsInverse: c = np.conj(pow(c, float(PowerRe))) + c0 else: c = np.conj(pow(c, float(PowerRe))) + 1 / c0 if abs(c) >= Limit: break elif fractalType == "Burning Ship": if not IsInverse: c = pow((abs(c.real) + abs(c.imag) * 1j), float(PowerRe)) + c0 else: c = pow((abs(c.real) + abs(c.imag) * 1j), float(PowerRe)) + 1 / c0 if abs(c) >= Limit: break elif fractalType == "MandelShip": if not IsInverse: c = pow(c, float(PowerRe)) + c0 if abs(c) >= Limit: break numIterations += 1 c = pow((abs(c.real) + abs(c.imag) * 1j), float(PowerRe)) + c0 if abs(c) >= Limit: break numIterations += 1 c = pow(c, float(PowerRe)) + c0 if abs(c) >= Limit: break numIterations += 1 c = pow(c, float(PowerRe)) + c0 if abs(c) >= Limit: break else: c = pow(c, float(PowerRe)) + 1 / c0 if abs(c) >= Limit: break numIterations += 1 c = pow((abs(c.real) + abs(c.imag) * 1j), float(PowerRe)) + 1 / c0 if abs(c) >= Limit: break numIterations += 1 c = pow(c, float(PowerRe)) + 1 / c0 if abs(c) >= Limit: break numIterations += 1 c = pow(c, float(PowerRe)) + 1 / c0 if abs(c) >= Limit: break elif fractalType == "Perpendicular Mandelbrot": c = pow((abs(c.real) - c.imag * 1j), float(PowerRe)) + c0 if abs(c) >= Limit: break elif fractalType == "Perpendicular Burning Ship": c = pow((c.real + abs(c.imag) * 1j), float(PowerRe)) + c0 if abs(c) >= Limit: break elif fractalType == "Perpendicular Celtic": a2 = abs((a1 * a1) - (b1 * b1)) + ax b2 = abs(a1) * b1 * -2 + ay if (a2 * a2) + (b2 * b2) > Limit * 2: break numIterations += 1 a1 = abs((a2 * a2) - (b2 * b2)) + ax b1 = abs(a2) * b2 * -2 + ay if (a1 * a1) + (b1 * b1) > Limit * 2: break elif fractalType == "Perpendicular Buffalo": a1sqr = a1 * a1 b1sqr = b1 * b1 a2sqr = a2 * a2 b2sqr = b2 * b2 a2 = abs(a1sqr - b1sqr) + ax b2 = a1 * abs(b1) * -2 + ay if (a1 * a1) + (b1 * b1) > Limit * 2: break numIterations += 1 a1 = abs(a2sqr - b2sqr) + ax b1 = a2 * abs(b2) * -2 + ay if (a2 * a2) + (b2 * b2) > Limit * 2: break elif fractalType == "Mandelbrot Heart": c = pow((abs(c.real) + c.imag * 1j), float(PowerRe)) + c0 if abs(c) >= Limit: break elif fractalType == "Buffalo": c = pow(((abs(c.real) + abs(c.imag) * 1j) + c0 / 2), float(PowerRe)) + pow( c0 / 2 + (abs(c.real) + abs(c.imag) * 1j), float(PowerRe)) if abs(c) >= Limit: break elif fractalType == "Celtic Mandelbrot": c = pow( ((abs(c.real) + c.imag * 1j) + c0 / 2), float(PowerRe)) + pow( c0 / 2 + (abs(c.real) + c.imag * 1j), float(PowerRe)) if abs(c) >= Limit: break elif fractalType == "Celtic Mandelbar": c = pow( ((abs(c.real) - c.imag * 1j) + c0 / 2), float(PowerRe)) + pow( c0 / 2 + (abs(c.real) - c.imag * 1j), float(PowerRe)) if abs(c) >= Limit: break elif fractalType == "Celtic Heart": a2 = abs((a1 * a1) - (b1 * b1)) + ax b2 = abs(a1) * b1 * 2 + ay if (a2 * a2) + (b2 * b2) > Limit * 2: break numIterations += 1 a1 = abs((a2 * a2) - (b2 * b2)) + ax b1 = abs(a2) * b2 * 2 + ay if (a1 * a1) + (b1 * b1) > Limit * 2: break elif fractalType == "Ultra Hybrid": # Mandelbrot c = pow(c, float(PowerRe)) + c0 if abs(c) >= Limit: break numIterations += 1 # Burning Ship c = pow( abs(c.real) + 1j * abs(c.imag), float(PowerRe)) + c0 if abs(c) >= Limit: break numIterations += 1 # Tricorn / Mandelbar c = pow(np.conj(c), float(PowerRe)) + c0 if abs(c) >= Limit: break numIterations += 1 # Perpendicular Mandelbrot c = pow((abs(c.real) - c.imag * 1j), float(PowerRe)) + c0 if abs(c) >= Limit: break # Perpendicular Burning Ship numIterations += 1 c = pow((c.real + abs(c.imag) * 1j), float(PowerRe)) + c0 if abs(c) >= Limit: break numIterations += 1 elif fractalType == "Psuedo Mandelbrot": # Basically the mandelbrot except using irrational power values can result in a different mandelbrot. c = c0 - pow(c, float(PowerRe)) if abs(c) >= Limit: break # Does not work, need a suggestion from contributors. #elif fractalType == "Custom": # def custom(c, c0, Limit): # c = c+c0 # if abs(c) >= Limit: # return 0 # return c # custom(c*c, c0, Limit) if numIterations < int(MaxIterations): image.setPixel( x + halfWidth, y + halfHeight, self.colormap[numIterations % RenderThread.ColormapSize]) allBlack = False else: image.setPixel(x + halfWidth, y + halfHeight, qRgb(0, 0, 0)) if allBlack and curpass == 0: curpass = 4 else: if not self.restart: self.renderedImage.emit( image, np.float128(requestedScaleFactor)) curpass += 1 self.mutex.lock() if not self.restart: self.condition.wait(self.mutex) self.restart = False self.mutex.unlock()
def test_gentype_nonzero( self ): # This exercises gentype_nonzero, and thus may point the path to # executing other gentype_* functions. z = np.clongdouble( 4 + 5j ) r = np.nonzero( z )