Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Yori Fournier
myplotlib
Commits
3dfebf0e
Commit
3dfebf0e
authored
Jan 22, 2017
by
Yori 'AGy' Fournier
Browse files
corrected the BUG Figure.__init__ was complaining from user arguments
parent
45c165f8
Changes
2
Hide whitespace changes
Inline
Side-by-side
myFig.py
View file @
3dfebf0e
...
...
@@ -88,7 +88,7 @@ class MyFig_base(Figure):
'debug'
:
D_DEBUG
,
'formatted'
:
D_FORMATTED
}
# check attributes
in keywords
# check attributes
for
attribute
in
attributes
.
keys
():
# if in kwargs
if
attribute
in
kwargs
.
keys
():
...
...
@@ -98,8 +98,20 @@ class MyFig_base(Figure):
del
kwargs
[
attribute
]
else
:
setattr
(
self
,
attribute
,
attributes
[
attribute
])
# If some user keywords are defined
if
hasattr
(
self
,
'keywords'
):
# check keywords
for
keyword
in
self
.
keywords
.
keys
():
# if in kwargs
if
keyword
in
kwargs
.
keys
():
# overwrite the default value
self
.
keywords
[
keyword
]
=
kwargs
[
keyword
]
# suppress keyword from kwargs for Figure.__init__
del
kwargs
[
keyword
]
else
:
self
.
keywords
=
{}
self
.
keywords
=
{}
self
.
rawdata
=
rawdata
# add figsize in the kwargs for Figure.__init__
...
...
@@ -231,21 +243,25 @@ class MyFig(MyFig_base):
# CONSTRUCTOR ------------------------------------------------------
def
__init__
(
self
,
rawdata
,
*
args
,
**
kwargs
):
# define user keywords before
# __init__ to erase them from kwargs
self
.
defineKeywords
()
MyFig_base
.
__init__
(
self
,
rawdata
,
*
args
,
**
kwargs
)
self
.
initialize
(
*
args
,
**
kwargs
)
self
.
_
initialize
(
*
args
,
**
kwargs
)
# INITIALIZE -------------------------------------------------------
def
initialize
(
self
,
*
args
,
**
kwargs
):
def
_
initialize
(
self
,
*
args
,
**
kwargs
):
#
sefine user
keywords
self
.
defineKeywords
(
)
#
update the attributes and
keywords
self
.
update
(
**
kwargs
)
# add the axes
self
.
addAxes
(
*
args
,
**
kwargs
)
self
.
addAxes
()
#
set the rawdata through the function
#
need to be done for the first init
self
.
set_rawdata
(
self
.
rawdata
)
# This function can be overwriten
# DEFINE KEYWORDS --------------------------------------------------
...
...
@@ -311,7 +327,8 @@ class MyFig(MyFig_base):
return
(
status
)
# RESET ------------------------------------------------------------
def
reset
(
self
):
def
reset
(
self
,
*
args
,
**
kwargs
):
self
.
clf
()
self
.
initialize
()
self
.
defineKeywords
()
self
.
_initialize
(
*
args
,
**
kwargs
)
self
.
plot
()
test/figTest.py
View file @
3dfebf0e
...
...
@@ -111,9 +111,9 @@ class FigTest2(MyFig):
return
(
True
)
def
addAxes
(
self
,
*
args
,
**
kwargs
):
def
addAxes
(
self
):
ratio
=
6.
/
8.
# height/width of the axes (in inch)
frame
=
[
0.0
,
0.0
,
1.0
,
1.0
]
# part of the fig that is available
self
.
add_axes
(
AxTest1
(
self
,
ratio
,
frame
,
*
args
,
**
kwargs
))
self
.
add_axes
(
AxTest1
(
self
,
ratio
,
frame
))
Yori Fournier
@yfournier
mentioned in issue
#15 (closed)
·
Jan 22, 2017
mentioned in issue
#15 (closed)
mentioned in issue #15
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment