MCPcopy Index your code
hub / github.com/quantopian/zipline / test_copy

Method test_copy

tests/pipeline/test_adjusted_array.py:521–545  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

519 )
520
521 def test_copy(self):
522 data = arange(5 * 3, dtype='f8').reshape(5, 3)
523 original_data = data.copy()
524 adjustments = {2: [Float64Multiply(0, 4, 0, 2, 2.0)]}
525 adjusted_array = AdjustedArray(data, adjustments, float('nan'))
526 traverse_copy = adjusted_array.copy()
527 clean_copy = adjusted_array.copy()
528
529 a_it = adjusted_array.traverse(2, copy=False)
530 b_it = traverse_copy.traverse(2, copy=False)
531 for a, b in zip(a_it, b_it):
532 assert_equal(a, b)
533
534 with self.assertRaises(ValueError) as e:
535 adjusted_array.copy()
536
537 assert_equal(
538 str(e.exception),
539 'cannot copy invalidated AdjustedArray',
540 )
541
542 # the clean copy should have the original data even though the
543 # original adjusted array has it's data mutated in place
544 assert_equal(clean_copy.data, original_data)
545 assert_equal(adjusted_array.data, original_data * 2)
546
547 @parameterized.expand(
548 chain(

Callers

nothing calls this directly

Calls 4

copyMethod · 0.95
traverseMethod · 0.95
AdjustedArrayClass · 0.90
assert_equalFunction · 0.90

Tested by

no test coverage detected