Skip to content

Commit

Permalink
refactor binopSVMsg
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremiah Corrado <jeremiah.corrado@hpe.com>
  • Loading branch information
jeremiah-corrado committed Sep 12, 2024
1 parent 736b500 commit 57ecd25
Show file tree
Hide file tree
Showing 5 changed files with 905 additions and 682 deletions.
9 changes: 9 additions & 0 deletions .configs/registration-config-multi-dim.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
"bool",
"bigint"
]
},
"binop": {
"dtype": [
"int",
"uint",
"real",
"bool",
"bigint"
]
}
}
}
9 changes: 9 additions & 0 deletions .configs/registration-config-single-dim.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
"bool",
"bigint"
]
},
"binop": {
"dtype": [
"int",
"uint",
"real",
"bool",
"bigint"
]
}
}
}
13 changes: 8 additions & 5 deletions arkouda/pdarrayclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,10 @@ def format_other(self, other) -> str:
fmt = NUMBER_FORMAT_STRINGS[self.dtype.name]
return fmt.format(other)

def _binop_cmd_group(op: str) -> str:
def _binop_cmd_group(self, op: str) -> str:
"""
get the name of the command that implements an operator
"""
if op in ["+", "-", "*", "%", "**", "//"]:
op_cmd = "arithmeticOp"
elif op in ["==", "!=", "<", ">", "<=", ">="]:
Expand Down Expand Up @@ -527,8 +530,7 @@ def _binop(self, other: pdarray, op: str) -> pdarray:
return NotImplemented
if op not in self.BinOps:
raise ValueError(f"bad operator {op}")

op_cmd = pdarray._binop_cmd_group(op)
op_cmd = self._binop_cmd_group(op)

# pdarray binop pdarray
if isinstance(other, pdarray):
Expand Down Expand Up @@ -601,9 +603,10 @@ def _r_binop(self, other: pdarray, op: str) -> pdarray:
other = self.dtype.type(other)
if dt not in DTypes:
raise TypeError(f"Unhandled scalar type: {other} ({type(other)})")
op_cmd = self._binop_cmd_group(op)
repMsg = generic_msg(
cmd=f"binopsv{self.ndim}D",
args={"op": op, "dtype": dt, "value": other, "a": self},
cmd=f"{op_cmd}SV<{dt},{self.dtype},{self.ndim}>",
args={"op": op, "value": other, "b": self},
)
return create_pdarray(repMsg)

Expand Down
Loading

0 comments on commit 57ecd25

Please sign in to comment.