Repository: quantopian/zipline
File: tests/pipeline/test_international_markets.py (Python)

Code before:
            'close': EquityPricing.close.latest,
            'volume': EquityPricing.volume.latest,
        }, domain=US_EQUITIES)
        dataset_specialized = Pipeline({
            'open': USEquityPricing.open.latest,
            'high': USEquityPricing.high.latest,
            'low': USEquityPricing.low.latest,
            'close': USEquityPricing.close.latest,
            'volume': USEquityPricing.volume.latest,
        })

        sessions = self.daily_bar_sessions['XNYS']
        self.assert_identical_results(
            pipeline_specialized,
            dataset_specialized,
            sessions[1],
            sessions[-1],
        )

    def test_cannot_convert_volume_data(self):
        with self.assertRaises(TypeError) as exc:
            Pipeline({'volume': EquityPricing.volume.fx('EUR').latest})

        assert_equal(
            str(exc.exception),
            'The .fx method cannot be called on EquityPricing.volume because '
            'it does not produce currency-denominated data.',
        )

    def check_expected_latest_value(self, calendar, col, date, asset, value):
        """Check the expected result of column.latest from a pipeline.
        """
        if np.isnan(value):
            # If we got a NaN, we should be outside the asset's
            # lifetime.
            self.assertTrue(date <= asset.start_date or date > asset.end_date)
        else:
            self.assertTrue(asset.start_date < date <= asset.end_date)
            bars = self.daily_bar_data[calendar.name]
            # Subtract a day because pipeline shows values as of the morning
            expected_value = bars[asset.sid].loc[date - calendar.day, col]
            assert_equal(value, expected_value)

    def assert_identical_results(self, left, right, start_date, end_date):
        """Assert that two pipelines produce the same results.
        """
        left_result = self.run_pipeline(left, start_date, end_date)
        right_result = self.run_pipeline(right, start_date, end_date)
        assert_equal(left_result, right_result)



Review comment (suggestion):
Elsewhere in the API for errors like this we write `.fx()` rather than `.fx`. See, for instance, [float64_only](https://github.com/quantopian/zipline/blob/master/zipline/pipeline/factors/factor.py#L368-L374)

Code after:
            'close': EquityPricing.close.latest,
            'volume': EquityPricing.volume.latest,
        }, domain=US_EQUITIES)
        dataset_specialized = Pipeline({
            'open': USEquityPricing.open.latest,
            'high': USEquityPricing.high.latest,
            'low': USEquityPricing.low.latest,
            'close': USEquityPricing.close.latest,
            'volume': USEquityPricing.volume.latest,
        })

        sessions = self.daily_bar_sessions['XNYS']
        self.assert_identical_results(
            pipeline_specialized,
            dataset_specialized,
            sessions[1],
            sessions[-1],
        )

    def test_cannot_convert_volume_data(self):
        with self.assertRaises(TypeError) as exc:
            EquityPricing.volume.fx('EUR')

        assert_equal(
            str(exc.exception),
            'The .fx() method cannot be called on EquityPricing.volume '
            'because it does not produce currency-denominated data.',
        )

    def check_expected_latest_value(self, calendar, col, date, asset, value):
        """Check the expected result of column.latest from a pipeline.
        """
        if np.isnan(value):
            # If we got a NaN, we should be outside the asset's
            # lifetime.
            self.assertTrue(date <= asset.start_date or date > asset.end_date)
        else:
            self.assertTrue(asset.start_date < date <= asset.end_date)
            bars = self.daily_bar_data[calendar.name]
            # Subtract a day because pipeline shows values as of the morning
            expected_value = bars[asset.sid].loc[date - calendar.day, col]
            assert_equal(value, expected_value)

    def assert_identical_results(self, left, right, start_date, end_date):
        """Assert that two pipelines produce the same results.
        """
        left_result = self.run_pipeline(left, start_date, end_date)
        right_result = self.run_pipeline(right, start_date, end_date)
        assert_equal(left_result, right_result)