Skip to content

Commit

Permalink
Merge pull request #105 from MassimoCimmino/issue103_floatTypeChecking
Browse files Browse the repository at this point in the history
Issue103 float type checking
  • Loading branch information
MassimoCimmino authored May 20, 2021
2 parents 5e10e2b + 1eb45c6 commit f6c7f6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,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

Expand Down
10 changes: 5 additions & 5 deletions pygfunction/gfunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,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, \
Expand Down Expand Up @@ -1489,7 +1489,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 " \
Expand Down Expand Up @@ -2329,8 +2329,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

0 comments on commit f6c7f6b

Please sign in to comment.