This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Licensed to the Apache Software Foundation (ASF) under one or more | |
# contributor license agreements. See the NOTICE file distributed with | |
# this work for additional information regarding copyright ownership. | |
# The ASF licenses this file to You under the Apache License, Version 2.0 | |
# (the "License"); you may not use this file except in compliance with | |
# the License. You may obtain a copy of the License at | |
# |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import partial | |
import multiprocessing | |
import os | |
import socket | |
import sys | |
from sklearn.preprocessing import StandardScaler | |
import numpy as np | |
import pandas as pd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SpanOpMixin: | |
def __add__(self, other) -> Union["Span", "SpanArray"]: | |
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)): | |
# Rely on pandas to unbox and dispatch to us. | |
return NotImplemented | |
if isinstance(self, Span) and isinstance(other, Span): | |
# Span + *Span = Span | |
return Span(self.target_text, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Addition of `Span` with Series of `SpanDtype` produces another Series | |
df["span"].iloc[1] + df["span"].iloc[3:5] | |
# 3 [0, 16): 'Monty Python and' | |
# 4 [0, 20): 'Monty Python and the' | |
# Name: span, dtype: SpanDtype |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reduce the `SpanArray` to a single `Span` covering tokens 2 up to 5. | |
df["span"].iloc[2:5].sum() | |
# [6, 20): 'Python and the' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pytest.fixture | |
def dtype(): | |
""" Return dtype of your extension array.""" | |
return TensorDtype() | |
@pytest.fixture | |
def data(dtype): | |
""" Return an extension array as data for the tests.""" | |
return pd.array(np.array([[i] for i in range(100)]), dtype=dtype) | |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder