• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CalebBell / fluids / 5169698981

pending completion
5169698981

push

github-actions

CalebBell
Small change

4064 of 5340 branches covered (76.1%)

4 of 4 new or added lines in 2 files covered. (100.0%)

357 existing lines in 23 files now uncovered.

11503 of 13354 relevant lines covered (86.14%)

17.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.59
/fluids/vectorized.py
1
"""Chemical Engineering Design Library (ChEDL). Utilities for process modeling.
2
Copyright (C) 2017, Caleb Bell <Caleb.Andrew.Bell@gmail.com>
3

4
Permission is hereby granted, free of charge, to any person obtaining a copy
5
of this software and associated documentation files (the "Software"), to deal
6
in the Software without restriction, including without limitation the rights
7
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
copies of the Software, and to permit persons to whom the Software is
9
furnished to do so, subject to the following conditions:
10

11
The above copyright notice and this permission notice shall be included in all
12
copies or substantial portions of the Software.
13

14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
SOFTWARE.
21
"""
22

23
import fluids as normal_fluids
20✔
24
from fluids.numerics import FakePackage
20✔
25
from fluids.numerics import numpy as np
20✔
26

27
"""Basic module which wraps all fluids functions with numpy's vectorize.
6✔
28
All other object - dicts, classes, etc - are not wrapped. Supports star
29
imports; so the same objects exported when importing from the main library
30
will be imported from here.
31

32
>>> from fluids.vectorized import *
33

34
Inputs do not need to be numpy arrays; they can be any iterable:
35

36
>>> fluids.vectorized.friction_factor(Re=[100, 1000, 10000], eD=0)
37
array([ 0.64      ,  0.064     ,  0.03088295])
38

39
Note that because this needs to import fluids itself, fluids.vectorized
40
needs to be imported separately; the following will cause an error:
41

42
>>> import fluids
43
>>> fluids.vectorized # Won't work, has not been imported yet
44

45
The correct syntax is as follows:
46

47
>>> import fluids.vectorized # Necessary
48
>>> from fluids.vectorized import * # May be used without first importing fluids
49

50

51
This module is lightweight! It takes approximately 3 ms to load, and increases
52
ram usage by only 250 KB.
53
"""
54

55
__all__ = []
20✔
56

57
__funcs = {}
20✔
58

59
bad_names = {'__file__', '__name__', '__package__', '__cached__'}
20✔
60

61
if isinstance(np, FakePackage):
20!
UNCOV
62
    pass
×
63
else:
64
    import types
20✔
65
    for name in dir(normal_fluids):
20✔
66
        obj = getattr(normal_fluids, name)
20✔
67
        if isinstance(obj, types.FunctionType):
20✔
68
            obj = np.vectorize(obj)
20✔
69
        elif isinstance(obj, str) and name in bad_names:
20✔
70
            continue
20✔
71
        __all__.append(name)
20✔
72
        __funcs[name] = obj
20✔
73
globals().update(__funcs)
20✔
74
del __funcs
20✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc