From f7e8bd260fb1e748b12a93da829f1c946624d01b Mon Sep 17 00:00:00 2001 From: Massimo Cimmino Date: Thu, 20 May 2021 15:53:13 -0400 Subject: [PATCH 1/2] Fix float type checking --- pygfunction/gfunction.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pygfunction/gfunction.py b/pygfunction/gfunction.py index 4da8f3d3..0318fa42 100644 --- a/pygfunction/gfunction.py +++ b/pygfunction/gfunction.py @@ -748,9 +748,9 @@ def _check_inputs(self): assert self.network is None or (self.network.m_flow is not None and self.network.cp is not None), \ "The mass flow rate 'm_flow' and heat capacity 'cp' must be " \ "provided at the instanciation of the 'Network' object." - assert type(self.time) is np.ndarray or type(self.time) is float or self.time is None, \ + assert type(self.time) is np.ndarray or isinstance(self.time, (np.floating, float)) or self.time is None, \ "Time should be a float or an array." - assert type(self.alpha) is float, \ + assert isinstance(self.alpha, (np.floating, float)), \ "The thermal diffusivity 'alpha' should be a float or an array." acceptable_boundary_conditions = ['UHTR', 'UBWT', 'MIFT'] assert type(self.boundary_condition) is str and self.boundary_condition in acceptable_boundary_conditions, \ @@ -1527,7 +1527,7 @@ def _check_inputs(self): assert self.network is None or (self.network.m_flow is not None and self.network.cp is not None), \ "The mass flow rate 'm_flow' and heat capacity 'cp' must be " \ "provided at the instanciation of the 'Network' object." - assert type(self.time) is np.ndarray or type(self.time) is float or self.time is None, \ + assert type(self.time) is np.ndarray or isinstance(self.time, (float, np.floating)) or self.time is None, \ "Time should be a float or an array." assert type(self.nSegments) is int and self.nSegments >= 1, \ "The number of segments 'nSegments' should be a positive int " \ @@ -2367,8 +2367,8 @@ def _check_solver_specific_inputs(self): are what is expected. """ - assert type(self.disTol) is float and self.disTol > 0., \ + assert isinstance(self.disTol, (np.floating, float)) and self.disTol > 0., \ "The distance tolerance 'disTol' should be a positive float." - assert type(self.tol) is float and self.tol > 0., \ + assert isinstance(self.tol, (np.floating, float)) and self.tol > 0., \ "The relative tolerance 'tol' should be a positive float." return From 1eb45c6a125ce4d64385545f84f51da91434bb57 Mon Sep 17 00:00:00 2001 From: Massimo Cimmino Date: Thu, 20 May 2021 15:55:15 -0400 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59dcfa8a..74b63f4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ ### Bug fixes * [Issue 86](https://github.com/MassimoCimmino/pygfunction/issues/86) - Documentation is now built using Python 3 to support Python 3 features in the code. +* [Issue 103](https://github.com/MassimoCimmino/pygfunction/issues/103) - Fixed `gFunction` class to allow both builtin `float` and `numpy.floating` inputs. ### Other changes