Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WindEnergyToolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wtlib
WindEnergyToolbox
Commits
cecf3c23
Commit
cecf3c23
authored
9 years ago
by
David Verelst
Browse files
Options
Downloads
Patches
Plain Diff
ugly hack: FileNotFoundError absent in PY2
parent
9ae2e0c5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wetb/dlc/high_level.py
+8
-0
8 additions, 0 deletions
wetb/dlc/high_level.py
wetb/dlc/tests/test_high_level.py
+8
-2
8 additions, 2 deletions
wetb/dlc/tests/test_high_level.py
with
16 additions
and
2 deletions
wetb/dlc/high_level.py
+
8
−
0
View file @
cecf3c23
...
...
@@ -24,6 +24,14 @@ from wetb.utils.caching import cache_function
from
collections
import
OrderedDict
#HOURS_PR_20YEAR = 20 * 365 * 24
# hack around FileNotFoundError not being in Python2
try
:
FileNotFoundError
except
NameError
as
e
:
class
FileNotFoundError
(
OSError
):
pass
def
Weibull
(
u
,
k
,
start
,
stop
,
step
):
C
=
2
*
u
/
np
.
sqrt
(
np
.
pi
)
cdf
=
lambda
x
:
-
np
.
exp
(
-
(
x
/
C
)
**
k
)
...
...
This diff is collapsed.
Click to expand it.
wetb/dlc/tests/test_high_level.py
+
8
−
2
View file @
cecf3c23
...
...
@@ -74,8 +74,14 @@ class TestDLCHighLevel(unittest.TestCase):
self
.
assertTrue
(
k
in
self
.
dlc_hl
.
sensor_info
().
keys
(),
k
)
def
test_fail_on_res_not_fount
(
self
):
self
.
dlc_hl
=
DLCHighLevel
(
testfilepath
+
'
DLC_test.xlsx
'
,
fail_on_resfile_not_found
=
True
)
self
.
assertRaisesRegex
(
FileNotFoundError
,
"
Result files for dlc=
'
12
'
, wsp=
'
6
'
, wdir=
'
-10
'
not found
"
)
# hack around FileNotFoundError not being in Python2.7
try
:
self
.
dlc_hl
=
DLCHighLevel
(
testfilepath
+
'
DLC_test.xlsx
'
,
fail_on_resfile_not_found
=
True
)
except
Exception
as
e
:
# FileNotFoundError on Py3.3+ inherits from IOError
assert
isinstance
(
e
.
__cause__
,
IOError
)
# self.assertRaises(FileNotFoundError, "Result files for dlc='12', wsp='6', wdir='-10' not found")
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment