Changed check for default opts

This commit is contained in:
2023-02-12 01:38:27 +02:00
parent e08c172f68
commit 666aec3767

View File

@ -107,8 +107,7 @@ class Pitch(Event):
self.update_note() self.update_note()
def update_note(self): def update_note(self):
"""Update note if Key, Scale and Pitch-class is present """Update note if Key, Scale and Pitch-class is present"""
"""
if ( if (
(self.key is not None) (self.key is not None)
and (self.scale is not None) and (self.scale is not None)
@ -268,7 +267,7 @@ class Sequence(Meta):
options = self.__update_options(current, options) options = self.__update_options(current, options)
else: else:
if set(("key", "scale")) <= options.keys(): if set(("key", "scale")) <= options.keys():
if isinstance(current,Cyclic): if isinstance(current, Cyclic):
current = current.get_value() current = current.get_value()
if isinstance(current, (Pitch, RandomPitch, RandomInteger)): if isinstance(current, (Pitch, RandomPitch, RandomInteger)):
current = self.__update_pitch(current, options) current = self.__update_pitch(current, options)
@ -420,16 +419,18 @@ class Ziffers(Sequence):
# pylint: disable=locally-disabled, dangerous-default-value # pylint: disable=locally-disabled, dangerous-default-value
def init_opts(self, options=None): def init_opts(self, options=None):
"""Evaluate the Ziffers tree using the options""" """Evaluate the Ziffers tree using the options"""
if options is None or len(options)<=0: self.options.update(DEFAULT_OPTIONS)
self.options = DEFAULT_OPTIONS if options:
else:
self.options.update(options) self.options.update(options)
else:
self.options = DEFAULT_OPTIONS
self.iterator = iter(self.evaluate_tree(self.options)) self.iterator = iter(self.evaluate_tree(self.options))
def re_eval(self, options=None): def re_eval(self, options=None):
"""Re-evaluate the iterator""" """Re-evaluate the iterator"""
if options is not None: self.options.update(DEFAULT_OPTIONS)
if options:
self.options.update(options) self.options.update(options)
self.iterator = iter(self.evaluate_tree(self.options)) self.iterator = iter(self.evaluate_tree(self.options))
@ -560,7 +561,7 @@ class Cyclic(Item):
return text return text
def get_value(self): def get_value(self):
"""Get the value for the current cycle""" """Get the value for the current cycle"""
value = self.values[self.cycle % len(self.values)] value = self.values[self.cycle % len(self.values)]
self.cycle += 1 self.cycle += 1
return value return value
@ -619,9 +620,7 @@ class ListOperation(Sequence):
else: else:
result = [ result = [
Pitch( Pitch(
pitch_class=operation( pitch_class=operation(x.get_value(), right_value.get_value()),
x.get_value(), right_value.get_value()
),
kwargs=options, kwargs=options,
) )
for x in result for x in result