Recent Releases of properties
properties - v0.6.1 - Support np.bool_ in Boolean.from_json
Bug Fixes
properties.Boolean.from_jsonnow allowsnp.bool_values in the input JSON. (See #289 - thanks @lheagy !)
- Python
Published by fwkoch over 6 years ago
properties - v0.6.0 - Fix Diamond Inheritance, Allow Unsigned Int Arrays
Minor Changes
properties.Arraynow supports unsigned integer arrays. (See https://github.com/seequent/properties/issues/274)coerceis added as a new keyword argument forproperties.Array. By default, this isTrueand inputs are coerced to the corresponding numpy array class, matching previous behaviour. However, ifcoerce=Falseinputs are not coerced and aValidationErroris raised if they do not match the corresponding numpy array class. (See https://github.com/seequent/properties/issues/272)- Properties defined on mixin classes which use the
PropertyMetaclassbut do inheritHasPropertiesare now respected. (See https://github.com/seequent/properties/pull/283 - thanks @hishnash!) - Explicit support added for Python 3.7 and removed for 3.4. (See https://github.com/seequent/properties/pull/281)
Bug Fixes
- Order of property resolution for
HasPropertiesclasses with diamond inheritance was fixed to be more sensible and in line with attribute resolution forobjectdiamond inheritance. Although this is considered a fix, it does fundamentally change inheritance logic for existing classes with diamond inheritance and is therefore not backwards compatible. (See https://github.com/seequent/properties/issues/275 and additional conversation https://github.com/seequent/properties/pull/276) - Ensure
ValidationErrorswith noreason/prop/instanceare not ignored. (See https://github.com/seequent/properties/issues/271)
- Python
Published by fwkoch over 6 years ago
properties - v0.5.6 - Speed up Vector3Array validation
Bug fix
Vector3Arrayvalidation is simplified to not include the check for string representations (e.g. 'up', 'east') if using a numpy array. This vastly speeds up validation for large arrays since we no longer must iterate through every value. This fix is already present inVector2Array. See gmggroup/omf#43
- Python
Published by fwkoch almost 7 years ago
properties - v0.5.5 - Better Error Messaging
New Feature
- Improved
ValidationErrormessaging, including more details on property errors and info about underlying errors onUnionandInstanceproperty validation (See: https://github.com/seequent/properties/pull/261)
Bug Fixes
- Remove
functools.wrapson serializer/deserializer functions to fix Python 2 bug (See: https://github.com/gmggroup/omf/issues/30 and https://github.com/seequent/properties/pull/265)
- Python
Published by fwkoch about 7 years ago
properties - v0.5.4 - URL property under web extras
New Features
- New
URLproperty underwebextras
Bug Fixes
- Fix typo in
Pointeruid_propgetter
- Python
Published by fwkoch over 7 years ago
properties - v0.5.3 - Task refactor, minor bug fixes
Minor Changes
properties.extras.Taskhas been refactored for more distinction between inputs/outputs and the task itself (see #252 for slightly more context).
Bug Fixes
- Container property names now propagate to
propwhen the default is used (see #254). - Custom serializer/deserializer functions that allow
kwargsnow respect providedkwargsrather than ignoring them (see #253).
- Python
Published by fwkoch over 7 years ago
properties - v0.5.2 - Unpin vectormath
Minor Updates
- Unpin
vectormathdependency to allow any release >=0.1.4 (see #247).- This is in response to the
vectormathupdate from version 0.1.4 to 0.2.0, which introduced some backwards-incompatible changes (see the release notes). Now, either version of the library may be used withproperties
- This is in response to the
- Python
Published by fwkoch over 7 years ago
properties - v0.5.1 - Make picklable, fix union deserialization
Minor Changes
- Pickling
HasPropertiesinstances works better now. They no longer override__reduce__and__setstate__, and instead are just tweaked so the default pickle behavior is satisfactory (see #243).
Bug Fixes
- Bug where union deserialization leads to invalid state has been fixed (see #245).
- Python
Published by fwkoch over 7 years ago
properties - v0.5.0 - Better validation errors, new extras, Union property tweaks
Backwards-Incompatible Changes
Unionproperty deserialization has been improved more reliably reconstruct correct instances (see #228)- This requires new
strict_instancesattribute onUnionproperties - It also adds
strictandassert_validondeserialize, instead of `verbose. - There is no guarantee that
Unionproperties behave identically to their previous behaviour.
- This requires new
Taskclasses are moved fromproperties.task.Tasktoproperties.extras.Task
Major Features
- New
ValidationErroris raised when validation fails (see #224)- This is a subclass of
ValueError - Multiple validation errors are now collected and raised together in one error description.
- There is also an error hook called on validation error to customize error behaviour
- This is a subclass of
- New extras classes:
HasUIDandPointer(see #234)Singleton(see #227)
- Python
Published by fwkoch over 7 years ago
properties - v0.4.0 - Links, Dictionary property, and more
Backwards-Incompatible Changes
Container properties no longer use an empty container as their
_class_default; instead, the class default isproperties.undefined, like all other built-in property types. This gives consistent behavior across all built-in property defaults. It also avoids unexpected problems with validation outlined in #169. (See #219)In order to update code from
properties v0.3.5tov0.4.0, you may simply add the appropriate default on each container property. For example:```python import properties assert properties.version == '0.3.5'
class MyClass(properties.HasProperties):
my_list = properties.List( doc='List of strings', prop=properties.String(''), )behaves identically topython import properties assert properties.version == '0.4.0'class MyClass(properties.HasProperties):
my_list = properties.List( doc='List of strings', prop=properties.String(''), default=list, )```
Major New Features
- New
Dictionaryproperty. (See #188, issue #165) linkanddirectional_linkobjects allow values for properties (and traits) across HasProperties (and HasTraits) instances to be linked. The API for links mimics that from traitlets: http://traitlets.readthedocs.io/en/stable/utils.html#links. (See #155)properties.Boolhas been renamedproperties.Booleanto normalize naming conventions across the library (e.g. the integer property isproperties.Integer, notproperty.Int). (See #209)
Minor Changes
- Properties may now be private (i.e. names may begin with underscore). (See #194, issue #191)
- Container properties may now leave
propunspecified for untyped contents. (See #188) - Array properties:
shapemay now be unspecified (if set toNone) or have multiple valid values (if set to asetof valid shapes). Vector array properties may also specify specific shapes, as long as the second dimension is correct. (See #195, issue #192)complexis now a validdtype. (See #215, issue #208)
- Dynamic properties:
- May be serialized with a HasProperties instance by specifying
save_dynamic=True. (See #202) - No longer raise an error if they evaluate to
None/undefined. (See #187, issue #173)
- May be serialized with a HasProperties instance by specifying
- Renamed properties now have an option to not raise a warning. (See #203, issue #201)
stop_recursion_withutil function has been deprecated. (See #204, issue #168)- Docstring improvements:
__IPYTHON__interrogation to determine sphinx or plain text formatting. (See #156)- Better wording on limited-size container properties. (See #185, issue #178)
- Custom docs for renamed properties. (See #207)
Bug Fixes
- For container properties, when an instance of a subclass of the base container type are assigned to a property, their class is now maintained (e.g.
OrderedDictis no longer coerced to standarddictonvalidate). (See #221) defaultvalue validation no longer fails due to the order which property attributes are set. (See #186, issue #177)properties.copynow maintains classes of the original. (See #184, issue #175)- Union properties with
required=Falseno longer fail validation when unset. (See #199, issue #198) - Deserialization from dictionary that includes a renamed property no longer fails. (See #217)
- Conflicts can no longer arise from setting dynamic properties on init. (See #187, issue #173)
- Metaclass setup no longer fails if
__setattr__is overridden. (See #158) - Sphinx linking for custom property classes now works. (See #156, issue #153)
- Python
Published by fwkoch about 8 years ago
properties - v0.3.5 - Revert length conditionals
Bug Fixes
v0.3.4attempted to clean up some code that looked likeif len(val) > 0:to justif val:. This works forlists, but notnp.ndarrays since they have a different way of determining truth. This release reverts these changes back to checking length.
- Python
Published by fwkoch over 8 years ago
properties - v0.3.4 - ARANZ Branding
Minor Changes
- Properties has been moved under ARANZ Geo Limited branding
auto_createonInstanceproperty has been deprecated (to be removed in a future release)- Instead of using
auto_create, the instance class should be specified asdefault. This will maintain identical behavior.
- Instead of using
- Python
Published by fwkoch over 8 years ago
properties - v0.3.3 - Modifications to equal and new copy function
Major Features
- New
properties.copyfunction that returns a copy of a HasProperties instance. This method uses serialize and deserialize to create the new instance. (see #147) HasProperties.equalhas been moved toproperties.equal(see #147)- This function determines if all property values on two HasProperties instances are equal
- The movement to a top-level function from HasProperties method sets a precedent for keeping the HasProperties class namespace clean
Minor Changes
- Constraints placed on
equalinput soNoneandproperties.undefinednever reachequal(see #151) - Backwards-compatibility warning - For consistency, in the change notification dictionary
previousis nowproperties.undefinedrather thanNoneif the property value is not defined. This now matches the existing behavior ofvaluein the change notification dictionary beingproperties.undefinedrather thanNoneif the value is deleted. (see #151)
Bug Fixes
properties.Property.equalcould return an iterator rather than a boolean given certain inputs (eg numpy arrays). This method now ensures iterators are reduced to a single boolean. (see #151)
- Python
Published by fwkoch almost 9 years ago
properties - v0.3.2 - Fix intersphinx class links
Bug Fixes
- Fix links in autogenerated docstrings so they point correctly to the new docs introduced in v0.3.1 (see https://github.com/3ptscience/properties/pull/145)
- Python
Published by fwkoch almost 9 years ago
properties - v0.3.1 - Many New Features: DynamicProperty, Set/Tuple, equal method, etc.
Major Features
New Property types
FileProperty - New Property validated as a file or file name. May providemodeto use for opening a file - ifNone, file must already be open. Also may providevalid_modesfor files that are already open - ifNone, any mode (or file-like objects without mode likeBytesIO) will be valid. (see #100)ImagePNGProperty is now a subclass ofFile. (see #118)
DynamicProperty- New Property created when another property wraps a method. Behaves much like@property, where you can register setters and deleters that use other Properties.DynamicPropertys are never saved to the class. (see #108)SetandTupleProperties - New Properties withsetandtupleunderlying data structures. (see #125)RenamedProperty - for aiding backwards compatibility. (see #126)
Other features
equalmethod onPropertyclasses andHasProperties- This determines if two valid Property values are equal. It is used with
HasPropertiesvalidation to ensure values have been set and validated correctly. (see #124) - Backwards-Compatibility Warning -
HasPropertiesvalidateis now more strict. Rather than simply confirming properties are valid, it confirms that they are valid AND equal to their validated value. This difference is subtle and unlikely to be a problem under normal use. It provides one extra layer of checking that everything was set properly. - New
observerhandler that only fires on change, rather than set. use kwargchange_only=True. (see #125)
- This determines if two valid Property values are equal. It is used with
regexattribute forStringProperty - Ifregexis specified,re.searchon the input string must match the regular expression. (see #117)- Modifications to
StringChoiceProperty (see #120):descriptionsattribute - set this to a dictionary with choice keys and description values for improved documentationcase_sensitiveattribute - determines if choice case should be enforced or just coerced- order of
choicesis now preserved (if applicable)
coerceattribute for container properties (List,Tuple,Set) that ifTrue, allows other container types or individual values (not in a container) as inputs, all of which are coerced to the appropriate container. (see #125)observe_mutationsattribute forListandSetProperties (see #127)- This uses custom container classes that
HasPropertieschange notifications when mutated - Pros: more reliable notifications, Cons: containers are repeatedly copied (bad for large lists/sets)
- This uses custom container classes that
- New method decorator to
stop_recursion_witha specified value if a method gets called recursively on the sameHasPropertiesinstance. (see #121) - New
listeners_disabled/observers_disabled/validators_disabledcontext managers for disablingvalidateandobservehandlers. (see #123, #125) - Enormous overhaul to sphinx docs and docstrings to make the online documentation much more useful. (see #136)
- Backwards-Compatibility Warning - Intersphinx-linked documentation for projects implementing
HasPropertieswill need to rebuild their documentation for links to be correct.
- Backwards-Compatibility Warning - Intersphinx-linked documentation for projects implementing
Minor Changes
- Backwards-Compatibility Warning -
info_textandinfo()have been modified toclass_infoandinforespectively.HasPropertieswith the former attributes will raise aFutureWarningbut still work for now. (see #116) Tasks now have a built-in status report callback (see #122)- Improved
errormessaging wheninstance is Noneand validation of Property attributes. (see #116) - Improved automatic docstring formatting - no longer dependent on Sphinx formatting. (see #119)
InstanceProperties now support old-style classes. (see #116)_defaultsmay now containproperties.undefinedto override previous default values with no default value. (see #136)
Bug Fixes
- Fixed bug where array validation was not raising an error if the
array.type.kindwas not 'i', 'f', or 'b' (see #107)
- Python
Published by fwkoch about 9 years ago
properties - v0.3.0 - Major update: Serialization, Defaults, Metadata, etc.
Major Features
- Serialization:
- Note:
as_jsonhas been renamedto_jsonfor better parallels betweenfrom_jsonandto_json - Currently serialization/deserialization uses JSON. This can be overridden by registering custom
serializers anddeserializers toPropertyinstances, and possibly overridingserializein aHasPropertiessubclass. All the serialization methods pass around anykwargsthey receive. This allows more flexibility in custom serializers (for example, an open file can be passed around). - In
HasProperties: serializecreates a JSON dictionary of all the properties using the property serialize functions. This dictionary may have a__class__key that stores theHasPropertiesclass for smart deserialization.deserializetakes a dictionary and creates a new instance of theHasPropertiesclass using valid property keywords in the dictionary. Ifdeserializeis used ontrustedJSON, it will use the_REGISTRYto find the correct__class__to construct. If the JSON is nottrusted,deserializeconstructs an instance of the class it is called on.- In
Propertyclasses and subclasses: to_jsonis a static method that takes a valid property value and converts it to JSON-serializable version. If the value cannot be converted statically (ie aPropertyinstance is required), this errors.from_jsonis a static method that takes a JSON-serializable value and converts it to the a valid property value. Again, if aPropertyinstance is required, this errors.serializetakes a property value and serializes it using either the registeredserializer,to_json, orProperty-subclass-specific serialization logic.deserializetakes a JSON value and deserializes it to a valid property value using either the registereddeserializer,from_json, orProperty-subclass-specific deserialization logic.
- Note:
- Defaults:
defaultswrapper has been removed. To implement dynamic defaults, specify a callable in the_defaultsdictionary - this can no longer depend onself._defaultsdictionary is now inherited. Any defaults not specified in a class will be inherited from parent classes.- This differs from old behaviour where
_defaultsoverwrote parent class values for_defaults - default values are set before
__init__or with new function_reset. Deleting a property sets it to undefined. - This differs from old behavior where defaults were set on first
getand deleting a property set it to default. - On init, defaults do not fire change notifications, kwargs do.
- Additional validation of handlers and defaults in the metaclass.
- Metadata tagging:
- Properties can be tagged with additional arbitrary metadata. This is stored on the property in
meta - e.g.
properties.String('password').tag(encrypt=True)
- Properties can be tagged with additional arbitrary metadata. This is stored on the property in
- Dependencies have been reduced for the base
propertiesfunctionality. As a result, installation from PyPI has changed.pip install propertiesonly installspropertiesand the basic requirementsixpip install propreties[math]getsnumpyandvectormathfor the math properties (Arrayis now a math property)pip install properties[image]gets image dependencies (ImagePNG is now native toproperties;properties_image` is no longer needed)pip install properties[full]gets everything
- Beta release support
Minor Changes
- Overriding
__init__has been simplified by moving some instance setup toPropertyMetaclass__call__- By default
__init__now only setskwargs(and fires change notifications)
- By default
Float,Integer, andComplexvalidation has been changed to be more leniant. Intry/except, values are coerced then equality is checked. If both of those pass with no exceptions, the value is valid.- Notably, this allows
numpy.float16and other similar numpy classes that are not subclasses offloat/int/complexto pass validation. - This does not apply for
Bool- values here must be typeboolto pass (eg.numpy.bool8does not pass.
- Notably, this allows
- New
taskmodule for defining for implementing callableHasPropertiesTasks Arrayproperties may now be ofdtypeboolin addition tointorfloat- Exception types:
- Note: changing exception types may introduce backwards-incompatibility in error handling
- No more
AssertionErrorsorKeyErrorsare raised. Now properties raises three types of errors: AttributeErrorson assignment to nonexistent properties/attributesTypeErrorswhenPropertyattributes (e.g.required) are set to invalid valuesValueErrorswhen property values are invalid (i.e. validation onsetfails)
- Terms used to construct properties are now stored on the property for recreating a (possibly modified) version of the property. The
termsattribute is an instance of aPropertyTermsnamedtuple, which contains fields:name,cls,args,kwargsandmeta. StringChoiceproperties now allowsets as input. There is also additional validation to ensure no duplicates are present.filter_propsnow has an option to exclude immutable properties- Minor improvements to doc strings and sphinx docs
- Properties are now alphabetized in the docs (or the order can be customized by setting
_doc_orderto a list of the property names in the desired order).
- Properties are now alphabetized in the docs (or the order can be customized by setting
- Property attributes
helpandhelpdocwere renameddocto remove the name conflict with builtinhelpthis change is not backwards compatible but it is unlikely these attributes are referenced externally anywhere. - Expanded testing
- Video added to README
Bug Fixes
Stringproperties now can handle unicode because casting tostrwas removed.- There is now a
unicodeattribute. IfTrue(default) all strings are coerced to unicode; ifFalsethe input string type is maintained.
- There is now a
- Property
validators (observers that fire on set, before the change) may now coerce the value by modifying thechangedictionary. Previously they were allowed to have a coerced return value, but this value was never used. - Array
dtypevalidation previously allowed bad types to pass as long as 1+ good type was present. Now only good types (int,float, andbool) are allowed.
- Python
Published by fwkoch about 9 years ago
properties - v0.2.3 - New default behaviour, updated vectormath compatibility
Major Features
- New
defaultbehaviour:defaultvalues are validated but the underlying value is unchanged. This is mostly important when documenting (so, for example, if aColorproperty has a default value'random', "random" shows up in the docs, rather than some coerced RGB triple).startup()has been removed. This was used mainly to instantiate new instances inInstanceproperties and lists inListproperties. Now, if a default value is callable, it is called when accessed._class_defaultis used much more sparingly. Basic properties (ieIntegers andBools) no longer have a class default (other thanundefined). This is only used inListandInstanceclasses but may be defined in otherPropertysubclasses.- Improved determination of default values from nested property classes like
ListandUnionincluding warnings if unused defaults are defined.
- Updated
vectormath:- Now dependent on
vectormath >= 0.1.0(see release notes) - The separation of individual
Vectorclasses vs.VectorArrayclasses is mirrored inproperties - The old
Vector2andVector3are nowVector2ArrayandVector3Arrayproperties and individual vector properties namedVector2andVector3have been introduced.
- Now dependent on
Minor Changes
requiredis nowTrueby default - This assumes most properties you add to aHasPropertiesclass are there for a reason._exclusive_kwargshas been removed fromHasPropertiesin favour of separatefilter_propsutil function- Immutable
GettablePropertiesare now documented in sphinx as attributes rather than properties. - Extensive cleanup to allow pylint tests to pass
- Minor improvements to README and docs
Bug Fixes
- Class validator functions were not callable on their own; now they are.
- Python
Published by fwkoch over 9 years ago
properties - v0.2.2 - Sphinx AutoDoc; Improved List, Union, and Instance Properties
New Features
- Sphinx documentation generated for
HasPropertiesclasses in the metaclass based on the class's properties
Minor Changes:
requiredproperties may now havedefaultvalues. On validate, a required property cannot beNoneorundefinedassert_validensuresHasPropertyclasses are valid- List:
Listproperties are now lists of a givenpropertytype. AHasPropertiesclass can also be provided - this is coerced into aninstanceproperty of that class.- validation errors raise list errors rather than errors of the property type
assert_validvalidatesHasPropertiesinstances only- list now has min/max length property
- Union:
- Similar to list,
Unionnow allowsHasPropertiesclasses, coercing them intoInstanceproperties - Union was moved to base from basic
- Similar to list,
- Uid:
assert_validensures the uid has not been tampered with
- Additional testing of the new features
- Improved docstrings
- Python
Published by fwkoch over 9 years ago
properties - v0.2.1 - Validators
New features:
- @properties.validator wrapper for methods of HasProperties classes.
- If this wrapper is used without arguments, the wrapped function becomes a ClassValidator that is called on has_props_instance.validate()
- If this wrapper is given property name(s) like the @properties.observer wrapper, then the wrapped function is called on property change. validator functions are called before the change; observer functions are called after the change.
- @properties.observe => @properties.observer rename to match validator
Minor changes:
- choices is now required on StringChoices __init__ - this fixes problems with validation of default values (ie trying to set and validate default before the choices are set)
- Python
Published by rowanc1 over 9 years ago
properties - v0.2.0 - Clean API
This is almost a complete rewrite that is more inline with traitlets except that the class namespace is much cleaner. This is quite important as these classes are exposed to interactive use.
This version includes: - observers - class _REGISTRY for all subclasses - better defaults and validators
- Python
Published by rowanc1 over 9 years ago
properties - v0.1.5 - Bug Fixes
Bug Fixes
- use
tofile()instead oftobytes()to maintain numpy 1.7 compatibility - remove unused string format variable in array error
- replace '3point Science, Inc' with '3point Science' in the documentation
- Python
Published by fwkoch over 9 years ago
properties - v0.1.4 - Bug fixes
Bug Fixes
- Fix a bug where
preandpostvalues are incorrect in_on_property_changewhen using+= - Remove
equal_naninproperties.array.serializeso numpy requirement >= 1.7 is accurate - Improve error messaging in
properties.vector
- Python
Published by fwkoch over 9 years ago
properties - v0.1.3 - Resolve Pointers, Dirty, and PEP8
Major Features
- Pointer ptype may now be the string name of a property class.
- This allows recursive pointers to compile
- Once importing is complete
properties.Pointer.resolve()resolves these string ptypes into PropertyClass ptypes - This release introduces and corrects for infinite loops during validation
- PropertyClasses now contain a
_dirtyattribute- This lists the properties that have been changed
- It recurses into pointers to determine if they are dirty as well
_on_property_changehook fires when properties are changed_mark_cleanmakes all properties no longer dirty
- Several non-backwards-compatible variable and method name changes for PEP8 compatibility
properties.vmath.Vectormethods.as*with camelCase renamed to.as_*with no camel caseproperties.basic.RangeattributesmaxValueandminValuerenamedmax_valueandmin_value- Other internal name changes are also included
Minor Features
- Color may now be 'random'
- Array properties may only have dtype
float,int, or(float, int).Noneis no longer an option - 'auto_create' is now an attribute of properties
- The default is
True - However it can be set to
Falseif an creating a default property class instance is unwanted (or cannot be done due to required initialization parameters)
- The default is
- 'repeated' properties can now be 'required' so one or more value is required
- Improved
properties.basic.Rangeandproperties.basic.RangeInt - Broken and incomplete math classes (matrix, plane, and parallelogram) removed
- Python
Published by fwkoch over 9 years ago