예제 #1
0
    def test_error_handling(self):
        with self.assertRaises(RuntimeError) as cm:
            ak.concatenate([ak.ones(100), ak.array([True])])

        self.assertEqual(
            'Error: concatenateMsg: Incompatible arguments: ' +
            'Expected float64 dtype but got bool dtype', cm.exception.args[0])

        with self.assertRaises(TypeError):
            ak.union1d([-1, 0, 1], [-2, 0, 2])

        with self.assertRaises(RuntimeError) as cm:
            ak.cos(ak.randint(0, 1, 100, dtype=ak.bool))
        self.assertEqual('Error: efuncMsg: cos bool not implemented',
                         cm.exception.args[0])
예제 #2
0
    def testUnion1d(self):
        pdaOne = ak.array([-1, 0, 1])
        pdaTwo = ak.array([-2, 0, 2])
        expected = ak.array([-2, -1, 0, 1, 2])
        self.assertTrue((expected == ak.union1d(pdaOne, pdaTwo)).all())

        with self.assertRaises(RuntimeError) as cm:
            ak.union1d(ak.array([-1.0, 0.0, 1.0]), ak.array([-2.0, 0.0, 2.0]))
        self.assertEqual('Error: unique: float64 not implemented',
                         cm.exception.args[0])

        with self.assertRaises(RuntimeError) as cm:
            ak.union1d(ak.array([True, True, True]),
                       ak.array([True, False, True]))
        self.assertEqual('Error: unique: bool not implemented',
                         cm.exception.args[0])
        with self.assertRaises(TypeError):
            ak.union1d([-1, 0, 1], [-2, 0, 2])
예제 #3
0
 def testOneDimensionalSetUnion(self):
     set_union = ak.union1d(self.a, self.b)
     # elements in a or elements in b (or in both a and b)
     self.assertTrue(ak.all(ak.in1d(set_union,self.a) \
                            | ak.in1d(set_union,self.b)))
예제 #4
0
    parser.add_argument('port', type=int, help='Port of arkouda server')
    parser.add_argument('-n',
                        '--size',
                        type=int,
                        default=10**6,
                        help='Problem size: length of array to argsort')

    args = parser.parse_args()
    ak.verbose = False
    ak.connect(args.hostname, args.port)
    print("size = ", args.size)
    SIZE = args.size
    a = ak.randint(0, 2 * SIZE, SIZE)
    b = ak.randint(0, 2 * SIZE, SIZE)

    set_union = ak.union1d(a, b)
    print("union1d = ", set_union.size, set_union)
    # elements in a or elements in b (or in both a and b)
    passed = ak.all(ak.in1d(set_union, a) | ak.in1d(set_union, b))
    print("union1d passed test: ", passed)

    set_intersection = ak.intersect1d(a, b)
    print("intersect1d = ", set_intersection.size, set_intersection)
    # elements in a and elements in b (elements in both a and b)
    passed = ak.all(
        ak.in1d(set_intersection, a) & ak.in1d(set_intersection, b))
    print("intersect1d passed test: ", passed)

    set_difference = ak.setdiff1d(a, b)
    print("setdiff1d = ", set_difference.size, set_difference)
    # elements in a and not in b