|
| 1 | +"""Julia wrappers initialized by PythonCall.""" |
| 2 | + |
| 3 | +from juliacall import JlBase |
| 4 | + |
| 5 | +# Populated by Julia during initialization. |
| 6 | +_jl_methods = {} |
| 7 | + |
| 8 | + |
| 9 | +class JlBase2(JlBase): |
| 10 | + __module__ = "juliacall" |
| 11 | + __slots__ = () |
| 12 | + def __repr__(self): |
| 13 | + t = type(self) |
| 14 | + if t is Jl: |
| 15 | + name = "Julia" |
| 16 | + else: |
| 17 | + name = t.__name__ |
| 18 | + return name + ":" + self._jl_callmethod(_jl_methods["__repr__"]) |
| 19 | +class JlIter(JlBase2): |
| 20 | + __module__ = "juliacall" |
| 21 | + __slots__ = () |
| 22 | + def __iter__(self): |
| 23 | + return self |
| 24 | + def __hash__(self): |
| 25 | + return self._jl_callmethod(_jl_methods["__hash__"]) |
| 26 | + def __next__(self): |
| 27 | + return self._jl_callmethod(_jl_methods["iterator_next"]) |
| 28 | +class Jl(JlBase2): |
| 29 | + __module__ = "juliacall" |
| 30 | + __slots__ = () |
| 31 | + def __str__(self): |
| 32 | + return self._jl_callmethod(_jl_methods["__str__"]) |
| 33 | + def __getattr__(self, k): |
| 34 | + if k.startswith("__") and k.endswith("__"): |
| 35 | + raise AttributeError(k) |
| 36 | + else: |
| 37 | + return self._jl_callmethod(_jl_methods["__getattr__"], k) |
| 38 | + def __setattr__(self, k, v): |
| 39 | + try: |
| 40 | + JlBase.__setattr__(self, k, v) |
| 41 | + except AttributeError: |
| 42 | + if k.startswith("__") and k.endswith("__"): |
| 43 | + raise |
| 44 | + else: |
| 45 | + return |
| 46 | + self._jl_callmethod(_jl_methods["__setattr__"], k, v) |
| 47 | + def __dir__(self): |
| 48 | + return JlBase.__dir__(self) + self._jl_callmethod(_jl_methods["__dir__"]) |
| 49 | + def __call__(self, *args, **kwargs): |
| 50 | + return self._jl_callmethod(_jl_methods["__call__"], args, kwargs) |
| 51 | + def __bool__(self): |
| 52 | + return self._jl_callmethod(_jl_methods["__bool__"]) |
| 53 | + def __len__(self): |
| 54 | + return self._jl_callmethod(_jl_methods["__len__"]) |
| 55 | + def __getitem__(self, k): |
| 56 | + return self._jl_callmethod(_jl_methods["__getitem__"], k) |
| 57 | + def __setitem__(self, k, v): |
| 58 | + self._jl_callmethod(_jl_methods["__setitem__"], k, v) |
| 59 | + def __delitem__(self, k): |
| 60 | + self._jl_callmethod(_jl_methods["__delitem__"], k) |
| 61 | + def __iter__(self): |
| 62 | + return self._jl_callmethod(_jl_methods["__iter__"]) |
| 63 | + def __next__(self): |
| 64 | + return self._jl_callmethod(_jl_methods["__next__"]) |
| 65 | + def __reversed__(self): |
| 66 | + return self._jl_callmethod(_jl_methods["__reversed__"]) |
| 67 | + def __contains__(self, v): |
| 68 | + return self._jl_callmethod(_jl_methods["__contains__"], v) |
| 69 | + def __pos__(self): |
| 70 | + return self._jl_callmethod(_jl_methods["__pos__"]) |
| 71 | + def __neg__(self): |
| 72 | + return self._jl_callmethod(_jl_methods["__neg__"]) |
| 73 | + def __abs__(self): |
| 74 | + return self._jl_callmethod(_jl_methods["__abs__"]) |
| 75 | + def abs(self): |
| 76 | + return self._jl_callmethod(_jl_methods["__abs__"]) |
| 77 | + def __invert__(self): |
| 78 | + return self._jl_callmethod(_jl_methods["__invert__"]) |
| 79 | + def __add__(self, other): |
| 80 | + return self._jl_callmethod(_jl_methods["__add__"], other) |
| 81 | + def __sub__(self, other): |
| 82 | + return self._jl_callmethod(_jl_methods["__sub__"], other) |
| 83 | + def __mul__(self, other): |
| 84 | + return self._jl_callmethod(_jl_methods["__mul__"], other) |
| 85 | + def __truediv__(self, other): |
| 86 | + return self._jl_callmethod(_jl_methods["__truediv__"], other) |
| 87 | + def __floordiv__(self, other): |
| 88 | + return self._jl_callmethod(_jl_methods["__floordiv__"], other) |
| 89 | + def __mod__(self, other): |
| 90 | + return self._jl_callmethod(_jl_methods["__mod__"], other) |
| 91 | + def __pow__(self, other, modulo=None): |
| 92 | + if modulo is None: |
| 93 | + return self._jl_callmethod(_jl_methods["__pow__"], other) |
| 94 | + else: |
| 95 | + return self._jl_callmethod(_jl_methods["__pow_modulo__"], other, modulo) |
| 96 | + def __lshift__(self, other): |
| 97 | + return self._jl_callmethod(_jl_methods["__lshift__"], other) |
| 98 | + def __rshift__(self, other): |
| 99 | + return self._jl_callmethod(_jl_methods["__rshift__"], other) |
| 100 | + def __and__(self, other): |
| 101 | + return self._jl_callmethod(_jl_methods["__and__"], other) |
| 102 | + def __xor__(self, other): |
| 103 | + return self._jl_callmethod(_jl_methods["__xor__"], other) |
| 104 | + def __or__(self, other): |
| 105 | + return self._jl_callmethod(_jl_methods["__or__"], other) |
| 106 | + def __radd__(self, other): |
| 107 | + return self._jl_callmethod(_jl_methods["__radd__"], other) |
| 108 | + def __rsub__(self, other): |
| 109 | + return self._jl_callmethod(_jl_methods["__rsub__"], other) |
| 110 | + def __rmul__(self, other): |
| 111 | + return self._jl_callmethod(_jl_methods["__rmul__"], other) |
| 112 | + def __rtruediv__(self, other): |
| 113 | + return self._jl_callmethod(_jl_methods["__rtruediv__"], other) |
| 114 | + def __rfloordiv__(self, other): |
| 115 | + return self._jl_callmethod(_jl_methods["__rfloordiv__"], other) |
| 116 | + def __rmod__(self, other): |
| 117 | + return self._jl_callmethod(_jl_methods["__rmod__"], other) |
| 118 | + def __rpow__(self, other, modulo=None): |
| 119 | + if modulo is None: |
| 120 | + return self._jl_callmethod(_jl_methods["__rpow__"], other) |
| 121 | + else: |
| 122 | + return self._jl_callmethod(_jl_methods["__rpow_modulo__"], other, modulo) |
| 123 | + def __rlshift__(self, other): |
| 124 | + return self._jl_callmethod(_jl_methods["__rlshift__"], other) |
| 125 | + def __rrshift__(self, other): |
| 126 | + return self._jl_callmethod(_jl_methods["__rrshift__"], other) |
| 127 | + def __rand__(self, other): |
| 128 | + return self._jl_callmethod(_jl_methods["__rand__"], other) |
| 129 | + def __rxor__(self, other): |
| 130 | + return self._jl_callmethod(_jl_methods["__rxor__"], other) |
| 131 | + def __ror__(self, other): |
| 132 | + return self._jl_callmethod(_jl_methods["__ror__"], other) |
| 133 | + def __hash__(self): |
| 134 | + return self._jl_callmethod(_jl_methods["__hash__"]) |
| 135 | + def __eq__(self, other): |
| 136 | + return self._jl_callmethod(_jl_methods["__eq__"], other) |
| 137 | + def __ne__(self, other): |
| 138 | + return self._jl_callmethod(_jl_methods["__ne__"], other) |
| 139 | + def __le__(self, other): |
| 140 | + return self._jl_callmethod(_jl_methods["__le__"], other) |
| 141 | + def __lt__(self, other): |
| 142 | + return self._jl_callmethod(_jl_methods["__lt__"], other) |
| 143 | + def __ge__(self, other): |
| 144 | + return self._jl_callmethod(_jl_methods["__ge__"], other) |
| 145 | + def __gt__(self, other): |
| 146 | + return self._jl_callmethod(_jl_methods["__gt__"], other) |
| 147 | + def __int__(self): |
| 148 | + return self._jl_callmethod(_jl_methods["__int__"]) |
| 149 | + def __float__(self): |
| 150 | + return self._jl_callmethod(_jl_methods["__float__"]) |
| 151 | + def __complex__(self): |
| 152 | + return self._jl_callmethod(_jl_methods["__complex__"]) |
| 153 | + def __index__(self): |
| 154 | + return self._jl_callmethod(_jl_methods["__index__"]) |
| 155 | + def __trunc__(self): |
| 156 | + return self._jl_callmethod(_jl_methods["__trunc__"]) |
| 157 | + def __floor__(self): |
| 158 | + return self._jl_callmethod(_jl_methods["__floor__"]) |
| 159 | + def __ceil__(self): |
| 160 | + return self._jl_callmethod(_jl_methods["__ceil__"]) |
| 161 | + def __round__(self, ndigits=None): |
| 162 | + if ndigits is None: |
| 163 | + return self._jl_callmethod(_jl_methods["__round__"]) |
| 164 | + else: |
| 165 | + return self._jl_callmethod(_jl_methods["__round__"], ndigits) |
| 166 | + @property |
| 167 | + def __name__(self): |
| 168 | + return self._jl_callmethod(_jl_methods["__name__"]) |
| 169 | + def jl_display(self, mime=None): |
| 170 | + '''Display this, optionally specifying the MIME type.''' |
| 171 | + return self._jl_callmethod(_jl_methods["jl_display"], mime) |
| 172 | + def jl_help(self, mime=None): |
| 173 | + '''Show help for this Julia object.''' |
| 174 | + return self._jl_callmethod(_jl_methods["jl_help"], mime) |
| 175 | + def jl_eval(self, expr): |
| 176 | + return self._jl_callmethod(_jl_methods["jl_eval"], expr) |
| 177 | + def jl_to_py(self): |
| 178 | + return self._jl_callmethod(_jl_methods["jl_to_py"]) |
| 179 | + def jl_callback(self, *args, **kwargs): |
| 180 | + return self._jl_callmethod(_jl_methods["jl_callback"], args, kwargs) |
| 181 | + def _repr_mimebundle_(self, include=None, exclude=None): |
| 182 | + return self._jl_callmethod(_jl_methods["_repr_mimebundle_"], include, exclude) |
| 183 | + @property |
| 184 | + def __numpy_dtype__(self): |
| 185 | + return self._jl_callmethod(_jl_methods["__numpy_dtype__"]) |
0 commit comments