All notable changes to magpylib are documented here.
Fix copy order Bug (#530)
Graphic performance update for plotly when showing a large number of objects. (#524)
This is a major update that includes
Improved internal workings
Magpylib class changes/fixes:#
Boxclass renamed to
Circularclass renamed to
All Magpylib objects can now be initialized without excitation and dimension attributes.
All classes now have the
parentattribute to reference to a collection they are part of. Any object can only have a single parent.
All classes have the
describemethod which gives a quick object property overview.
Field computation changes/fixes:#
New computation core. Added top level subpackage
magpylib.corewhere all field implementations can be accessed directly without the position/orienation interface. (#376)
Direct interface functions
getHv) are now integrated into
getH. See docu for details (#449)
Generally improved field expressions: (#374)
Negative dimension input taken as absolute when only positive dimensions are allowed.
Scale invariant field evaluations.
Special cases caught within 1e-15 rtol and atol to account for numerical imprecision with positioning (e.g. object rotation).
Supress numpy divide/invalid warnings. return
(0,0,0)(e.g. on magnet edges or on line currents) and allow return of
Improved numerical stability of current loop field. Now 12-14 correct digits everywhere. (#374)
Linesfield computation error. (#368)
Object oriented interface fixes and modifications:
With the new kwarg
pixel_aggit is now possible to apply a numpy function with reducing functionality (like
average) to the pixel output. In this case, it is allowed to provide
getHwith different observer input shapes. (#503)
Major graphic output overhaul:#
showarguments replace previous ones. Some are now handed over through styles.
Geometry interface modification#
Added all scipy Rotation forms as rotation object methods. (#427)
rotatemethods have default
start=0-> applied to whole path, vector input:
start=len_path-> append) instead of
rotatemethods maintain collection geometry when applied to a collection.
orientationsetter methods in line with
rotatefunctionality and maintain
Modifications to the
Instead of the property
Collection.sourcesthere are now the
Collection.collectionsproperties. Setting these collection properties will automatically override parents. (#446, #502)
All methods applied to a collection maintain relative child-positions in the local reference frame.
Collection, so that
Collection.childrenlength is returned. (#383)
-operation was removed.
+operation now functions as
a + b = Collection(a, b). Warning:
a + b + cnow creates a nested collection !
removeinput is now only
*argsor a single flat list or tuple of Magpylib objects.
removehave some additional functionality related to child-parent relations.
describemethod gives a great Collection tree overview.
Magpylib error message improvement. Msg will now tell you what input is expected.
Defaults and input checks (#406)
magpylib.Configparameters are now in
config.ITERCYLINDERis now obsolete. The iterative solution replaced by a new analytical expression.
config.inputchecksis removed - input checks are always performed.
fix docs build
When adding with
Source + Collectionto create a new
Collection, the original now remains unaffected (#472)
This is a major update that includes
Improved internal workings
orientationattribute stores the relative rotation of an object with respect to the reference orientation (defined in each class docstring).
The default (
orientation=None) corresponds to a unit rotation.
orientationis stored as a
Calling the attribute
source.orientationreturns a scipy Rotation object
Make use of all advantages of this great scipy package:
combine subsequent rotations
R1 * R2 * R3
Sensor(position, pixel, orientation)class has the argument
(0,0,0)by default and refers to pixel positions inside the Sensor (in the Sensor local CS).
pixelis an arbitrary array_like of the shape (N1, N2, …, 3).
orientationattributes can now store paths in the global CS. For a path of length M the attribute
positionis an array of the shape (M,3) and
orientationis a Rotation object with length M. Each path position is associated with a respective rotation.
getH()will evaluate the field for all source path positions.
Paths can be set by hand
position = X,
orientation = Y, but they can also conveniently be generated using the
Paths can be shown via the
display(). By setting
show_path=xthe object will be displayed at every
x’th path step. This helps to follow up on object rotation along the path.
All objects have a
reset_path()method defined to set their paths to
Streamlining operation with all Magpylib objects:
All objects (Sensors, Sources, Collections) have additional direct access to
.display()method for quick self-inspection.
getH()methods for fast field computations
__repr__attribute defined and will return their type and their
Other new features:
Configallows users to access and edit Magpylib default values.
.currentsub-packages were moved to the top level.
.momentsub-package was renamed to
.miscand was moved to the top level.
.vectorsub-package was completely removed. Functionalities are mostly replaced by new top-level function
.mathsub-package was removed. Functionalities are mostly provided by the
scipy - Rotationpackage.
The top level function
displaySystem()was renamed to
Renamed attributes (parameters cannot be initialized in their short forms anymore):
axisare replaced by
dimensionis replaced by
diameterfor Loop and Sphere classes.
axisare replaced by
orientation(see Added Section)
Modified rotate methods:
The class methods
.rotate(angle, axis, anchor)have been replaced by a new
.rotate(rotation, anchor, increment, start)method where
rotationist a scipy
The original angle-axis-anchor rotation is now provided by the new method
.rotate_from_angax(angle, axis, anchor, increment, start, degrees).
axiscan now easily be set to the global CS axes with
The anchor argument
anchor=0represents the origin
angleargument is in units of deg by default. It can now be set to rad using the
The “move”-class method is now
.move(displacement, increment, start)
Rotation and move methods can now be used to generate paths using vector input and the
All operations can now be chained (e.g.
getB(pos)now takes single AND vector position arguments. If a vector is handed to getB it will automatically execute vectorized code from the vector module.
In a finite region (size defined by
Config.EDGESIZE) about magnet edges and line currents the field evaluates to
(NaN, NaN, NaN). Special case catching reduces performance slightly.
The Box field is now more stable. Numerical instabilities in the outfield were completely removed.
Updated Field computation interface
There are two fundamental arguments for field computation:
sourcesrefers to a source/Collection or to a 1D list of L sources and/or Collections.
observersrefers to a set of positions of shape (N1, N2, …, 3) or a Sensor with
pixelshape (N1, N2, …, 3) or a 1D list of K Sensors.
With Magpylib3 there are several ways to compute the field:
The output shape is always (L, M, K, N1, N2, …, 3) with L sources, M path positions, K sensors and N (pixel) positions.
Objects with shorter paths will be considered as static once their path ends while other paths still continue.
magpylib.getBv(**kwargs)gives direct access to the field formulas and mostly replaces the
getBv_XXX()functionality of v2. All inputs must be arrays of length N or of length 1 (statics will be tiled).
getBvis the fastest way to compute the fields it is much more convenient to use
getB()which mostly provides the same performance. Specifically,the new
getB()automatically groups all inputs for combined vectorized evaluation. This leads to a massive speedup when dealing with large Collections of similar sources.
In addition to
getB, the new
getHreturns the field in [kA/m].
niter=50does not exist anymore for the Cylinder field computation. The functionality was completely replaced by the config setting
Improved performance of getB for diametral magnetized Cylinders by 20%.
GetB of Line current now uses vectorized code which leads to massive performance enhancement.
IMPORTANT: position arguments of
getBvfunctions have been flipped! First comes the source position POSm THEN the observer position POSo!
completed the library vector functionality adding magnet Cylinder, moment Dipole, current Loop and Line. This includes adding several private vectorized functions (e.g. ellipticV) to mathLib_vector, adding respective tests and docs examples.
Docstrings for vector functions.
bringing documentation up to speed
init file bug
This is a major update that includes
API changes New features Improved internal workings
displaySystem is now a top-level function, not a Collection method anymore.
getBsweep and multiprocessing options have been completely removed, this functionality should be overtaken by the new vector functionality which uses the numpy native vectorized code paradigm. If mkl library is set (test by numpy.show_config()) numpy will also automatically use multiprocessing. Code parallelization at magpylib level should be done by hand.
Docstrings are adjusted to work better with intellisense. (Problems with *.rst code)
public rotatePosition() is now called angleAxisRotation(), former private angleAxisRotation is now called angleAxisRotation_priv().
Major rework of the documentation and examples.
Performance computation trough vector functionality included in new top-level subpackage “vector”
Vectorized versions of math functions added to “math” subpackage
Optimized getB call (utility integrated)
Improved Documentation (added Sensor class v1)
This allows users to create a coordinate system-enabled Sensor object, which can be placed, rotated, moved and oriented.
This object can take the B-Field of a system (be it single source or a Collection) with the added functionality of having its own reference in the coordinate space, allowing users to easily acquire relative B-Field measurements of a system from an arbitrarily placed sensor object.
Sensors in a list may be displayed in the
Collection.displaySystem()by using the
Added content to the
__repr__builtin to all source classes for quick console evaluations, simply call a defined object in your Python shell to print out its attributes.
Edge cases in field calculations now return a proper RuntimeWarning instead of console prints
Unused imports and variables
Collection.displaySystem()not having the
block=Falsesetting for matplotlib’s
pyplot.show()by default, this meant that outside interactive mode calling this function would hang the script until the plot was closed.
If for some reason you want to block the application, you may still use
suppress=Truekwarg then call pyplot.show() normally.
This should cause no API changes, if you have problems please notify us.
Fix multiprocessing enabled
Collection.getBsweep()for lots of objects with few positions causing great performance loss. This functionality now behaves as expected for the use case.
Collection.displaySystem()’s drawing of Dipole objects in external axes (plots) using the
subplotAxkwarg crashing the application. This functionality now behaves as expected for the use case.
Implemented one new kwarg for
subplotAx=NoneDraw into a subplot axe that already exists. The subplot needs to be 3D projected
This allows for creating side-by-side plots using displaySystem. Figure information must be set manually in pyplot.figure() in order to not squash the plots upon subplotting.
Click here for Example
getBsweep()for Collections and Sources now always returns a numpy array
Zero-length segments in Line sources now return
[0,0,0]and a warning, making it easier to draw spirals without letting users do this unaware.
Added a workaround fix for a rotation bug we are still working on.
MANIFEST.infile containing the LICENSE for bundling in PyPi
Issue and Pull Request Templates to Repository
Continuous Integration settings (Azure and Appveyor)
Code Coverage Reports with codecov
Support for Python 3.5 and under.
The first official release of the magpylib library.