@@ -38,12 +38,13 @@ class BooleanOps(DataTypeOps):
38
38
39
39
@property
40
40
def pretty_name (self ) -> str :
41
- return ' booleans'
41
+ return " booleans"
42
42
43
43
def add (self , left , right ) -> Union ["Series" , "Index" ]:
44
44
if not is_valid_operand_for_numeric_arithmetic (right , allow_bool = False ):
45
45
raise TypeError (
46
- "Addition can not be applied to %s and the given type." % self .pretty_name )
46
+ "Addition can not be applied to %s and the given type." % self .pretty_name
47
+ )
47
48
48
49
if isinstance (right , numbers .Number ) and not isinstance (right , bool ):
49
50
left = left .spark .transform (lambda scol : scol .cast (as_spark_type (type (right ))))
@@ -56,7 +57,8 @@ def add(self, left, right) -> Union["Series", "Index"]:
56
57
def sub (self , left , right ) -> Union ["Series" , "Index" ]:
57
58
if not is_valid_operand_for_numeric_arithmetic (right , allow_bool = False ):
58
59
raise TypeError (
59
- "Subtraction can not be applied to %s and the given type." % self .pretty_name )
60
+ "Subtraction can not be applied to %s and the given type." % self .pretty_name
61
+ )
60
62
if isinstance (right , numbers .Number ) and not isinstance (right , bool ):
61
63
left = left .spark .transform (lambda scol : scol .cast (as_spark_type (type (right ))))
62
64
return left - right
@@ -68,7 +70,8 @@ def sub(self, left, right) -> Union["Series", "Index"]:
68
70
def mul (self , left , right ) -> Union ["Series" , "Index" ]:
69
71
if not is_valid_operand_for_numeric_arithmetic (right , allow_bool = False ):
70
72
raise TypeError (
71
- "Multiplication can not be applied to %s and the given type." % self .pretty_name )
73
+ "Multiplication can not be applied to %s and the given type." % self .pretty_name
74
+ )
72
75
if isinstance (right , numbers .Number ) and not isinstance (right , bool ):
73
76
left = left .spark .transform (lambda scol : scol .cast (as_spark_type (type (right ))))
74
77
return left * right
@@ -80,7 +83,8 @@ def mul(self, left, right) -> Union["Series", "Index"]:
80
83
def truediv (self , left , right ) -> Union ["Series" , "Index" ]:
81
84
if not is_valid_operand_for_numeric_arithmetic (right , allow_bool = False ):
82
85
raise TypeError (
83
- "True division can not be applied to %s and the given type." % self .pretty_name )
86
+ "True division can not be applied to %s and the given type." % self .pretty_name
87
+ )
84
88
if isinstance (right , numbers .Number ) and not isinstance (right , bool ):
85
89
left = left .spark .transform (lambda scol : scol .cast (as_spark_type (type (right ))))
86
90
return left / right
@@ -92,7 +96,8 @@ def truediv(self, left, right) -> Union["Series", "Index"]:
92
96
def floordiv (self , left , right ) -> Union ["Series" , "Index" ]:
93
97
if not is_valid_operand_for_numeric_arithmetic (right , allow_bool = False ):
94
98
raise TypeError (
95
- "Floor division can not be applied to %s and the given type." % self .pretty_name )
99
+ "Floor division can not be applied to %s and the given type." % self .pretty_name
100
+ )
96
101
if isinstance (right , numbers .Number ) and not isinstance (right , bool ):
97
102
left = left .spark .transform (lambda scol : scol .cast (as_spark_type (type (right ))))
98
103
return left // right
@@ -104,7 +109,8 @@ def floordiv(self, left, right) -> Union["Series", "Index"]:
104
109
def mod (self , left , right ) -> Union ["Series" , "Index" ]:
105
110
if not is_valid_operand_for_numeric_arithmetic (right , allow_bool = False ):
106
111
raise TypeError (
107
- "Modulo can not be applied to %s and the given type." % self .pretty_name )
112
+ "Modulo can not be applied to %s and the given type." % self .pretty_name
113
+ )
108
114
if isinstance (right , numbers .Number ) and not isinstance (right , bool ):
109
115
left = left .spark .transform (lambda scol : scol .cast (as_spark_type (type (right ))))
110
116
return left % right
@@ -116,7 +122,8 @@ def mod(self, left, right) -> Union["Series", "Index"]:
116
122
def pow (self , left , right ) -> Union ["Series" , "Index" ]:
117
123
if not is_valid_operand_for_numeric_arithmetic (right , allow_bool = False ):
118
124
raise TypeError (
119
- "Exponentiation can not be applied to %s and the given type." % self .pretty_name )
125
+ "Exponentiation can not be applied to %s and the given type." % self .pretty_name
126
+ )
120
127
if isinstance (right , numbers .Number ) and not isinstance (right , bool ):
121
128
left = left .spark .transform (lambda scol : scol .cast (as_spark_type (type (right ))))
122
129
return left ** right
@@ -131,52 +138,59 @@ def radd(self, left, right) -> Union["Series", "Index"]:
131
138
return right + left
132
139
else :
133
140
raise TypeError (
134
- "Addition can not be applied to %s and the given type." % self .pretty_name )
141
+ "Addition can not be applied to %s and the given type." % self .pretty_name
142
+ )
135
143
136
144
def rsub (self , left , right ) -> Union ["Series" , "Index" ]:
137
145
if isinstance (right , numbers .Number ) and not isinstance (right , bool ):
138
146
left = left .spark .transform (lambda scol : scol .cast (as_spark_type (type (right ))))
139
147
return right - left
140
148
else :
141
149
raise TypeError (
142
- "Subtraction can not be applied to %s and the given type." % self .pretty_name )
150
+ "Subtraction can not be applied to %s and the given type." % self .pretty_name
151
+ )
143
152
144
153
def rmul (self , left , right ) -> Union ["Series" , "Index" ]:
145
154
if isinstance (right , numbers .Number ) and not isinstance (right , bool ):
146
155
left = left .spark .transform (lambda scol : scol .cast (as_spark_type (type (right ))))
147
156
return right * left
148
157
else :
149
158
raise TypeError (
150
- "Multiplication can not be applied to %s and the given type." % self .pretty_name )
159
+ "Multiplication can not be applied to %s and the given type." % self .pretty_name
160
+ )
151
161
152
162
def rtruediv (self , left , right ) -> Union ["Series" , "Index" ]:
153
163
if isinstance (right , numbers .Number ) and not isinstance (right , bool ):
154
164
left = left .spark .transform (lambda scol : scol .cast (as_spark_type (type (right ))))
155
165
return right / left
156
166
else :
157
167
raise TypeError (
158
- "True division can not be applied to %s and the given type." % self .pretty_name )
168
+ "True division can not be applied to %s and the given type." % self .pretty_name
169
+ )
159
170
160
171
def rfloordiv (self , left , right ) -> Union ["Series" , "Index" ]:
161
172
if isinstance (right , numbers .Number ) and not isinstance (right , bool ):
162
173
left = left .spark .transform (lambda scol : scol .cast (as_spark_type (type (right ))))
163
174
return right // left
164
175
else :
165
176
raise TypeError (
166
- "Floor division can not be applied to %s and the given type." % self .pretty_name )
177
+ "Floor division can not be applied to %s and the given type." % self .pretty_name
178
+ )
167
179
168
180
def rpow (self , left , right ) -> Union ["Series" , "Index" ]:
169
181
if isinstance (right , numbers .Number ) and not isinstance (right , bool ):
170
182
left = left .spark .transform (lambda scol : scol .cast (as_spark_type (type (right ))))
171
183
return right ** left
172
184
else :
173
185
raise TypeError (
174
- "Exponentiation can not be applied to %s and the given type." % self .pretty_name )
186
+ "Exponentiation can not be applied to %s and the given type." % self .pretty_name
187
+ )
175
188
176
189
def rmod (self , left , right ) -> Union ["Series" , "Index" ]:
177
190
if isinstance (right , numbers .Number ) and not isinstance (right , bool ):
178
191
left = left .spark .transform (lambda scol : scol .cast (as_spark_type (type (right ))))
179
192
return right % left
180
193
else :
181
194
raise TypeError (
182
- "Modulo can not be applied to %s and the given type." % self .pretty_name )
195
+ "Modulo can not be applied to %s and the given type." % self .pretty_name
196
+ )
0 commit comments