human
Can you provide a Python code to compute determinant given the following:
I am working on the file "Playground.ipynb".
The first task is:
Roadmap

<s>Addition and subtraction</s>
<s>Scaling (multiplication)</s>
<s>Visualizing in 2D</s>
<s>Visualizing in 3D</s>
Visualization legends
Visualize dot products as projections
Compute determinant
Cross products
Can you write Python code for it?
assistant
#Here is Python code to compute determinant
.

class Vector():
    """The base class for all vector operations"""
    
    def __init__(self, arr, base=np.array([1, 1])):
        self._arr = arr
        self.base = base
    
    def dot(self, other):
        return np.dot(self._arr, other._arr)

    def cross(self, other):
        return Vector(np.cross(self._arr, other._arr))
    
    def plot(self, ax=None):
        dims = len(self._arr)
        if dims > 3:
            raise Exception('Cannot plot over 3 dimensions')
        if not ax:
            fig = plt.figure()
            proj = '3d' if dims == 3 else None
            ax = fig.add_subplot(111, projection=proj)
        if dims == 1:
            self._plot1d(ax)
        elif dims == 2:
            self._plot2d(ax)
        elif dims == 3:
            self._plot3d(ax)
            
    def _plot2d(self, ax):
        x, y = self._arr * self.base
        ax.plot([0, x], [0, y])
        min_, max_ = min(x, y), max(x, y)
        ax.set_xlim([min(0, min_), max_])
        ax.set_ylim([min(0, min_), max_])
        
    def _plot2d_quiver(self, ax):
        """Work in progress."""
        x, y = self._arr
        ax.quiver(0, 0, x, y, angles='xy', scale_units='xy', scale=1)
        xmin = 0 if x >= 0 else x
        xmax = 0 if x <= 0 else x
        ymin = 0 if y >= 0 else y
        ymax = 0 if y <= 0 else y
        ax.set_xlim([xmin, xmax])
        ax.set_ylim([ymin, ymax])
        return ax
        
    def _plot3d(self, ax):
        x, y, z = self._arr
        ax.plot([0, x], [0, y], [0, z])

    def __add__(self, other):
        return Vector(self._arr + other._arr)

    def __sub__(self, other):
        return Vector(self._arr - other._arr)

    def __mul__(self, scalar):
        return self._arr * scalar
    
    def __eq__(self, other):
        return np.all(self._arr == other._arr)
    
    def _repr_png_(self):
        return display_png(self.plot())
    
    def __repr__(self):
        return 'vector({})'.format([x for x in self._arr])