From 9d8825fffe2dfdda1093938e31dbde492605af06 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Wed, 3 Apr 2024 13:51:56 -0400 Subject: [PATCH] cleanups --- quantlib/instrument.pyx | 1 - quantlib/models/calibration_helper.pyx | 5 +---- quantlib/pricingengines/_pricing_engine.pxd | 2 +- quantlib/pricingengines/credit/isda_cds_engine.pyx | 5 ++--- quantlib/pricingengines/credit/midpoint_cds_engine.pyx | 1 - quantlib/pricingengines/engine.pxd | 2 -- quantlib/pricingengines/swap.pyx | 1 - quantlib/pricingengines/vanilla/mceuropeanhestonengine.pyx | 2 -- 8 files changed, 4 insertions(+), 15 deletions(-) diff --git a/quantlib/instrument.pyx b/quantlib/instrument.pyx index f0da250d9..3defea419 100644 --- a/quantlib/instrument.pyx +++ b/quantlib/instrument.pyx @@ -1,5 +1,4 @@ """Abstract instrument class""" -from cython.operator cimport dereference as deref from quantlib.time.date cimport date_from_qldate from quantlib.pricingengines.engine cimport PricingEngine from quantlib.handle cimport static_pointer_cast diff --git a/quantlib/models/calibration_helper.pyx b/quantlib/models/calibration_helper.pyx index 0f1980c3f..d9df4863a 100644 --- a/quantlib/models/calibration_helper.pyx +++ b/quantlib/models/calibration_helper.pyx @@ -7,12 +7,9 @@ FOR A PARTICULAR PURPOSE. See the license for more details. """ -include '../types.pxi' - +from quantlib.types cimport Real, Size, Volatility from quantlib.handle cimport shared_ptr -from cython.operator cimport dereference as deref -cimport quantlib.pricingengines._pricing_engine as _pe from quantlib.pricingengines.engine cimport PricingEngine diff --git a/quantlib/pricingengines/_pricing_engine.pxd b/quantlib/pricingengines/_pricing_engine.pxd index b8c11558f..c1646407c 100644 --- a/quantlib/pricingengines/_pricing_engine.pxd +++ b/quantlib/pricingengines/_pricing_engine.pxd @@ -1,4 +1,4 @@ -cdef extern from 'ql/pricingengine.hpp' namespace 'QuantLib': +cdef extern from 'ql/pricingengine.hpp' namespace 'QuantLib' nogil: cdef cppclass PricingEngine: pass diff --git a/quantlib/pricingengines/credit/isda_cds_engine.pyx b/quantlib/pricingengines/credit/isda_cds_engine.pyx index d0159215d..151d3aee6 100644 --- a/quantlib/pricingengines/credit/isda_cds_engine.pyx +++ b/quantlib/pricingengines/credit/isda_cds_engine.pyx @@ -57,9 +57,8 @@ cdef class IsdaCdsEngine(PricingEngine): <_ice.ForwardsInCouponPeriod>forwards_in_coupon_period) ) - cdef _ice.IsdaCdsEngine* _get_cds_engine(self): - cdef _ice.IsdaCdsEngine* ref = <_ice.IsdaCdsEngine*>(self._thisptr.get()) - return ref + cdef inline _ice.IsdaCdsEngine* _get_cds_engine(self) nogil: + return <_ice.IsdaCdsEngine*>(self._thisptr.get()) @property def isda_rate_curve(self): diff --git a/quantlib/pricingengines/credit/midpoint_cds_engine.pyx b/quantlib/pricingengines/credit/midpoint_cds_engine.pyx index 0ce63b048..33219b923 100644 --- a/quantlib/pricingengines/credit/midpoint_cds_engine.pyx +++ b/quantlib/pricingengines/credit/midpoint_cds_engine.pyx @@ -9,7 +9,6 @@ from cython.operator cimport dereference as deref from libcpp cimport bool from quantlib.handle cimport Handle, shared_ptr, optional -cimport quantlib.pricingengines._pricing_engine as _pe from . cimport _midpoint_cds_engine as _mce from quantlib.pricingengines.engine cimport PricingEngine diff --git a/quantlib/pricingengines/engine.pxd b/quantlib/pricingengines/engine.pxd index 9f5310378..e69139a2d 100644 --- a/quantlib/pricingengines/engine.pxd +++ b/quantlib/pricingengines/engine.pxd @@ -3,5 +3,3 @@ cimport quantlib.pricingengines._pricing_engine as _pe cdef class PricingEngine: cdef shared_ptr[_pe.PricingEngine] _thisptr - - diff --git a/quantlib/pricingengines/swap.pyx b/quantlib/pricingengines/swap.pyx index 3c73c1314..3946a30c0 100644 --- a/quantlib/pricingengines/swap.pyx +++ b/quantlib/pricingengines/swap.pyx @@ -6,7 +6,6 @@ from quantlib.pricingengines.vanilla.vanilla cimport PricingEngine from quantlib.termstructures.yield_term_structure cimport YieldTermStructure cimport quantlib.pricingengines._swap as _swap -cimport quantlib.pricingengines._pricing_engine as _pe cimport quantlib.termstructures._yield_term_structure as _yts from quantlib.time.date cimport Date diff --git a/quantlib/pricingengines/vanilla/mceuropeanhestonengine.pyx b/quantlib/pricingengines/vanilla/mceuropeanhestonengine.pyx index 3ed19f44b..f52b9abe8 100644 --- a/quantlib/pricingengines/vanilla/mceuropeanhestonengine.pyx +++ b/quantlib/pricingengines/vanilla/mceuropeanhestonengine.pyx @@ -1,9 +1,7 @@ from quantlib.types cimport BigNatural, Integer, Real, Size from libcpp cimport bool -from cython.operator cimport dereference as deref from quantlib.handle cimport shared_ptr, static_pointer_cast from quantlib.utilities.null cimport Null -cimport quantlib.pricingengines._pricing_engine as _pe from quantlib.processes.heston_process cimport HestonProcess cimport quantlib.processes._heston_process as _hp from .mcvanillaengine cimport MCVanillaEngine